summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-12-25 23:54:23 +0000
committerDavid Mitchell <davem@iabyn.com>2016-02-03 09:19:18 +0000
commit47878d9caf766872f9956edf713aa65c5b6383aa (patch)
treedec7908731ad4d11b6a9013368cdfb51aeded8af
parent49f582ca76846f57550ebf6b762959f757bbdcd5 (diff)
downloadperl-47878d9caf766872f9956edf713aa65c5b6383aa.tar.gz
move PL_savestack_ix saving into PUSHBLOCK
Currently blku_oldsaveix was being set by the various PUSHFOO macros, except for PUSHSUB and PUSHEVAL which expected their caller to do it manually. Now that all the main context state is stored on the context stack rather than than some on the save stack too, things are a lot simpler, and this messy transitional state can now be rationalised, whereby blku_oldsaveix is now always set by PUSHBLOCK; the exact value being specified by a new arg to PUSHBLOCK.
-rw-r--r--cop.h17
-rw-r--r--pp_ctl.c22
-rw-r--r--pp_hot.c3
-rw-r--r--pp_sort.c3
-rw-r--r--pp_sys.c2
5 files changed, 20 insertions, 27 deletions
diff --git a/cop.h b/cop.h
index 5df35645b5..f58e89c2ce 100644
--- a/cop.h
+++ b/cop.h
@@ -641,7 +641,6 @@ struct block_format {
cx->blk_format.dfoutgv = PL_defoutgv; \
cx->blk_format.prevcomppad = PL_comppad; \
cx->blk_u16 = 0; \
- cx->blk_oldsaveix = PL_savestack_ix; \
SvREFCNT_inc_simple_void_NN(cv); \
CvDEPTH(cv)++; \
SvREFCNT_inc_void(cx->blk_format.dfoutgv)
@@ -835,8 +834,7 @@ struct block_loop {
#define PUSHLOOP_PLAIN(cx) \
- cx->blk_loop.my_op = cLOOP; \
- cx->blk_oldsaveix = PL_savestack_ix;
+ cx->blk_loop.my_op = cLOOP;
#ifdef USE_ITHREADS
# define PUSHLOOP_FOR_setpad(c) (c)->blk_loop.oldcomppad = PL_comppad
@@ -847,7 +845,6 @@ struct block_loop {
#define PUSHLOOP_FOR(cx, ivar, isave) \
cx->blk_loop.my_op = cLOOP; \
cx->blk_loop.itervar_u.svp = (SV**)(ivar); \
- cx->blk_oldsaveix = PL_savestack_ix; \
cx->blk_loop.itersave = isave; \
PUSHLOOP_FOR_setpad(cx);
@@ -885,7 +882,6 @@ struct block_givwhen {
};
#define PUSHWHEN(cx) \
- cx->blk_oldsaveix = PL_savestack_ix; \
cx->blk_givwhen.leave_op = cLOGOP->op_other;
#define PUSHGIVEN(cx, orig_var) \
@@ -909,7 +905,7 @@ struct block_givwhen {
/* basic block, i.e. pp_enter/leave */
#define PUSHBASICBLK(cx) \
- cx->blk_oldsaveix = PL_savestack_ix;
+ NOOP;
#define CX_POPBASICBLK(cx) \
assert(CxTYPE(cx) == CXt_BLOCK); \
@@ -965,11 +961,14 @@ struct block {
__FILE__, __LINE__));
/* Enter a block. */
-#define PUSHBLOCK(cx,t,sp) CXINC, cx = CX_CUR(), \
+#define PUSHBLOCK(cx,t,sp, saveix) \
+ CXINC, \
+ cx = CX_CUR(), \
cx->cx_type = t, \
cx->blk_oldsp = sp - PL_stack_base, \
cx->blk_oldcop = PL_curcop, \
cx->blk_oldmarksp = PL_markstack_ptr - PL_markstack, \
+ cx->blk_oldsaveix = saveix, \
cx->blk_oldscopesp = PL_scopestack_ix, \
cx->blk_oldpm = PL_curpm, \
cx->blk_gimme = (U8)gimme; \
@@ -1344,9 +1343,9 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
multicall_oldcatch = CATCH_GET; \
CATCH_SET(TRUE); \
PUSHSTACKi(PERLSI_MULTICALL); \
- PUSHBLOCK(cx, (CXt_SUB|CXp_MULTICALL|flags), PL_stack_sp); \
+ PUSHBLOCK(cx, (CXt_SUB|CXp_MULTICALL|flags), PL_stack_sp, \
+ PL_savestack_ix); \
PUSHSUB(cx); \
- cx->blk_oldsaveix = PL_savestack_ix; \
SAVEOP(); \
saveix_floor = PL_savestack_ix; \
if (!(flags & CXp_SUB_RE_FAKE)) \
diff --git a/pp_ctl.c b/pp_ctl.c
index 48654f420b..1f4786f766 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2014,10 +2014,9 @@ PP(pp_dbstate)
}
else {
U8 hasargs = 0;
- PUSHBLOCK(cx, CXt_SUB, SP);
+ PUSHBLOCK(cx, CXt_SUB, SP, PL_savestack_ix);
PUSHSUB_DB(cx);
cx->blk_sub.retop = PL_op->op_next;
- cx->blk_oldsaveix = PL_savestack_ix;
SAVEI32(PL_debug);
PL_debug = 0;
@@ -2040,7 +2039,7 @@ PP(pp_enter)
PERL_CONTEXT *cx;
I32 gimme = GIMME_V;
- PUSHBLOCK(cx, CXt_BLOCK, SP);
+ PUSHBLOCK(cx, CXt_BLOCK, SP, PL_savestack_ix);
PUSHBASICBLK(cx);
RETURN;
@@ -2140,7 +2139,7 @@ PP(pp_enteriter)
/* OPpITER_DEF (implicit $_) should only occur with a GV iter var */
assert((cxflags & CXp_FOR_GV) || !(PL_op->op_private & OPpITER_DEF));
- PUSHBLOCK(cx, cxflags, MARK);
+ PUSHBLOCK(cx, cxflags, MARK, PL_savestack_ix);
PUSHLOOP_FOR(cx, itervarp, itersave);
if (PL_op->op_flags & OPf_STACKED) {
@@ -2215,7 +2214,7 @@ PP(pp_enterloop)
PERL_CONTEXT *cx;
const I32 gimme = GIMME_V;
- PUSHBLOCK(cx, CXt_LOOP_PLAIN, SP);
+ PUSHBLOCK(cx, CXt_LOOP_PLAIN, SP, PL_savestack_ix);
PUSHLOOP_PLAIN(cx);
RETURN;
@@ -4044,9 +4043,8 @@ PP(pp_require)
}
/* switch to eval mode */
- PUSHBLOCK(cx, CXt_EVAL, SP);
+ PUSHBLOCK(cx, CXt_EVAL, SP, old_savestack_ix);
PUSHEVAL(cx, name);
- cx->blk_oldsaveix = old_savestack_ix;
cx->blk_eval.retop = PL_op->op_next;
SAVECOPLINE(&PL_compiling);
@@ -4160,9 +4158,8 @@ PP(pp_entereval)
* to do the dirty work for us */
runcv = find_runcv(&seq);
- PUSHBLOCK(cx, (CXt_EVAL|CXp_REAL), SP);
+ PUSHBLOCK(cx, (CXt_EVAL|CXp_REAL), SP, old_savestack_ix);
PUSHEVAL(cx, 0);
- cx->blk_oldsaveix = old_savestack_ix;
cx->blk_eval.retop = PL_op->op_next;
/* prepare to compile string */
@@ -4292,9 +4289,8 @@ Perl_create_eval_scope(pTHX_ U32 flags)
PERL_CONTEXT *cx;
const I32 gimme = GIMME_V;
- PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), PL_stack_sp);
+ PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), PL_stack_sp, PL_savestack_ix);
PUSHEVAL(cx, 0);
- cx->blk_oldsaveix = PL_savestack_ix;
PL_in_eval = EVAL_INEVAL;
if (flags & G_KEEPERR)
@@ -4353,7 +4349,7 @@ PP(pp_entergiven)
assert(!PL_op->op_targ); /* used to be set for lexical $_ */
GvSV(PL_defgv) = SvREFCNT_inc(newsv);
- PUSHBLOCK(cx, CXt_GIVEN, SP);
+ PUSHBLOCK(cx, CXt_GIVEN, SP, PL_savestack_ix);
PUSHGIVEN(cx, origsv);
RETURN;
@@ -4933,7 +4929,7 @@ PP(pp_enterwhen)
if ((0 == (PL_op->op_flags & OPf_SPECIAL)) && !SvTRUEx(POPs))
RETURNOP(cLOGOP->op_other->op_next);
- PUSHBLOCK(cx, CXt_WHEN, SP);
+ PUSHBLOCK(cx, CXt_WHEN, SP, PL_savestack_ix);
PUSHWHEN(cx);
RETURN;
diff --git a/pp_hot.c b/pp_hot.c
index 2442850ce6..127e5624ae 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3852,11 +3852,10 @@ PP(pp_entersub)
}
gimme = GIMME_V;
- PUSHBLOCK(cx, CXt_SUB, MARK);
+ PUSHBLOCK(cx, CXt_SUB, MARK, old_savestack_ix);
hasargs = cBOOL(PL_op->op_flags & OPf_STACKED);
PUSHSUB(cx);
cx->blk_sub.retop = PL_op->op_next;
- cx->blk_oldsaveix = old_savestack_ix;
padlist = CvPADLIST(cv);
if (UNLIKELY((depth = ++CvDEPTH(cv)) >= 2))
diff --git a/pp_sort.c b/pp_sort.c
index 9e0d64cb04..65609da5fe 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1668,7 +1668,7 @@ PP(pp_sort)
}
gimme = G_SCALAR;
- PUSHBLOCK(cx, CXt_NULL, PL_stack_base);
+ PUSHBLOCK(cx, CXt_NULL, PL_stack_base, old_savestack_ix);
if (!(flags & OPf_SPECIAL)) {
cx->cx_type = CXt_SUB|CXp_MULTICALL;
PUSHSUB(cx);
@@ -1689,7 +1689,6 @@ PP(pp_sort)
}
}
- cx->blk_oldsaveix = old_savestack_ix;
start = p1 - max;
sortsvp(aTHX_ start, max,
diff --git a/pp_sys.c b/pp_sys.c
index 3be4be3b76..74fede749d 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1389,7 +1389,7 @@ S_doform(pTHX_ CV *cv, GV *gv, OP *retop)
if (CvCLONE(cv))
cv = MUTABLE_CV(sv_2mortal(MUTABLE_SV(cv_clone(cv))));
- PUSHBLOCK(cx, CXt_FORMAT, PL_stack_sp);
+ PUSHBLOCK(cx, CXt_FORMAT, PL_stack_sp, PL_savestack_ix);
PUSHFORMAT(cx, retop);
if (CvDEPTH(cv) >= 2)
pad_push(CvPADLIST(cv), CvDEPTH(cv));