In perl.git, the branch smoke-me/nicholas/redundant-SPAGAIN has been updated
<http://perl5.git.perl.org/perl.git/commitdiff/dab3f1d7ef3486a0e6376037a136fd7a68e54635?hp=a9c9e371c40cf388593577cf577494e91793f62a> - Log ----------------------------------------------------------------- commit dab3f1d7ef3486a0e6376037a136fd7a68e54635 Author: Nicholas Clark <[email protected]> Date: Fri Oct 4 13:28:58 2013 +0200 Remove redundant SPAGAIN & PUTBACK after PUSHSTACKi(). PUSHSTACKi() calls SWITCHSTACK(), which sets PL_stack_sp and sp like this: sp = PL_stack_sp = PL_stack_base + AvFILLp(t) Hence after PUSHSTACKi() both are identical, so use of SPAGAIN or PUTBACK to assign one to the other is redundant. The use of SPAGAIN in encoding.xs and via.xs was added with commit 24f59afc531955e5 (April 2002) which added the use of PUSHSTACKi(). It feels like cargo-cult. The use of PUTBACK in Perl_amagic_call() predates the introduction of nested stacks and PUSHSTACKi() in commit e336de0d01f30cc4 (April 1998). It dates from perl 5.000, but it's not clear that it was ever needed, as the code in question looked like this, and nothing could have moved the stack between the dSP and PUTBACK: dSP; BINOP myop; SV* res; Zero(&myop, 1, BINOP); myop.op_last = (OP *) &myop; myop.op_next = Nullop; myop.op_flags = OPf_KNOW|OPf_STACKED; ENTER; SAVESPTR(op); op = (OP *) &myop; PUTBACK; The PUTBACK and SPAGAIN in Perl_require_pv() were added by commit d3acc0f7e5197310 (June 1998) which also added the PUSHSTACKi(). They have both been redundant since they were added. ----------------------------------------------------------------------- Summary of changes: ext/PerlIO-encoding/encoding.pm | 2 +- ext/PerlIO-encoding/encoding.xs | 7 ------- ext/PerlIO-via/via.pm | 2 +- ext/PerlIO-via/via.xs | 1 - gv.c | 1 - perl.c | 2 -- 6 files changed, 2 insertions(+), 13 deletions(-) diff --git a/ext/PerlIO-encoding/encoding.pm b/ext/PerlIO-encoding/encoding.pm index e270819..e3291a5 100644 --- a/ext/PerlIO-encoding/encoding.pm +++ b/ext/PerlIO-encoding/encoding.pm @@ -1,7 +1,7 @@ package PerlIO::encoding; use strict; -our $VERSION = '0.16'; +our $VERSION = '0.17'; our $DEBUG = 0; $DEBUG and warn __PACKAGE__, " called by ", join(", ", caller), "\n"; diff --git a/ext/PerlIO-encoding/encoding.xs b/ext/PerlIO-encoding/encoding.xs index 2d06d82..a0415d0 100644 --- a/ext/PerlIO-encoding/encoding.xs +++ b/ext/PerlIO-encoding/encoding.xs @@ -60,7 +60,6 @@ PerlIOEncode_getarg(pTHX_ PerlIO * f, CLONE_PARAMS * param, int flags) dSP; /* Not 100% sure stack swap is right thing to do during dup ... */ PUSHSTACKi(PERLSI_MAGIC); - SPAGAIN; ENTER; SAVETMPS; PUSHMARK(sp); @@ -87,8 +86,6 @@ PerlIOEncode_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, PerlIO_funcs * SV *result = Nullsv; PUSHSTACKi(PERLSI_MAGIC); - SPAGAIN; - ENTER; SAVETMPS; @@ -239,7 +236,6 @@ PerlIOEncode_fill(pTHX_ PerlIO * f) } } PUSHSTACKi(PERLSI_MAGIC); - SPAGAIN; ENTER; SAVETMPS; retry: @@ -413,7 +409,6 @@ PerlIOEncode_flush(pTHX_ PerlIO * f) if (e->inEncodeCall) return 0; /* Write case - encode the buffer and write() to layer below */ PUSHSTACKi(PERLSI_MAGIC); - SPAGAIN; ENTER; SAVETMPS; PUSHMARK(sp); @@ -476,7 +471,6 @@ PerlIOEncode_flush(pTHX_ PerlIO * f) re-encode and unread() to layer below */ PUSHSTACKi(PERLSI_MAGIC); - SPAGAIN; ENTER; SAVETMPS; str = sv_newmortal(); @@ -650,7 +644,6 @@ BOOT: * is invoked without prior "use Encode". -- dankogai */ PUSHSTACKi(PERLSI_MAGIC); - SPAGAIN; if (!get_cvs(OUR_DEFAULT_FB, 0)) { #if 0 /* This would just be an irritant now loading works */ diff --git a/ext/PerlIO-via/via.pm b/ext/PerlIO-via/via.pm index 601be80..2fa37b1 100644 --- a/ext/PerlIO-via/via.pm +++ b/ext/PerlIO-via/via.pm @@ -1,5 +1,5 @@ package PerlIO::via; -our $VERSION = '0.12'; +our $VERSION = '0.13'; require XSLoader; XSLoader::load(); 1; diff --git a/ext/PerlIO-via/via.xs b/ext/PerlIO-via/via.xs index 56889bf..21f0629 100644 --- a/ext/PerlIO-via/via.xs +++ b/ext/PerlIO-via/via.xs @@ -79,7 +79,6 @@ PerlIOVia_method(pTHX_ PerlIO * f, const char *method, CV ** save, int flags, SV *arg; PUSHSTACKi(PERLSI_MAGIC); ENTER; - SPAGAIN; PUSHMARK(sp); XPUSHs(s->obj); while ((arg = va_arg(ap, SV *))) { diff --git a/gv.c b/gv.c index 9f0b57e..2a3691e 100644 --- a/gv.c +++ b/gv.c @@ -3172,7 +3172,6 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) PL_op = (OP *) &myop; if (PERLDB_SUB && PL_curstash != PL_debstash) PL_op->op_private |= OPpENTERSUB_DB; - PUTBACK; Perl_pp_pushmark(aTHX); EXTEND(SP, notfound + 5); diff --git a/perl.c b/perl.c index e9cf22a..45d7e67 100644 --- a/perl.c +++ b/perl.c @@ -3036,10 +3036,8 @@ Perl_require_pv(pTHX_ const char *pv) PERL_ARGS_ASSERT_REQUIRE_PV; PUSHSTACKi(PERLSI_REQUIRE); - PUTBACK; sv = Perl_newSVpvf(aTHX_ "require q%c%s%c", 0, pv, 0); eval_sv(sv_2mortal(sv), G_DISCARD); - SPAGAIN; POPSTACK; } -- Perl5 Master Repository
