summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-10-15 13:48:25 +0100
committerDavid Mitchell <davem@iabyn.com>2016-02-03 08:59:43 +0000
commit2f450c1bae02c0b0fcd87271d9236f76d9575ed3 (patch)
treef7ea3b1444132be8aac2d74dd6d340e355e4892b
parent94a11f7c2b35ca4c446f3aa0ffff73539bfd267f (diff)
downloadperl-2f450c1bae02c0b0fcd87271d9236f76d9575ed3.tar.gz
move CX_LEAVE_SCOPE outside the POPFOO's
Currently every POPFOO macro has CX_LEAVE_SCOPE(cx) as its first action. Since this is common code and not specific to a particular POPFOO type, remove it from each POPFOO macro and make each caller of POPFOO explicitly call CX_LEAVE_SCOPE() instead. This should make no functional difference (but will help if you're single-stepping the code in a debugger :-)
-rw-r--r--cop.h11
-rw-r--r--pp_ctl.c26
-rw-r--r--pp_hot.c1
-rw-r--r--pp_sort.c6
-rw-r--r--pp_sys.c1
5 files changed, 32 insertions, 13 deletions
diff --git a/cop.h b/cop.h
index c2a1dc008e..b4e7cb284f 100644
--- a/cop.h
+++ b/cop.h
@@ -649,7 +649,6 @@ struct block_format {
#define POPSUB(cx) \
STMT_START { \
- CX_LEAVE_SCOPE(cx); \
if (!(cx->blk_u16 & CxPOPSUB_DONE)) { \
cx->blk_u16 |= CxPOPSUB_DONE; \
RETURN_PROBE(CvNAMED(cx->blk_sub.cv) \
@@ -682,7 +681,6 @@ struct block_format {
#define POPFORMAT(cx) \
STMT_START { \
- CX_LEAVE_SCOPE(cx); \
if (!(cx->blk_u16 & CxPOPSUB_DONE)) { \
CV * const cv = cx->blk_format.cv; \
GV * const dfuot = cx->blk_format.dfoutgv; \
@@ -729,7 +727,6 @@ struct block_eval {
#define POPEVAL(cx) \
STMT_START { \
- CX_LEAVE_SCOPE(cx); \
PL_in_eval = CxOLD_IN_EVAL(cx); \
optype = CxOLD_OP_TYPE(cx); \
PL_eval_root = cx->blk_eval.old_eval_root; \
@@ -809,7 +806,6 @@ struct block_loop {
PUSHLOOP_FOR_setpad(cx);
#define POPLOOP(cx) \
- CX_LEAVE_SCOPE(cx); \
if (CxTYPE(cx) == CXt_LOOP_LAZYSV) { \
SvREFCNT_dec_NN(cx->blk_loop.state_u.lazysv.cur); \
SvREFCNT_dec_NN(cx->blk_loop.state_u.lazysv.end); \
@@ -841,10 +837,9 @@ struct block_givwhen {
cx->blk_givwhen.defsv_save = orig_var;
#define POPWHEN(cx) \
- CX_LEAVE_SCOPE(cx);
+ NOOP;
#define POPGIVEN(cx) \
- CX_LEAVE_SCOPE(cx); \
SvREFCNT_dec(GvSV(PL_defgv)); \
GvSV(PL_defgv) = cx->blk_givwhen.defsv_save;
@@ -855,7 +850,7 @@ struct block_givwhen {
cx->cx_u.cx_blk.blku_old_savestack_ix = PL_savestack_ix;
#define POPBASICBLK(cx) \
- CX_LEAVE_SCOPE(cx);
+ NOOP;
/* context common to subroutines, evals and loops */
@@ -1291,8 +1286,8 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
STMT_START { \
cx = &cxstack[cxstack_ix]; \
CvDEPTH(multicall_cv) = cx->blk_sub.olddepth; \
- /* includes partial unrolled POPSUB(): */ \
CX_LEAVE_SCOPE(cx); \
+ /* includes partial unrolled POPSUB(): */ \
PL_comppad = cx->blk_sub.prevcomppad; \
PL_curpad = LIKELY(PL_comppad) ? AvARRAY(PL_comppad) : NULL; \
SvREFCNT_dec_NN(multicall_cv); \
diff --git a/pp_ctl.c b/pp_ctl.c
index 1f915320fa..d005076ba2 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1515,29 +1515,38 @@ Perl_dounwind(pTHX_ I32 cxix)
POPSUBST(cx);
continue; /* not break */
case CXt_SUB:
+ CX_LEAVE_SCOPE(cx);
POPSUB(cx);
break;
case CXt_EVAL:
+ CX_LEAVE_SCOPE(cx);
POPEVAL(cx);
break;
case CXt_BLOCK:
+ CX_LEAVE_SCOPE(cx);
POPBASICBLK(cx);
break;
case CXt_LOOP_LAZYIV:
case CXt_LOOP_LAZYSV:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
+ CX_LEAVE_SCOPE(cx);
POPLOOP(cx);
break;
case CXt_WHEN:
+ CX_LEAVE_SCOPE(cx);
POPWHEN(cx);
break;
case CXt_GIVEN:
+ CX_LEAVE_SCOPE(cx);
POPGIVEN(cx);
break;
case CXt_NULL:
+ /* there isn't a POPNULL ! */
+ CX_LEAVE_SCOPE(cx);
break;
case CXt_FORMAT:
+ CX_LEAVE_SCOPE(cx);
POPFORMAT(cx);
break;
}
@@ -1656,6 +1665,7 @@ Perl_die_unwind(pTHX_ SV *msv)
my_exit(1);
}
+ CX_LEAVE_SCOPE(cx);
POPEVAL(cx);
POPBLOCK(cx);
cxstack_ix--;
@@ -2091,6 +2101,7 @@ PP(pp_leave)
leave_common(newsp, newsp, gimme, SVs_PADTMP|SVs_TEMP,
PL_op->op_private & OPpLVALUE);
+ CX_LEAVE_SCOPE(cx);
POPBASICBLK(cx);
POPBLOCK(cx);
cxstack_ix--;
@@ -2267,6 +2278,7 @@ PP(pp_leaveloop)
leave_common(newsp, MARK, gimme, SVs_PADTMP|SVs_TEMP,
PL_op->op_private & OPpLVALUE);
+ CX_LEAVE_SCOPE(cx);
POPLOOP(cx); /* Stack values are safe: release loop vars ... */
POPBLOCK(cx);
cxstack_ix--;
@@ -2326,6 +2338,7 @@ PP(pp_leavesublv)
what = "undef";
}
croak:
+ CX_LEAVE_SCOPE(cx);
POPSUB(cx);
cxstack_ix--;
PL_curpm = cx->blk_oldpm;
@@ -2395,6 +2408,7 @@ PP(pp_leavesublv)
}
PUTBACK;
+ CX_LEAVE_SCOPE(cx);
POPSUB(cx); /* Stack values are safe: release CV and @_ ... */
POPBLOCK(cx);
cxstack_ix--;
@@ -2570,6 +2584,7 @@ PP(pp_last)
TAINT_NOT;
/* Stack values are safe: */
+ CX_LEAVE_SCOPE(cx);
POPLOOP(cx); /* release loop vars ... */
POPBLOCK(cx);
cxstack_ix--;
@@ -2751,8 +2766,6 @@ PP(pp_goto)
TOPBLOCK(cx);
SPAGAIN;
- /* partial unrolled POPSUB(): */
-
/* protect @_ during save stack unwind. */
if (arg)
SvREFCNT_inc_NN(sv_2mortal(MUTABLE_SV(arg)));
@@ -2760,6 +2773,8 @@ PP(pp_goto)
assert(PL_scopestack_ix == cx->blk_oldscopesp);
CX_LEAVE_SCOPE(cx);
+ /* partial unrolled POPSUB(): */
+
if (CxTYPE(cx) == CXt_SUB && CxHASARGS(cx)) {
AV* av = MUTABLE_AV(PAD_SVl(0));
assert(AvARRAY(MUTABLE_AV(
@@ -3432,6 +3447,7 @@ S_doeval(pTHX_ int gimme, CV* outside, U32 seq, HV *hh)
}
SP = PL_stack_base + POPMARK; /* pop original mark */
cx = &cxstack[cxstack_ix];
+ CX_LEAVE_SCOPE(cx);
POPEVAL(cx);
POPBLOCK(cx);
cxstack_ix--;
@@ -4278,6 +4294,7 @@ PP(pp_leaveeval)
* to get the current hints. So restore it early.
*/
PL_curcop = cx->blk_oldcop;
+ CX_LEAVE_SCOPE(cx);
POPEVAL(cx);
POPBLOCK(cx);
cxstack_ix--;
@@ -4320,6 +4337,7 @@ Perl_delete_eval_scope(pTHX)
I32 optype;
cx = &cxstack[cxstack_ix];
+ CX_LEAVE_SCOPE(cx);
POPEVAL(cx);
POPBLOCK(cx);
cxstack_ix--;
@@ -4375,6 +4393,7 @@ PP(pp_leavetry)
PL_stack_sp = newsp;
else
leave_common(newsp, newsp, gimme, SVs_PADTMP|SVs_TEMP, FALSE);
+ CX_LEAVE_SCOPE(cx);
POPEVAL(cx);
POPBLOCK(cx);
cxstack_ix--;
@@ -4418,6 +4437,8 @@ PP(pp_leavegiven)
PL_stack_sp = newsp;
else
leave_common(newsp, newsp, gimme, SVs_PADTMP|SVs_TEMP, FALSE);
+
+ CX_LEAVE_SCOPE(cx);
POPGIVEN(cx);
POPBLOCK(cx);
cxstack_ix--;
@@ -5037,6 +5058,7 @@ PP(pp_continue)
cx = &cxstack[cxstack_ix];
assert(CxTYPE(cx) == CXt_WHEN);
PL_stack_sp = PL_stack_base + cx->blk_oldsp;
+ CX_LEAVE_SCOPE(cx);
POPWHEN(cx);
POPBLOCK(cx);
cxstack_ix--;
diff --git a/pp_hot.c b/pp_hot.c
index 22b9dd4461..147f9cb51e 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3336,6 +3336,7 @@ PP(pp_leavesub)
}
PUTBACK;
+ CX_LEAVE_SCOPE(cx);
POPSUB(cx); /* Stack values are safe: release CV and @_ ... */
POPBLOCK(cx);
cxstack_ix--;
diff --git a/pp_sort.c b/pp_sort.c
index 1d6f7d6a95..63214b9487 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1703,14 +1703,14 @@ PP(pp_sort)
PL_stack_sp = PL_stack_base + cx->blk_oldsp;
+ CX_LEAVE_SCOPE(cx);
if (!(flags & OPf_SPECIAL)) {
assert(CxTYPE(cx) == CXt_SUB);
POPSUB(cx);
}
- else {
+ else
assert(CxTYPE(cx) == CXt_NULL);
- CX_LEAVE_SCOPE(cx);
- }
+ /* there isn't a POPNULL ! */
POPBLOCK(cx);
cxstack_ix--;
diff --git a/pp_sys.c b/pp_sys.c
index 6c978eb257..be4dec4f6a 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1523,6 +1523,7 @@ PP(pp_leavewrite)
cx = &cxstack[cxstack_ix];
assert(CxTYPE(cx) == CXt_FORMAT);
SP = PL_stack_base + cx->blk_oldsp; /* ignore retval of formline */
+ CX_LEAVE_SCOPE(cx);
POPFORMAT(cx);
POPBLOCK(cx);
retop = cx->blk_sub.retop;