This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
make TOPBLOCK(cx) not set cx
authorDavid Mitchell <davem@iabyn.com>
Wed, 21 Oct 2015 08:47:21 +0000 (09:47 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 09:18:31 +0000 (09:18 +0000)
i.e. replace

    TOPBLOCK(cx);

with

     cx = CX_CUR();
     TOPBLOCK(cx);

This is part of general trend of separating out the cx/cxstack_ix
setting/manipulation from the save/restore actions

cop.h
pp_ctl.c

diff --git a/cop.h b/cop.h
index 208223f..de17f3a 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -971,7 +971,6 @@ struct block {
 
 /* Continue a block elsewhere (NEXT and REDO). */
 #define TOPBLOCK(cx)                                                   \
-       cx = CX_CUR();                                                  \
        CX_DEBUG(cx, "TOP");                                            \
        PL_stack_sp      = PL_stack_base + cx->blk_oldsp,               \
        PL_markstack_ptr = PL_markstack + cx->blk_oldmarksp,            \
index f2c30f4..82189bb 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2603,6 +2603,7 @@ PP(pp_next)
 
     S_unwind_loop(aTHX_ "next");
 
+    cx = CX_CUR();
     TOPBLOCK(cx);
     PL_curcop = cx->blk_oldcop;
     PERL_ASYNC_CHECK();
@@ -2622,6 +2623,7 @@ PP(pp_redo)
        redo_op = redo_op->op_next;
     }
 
+    cx = CX_CUR();
     TOPBLOCK(cx);
     CX_LEAVE_SCOPE(cx);
     FREETMPS;
@@ -2768,6 +2770,7 @@ PP(pp_goto)
            if (cxix < cxstack_ix) {
                dounwind(cxix);
             }
+            cx = CX_CUR();
            TOPBLOCK(cx);
            SPAGAIN;
 
@@ -3050,6 +3053,7 @@ PP(pp_goto)
            if (ix < 0)
                DIE(aTHX_ "panic: docatch: illegal ix=%ld", (long)ix);
            dounwind(ix);
+            cx = CX_CUR();
            TOPBLOCK(cx);
        }
 
@@ -5022,6 +5026,7 @@ PP(pp_leavewhen)
     if (CxFOREACH(cx)) {
         /* emulate pp_next. Note that any stack(s) cleanup will be
          * done by the pp_unstack which op_nextop should point to */
+        cx = CX_CUR();
        TOPBLOCK(cx);
        PL_curcop = cx->blk_oldcop;
        return cx->blk_loop.my_op->op_nextop;
@@ -5075,6 +5080,7 @@ PP(pp_break)
         dounwind(cxix);
 
     /* Restore the sp at the time we entered the given block */
+    cx = CX_CUR();
     TOPBLOCK(cx);
 
     return cx->blk_givwhen.leave_op;