In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/6c44c1e1b6f26ca7b902789dfedb643502065e3a?hp=0017a11ac92ab719250c9d2389dd14d7238eeefb>
- Log ----------------------------------------------------------------- commit 6c44c1e1b6f26ca7b902789dfedb643502065e3a Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Oct 18 22:31:14 2014 -0700 Tweak multiple nextstate optimisation further There was still one niggling nulled nextstate in the execution sequence in cases like this (the one numbered 4): $ ./perl -Ilib -MO=Concise -e 'time; our $x; our $y; time' 7 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 3 <0> time[t1] v ->4 - <0> ex-nextstate v ->5 - <1> rv2sv vK/OURINTR,1 ->4 - <$> gv(*x) s ->- 4 <0> ex-nextstate v ->5 - <1> rv2sv vK/OURINTR,1 ->5 - <$> gv(*y) s ->- 5 <;> nextstate(main 3 -e:1) v:{ ->6 6 <0> time[t4] v ->7 -e syntax OK M op.c commit 412989c2bb769ceb6fc1f51d96113e1e8f00c050 Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Oct 18 22:20:43 2014 -0700 Skip over state declarations at run time M lib/B/Deparse.t M op.c M t/op/opt.t ----------------------------------------------------------------------- Summary of changes: lib/B/Deparse.t | 11 +++++------ op.c | 16 ++++++++++++++++ t/op/opt.t | 10 +++++++++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t index 75d05e4..8db86c1 100644 --- a/lib/B/Deparse.t +++ b/lib/B/Deparse.t @@ -1093,8 +1093,8 @@ CORE::evalbytes ''; # CONTEXT no warnings 'experimental::smartmatch'; use feature (sprintf(":%vd", $^V)); use 1; +CORE::say $_; CORE::state $x; -CORE::say $x; CORE::given ($x) { CORE::when (3) { continue; @@ -1106,8 +1106,8 @@ CORE::given ($x) { CORE::evalbytes ''; () = CORE::__SUB__; >>>> +CORE::say $_; CORE::state $x; -CORE::say $x; CORE::given ($x) { CORE::when (3) { continue; @@ -1124,8 +1124,8 @@ CORE::evalbytes ''; # feature features when feature has been disabled by use VERSION use feature (sprintf(":%vd", $^V)); use 1; +CORE::say $_; CORE::state $x; -CORE::say $x; CORE::given ($x) { CORE::when (3) { continue; @@ -1139,8 +1139,8 @@ CORE::evalbytes ''; >>>> no feature; use feature ':default'; +CORE::say $_; CORE::state $x; -CORE::say $x; CORE::given ($x) { CORE::when (3) { continue; @@ -1492,8 +1492,7 @@ our($o7, undef, $o8) = (1, 2, 3); local($o7, undef, $o8) = (1, 2, 3); #### # 'state' works with padrange op -no strict; -use feature 'state'; +# CONTEXT no strict; use feature 'state'; state($z, @z); state $s1; $s1 = 1; diff --git a/op.c b/op.c index 2dcb389..e28cc54 100644 --- a/op.c +++ b/op.c @@ -11888,6 +11888,9 @@ Perl_rpeep(pTHX_ OP *o) op_null(o); if (oldop) oldop->op_next = nextop; + /* Skip (old)oldop assignment since the current oldop's + op_next already points to the next op. */ + continue; } } break; @@ -12183,6 +12186,18 @@ Perl_rpeep(pTHX_ OP *o) } case OP_PADAV: + case OP_PADSV: + case OP_PADHV: + /* Skip over state($x) in void context. */ + if (oldop && o->op_private == (OPpPAD_STATE|OPpLVAL_INTRO) + && (o->op_flags & OPf_WANT) == OPf_WANT_VOID) + { + oldop->op_next = o->op_next; + goto redo_nextstate; + } + if (o->op_type != OP_PADAV) + break; + /* FALLTHROUGH */ case OP_GV: if (o->op_type == OP_PADAV || o->op_next->op_type == OP_RV2AV) { OP* const pop = (o->op_type == OP_PADAV) ? @@ -12229,6 +12244,7 @@ Perl_rpeep(pTHX_ OP *o) oldop->op_next = o->op_next->op_next; /* Reprocess the previous op if it is a nextstate, to allow double-nextstate optimisation. */ + redo_nextstate: if (oldop->op_type == OP_NEXTSTATE) { oldop->op_opt = 0; o = oldop; diff --git a/t/op/opt.t b/t/op/opt.t index 50eff6d..690565e 100644 --- a/t/op/opt.t +++ b/t/op/opt.t @@ -9,8 +9,9 @@ BEGIN { @INC = '../lib'; } -plan 21; +plan 22; +use v5.10; # state use B qw 'svref_2object OPpASSIGN_COMMON'; @@ -62,6 +63,13 @@ is svref_2object(sub { 0;0;0;0;0;0;time })->START->next->name, 'time', 'multiple nextstates become one'; +# pad[ahs]v state declarations in void context + +is svref_2object(sub{state($foo,@fit,%far);state $bar;state($a,$b); time}) + ->START->next->name, 'time', + 'pad[ahs]v state declarations in void context'; + + # rv2[ahs]v in void context is svref_2object(sub { our($foo,@fit,%far); our $bar; our($a,$b); time }) -- Perl5 Master Repository