/* Exit a block (RETURN and LAST). */
#define POPBLOCK(cx,pm) \
DEBUG_CX("POP"); \
- cx = &cxstack[cxstack_ix--], \
PL_curcop = cx->blk_oldcop, \
PL_markstack_ptr = PL_markstack + cx->blk_oldmarksp, \
PL_scopestack_ix = cx->blk_oldscopesp, \
STMT_START { \
cx = &cxstack[cxstack_ix]; \
CvDEPTH(multicall_cv) = cx->blk_sub.olddepth; \
- POPBLOCK(cx,PL_curpm); \
- /* these two set for backcompat by callers */ \
- newsp = PL_stack_base + cx->blk_oldsp; \
- gimme = cx->blk_gimme; \
/* includes partial unrolled POPSUB(): */ \
CX_LEAVE_SCOPE(cx); \
PL_comppad = cx->blk_sub.prevcomppad; \
PL_curpad = LIKELY(PL_comppad) ? AvARRAY(PL_comppad) : NULL; \
SvREFCNT_dec_NN(multicall_cv); \
+ /* these two set for backcompat by callers */ \
+ newsp = PL_stack_base + cx->blk_oldsp; \
+ gimme = cx->blk_gimme; \
+ POPBLOCK(cx,PL_curpm); \
+ cxstack_ix--; \
POPSTACK; \
CATCH_SET(multicall_oldcatch); \
SPAGAIN; \
my_exit(1);
}
- POPBLOCK(cx,PL_curpm);
POPEVAL(cx);
+ POPBLOCK(cx,PL_curpm);
+ cxstack_ix--;
namesv = cx->blk_eval.old_namesv;
#ifdef DEBUGGING
oldcop = cx->blk_oldcop;
PMOP *newpm;
I32 gimme;
- if (PL_op->op_flags & OPf_SPECIAL) {
- cx = &cxstack[cxstack_ix];
- cx->blk_oldpm = PL_curpm; /* fake block should preserve $1 et al */
- }
-
cx = &cxstack[cxstack_ix];
assert(CxTYPE(cx) == CXt_BLOCK);
+
+ if (PL_op->op_flags & OPf_SPECIAL)
+ cx->blk_oldpm = PL_curpm; /* fake block should preserve $1 et al */
+
newsp = PL_stack_base + cx->blk_oldsp;
gimme = cx->blk_gimme;
leave_common(newsp, newsp, gimme, SVs_PADTMP|SVs_TEMP,
PL_op->op_private & OPpLVALUE);
- POPBLOCK(cx,newpm);
POPBASICBLK(cx);
-
+ POPBLOCK(cx,newpm);
PL_curpm = newpm; /* Don't pop $1 et al till now */
+ cxstack_ix--;
return NORMAL;
}
leave_common(newsp, MARK, gimme, SVs_PADTMP|SVs_TEMP,
PL_op->op_private & OPpLVALUE);
- POPBLOCK(cx,newpm);
POPLOOP(cx); /* Stack values are safe: release loop vars ... */
+ POPBLOCK(cx,newpm);
PL_curpm = newpm; /* ... and pop $1 et al */
+ cxstack_ix--;
return NORMAL;
}
}
PUTBACK;
- POPBLOCK(cx,newpm);
- cxstack_ix++; /* preserve cx entry on stack for use by POPSUB */
POPSUB(cx); /* Stack values are safe: release CV and @_ ... */
- cxstack_ix--;
+ POPBLOCK(cx,newpm);
PL_curpm = newpm; /* ... and pop $1 et al */
+ cxstack_ix--;
return cx->blk_sub.retop;
}
PP(pp_last)
{
PERL_CONTEXT *cx;
- OP *nextop = NULL;
PMOP *newpm;
S_unwind_loop(aTHX_ "last");
- POPBLOCK(cx,newpm);
- cxstack_ix++; /* temporarily protect top context */
+ cx = &cxstack[cxstack_ix];
+
assert(
CxTYPE(cx) == CXt_LOOP_LAZYIV
|| CxTYPE(cx) == CXt_LOOP_LAZYSV
|| CxTYPE(cx) == CXt_LOOP_PLAIN
);
PL_stack_sp = PL_stack_base + cx->blk_loop.resetsp;
- nextop = cx->blk_loop.my_op->op_lastop->op_next;
TAINT_NOT;
- cxstack_ix--;
/* Stack values are safe: */
POPLOOP(cx); /* release loop vars ... */
+ POPBLOCK(cx,newpm);
PL_curpm = newpm; /* ... and pop $1 et al */
+ cxstack_ix--;
- return nextop;
+ return cx->blk_loop.my_op->op_lastop->op_next;
}
PP(pp_next)
PL_eval_root = NULL;
}
SP = PL_stack_base + POPMARK; /* pop original mark */
- POPBLOCK(cx,PL_curpm);
+ cx = &cxstack[cxstack_ix];
POPEVAL(cx);
+ POPBLOCK(cx,PL_curpm);
+ cxstack_ix--;
namesv = cx->blk_eval.old_namesv;
}
leave_common(newsp, newsp, gimme, SVs_TEMP, FALSE);
SPAGAIN;
}
- POPBLOCK(cx,newpm);
+ /* the POPEVAL does a leavescope, which frees the optree associated
+ * with eval, which if it frees the nextstate associated with
+ * PL_curcop, sets PL_curcop to NULL. Which can mess up freeing a
+ * regex when running under 'use re Debug' because it needs PL_curcop
+ * to get the current hints. So restore it early.
+ */
+ PL_curcop = cx->blk_oldcop;
POPEVAL(cx);
+ POPBLOCK(cx,newpm);
+ PL_curpm = newpm; /* Don't pop $1 et al till now */
+ cxstack_ix--;
namesv = cx->blk_eval.old_namesv;
retop = cx->blk_eval.retop;
evalcv = cx->blk_eval.cv;
- PL_curpm = newpm; /* Don't pop $1 et al till now */
#ifdef DEBUGGING
assert(CvDEPTH(evalcv) == 1);
PERL_CONTEXT *cx;
I32 optype;
- POPBLOCK(cx,newpm);
+ cx = &cxstack[cxstack_ix];
POPEVAL(cx);
+ POPBLOCK(cx,newpm);
PL_curpm = newpm;
+ cxstack_ix--;
PERL_UNUSED_VAR(optype);
}
PL_stack_sp = newsp;
else
leave_common(newsp, newsp, gimme, SVs_PADTMP|SVs_TEMP, FALSE);
+ POPEVAL(cx);
POPBLOCK(cx,newpm);
+ cxstack_ix--;
retop = cx->blk_eval.retop;
- POPEVAL(cx);
PERL_UNUSED_VAR(optype);
PL_curpm = newpm; /* Don't pop $1 et al till now */
PL_stack_sp = newsp;
else
leave_common(newsp, newsp, gimme, SVs_PADTMP|SVs_TEMP, FALSE);
- POPBLOCK(cx,newpm);
POPGIVEN(cx);
- assert(CxTYPE(cx) == CXt_GIVEN);
-
+ POPBLOCK(cx,newpm);
PL_curpm = newpm; /* Don't pop $1 et al till now */
+ cxstack_ix--;
return NORMAL;
}
PP(pp_continue)
{
- dSP;
I32 cxix;
PERL_CONTEXT *cx;
PMOP *newpm;
if (cxix < cxstack_ix)
dounwind(cxix);
- POPBLOCK(cx,newpm);
+ cx = &cxstack[cxstack_ix];
assert(CxTYPE(cx) == CXt_WHEN);
+ PL_stack_sp = PL_stack_base + cx->blk_oldsp;
POPWHEN(cx);
-
- SP = PL_stack_base + cx->blk_oldsp;
+ POPBLOCK(cx,newpm);
PL_curpm = newpm; /* pop $1 et al */
+ cxstack_ix--;
- RETURNOP(cx->blk_givwhen.leave_op->op_next);
+ return cx->blk_givwhen.leave_op->op_next;
}
PP(pp_break)