In perl.git, the branch smoke-me/nicholas/redundant-SPAGAIN has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/aeda9c084044bd34f90db51c9200661ea56c5a64?hp=dab3f1d7ef3486a0e6376037a136fd7a68e54635>

- Log -----------------------------------------------------------------
commit aeda9c084044bd34f90db51c9200661ea56c5a64
Author: Nicholas Clark <[email protected]>
Date:   Fri Oct 4 15:33:49 2013 +0200

    No need to wrap calls to Perl_load_module() in ENTER/LEAVE
    
    As of commit 53a7735b62aee146 (May 2007) Perl_vload_module() wraps its call
    to Perl_utilize() with ENTER/LEAVE, so there's no longer a need for callers
    of Perl_load_module() to also wrap with ENTER/LEAVE.

M       ext/PerlIO-encoding/encoding.xs
M       op.c

commit 7009ce0ba6b3ef71e9de6e7c0f0e1ad0835b0441
Author: Nicholas Clark <[email protected]>
Date:   Fri Oct 4 15:15:56 2013 +0200

    Perl_load_module() no longer moves the current stack, so no need to save it.

M       ext/PerlIO-encoding/encoding.xs
M       ext/Win32CORE/Win32CORE.c
M       gv.c
M       toke.c

commit 5d2869827b638deb17800bb9caee24c998ab0549
Author: Nicholas Clark <[email protected]>
Date:   Fri Oct 4 14:54:00 2013 +0200

    S_process_special_blocks() should use a new stack for BEGIN blocks.
    
    This avoids the stack moving underneath anything that directly or indirectly
    calls Perl_load_module().

M       op.c
-----------------------------------------------------------------------

Summary of changes:
 ext/PerlIO-encoding/encoding.xs |  6 +-----
 ext/Win32CORE/Win32CORE.c       |  2 +-
 gv.c                            |  3 +--
 op.c                            | 10 +++++-----
 toke.c                          |  2 +-
 5 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/ext/PerlIO-encoding/encoding.xs b/ext/PerlIO-encoding/encoding.xs
index a0415d0..f522ef1 100644
--- a/ext/PerlIO-encoding/encoding.xs
+++ b/ext/PerlIO-encoding/encoding.xs
@@ -649,13 +649,9 @@ BOOT:
        /* This would just be an irritant now loading works */
        Perl_warner(aTHX_ packWARN(WARN_IO), ":encoding without 'use Encode'");
 #endif
-       ENTER;
-       /* Encode needs a lot of stack - it is likely to move ... */
-       PUTBACK;
        /* The SV is magically freed by load_module */
        load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Encode", 6), Nullsv, 
Nullsv);
-       SPAGAIN;
-       LEAVE;
+       assert(sp == PL_stack_sp);
     }
     PUSHMARK(sp);
     PUTBACK;
diff --git a/ext/Win32CORE/Win32CORE.c b/ext/Win32CORE/Win32CORE.c
index b318fcc..db58514 100644
--- a/ext/Win32CORE/Win32CORE.c
+++ b/ext/Win32CORE/Win32CORE.c
@@ -32,7 +32,7 @@ XS(w32_CORE_all){
     const char *function  = (const char *) XSANY.any_ptr;
     Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpvn("Win32",5), 
newSVnv(0.27));
     SetLastError(err);
-    SPAGAIN;
+    assert(sp == PL_stack_sp);
     PUSHMARK(SP-items);
     call_pv(function, GIMME_V);
 }
diff --git a/gv.c b/gv.c
index 2a3691e..e6885e8 100644
--- a/gv.c
+++ b/gv.c
@@ -1259,9 +1259,8 @@ S_require_tie_mod(pTHX_ GV *gv, const char *varpv, SV* 
namesv, const char *methp
        SAVEFREESV(namesv);
        if ( flags & 1 )
            save_scalar(gv);
-       PUSHSTACKi(PERLSI_MAGIC);
        Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, module, NULL);
