This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
No need to wrap calls to Perl_load_module() in ENTER/LEAVE
authorNicholas Clark <nick@ccl4.org>
Fri, 4 Oct 2013 13:33:49 +0000 (15:33 +0200)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 23 Nov 2013 05:20:37 +0000 (21:20 -0800)
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.

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

index f7b5a4c..f522ef1 100644 (file)
@@ -649,11 +649,9 @@ BOOT:
        /* This would just be an irritant now loading works */
        Perl_warner(aTHX_ packWARN(WARN_IO), ":encoding without 'use Encode'");
 #endif
-       ENTER;
        /* The SV is magically freed by load_module */
        load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Encode", 6), Nullsv, Nullsv);
        assert(sp == PL_stack_sp);
-       LEAVE;
     }
     PUSHMARK(sp);
     PUTBACK;
diff --git a/op.c b/op.c
index 8a60800..c2029a3 100644 (file)
--- a/op.c
+++ b/op.c
@@ -2588,7 +2588,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"
@@ -2602,7 +2601,6 @@ S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs)
                                                   newSVOP(OP_CONST, 0,
                                                           newRV(target)),
                                                   dup_attrlist(attrs))));
-    LEAVE;
 }
 
 STATIC void
@@ -2622,7 +2620,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)
@@ -2630,7 +2627,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));
@@ -5500,7 +5496,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);