This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
move sbu_oldsave into base of CX struct
authorDavid Mitchell <davem@iabyn.com>
Thu, 15 Oct 2015 13:04:09 +0000 (14:04 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:43 +0000 (08:59 +0000)
the context struct is a union of two basic types: the substitution context
and everything else.

This commit moves the sbu_oldsave field from the substitution context
into the base of the context struct, so that the next commit will allow
the same field (and macros) to be used by *all* context types.

cop.h
pp_ctl.c

diff --git a/cop.h b/cop.h
index b4e7cb2..8a45b09 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -940,7 +940,6 @@ struct subst {
     U8         sbu_type;       /* what kind of context this is */
     U8         sbu_rflags;
     U16                sbu_rxtainted;  /* matches struct block */
-    I32                sbu_oldsave;
     SSize_t    sbu_iters;
     SSize_t    sbu_maxiters;
     char *     sbu_orig;
@@ -955,7 +954,6 @@ struct subst {
 #define sb_iters       cx_u.cx_subst.sbu_iters
 #define sb_maxiters    cx_u.cx_subst.sbu_maxiters
 #define sb_rflags      cx_u.cx_subst.sbu_rflags
-#define sb_oldsave     cx_u.cx_subst.sbu_oldsave
 #define sb_rxtainted   cx_u.cx_subst.sbu_rxtainted
 #define sb_orig                cx_u.cx_subst.sbu_orig
 #define sb_dstr                cx_u.cx_subst.sbu_dstr
@@ -968,10 +966,10 @@ struct subst {
 
 #ifdef PERL_CORE
 #  define PUSHSUBST(cx) CXINC, cx = &cxstack[cxstack_ix],              \
+       cx->cx_old_savestack_ix = oldsave,                              \
        cx->sb_iters            = iters,                                \
        cx->sb_maxiters         = maxiters,                             \
        cx->sb_rflags           = r_flags,                              \
-       cx->sb_oldsave          = oldsave,                              \
        cx->sb_rxtainted        = rxtainted,                            \
        cx->sb_orig             = orig,                                 \
        cx->sb_dstr             = dstr,                                 \
@@ -995,6 +993,7 @@ struct subst {
 #define CxONCE(cx)             ((cx)->cx_type & CXp_ONCE)
 
 struct context {
+    I32                        cx_old_savestack_ix;
     union {
        struct block    cx_blk;
        struct subst    cx_subst;
index d005076..8564af3 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -285,7 +285,7 @@ PP(pp_substcont)
            /* PL_tainted must be correctly set for this mg_set */
            SvSETMAGIC(TARG);
            TAINT_NOT;
-           LEAVE_SCOPE(cx->sb_oldsave);
+           LEAVE_SCOPE(cx->cx_old_savestack_ix);
            POPSUBST(cx);
            PERL_ASYNC_CHECK();
            RETURNOP(pm->op_next);