This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add PUSH/POPBASICBLK macros.
authorDavid Mitchell <davem@iabyn.com>
Sat, 10 Oct 2015 14:39:53 +0000 (15:39 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:40 +0000 (08:59 +0000)
Most contexts types have a pair, e.g. PUSHSUB/POPSUB for CXt_SUB.
Add them for a basic block too, CXt_BLOCK, i.e. pp_enter/pp_leave.
It makes things slightly more regular ahead of future refactoring.

cop.h
pp_ctl.c

diff --git a/cop.h b/cop.h
index afaea1a..0798752 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -865,6 +865,18 @@ struct block_givwhen {
         PL_tmps_floor = cx->cx_u.cx_blk.blku_old_tmpsfloor;
 
 
+/* basic block, i.e. pp_enter/leave */
+
+#define PUSHBASICBLK(cx)                                                     \
+        cx->cx_u.cx_blk.blku_old_savestack_ix = PL_savestack_ix;        \
+        cx->cx_u.cx_blk.blku_old_tmpsfloor = PL_tmps_floor;             \
+        PL_tmps_floor = PL_tmps_ix;
+
+#define POPBASICBLK(cx)                                                      \
+        LEAVE_SCOPE(cx->cx_u.cx_blk.blku_old_savestack_ix);             \
+        PL_tmps_floor = cx->cx_u.cx_blk.blku_old_tmpsfloor;
+
+
 /* context common to subroutines, evals and loops */
 struct block {
     U8         blku_type;      /* what kind of context this is */
index c2722e9..069c126 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1523,8 +1523,7 @@ Perl_dounwind(pTHX_ I32 cxix)
            POPEVAL(cx);
             /* FALLTHROUGH */
        case CXt_BLOCK:
-            LEAVE_SCOPE(cx->cx_u.cx_blk.blku_old_savestack_ix);
-            PL_tmps_floor = cx->cx_u.cx_blk.blku_old_tmpsfloor;
+            POPBASICBLK(cx);
            break;
        case CXt_LOOP_LAZYIV:
        case CXt_LOOP_LAZYSV:
@@ -2065,9 +2064,7 @@ PP(pp_enter)
     I32 gimme = GIMME_V;
 
     PUSHBLOCK(cx, CXt_BLOCK, SP);
-    cx->cx_u.cx_blk.blku_old_savestack_ix = PL_savestack_ix;
-    cx->cx_u.cx_blk.blku_old_tmpsfloor = PL_tmps_floor;
-    PL_tmps_floor = PL_tmps_ix;
+    PUSHBASICBLK(cx);
 
     RETURN;
 }
@@ -2094,8 +2091,7 @@ PP(pp_leave)
         : leave_common(newsp, SP, newsp, gimme, SVs_PADTMP|SVs_TEMP,
                                PL_op->op_private & OPpLVALUE);
 
-    LEAVE_SCOPE(cx->cx_u.cx_blk.blku_old_savestack_ix);
-    PL_tmps_floor = cx->cx_u.cx_blk.blku_old_tmpsfloor;
+    POPBASICBLK(cx);
 
     PL_curpm = newpm;  /* Don't pop $1 et al till now */