From: Gurusamy Sarathy Date: Fri, 8 Oct 1999 22:50:51 +0000 (+0000) Subject: revert POP{SUB,LOOP}{1,2} logic to the simpler pre-5.003_24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a8bba7fac320f0a7f553e9a133cddd65ef2a66c7;p=p5sagit%2Fp5-mst-13.2.git revert POP{SUB,LOOP}{1,2} logic to the simpler pre-5.003_24 situation (assumptions about cx invalidation are not valid anymore) p4raw-id: //depot/perl@4320 --- diff --git a/cop.h b/cop.h index 1fdd6d1..88749fb 100644 --- a/cop.h +++ b/cop.h @@ -52,40 +52,32 @@ struct block_sub { cx->blk_sub.dfoutgv = PL_defoutgv; \ (void)SvREFCNT_inc(cx->blk_sub.dfoutgv) -#define POPSUB(cx) \ - { struct block_sub cxsub; \ - POPSUB1(cx); \ - POPSUB2(); } - -#define POPSUB1(cx) \ - cxsub = cx->blk_sub; /* because DESTROY may clobber *cx */ - #ifdef USE_THREADS #define POPSAVEARRAY() NOOP #else #define POPSAVEARRAY() \ STMT_START { \ SvREFCNT_dec(GvAV(PL_defgv)); \ - GvAV(PL_defgv) = cxsub.savearray; \ + GvAV(PL_defgv) = cx->blk_sub.savearray; \ } STMT_END #endif /* USE_THREADS */ -#define POPSUB2() \ - if (cxsub.hasargs) { \ +#define POPSUB(cx) \ + if (cx->blk_sub.hasargs) { \ POPSAVEARRAY(); \ /* abandon @_ if it got reified */ \ - if (AvREAL(cxsub.argarray)) { \ - SSize_t fill = AvFILLp(cxsub.argarray); \ - SvREFCNT_dec(cxsub.argarray); \ - cxsub.argarray = newAV(); \ - av_extend(cxsub.argarray, fill); \ - AvFLAGS(cxsub.argarray) = AVf_REIFY; \ - PL_curpad[0] = (SV*)cxsub.argarray; \ + if (AvREAL(cx->blk_sub.argarray)) { \ + SSize_t fill = AvFILLp(cx->blk_sub.argarray); \ + SvREFCNT_dec(cx->blk_sub.argarray); \ + cx->blk_sub.argarray = newAV(); \ + av_extend(cx->blk_sub.argarray, fill); \ + AvFLAGS(cx->blk_sub.argarray) = AVf_REIFY; \ + PL_curpad[0] = (SV*)cx->blk_sub.argarray; \ } \ } \ - if (cxsub.cv) { \ - if (!(CvDEPTH(cxsub.cv) = cxsub.olddepth)) \ - SvREFCNT_dec(cxsub.cv); \ + if (cx->blk_sub.cv) { \ + if (!(CvDEPTH(cx->blk_sub.cv) = cx->blk_sub.olddepth)) \ + SvREFCNT_dec(cx->blk_sub.cv); \ } #define POPFORMAT(cx) \ @@ -103,9 +95,9 @@ struct block_eval { #define PUSHEVAL(cx,n,fgv) \ cx->blk_eval.old_in_eval = PL_in_eval; \ - cx->blk_eval.old_op_type = PL_op->op_type; \ + cx->blk_eval.old_op_type = PL_op->op_type; \ cx->blk_eval.old_name = n; \ - cx->blk_eval.old_eval_root = PL_eval_root; \ + cx->blk_eval.old_eval_root = PL_eval_root; \ cx->blk_eval.cur_text = PL_linestr; #define POPEVAL(cx) \ @@ -141,22 +133,13 @@ struct block_loop { cx->blk_loop.iterix = -1; #define POPLOOP(cx) \ - { struct block_loop cxloop; \ - POPLOOP1(cx); \ - POPLOOP2(); } - -#define POPLOOP1(cx) \ - cxloop = cx->blk_loop; /* because DESTROY may clobber *cx */ \ - newsp = PL_stack_base + cxloop.resetsp; - -#define POPLOOP2() \ - SvREFCNT_dec(cxloop.iterlval); \ - if (cxloop.itervar) { \ - sv_2mortal(*cxloop.itervar); \ - *cxloop.itervar = cxloop.itersave; \ + SvREFCNT_dec(cx->blk_loop.iterlval); \ + if (cx->blk_loop.itervar) { \ + sv_2mortal(*(cx->blk_loop.itervar)); \ + *(cx->blk_loop.itervar) = cx->blk_loop.itersave; \ } \ - if (cxloop.iterary && cxloop.iterary != PL_curstack) \ - SvREFCNT_dec(cxloop.iterary); + if (cx->blk_loop.iterary && cx->blk_loop.iterary != PL_curstack)\ + SvREFCNT_dec(cx->blk_loop.iterary); /* context common to subroutines, evals and loops */ struct block { diff --git a/pp_ctl.c b/pp_ctl.c index a2b3139..746cb80 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1654,7 +1654,6 @@ PP(pp_leaveloop) { djSP; register PERL_CONTEXT *cx; - struct block_loop cxloop; I32 gimme; SV **newsp; PMOP *newpm; @@ -1662,7 +1661,7 @@ PP(pp_leaveloop) POPBLOCK(cx,newpm); mark = newsp; - POPLOOP1(cx); /* Delay POPLOOP2 until stack values are safe */ + newsp = PL_stack_base + cx->blk_loop.resetsp; TAINT_NOT; if (gimme == G_VOID) @@ -1682,7 +1681,7 @@ PP(pp_leaveloop) SP = newsp; PUTBACK; - POPLOOP2(); /* Stack values are safe: release loop vars ... */ + POPLOOP(cx); /* Stack values are safe: release loop vars ... */ PL_curpm = newpm; /* ... and pop $1 et al */ LEAVE; @@ -1696,7 +1695,6 @@ PP(pp_return) djSP; dMARK; I32 cxix; register PERL_CONTEXT *cx; - struct block_sub cxsub; bool popsub2 = FALSE; I32 gimme; SV **newsp; @@ -1722,7 +1720,6 @@ PP(pp_return) POPBLOCK(cx,newpm); switch (CxTYPE(cx)) { case CXt_SUB: - POPSUB1(cx); /* Delay POPSUB2 until stack values are safe */ popsub2 = TRUE; break; case CXt_EVAL: @@ -1747,7 +1744,7 @@ PP(pp_return) if (gimme == G_SCALAR) { if (MARK < SP) { if (popsub2) { - if (cxsub.cv && CvDEPTH(cxsub.cv) > 1) { + if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) { if (SvTEMP(TOPs)) { *++newsp = SvREFCNT_inc(*SP); FREETMPS; @@ -1774,7 +1771,7 @@ PP(pp_return) /* Stack values are safe: */ if (popsub2) { - POPSUB2(); /* release CV and @_ ... */ + POPSUB(cx); /* release CV and @_ ... */ } PL_curpm = newpm; /* ... and pop $1 et al */ @@ -1787,15 +1784,13 @@ PP(pp_last) djSP; I32 cxix; register PERL_CONTEXT *cx; - struct block_loop cxloop; - struct block_sub cxsub; I32 pop2 = 0; I32 gimme; I32 optype; OP *nextop; SV **newsp; PMOP *newpm; - SV **mark = PL_stack_base + cxstack[cxstack_ix].blk_oldsp; + SV **mark; if (PL_op->op_flags & OPf_SPECIAL) { cxix = dopoptoloop(cxstack_ix); @@ -1811,14 +1806,14 @@ PP(pp_last) dounwind(cxix); POPBLOCK(cx,newpm); + mark = newsp; switch (CxTYPE(cx)) { case CXt_LOOP: - POPLOOP1(cx); /* Delay POPLOOP2 until stack values are safe */ pop2 = CXt_LOOP; - nextop = cxloop.last_op->op_next; + newsp = PL_stack_base + cx->blk_loop.resetsp; + nextop = cx->blk_loop.last_op->op_next; break; case CXt_SUB: - POPSUB1(cx); /* Delay POPSUB2 until stack values are safe */ pop2 = CXt_SUB; nextop = pop_return(); break; @@ -1851,11 +1846,11 @@ PP(pp_last) /* Stack values are safe: */ switch (pop2) { case CXt_LOOP: - POPLOOP2(); /* release loop vars ... */ + POPLOOP(cx); /* release loop vars ... */ LEAVE; break; case CXt_SUB: - POPSUB2(); /* release CV and @_ ... */ + POPSUB(cx); /* release CV and @_ ... */ break; } PL_curpm = newpm; /* ... and pop $1 et al */ diff --git a/pp_hot.c b/pp_hot.c index 8e795cb..90e8f5f 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1914,16 +1914,14 @@ PP(pp_leavesub) PMOP *newpm; I32 gimme; register PERL_CONTEXT *cx; - struct block_sub cxsub; POPBLOCK(cx,newpm); - POPSUB1(cx); /* Delay POPSUB2 until stack values are safe */ TAINT_NOT; if (gimme == G_SCALAR) { MARK = newsp + 1; if (MARK <= SP) { - if (cxsub.cv && CvDEPTH(cxsub.cv) > 1) { + if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) { if (SvTEMP(TOPs)) { *MARK = SvREFCNT_inc(TOPs); FREETMPS; @@ -1953,7 +1951,7 @@ PP(pp_leavesub) } PUTBACK; - POPSUB2(); /* Stack values are safe: release CV and @_ ... */ + POPSUB(cx); /* Stack values are safe: release CV and @_ ... */ PL_curpm = newpm; /* ... and pop $1 et al */ LEAVE; @@ -1970,10 +1968,8 @@ PP(pp_leavesublv) PMOP *newpm; I32 gimme; register PERL_CONTEXT *cx; - struct block_sub cxsub; POPBLOCK(cx,newpm); - POPSUB1(cx); /* Delay POPSUB2 until stack values are safe */ TAINT_NOT; @@ -1988,7 +1984,7 @@ PP(pp_leavesublv) if (gimme == G_SCALAR) goto temporise; if (gimme == G_ARRAY) { - if (!CvLVALUE(cxsub.cv)) + if (!CvLVALUE(cx->blk_sub.cv)) goto temporise_array; EXTEND_MORTAL(SP - newsp); for (mark = newsp + 1; mark <= SP; mark++) { @@ -2008,8 +2004,8 @@ PP(pp_leavesublv) /* Here we go for robustness, not for speed, so we change all * the refcounts so the caller gets a live guy. Cannot set * TEMP, so sv_2mortal is out of question. */ - if (!CvLVALUE(cxsub.cv)) { - POPSUB2(); + if (!CvLVALUE(cx->blk_sub.cv)) { + POPSUB(cx); PL_curpm = newpm; DIE(aTHX_ "Can't modify non-lvalue subroutine call"); } @@ -2018,7 +2014,7 @@ PP(pp_leavesublv) EXTEND_MORTAL(1); if (MARK == SP) { if (SvFLAGS(TOPs) & (SVs_TEMP | SVs_PADTMP | SVf_READONLY)) { - POPSUB2(); + POPSUB(cx); PL_curpm = newpm; DIE(aTHX_ "Can't return a %s from lvalue subroutine", SvREADONLY(TOPs) ? "readonly value" : "temporary"); @@ -2030,7 +2026,7 @@ PP(pp_leavesublv) } } else { /* Should not happen? */ - POPSUB2(); + POPSUB(cx); PL_curpm = newpm; DIE(aTHX_ "%s returned from lvalue subroutine in scalar context", (MARK > SP ? "Empty array" : "Array")); @@ -2043,7 +2039,7 @@ PP(pp_leavesublv) if (SvFLAGS(*mark) & (SVs_TEMP | SVs_PADTMP | SVf_READONLY)) { /* Might be flattened array after $#array = */ PUTBACK; - POPSUB2(); + POPSUB(cx); PL_curpm = newpm; DIE(aTHX_ "Can't return %s from lvalue subroutine", (*mark != &PL_sv_undef) @@ -2065,7 +2061,7 @@ PP(pp_leavesublv) temporise: MARK = newsp + 1; if (MARK <= SP) { - if (cxsub.cv && CvDEPTH(cxsub.cv) > 1) { + if (cx->blk_sub.cv && CvDEPTH(cx->blk_sub.cv) > 1) { if (SvTEMP(TOPs)) { *MARK = SvREFCNT_inc(TOPs); FREETMPS; @@ -2097,7 +2093,7 @@ PP(pp_leavesublv) } PUTBACK; - POPSUB2(); /* Stack values are safe: release CV and @_ ... */ + POPSUB(cx); /* Stack values are safe: release CV and @_ ... */ PL_curpm = newpm; /* ... and pop $1 et al */ LEAVE;