OP * next_op;
SV ** itervar;
#endif
- SV * itersave;
union {
struct { /* valid if type is LOOP_FOR or LOOP_PLAIN (but {NULL,0})*/
AV * ary; /* use the stack if this is NULL */
: (SV**)NULL)
# define CX_ITERDATA_SET(cx,idata) \
CX_CURPAD_SAVE(cx->blk_loop); \
- if ((cx->blk_loop.iterdata = (idata)) && SvPADMY(*CxITERVAR(cx))) \
- cx->blk_loop.itersave = SvREFCNT_inc(*CxITERVAR(cx)); \
- else \
- cx->blk_loop.itersave = NULL;
+ cx->blk_loop.iterdata = (idata);
#else
# define CxITERVAR(c) ((c)->blk_loop.itervar)
# define CX_ITERDATA_SET(cx,ivar) \
- if ((cx->blk_loop.itervar = (SV**)(ivar)) \
- && SvPADMY(*CxITERVAR(cx))) \
- cx->blk_loop.itersave = SvREFCNT_inc(*CxITERVAR(cx)); \
- else \
- cx->blk_loop.itersave = NULL;
+ cx->blk_loop.itervar = (SV**)(ivar);
#endif
#define CxLABEL(c) (0 + (c)->blk_oldcop->cop_label)
#define CxHASARGS(c) (((c)->cx_type & CXp_HASARGS) == CXp_HASARGS)
SvREFCNT_dec(cx->blk_loop.state_u.lazysv.cur); \
SvREFCNT_dec(cx->blk_loop.state_u.lazysv.end); \
} \
- if (cx->blk_loop.itersave) { \
- SV ** const s_v_p = CxITERVAR(cx); \
- assert(SvPADMY(cx->blk_loop.itersave)); \
- sv_2mortal(*s_v_p); \
- *s_v_p = cx->blk_loop.itersave; \
- } \
if (CxTYPE(cx) == CXt_LOOP_FOR) \
SvREFCNT_dec(cx->blk_loop.state_u.ary.ary);
Ap |void |save_pptr |NN char** pptr
Ap |void |save_vptr |NN void* pptr
Ap |void |save_re_context
-Ap |void |save_padsv |PADOFFSET off
+Ap |void |save_padsv_and_mortalize|PADOFFSET off
Ap |void |save_sptr |NN SV** sptr
Ap |SV* |save_svref |NN SV** sptr
p |OP* |sawparens |NULLOK OP* o
#define save_pptr Perl_save_pptr
#define save_vptr Perl_save_vptr
#define save_re_context Perl_save_re_context
-#define save_padsv Perl_save_padsv
+#define save_padsv_and_mortalize Perl_save_padsv_and_mortalize
#define save_sptr Perl_save_sptr
#define save_svref Perl_save_svref
#ifdef PERL_CORE
#define save_pptr(a) Perl_save_pptr(aTHX_ a)
#define save_vptr(a) Perl_save_vptr(aTHX_ a)
#define save_re_context() Perl_save_re_context(aTHX)
-#define save_padsv(a) Perl_save_padsv(aTHX_ a)
+#define save_padsv_and_mortalize(a) Perl_save_padsv_and_mortalize(aTHX_ a)
#define save_sptr(a) Perl_save_sptr(aTHX_ a)
#define save_svref(a) Perl_save_svref(aTHX_ a)
#ifdef PERL_CORE
SAVESETSVFLAGS(PAD_SVl(PL_op->op_targ),
SVs_PADSTALE, SVs_PADSTALE);
}
+ SAVEPADSVANDMORTALIZE(PL_op->op_targ);
#ifndef USE_ITHREADS
svp = &PAD_SVl(PL_op->op_targ); /* "my" variable */
- SAVESPTR(*svp);
#else
- SAVEPADSV(PL_op->op_targ);
iterdata = INT2PTR(void*, PL_op->op_targ);
cxtype |= CXp_PADVAR;
#endif
__attribute__nonnull__(pTHX_1);
PERL_CALLCONV void Perl_save_re_context(pTHX);
-PERL_CALLCONV void Perl_save_padsv(pTHX_ PADOFFSET off);
+PERL_CALLCONV void Perl_save_padsv_and_mortalize(pTHX_ PADOFFSET off);
PERL_CALLCONV void Perl_save_sptr(pTHX_ SV** sptr)
__attribute__nonnull__(pTHX_1);
}
void
-Perl_save_padsv(pTHX_ PADOFFSET off)
+Perl_save_padsv_and_mortalize(pTHX_ PADOFFSET off)
{
dVAR;
SSCHECK(4);
ASSERT_CURPAD_ACTIVE("save_padsv");
- SSPUSHPTR(PL_curpad[off]);
+ SSPUSHPTR(SvREFCNT_inc_simple_NN(PL_curpad[off]));
SSPUSHPTR(PL_comppad);
SSPUSHLONG((long)off);
- SSPUSHINT(SAVEt_PADSV);
+ SSPUSHINT(SAVEt_PADSV_AND_MORTALIZE);
}
void
else
PL_curpad = NULL;
break;
- case SAVEt_PADSV:
+ case SAVEt_PADSV_AND_MORTALIZE:
{
const PADOFFSET off = (PADOFFSET)SSPOPLONG;
+ SV **svp;
ptr = SSPOPPTR;
- if (ptr)
- assert(AvARRAY((PAD*)ptr)[off] == (SV*)SSPOPPTR);
+ assert (ptr);
+ svp = AvARRAY((PAD*)ptr) + off;
+ /* This mortalizing used to be done by POPLOOP() via itersave.
+ But as we have all the information here, we can do it here,
+ save even having to have itersave in the struct. */
+ sv_2mortal(*svp);
+ *svp = (SV*)SSPOPPTR;
}
break;
case SAVEt_SAVESWITCHSTACK:
(long)cx->blk_loop.state_u.ary.ix);
PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
PTR2UV(CxITERVAR(cx)));
- if (CxITERVAR(cx))
- PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%"UVxf"\n",
- PTR2UV(cx->blk_loop.itersave));
break;
case CXt_SUBST:
#define SAVEt_I8 32
#define SAVEt_COMPPAD 33
#define SAVEt_GENERIC_PVREF 34
-#define SAVEt_PADSV 35
+#define SAVEt_PADSV_AND_MORTALIZE 35
#define SAVEt_MORTALIZESV 36
#define SAVEt_SHARED_PVREF 37
#define SAVEt_BOOL 38
#define SAVESPTR(s) save_sptr((SV**)&(s))
#define SAVEPPTR(s) save_pptr((char**)&(s))
#define SAVEVPTR(s) save_vptr((void*)&(s))
-#define SAVEPADSV(s) save_padsv(s)
+#define SAVEPADSVANDMORTALIZE(s) save_padsv_and_mortalize(s)
#define SAVEFREESV(s) save_freesv((SV*)(s))
#define SAVEMORTALIZESV(s) save_mortalizesv((SV*)(s))
#define SAVEFREEOP(o) save_freeop((OP*)(o))
ncx->blk_loop.oldcomppad
= (PAD*)ptr_table_fetch(PL_ptr_table,
ncx->blk_loop.oldcomppad);
- ncx->blk_loop.itersave = sv_dup_inc(ncx->blk_loop.itersave,
- param);
break;
case CXt_FORMAT:
ncx->blk_format.cv = cv_dup(ncx->blk_format.cv, param);
TOPPTR(nss,ix) = hv_dup_inc(hv, param);
}
break;
- case SAVEt_PADSV:
+ case SAVEt_PADSV_AND_MORTALIZE:
longval = (long)POPLONG(ss,ix);
TOPLONG(nss,ix) = longval;
ptr = POPPTR(ss,ix);
TOPPTR(nss,ix) = any_dup(ptr, proto_perl);
sv = (SV*)POPPTR(ss,ix);
- TOPPTR(nss,ix) = sv_dup(sv, param);
+ TOPPTR(nss,ix) = sv_dup_inc(sv, param);
break;
case SAVEt_BOOL:
ptr = POPPTR(ss,ix);