Change 33059 by [EMAIL PROTECTED] on 2008/01/24 10:44:25
Split out foreach iterations of temporary lists on the stack to
CXt_LOOP_STACK. Don't use cx->blk_loop.iterary to store PL_curstack.
Affected files ...
... //depot/perl/cop.h#165 edit
... //depot/perl/pp_ctl.c#669 edit
... //depot/perl/pp_hot.c#560 edit
... //depot/perl/sv.c#1493 edit
Differences ...
==== //depot/perl/cop.h#165 (text) ====
Index: perl/cop.h
--- perl/cop.h#164~33057~ 2008-01-24 01:36:05.000000000 -0800
+++ perl/cop.h 2008-01-24 02:44:25.000000000 -0800
@@ -529,7 +529,7 @@
SvREFCNT_dec(cx->blk_loop.itersave); \
} \
} \
- if (cx->blk_loop.iterary && cx->blk_loop.iterary != PL_curstack)\
+ if ((CxTYPE(cx) != CXt_LOOP_STACK) && cx->blk_loop.iterary) \
SvREFCNT_dec(cx->blk_loop.iterary);
/* given/when context */
@@ -681,7 +681,8 @@
#define CXt_GIVEN 7
#define CXt_LOOP_PLAIN 8
#define CXt_LOOP_FOR 9
-#define CXt_LOOP_RES1 10
+/* Foreach on a temporary list on the stack */
+#define CXt_LOOP_STACK 10
#define CXt_LOOP_RES2 11
/* private flags for CXt_SUB and CXt_NULL
==== //depot/perl/pp_ctl.c#669 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#668~33057~ 2008-01-24 01:36:05.000000000 -0800
+++ perl/pp_ctl.c 2008-01-24 02:44:25.000000000 -0800
@@ -1256,6 +1256,7 @@
if (CxTYPE(cx) == CXt_NULL)
return -1;
break;
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
if ( !CxLABEL(cx) || strNE(label, CxLABEL(cx)) ) {
@@ -1372,6 +1373,7 @@
if ((CxTYPE(cx)) == CXt_NULL)
return -1;
break;
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
DEBUG_l( Perl_deb(aTHX_ "(Found loop #%ld)\n", (long)i));
@@ -1397,6 +1399,7 @@
case CXt_LOOP_PLAIN:
assert(!CxFOREACHDEF(cx));
break;
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
if (CxFOREACHDEF(cx)) {
DEBUG_l( Perl_deb(aTHX_ "(Found foreach #%ld)\n", (long)i));
@@ -1448,6 +1451,7 @@
case CXt_EVAL:
POPEVAL(cx);
break;
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
POPLOOP(cx);
@@ -1827,7 +1831,7 @@
register PERL_CONTEXT *cx;
const I32 gimme = GIMME_V;
SV **svp;
- U16 cxtype = CXt_LOOP_FOR;
+ U16 cxtype = 0;
#ifdef USE_ITHREADS
void *iterdata;
#endif
@@ -1865,6 +1869,7 @@
ENTER;
+ cxtype |= (PL_op->op_flags & OPf_STACKED) ? CXt_LOOP_FOR : CXt_LOOP_STACK;
PUSHBLOCK(cx, cxtype, SP);
#ifdef USE_ITHREADS
PUSHLOOP_FOR(cx, iterdata, MARK);
@@ -1919,7 +1924,7 @@
}
}
else {
- cx->blk_loop.iterary = PL_curstack;
+ cx->blk_loop.iterary = (SV*)0xDEADBEEF;
if (PL_op->op_private & OPpITER_REVERSED) {
cx->blk_loop.itermax = MARK - PL_stack_base + 1;
cx->blk_loop.iterix = cx->blk_oldsp + 1;
@@ -2145,6 +2150,7 @@
cxstack_ix++; /* temporarily protect top context */
mark = newsp;
switch (CxTYPE(cx)) {
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
pop2 = CxTYPE(cx);
@@ -2190,6 +2196,7 @@
/* Stack values are safe: */
switch (pop2) {
case CXt_LOOP_PLAIN:
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
POPLOOP(cx); /* release loop vars ... */
LEAVE;
@@ -2548,6 +2555,7 @@
break;
}
/* else fall through */
+ case CXt_LOOP_STACK:
case CXt_LOOP_FOR:
case CXt_LOOP_PLAIN:
gotoprobe = cx->blk_oldcop->op_sibling;
==== //depot/perl/pp_hot.c#560 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#559~33057~ 2008-01-24 01:36:05.000000000 -0800
+++ perl/pp_hot.c 2008-01-24 02:44:25.000000000 -0800
@@ -1911,7 +1911,7 @@
DIE(aTHX_ "panic: pp_iter");
itersvp = CxITERVAR(cx);
- av = cx->blk_loop.iterary;
+ av = CxTYPE(cx) == CXt_LOOP_STACK ? PL_curstack : cx->blk_loop.iterary;
if (SvTYPE(av) != SVt_PVAV) {
/* iterate ($min .. $max) */
if (cx->blk_loop.iterlval) {
==== //depot/perl/sv.c#1493 (text) ====
Index: perl/sv.c
--- perl/sv.c#1492~33057~ 2008-01-24 01:36:05.000000000 -0800
+++ perl/sv.c 2008-01-24 02:44:25.000000000 -0800
@@ -10545,6 +10545,7 @@
case CXt_LOOP_FOR:
ncx->blk_loop.iterary = av_dup_inc(ncx->blk_loop.iterary,
param);
+ case CXt_LOOP_STACK:
case CXt_LOOP_PLAIN:
ncx->blk_loop.iterdata = (CxPADLOOP(ncx)
? ncx->blk_loop.iterdata
End of Patch.