-       POPSTACK;
+       assert(sp == PL_stack_sp);
        stash = gv_stashsv(namesv, 0);
        if (!stash)
            Perl_croak(aTHX_ "panic: Can't use %c%c because %"SVf" is not 
available",
diff --git a/op.c b/op.c
index 29c9467..025cdb8 100644
--- a/op.c
+++ b/op.c
@@ -2548,7 +2548,6 @@ S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs)
     PERL_ARGS_ASSERT_APPLY_ATTRS;
 
     /* fake up C<use attributes $pkg,$rv,@attrs> */
-    ENTER;             /* need to protect against side-effects of 'use' */
 
 #define ATTRSMODULE "attributes"
 #define ATTRSMODULE_PM "attributes.pm"
@@ -2562,7 +2561,6 @@ S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs)
                                                   newSVOP(OP_CONST, 0,
                                                           newRV(target)),
                                                   dup_attrlist(attrs))));
-    LEAVE;
 }
 
 STATIC void
@@ -2582,7 +2580,6 @@ S_apply_attrs_my(pTHX_ HV *stash, OP *target, OP *attrs, 
OP **imopsp)
           target->op_type == OP_PADAV);
 
     /* Ensure that attributes.pm is loaded. */
-    ENTER;             /* need to protect against side-effects of 'use' */
     /* Don't force the C<use> if we don't need it. */
     svp = hv_fetchs(GvHVn(PL_incgv), ATTRSMODULE_PM, FALSE);
     if (svp && *svp != &PL_sv_undef)
@@ -2590,7 +2587,6 @@ S_apply_attrs_my(pTHX_ HV *stash, OP *target, OP *attrs, 
OP **imopsp)
     else
        Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT,
                               newSVpvs(ATTRSMODULE), NULL);
-    LEAVE;
 
     /* Need package name for method call. */
     pack = newSVOP(OP_CONST, 0, newSVpvs(ATTRSMODULE));
@@ -5366,7 +5362,8 @@ Perl_vload_module(pTHX_ U32 flags, SV *name, SV *ver, 
va_list *args)
      * that it has a PL_parser to play with while doing that, and also
      * that it doesn't mess with any existing parser, by creating a tmp
      * new parser with lex_start(). This won't actually be used for much,
-     * since pp_require() will create another parser for the real work. */
+     * since pp_require() will create another parser for the real work.
+     * The ENTER/LEAVE pair protect callers from any side effects of use.  */
 
     ENTER;
     SAVEVPTR(PL_curcop);
@@ -7816,8 +7813,10 @@ S_process_special_blocks(pTHX_ I32 floor, const char 
*const fullname,
     if (*name == 'B') {
        if (strEQ(name, "BEGIN")) {
            const I32 oldscope = PL_scopestack_ix;
+            dSP;
            if (floor) LEAVE_SCOPE(floor);
            ENTER;
+            PUSHSTACKi(PERLSI_REQUIRE);
            SAVECOPFILE(&PL_compiling);
            SAVECOPLINE(&PL_compiling);
            SAVEVPTR(PL_curcop);
@@ -7827,6 +7826,7 @@ S_process_special_blocks(pTHX_ I32 floor, const char 
*const fullname,
            GvCV_set(gv,0);             /* cv has been hijacked */
            call_list(oldscope, PL_beginav);
 
+            POPSTACK;
            LEAVE;
        }
        else
diff --git a/toke.c b/toke.c
index 97205a3..e6ec7f7 100644
--- a/toke.c
+++ b/toke.c
@@ -9192,7 +9192,7 @@ S_new_constant(pTHX_ const char *s, STRLEN len, const 
char *key, STRLEN keylen,
                            newSVpvs(":full"),
                            newSVpvs(":short"),
                            NULL);
-           SPAGAIN;
+            assert(sp == PL_stack_sp);
            table = GvHV(PL_hintgv);
            if (table
                && (PL_hints & HINT_LOCALIZE_HH)

--
Perl5 Master Repository

Reply via email to