summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-26 17:54:29 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-26 17:54:29 +0000
commit09edbca0f5c7caf9dd4acef80d8e6275e5a95ea1 (patch)
treee0dc9093a93c63c250e26059deebe7f51400a7ca /scope.c
parentdceb5f6256f15f796b36d673cf34f57b7feb1127 (diff)
downloadperl-09edbca0f5c7caf9dd4acef80d8e6275e5a95ea1.tar.gz
Investigation reveals that the work of restoring the iterator to the
pad is shared between POPLOOP, using itersave, and the end of scope restore action requested by Perl_save_padsv(). In fact, the only user of SAVEt_PADSV is pp_enteriter, and it already provides enough information to allow it to perform the sv_2mortal() in POPLOOP. So make it do so. Rather than creating a new routine, use the existing routine because nothing else (at least nothing else known to Google's codesearch) uses it. But rename it just in case something we can't see is being naughty and using our private functions - they will get link errors against 5.12. All this means that itersave is now redundant. So remove it. This makes struct context 48 bytes on ILP32 platforms with 32bit IVs, down from 64 bytes in 5.10. 33% more context stack in the same memory. p4raw-id: //depot/perl@33080
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/scope.c b/scope.c
index 616247e674..fae4892ab1 100644
--- a/scope.c
+++ b/scope.c
@@ -412,15 +412,15 @@ Perl_save_sptr(pTHX_ SV **sptr)
}
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
@@ -929,12 +929,18 @@ Perl_leave_scope(pTHX_ I32 base)
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:
@@ -1101,9 +1107,6 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
(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: