This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make LEAVESUB() always immediately follow POPSUB()
authorDavid Mitchell <davem@iabyn.com>
Sat, 10 Oct 2015 22:10:23 +0000 (23:10 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:41 +0000 (08:59 +0000)
Many years ago, POPSUB was split into two parts, with a final cleanup
being done by the LEAVESUB() macro. This is no longer needed;
shuffle LEAVESUB up a bit in various places so that it always immediately
follows POPSUB. Then the next commit will eliminate it altogether.

cop.h
pp_ctl.c
pp_hot.c

diff --git a/cop.h b/cop.h
index 25ea120..fbaa8a0 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -1315,7 +1315,6 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
     STMT_START {                                                       \
        cx = &cxstack[cxstack_ix];                                      \
         CvDEPTH(multicall_cv) = cx->blk_sub.olddepth;                   \
-        LEAVESUB(multicall_cv);                                        \
        POPBLOCK(cx,PL_curpm);                                          \
         /* these two set for backcompat by callers */                   \
         newsp = PL_stack_base + cx->blk_oldsp;                          \
@@ -1324,6 +1323,7 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
        CX_LEAVE_SCOPE(cx);                                             \
         PL_comppad = cx->blk_sub.prevcomppad;                           \
         PL_curpad = LIKELY(PL_comppad) ? AvARRAY(PL_comppad) : NULL;    \
+        LEAVESUB(multicall_cv);                                        \
        POPSTACK;                                                       \
        CATCH_SET(multicall_oldcatch);                                  \
        SPAGAIN;                                                        \
index 111d139..d30b520 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2342,9 +2342,9 @@ PP(pp_leavesublv)
            }
           croak:
            POPSUB(cx,sv);
+           LEAVESUB(sv);
            cxstack_ix--;
            PL_curpm = cx->blk_oldpm;
-           LEAVESUB(sv);
            Perl_croak(aTHX_
                      "Can't return %s from lvalue subroutine", what
            );
@@ -2414,9 +2414,9 @@ PP(pp_leavesublv)
     POPBLOCK(cx,newpm);
     cxstack_ix++; /* preserve cx entry on stack for use by POPSUB */
     POPSUB(cx,sv);     /* Stack values are safe: release CV and @_ ... */
+    LEAVESUB(sv);
     cxstack_ix--;
     PL_curpm = newpm;  /* ... and pop $1 et al */
-    LEAVESUB(sv);
 
     return cx->blk_sub.retop;
 }
index 8f2298b..081c163 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3341,10 +3341,10 @@ PP(pp_leavesub)
     POPBLOCK(cx,newpm);
     cxstack_ix++; /* temporarily protect top context */
     POPSUB(cx,sv);     /* Stack values are safe: release CV and @_ ... */
+    LEAVESUB(sv);
     cxstack_ix--;
     PL_curpm = newpm;  /* ... and pop $1 et al */
 
-    LEAVESUB(sv);
     return cx->blk_sub.retop;
 }