struct block_loop {
char * label;
I32 resetsp;
- OP * redo_op;
- OP * next_op;
- OP * last_op;
+ LOOP * my_op; /* My op, that contains redo, next and last ops. */
+ /* (except for non_ithreads we need to modify next_op in pp_ctl.c, hence
+ why next_op is conditionally defined below.) */
#ifdef USE_ITHREADS
void * iterdata;
PAD *oldcomppad;
#else
+ OP * next_op;
SV ** itervar;
#endif
SV * itersave;
cx->blk_loop.itersave = NULL;
#endif
+#ifdef USE_ITHREADS
+# define PUSHLOOP_OP_NEXT /* No need to do anything. */
+# define CX_LOOP_NEXTOP_GET(cx) ((cx)->blk_loop.my_op->op_nextop + 0)
+#else
+# define PUSHLOOP_OP_NEXT cx->blk_loop.next_op = cLOOP->op_nextop
+# define CX_LOOP_NEXTOP_GET(cx) ((cx)->blk_loop.next_op + 0)
+#endif
+
#define PUSHLOOP(cx, dat, s) \
cx->blk_loop.label = PL_curcop->cop_label; \
cx->blk_loop.resetsp = s - PL_stack_base; \
- cx->blk_loop.redo_op = cLOOP->op_redoop; \
- cx->blk_loop.next_op = cLOOP->op_nextop; \
- cx->blk_loop.last_op = cLOOP->op_lastop; \
+ cx->blk_loop.my_op = cLOOP; \
+ PUSHLOOP_OP_NEXT; \
cx->blk_loop.iterlval = NULL; \
cx->blk_loop.iterary = NULL; \
cx->blk_loop.iterix = -1; \
case CXt_LOOP:
pop2 = CXt_LOOP;
newsp = PL_stack_base + cx->blk_loop.resetsp;
- nextop = cx->blk_loop.last_op->op_next;
+ nextop = cx->blk_loop.my_op->op_lastop->op_next;
break;
case CXt_SUB:
pop2 = CXt_SUB;
if (PL_scopestack_ix < inner)
leave_scope(PL_scopestack[PL_scopestack_ix]);
PL_curcop = cx->blk_oldcop;
- return cx->blk_loop.next_op;
+ return CX_LOOP_NEXTOP_GET(cx);
}
PP(pp_redo)
if (cxix < cxstack_ix)
dounwind(cxix);
- redo_op = cxstack[cxix].blk_loop.redo_op;
+ redo_op = cxstack[cxix].blk_loop.my_op->op_redoop;
if (redo_op->op_type == OP_ENTER) {
/* pop one less context to avoid $x being freed in while (my $x..) */
cxstack_ix++;
PL_curcop = cx->blk_oldcop;
if (CxFOREACH(cx))
- return cx->blk_loop.next_op;
+ return CX_LOOP_NEXTOP_GET(cx);
else
return cx->blk_givwhen.leave_op;
}
cx->blk_loop.label);
PerlIO_printf(Perl_debug_log, "BLK_LOOP.RESETSP = %ld\n",
(long)cx->blk_loop.resetsp);
- PerlIO_printf(Perl_debug_log, "BLK_LOOP.REDO_OP = 0x%"UVxf"\n",
- PTR2UV(cx->blk_loop.redo_op));
+ PerlIO_printf(Perl_debug_log, "BLK_LOOP.MY_OP = 0x%"UVxf"\n",
+ PTR2UV(cx->blk_loop.my_op));
PerlIO_printf(Perl_debug_log, "BLK_LOOP.NEXT_OP = 0x%"UVxf"\n",
- PTR2UV(cx->blk_loop.next_op));
- PerlIO_printf(Perl_debug_log, "BLK_LOOP.LAST_OP = 0x%"UVxf"\n",
- PTR2UV(cx->blk_loop.last_op));
+ PTR2UV(CX_LOOP_NEXTOP_GET(cx)));
PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
(long)cx->blk_loop.iterix);
PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
case CXt_LOOP:
ncx->blk_loop.label = cx->blk_loop.label;
ncx->blk_loop.resetsp = cx->blk_loop.resetsp;
- ncx->blk_loop.redo_op = cx->blk_loop.redo_op;
- ncx->blk_loop.next_op = cx->blk_loop.next_op;
- ncx->blk_loop.last_op = cx->blk_loop.last_op;
+ ncx->blk_loop.my_op = cx->blk_loop.my_op;
ncx->blk_loop.iterdata = (CxPADLOOP(cx)
? cx->blk_loop.iterdata
: gv_dup((GV*)cx->blk_loop.iterdata, param));