[Perl/perl5] 4a04bf: Tests for existing for loop optrees.
Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: 4a04bf00f0cd3fce8bdd48b0a8898a08c68fae33 https://github.com/Perl/perl5/commit/4a04bf00f0cd3fce8bdd48b0a8898a08c68fae33 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M MANIFEST A ext/B/t/optree_for.t Log Message: --- Tests for existing for loop optrees. Commit: 525dc1e45d4c3a81deef4481ad38a8e49380b753 https://github.com/Perl/perl5/commit/525dc1e45d4c3a81deef4481ad38a8e49380b753 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M pp_hot.c Log Message: --- Re-indent the case statement in pp_iter, ready for the next commit. Add braces and indent a block that will become a `for` loop in the next commit. With the exception of these and merging 3 opening braces onto the `if` or `else` on the previous lines, this commit is purely a whitespace change. Commit: c52d5e029a9e8dc660331b57193ea652aa0f2beb https://github.com/Perl/perl5/commit/c52d5e029a9e8dc660331b57193ea652aa0f2beb Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M pp_hot.c Log Message: --- Iterate for loops $n-at-a-time in PP_ITER. This commit provides the runtime changes needed to iterate for loops over two or more variables. Commit: 6ce22ce7e7abeb2ba69129f645e82f16d77fbd89 https://github.com/Perl/perl5/commit/6ce22ce7e7abeb2ba69129f645e82f16d77fbd89 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M op.c M pod/perldiag.pod Log Message: --- Generate the optree for n-at-a-time for loops. Perl_newFOROP can now also take an OP_LIST corresponding to two or more lexicals to iterate over n-at-a-time, where those lexicals are all declared in the for statement, and occupy consecutive pad slots. Commit: e92ce056f2022a3f96487b1b5a1862a3bf9c159c https://github.com/Perl/perl5/commit/e92ce056f2022a3f96487b1b5a1862a3bf9c159c Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M perly.act M perly.h M perly.tab M perly.y M toke.c Log Message: --- Implement n-at-a-time for loops. For example, this now works: for my ($key, $value) (%hash) { ... } Only for scalars declared with my as a list in the for loop statement. As many as you want (unless you want more than 4294967296). Commit: 83c7d349662bf85048f317a6b23155733307f486 https://github.com/Perl/perl5/commit/83c7d349662bf85048f317a6b23155733307f486 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M MANIFEST M pod/perlsyn.pod A t/op/for-many.t Log Message: --- Regression tests and documentation for n-at-a-time for. Commit: c386ecc10be9e73917fa6b819321f0cc47cacdb6 https://github.com/Perl/perl5/commit/c386ecc10be9e73917fa6b819321f0cc47cacdb6 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M ext/B/B/Concise.pm M ext/B/t/optree_for.t Log Message: --- B::Concise now handles n-at-a-time for. Commit: bf6e71ff82686b1287ef59c1565cc669d5301cc5 https://github.com/Perl/perl5/commit/bf6e71ff82686b1287ef59c1565cc669d5301cc5 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M lib/B/Deparse.pm M lib/B/Deparse.t Log Message: --- B::Deparse now handles n-at-a-time for. Commit: d9b6ecc18fa9d0af456180eceeef05148bcfdf9f https://github.com/Perl/perl5/commit/d9b6ecc18fa9d0af456180eceeef05148bcfdf9f Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M pp_hot.c Log Message: --- Move reading CxTYPE(cx) out of the loop, to be clear that it doesn't change. Move some other variable declarations into a tighter scope, and initialise variables at the point of declaration where possible. With the recent changes, the function consists of a 4-way switch inside a loop, where each iteration of the loop will take the same case in the switch. This implies a branch taken on each iteration of the loop, which is less efficient than the alternative structure of taking the branch once and then looping. However, the way the code is structured (particularly how two of the cases share code, by jumping sideways), means that rewriting it to "switch first" structure would not be clearer (and likely would also be hard to get right). Hence it seems better to let a compiler optimiser choose what is best. However, it might not realise that CxTYPE(cx) won't be changed, even as a side effect of any function called by this code. Hence hoist it into a constant variable to make this unequivocal. Commit: 3b54923c12732530d17e87f548066ceadc63daa4 https://github.com/Perl/perl5/commit/3b54923c12732530d17e87f548066ceadc63daa4 Author: Nicholas Clark Date: 2021-10-15 (Fri,
[Perl/perl5] 4a04bf: Tests for existing for loop optrees.
Branch: refs/heads/smoke-me/nicholas/pp_iter Home: https://github.com/Perl/perl5 Commit: 4a04bf00f0cd3fce8bdd48b0a8898a08c68fae33 https://github.com/Perl/perl5/commit/4a04bf00f0cd3fce8bdd48b0a8898a08c68fae33 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M MANIFEST A ext/B/t/optree_for.t Log Message: --- Tests for existing for loop optrees. Commit: 525dc1e45d4c3a81deef4481ad38a8e49380b753 https://github.com/Perl/perl5/commit/525dc1e45d4c3a81deef4481ad38a8e49380b753 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M pp_hot.c Log Message: --- Re-indent the case statement in pp_iter, ready for the next commit. Add braces and indent a block that will become a `for` loop in the next commit. With the exception of these and merging 3 opening braces onto the `if` or `else` on the previous lines, this commit is purely a whitespace change. Commit: c52d5e029a9e8dc660331b57193ea652aa0f2beb https://github.com/Perl/perl5/commit/c52d5e029a9e8dc660331b57193ea652aa0f2beb Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M pp_hot.c Log Message: --- Iterate for loops $n-at-a-time in PP_ITER. This commit provides the runtime changes needed to iterate for loops over two or more variables. Commit: 6ce22ce7e7abeb2ba69129f645e82f16d77fbd89 https://github.com/Perl/perl5/commit/6ce22ce7e7abeb2ba69129f645e82f16d77fbd89 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M op.c M pod/perldiag.pod Log Message: --- Generate the optree for n-at-a-time for loops. Perl_newFOROP can now also take an OP_LIST corresponding to two or more lexicals to iterate over n-at-a-time, where those lexicals are all declared in the for statement, and occupy consecutive pad slots. Commit: e92ce056f2022a3f96487b1b5a1862a3bf9c159c https://github.com/Perl/perl5/commit/e92ce056f2022a3f96487b1b5a1862a3bf9c159c Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M perly.act M perly.h M perly.tab M perly.y M toke.c Log Message: --- Implement n-at-a-time for loops. For example, this now works: for my ($key, $value) (%hash) { ... } Only for scalars declared with my as a list in the for loop statement. As many as you want (unless you want more than 4294967296). Commit: 83c7d349662bf85048f317a6b23155733307f486 https://github.com/Perl/perl5/commit/83c7d349662bf85048f317a6b23155733307f486 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M MANIFEST M pod/perlsyn.pod A t/op/for-many.t Log Message: --- Regression tests and documentation for n-at-a-time for. Commit: c386ecc10be9e73917fa6b819321f0cc47cacdb6 https://github.com/Perl/perl5/commit/c386ecc10be9e73917fa6b819321f0cc47cacdb6 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M ext/B/B/Concise.pm M ext/B/t/optree_for.t Log Message: --- B::Concise now handles n-at-a-time for. Commit: bf6e71ff82686b1287ef59c1565cc669d5301cc5 https://github.com/Perl/perl5/commit/bf6e71ff82686b1287ef59c1565cc669d5301cc5 Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M lib/B/Deparse.pm M lib/B/Deparse.t Log Message: --- B::Deparse now handles n-at-a-time for. Commit: d9b6ecc18fa9d0af456180eceeef05148bcfdf9f https://github.com/Perl/perl5/commit/d9b6ecc18fa9d0af456180eceeef05148bcfdf9f Author: Nicholas Clark Date: 2021-10-15 (Fri, 15 Oct 2021) Changed paths: M pp_hot.c Log Message: --- Move reading CxTYPE(cx) out of the loop, to be clear that it doesn't change. Move some other variable declarations into a tighter scope, and initialise variables at the point of declaration where possible. With the recent changes, the function consists of a 4-way switch inside a loop, where each iteration of the loop will take the same case in the switch. This implies a branch taken on each iteration of the loop, which is less efficient than the alternative structure of taking the branch once and then looping. However, the way the code is structured (particularly how two of the cases share code, by jumping sideways), means that rewriting it to "switch first" structure would not be clearer (and likely would also be hard to get right). Hence it seems better to let a compiler optimiser choose what is best. However, it might not realise that CxTYPE(cx) won't be changed, even as a side effect of any function called by this code. Hence hoist it into a constant variable to make this unequivocal. Commit: 3b54923c12732530d17e87f548066ceadc63daa4 https://github.com/Perl/perl5/commit/3b54923c12732530d17e87f548066ceadc63daa4 Author: Nicholas Clark