diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-02-20 13:36:21 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-05-02 08:58:00 +0100 |
commit | cdcdfc56b942396890ecdd18bacf1a8c90e7f966 (patch) | |
tree | 107c2eb83d7e595040e023deba0543e3065312d3 /scope.c | |
parent | d956618a38976d4304e0ac23da739ba2aee25f07 (diff) | |
download | perl-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.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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, |