In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/5b807558721d4a1b9a2121285e81b695d4b5025b?hp=a3353dbeb3804ed7053b9be5196a69c0811e7f94>
- Log ----------------------------------------------------------------- commit 5b807558721d4a1b9a2121285e81b695d4b5025b Author: Father Chrysostomos <[email protected]> Date: Fri Oct 17 13:56:52 2014 -0700 Allow void padrange even without nextstate This allows the padrange optimisation to happen with code like this: my ($a, $b), our $c; The padrange optimisation looks for: list pushmark padsv padsv ... nextstate if it is in void context. padsv pushes an sv on to the stack, and then nextstate resets the stack. padrange doesnât bother pushing in void context, which is why this optimisation was written this way. However, there are various ops that donât bother touching the stack in void context, for efficiency; conversely, there are many that do for simplicityâs sake. In all cases, however, things pushed in void con- text are subsequently reset, usually by list/nextstate/leavesub, before they can accidentally become part of a list. So whether pad- range pushes SVs or not in void context is irrelevant, and it does not matter whether there is a nextstate op. Further, this optimisation also allowed: ex-list pushmark ... pushmark and list ops cancel each other out in list and void context. padrange does not push a mark in void context, so the list is removed from the execution chain. That was also happening for a nulled list, which is incorrect, as that means a lone pushmark is being removed. I donât believe ex-list+pushmark ever occurs in void context, but if it does then this code was wrong. M op.c commit de4d3e9afc1a641a8e2646dfc1104c961e49c70d Author: Father Chrysostomos <[email protected]> Date: Fri Oct 17 13:21:59 2014 -0700 op.c: Change a pushre if into assert() M op.c ----------------------------------------------------------------------- Summary of changes: op.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/op.c b/op.c index 44d52f9..7c59648 100644 --- a/op.c +++ b/op.c @@ -6133,9 +6133,9 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right) if (right && right->op_type == OP_SPLIT && !(right->op_flags & OPf_STACKED)) { OP* tmpop = ((LISTOP*)right)->op_first; - if (tmpop && (tmpop->op_type == OP_PUSHRE)) { - PMOP * const pm = (PMOP*)tmpop; - if ( + PMOP * const pm = (PMOP*)tmpop; + assert (tmpop && (tmpop->op_type == OP_PUSHRE)); + if ( #ifdef USE_ITHREADS !pm->op_pmreplrootu.op_pmtargetoff #else @@ -6214,7 +6214,6 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right) } } } - } } } return o; @@ -12084,17 +12083,16 @@ Perl_rpeep(pTHX_ OP *o) * padrange. * In particular in void context, we can only optimise to * a padrange if see see the complete sequence - * pushmark, pad*v, ...., list, nextstate - * which has the net effect of of leaving the stack empty - * (for now we leave the nextstate in the execution chain, for - * its other side-effects). + * pushmark, pad*v, ...., list + * which has the net effect of of leaving the markstack as it + * was. Not pushing on to the stack (whereas padsv does touch + * the stack) makes no difference in void context. */ assert(followop); if (gimme == OPf_WANT_VOID) { - if (OP_TYPE_IS_OR_WAS(followop, OP_LIST) + if (followop->op_type == OP_LIST && gimme == (followop->op_flags & OPf_WANT) - && ( followop->op_next->op_type == OP_NEXTSTATE - || followop->op_next->op_type == OP_DBSTATE)) + ) { followop = followop->op_next; /* skip OP_LIST */ -- Perl5 Master Repository
