summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-02-20 13:36:21 +0000
committerNicholas Clark <nick@ccl4.org>2010-05-02 08:58:00 +0100
commitcdcdfc56b942396890ecdd18bacf1a8c90e7f966 (patch)
tree107c2eb83d7e595040e023deba0543e3065312d3 /scope.c
parentd956618a38976d4304e0ac23da739ba2aee25f07 (diff)
downloadperl-cdcdfc56b942396890ecdd18bacf1a8c90e7f966.tar.gz
For SVt_CLEAR, store the pad offset with the type.
This saves 1 slot on the save stack for each lexical encountered at run time.
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/scope.c b/scope.c
index 78e57602c9..2b00d34dff 100644
--- a/scope.c
+++ b/scope.c
@@ -507,13 +507,18 @@ void
Perl_save_clearsv(pTHX_ SV **svp)
{
dVAR;
+ const UV offset = svp - PL_curpad;
+ const UV offset_shifted = offset << SAVE_TIGHT_SHIFT;
PERL_ARGS_ASSERT_SAVE_CLEARSV;
ASSERT_CURPAD_ACTIVE("save_clearsv");
- SSCHECK(2);
- SSPUSHLONG((long)(svp-PL_curpad));
- SSPUSHUV(SAVEt_CLEARSV);
+ if ((offset_shifted >> SAVE_TIGHT_SHIFT) != offset)
+ Perl_croak(aTHX_ "panic: pad offset %"UVuf" out of range (%p-%p)",
+ offset, svp, PL_curpad);
+
+ SSCHECK(1);
+ SSPUSHUV(offset_shifted | SAVEt_CLEARSV);
SvPADSTALE_off(*svp); /* mark lexical as active */
}
@@ -850,7 +855,7 @@ Perl_leave_scope(pTHX_ I32 base)
Safefree(ptr);
break;
case SAVEt_CLEARSV:
- ptr = (void*)&PL_curpad[SSPOPLONG];
+ ptr = (void*)&PL_curpad[uv >> SAVE_TIGHT_SHIFT];
sv = *(SV**)ptr;
DEBUG_Xv(PerlIO_printf(Perl_debug_log,