From: Nicholas Clark Date: Sat, 20 Feb 2010 12:21:52 +0000 (+0000) Subject: On the save stack, store the save type as the bottom 6 bits of a UV. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c6bf6a65e4bf512beae58d59446046f4ca20372f;p=p5sagit%2Fp5-mst-13.2.git On the save stack, store the save type as the bottom 6 bits of a UV. This makes the other 26 (or 58) bits available for save data. --- diff --git a/mathoms.c b/mathoms.c index 626bbb3..aaae227 100644 --- a/mathoms.c +++ b/mathoms.c @@ -1171,7 +1171,7 @@ Perl_save_long(pTHX_ long int *longp) SSCHECK(3); SSPUSHLONG(*longp); SSPUSHPTR(longp); - SSPUSHINT(SAVEt_LONG); + SSPUSHUV(SAVEt_LONG); } void @@ -1184,7 +1184,7 @@ Perl_save_iv(pTHX_ IV *ivp) SSCHECK(3); SSPUSHIV(*ivp); SSPUSHPTR(ivp); - SSPUSHINT(SAVEt_IV); + SSPUSHUV(SAVEt_IV); } void @@ -1196,7 +1196,7 @@ Perl_save_nogv(pTHX_ GV *gv) SSCHECK(2); SSPUSHPTR(gv); - SSPUSHINT(SAVEt_NSTAB); + SSPUSHUV(SAVEt_NSTAB); } void @@ -1213,7 +1213,7 @@ Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg) SSCHECK(3); SSPUSHPTR(sarg[i]); /* remember the pointer */ SSPUSHPTR(sv); /* remember the value */ - SSPUSHINT(SAVEt_ITEM); + SSPUSHUV(SAVEt_ITEM); } } diff --git a/mg.c b/mg.c index c89be40..59ead34 100644 --- a/mg.c +++ b/mg.c @@ -3071,11 +3071,12 @@ S_restore_magic(pTHX_ const void *p) */ if (PL_savestack_ix == mgs->mgs_ss_ix) { - I32 popval = SSPOPINT; - assert(popval == SAVEt_DESTRUCTOR_X); + UV type = SSPOPUV; + I32 popval; + assert(type == SAVEt_DESTRUCTOR_X); PL_savestack_ix -= 2; - popval = SSPOPINT; - assert(popval == SAVEt_ALLOC); + type = SSPOPUV; + assert(type == SAVEt_ALLOC); popval = SSPOPINT; PL_savestack_ix -= popval; } diff --git a/perl.h b/perl.h index 89997a0..c21aaa9 100644 --- a/perl.h +++ b/perl.h @@ -3324,6 +3324,7 @@ union any { void* any_ptr; I32 any_i32; IV any_iv; + UV any_uv; long any_long; bool any_bool; void (*any_dptr) (void*); diff --git a/regcomp.c b/regcomp.c index a9ebb73..1a815c6 100644 --- a/regcomp.c +++ b/regcomp.c @@ -9883,7 +9883,7 @@ Perl_save_re_context(pTHX) state = (struct re_save_state *)(PL_savestack + PL_savestack_ix); PL_savestack_ix += SAVESTACK_ALLOC_FOR_RE_SAVE_STATE; - SSPUSHINT(SAVEt_RE_STATE); + SSPUSHUV(SAVEt_RE_STATE); Copy(&PL_reg_state, state, 1, struct re_save_state); diff --git a/regexec.c b/regexec.c index 32efc67..cf79417 100644 --- a/regexec.c +++ b/regexec.c @@ -335,7 +335,7 @@ S_regcppush(pTHX_ I32 parenfloor) SSPUSHINT(*PL_reglastcloseparen); SSPUSHPTR(PL_reginput); SSPUSHINT(total_elems); - SSPUSHINT(SAVEt_REGCONTEXT); /* Magic cookie. */ + SSPUSHUV(SAVEt_REGCONTEXT); /* Magic cookie. */ return retval; } @@ -367,7 +367,7 @@ S_regcppop(pTHX_ const regexp *rex) PERL_ARGS_ASSERT_REGCPPOP; /* Pop REGCP_OTHER_ELEMS before the parentheses loop starts. */ - i = SSPOPINT; + i = SSPOPUV; assert(i == SAVEt_REGCONTEXT); /* Check that the magic cookie is there. */ i = SSPOPINT; /* Parentheses elements to pop. */ input = (char *) SSPOPPTR; diff --git a/scope.c b/scope.c index 6493933..78e5760 100644 --- a/scope.c +++ b/scope.c @@ -202,7 +202,7 @@ Perl_save_pushptrptr(pTHX_ void *const ptr1, void *const ptr2, const int type) SSCHECK(3); SSPUSHPTR(ptr1); SSPUSHPTR(ptr2); - SSPUSHINT(type); + SSPUSHUV(type); } SV * @@ -271,7 +271,7 @@ Perl_save_set_svflags(pTHX_ SV* sv, U32 mask, U32 val) SSPUSHPTR(sv); SSPUSHINT(mask); SSPUSHINT(val); - SSPUSHINT(SAVEt_SET_SVFLAGS); + SSPUSHUV(SAVEt_SET_SVFLAGS); } void @@ -376,7 +376,7 @@ Perl_save_bool(pTHX_ bool *boolp) SSCHECK(3); SSPUSHBOOL(*boolp); SSPUSHPTR(boolp); - SSPUSHINT(SAVEt_BOOL); + SSPUSHUV(SAVEt_BOOL); } void @@ -386,7 +386,7 @@ Perl_save_pushi32ptr(pTHX_ const I32 i, void *const ptr, const int type) SSCHECK(3); SSPUSHINT(i); SSPUSHPTR(ptr); - SSPUSHINT(type); + SSPUSHUV(type); } void @@ -471,7 +471,7 @@ Perl_save_padsv_and_mortalize(pTHX_ PADOFFSET off) SSPUSHPTR(SvREFCNT_inc_simple_NN(PL_curpad[off])); SSPUSHPTR(PL_comppad); SSPUSHLONG((long)off); - SSPUSHINT(SAVEt_PADSV_AND_MORTALIZE); + SSPUSHUV(SAVEt_PADSV_AND_MORTALIZE); } void @@ -500,7 +500,7 @@ Perl_save_pushptr(pTHX_ void *const ptr, const int type) dVAR; SSCHECK(2); SSPUSHPTR(ptr); - SSPUSHINT(type); + SSPUSHUV(type); } void @@ -513,7 +513,7 @@ Perl_save_clearsv(pTHX_ SV **svp) ASSERT_CURPAD_ACTIVE("save_clearsv"); SSCHECK(2); SSPUSHLONG((long)(svp-PL_curpad)); - SSPUSHINT(SAVEt_CLEARSV); + SSPUSHUV(SAVEt_CLEARSV); SvPADSTALE_off(*svp); /* mark lexical as active */ } @@ -563,7 +563,7 @@ Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void* p) SSCHECK(3); SSPUSHDPTR(f); SSPUSHPTR(p); - SSPUSHINT(SAVEt_DESTRUCTOR); + SSPUSHUV(SAVEt_DESTRUCTOR); } void @@ -573,7 +573,7 @@ Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p) SSCHECK(3); SSPUSHDXPTR(f); SSPUSHPTR(p); - SSPUSHINT(SAVEt_DESTRUCTOR_X); + SSPUSHUV(SAVEt_DESTRUCTOR_X); } void @@ -602,7 +602,7 @@ S_save_pushptri32ptr(pTHX_ void *const ptr1, const I32 i, void *const ptr2, SSPUSHPTR(ptr1); SSPUSHINT(i); SSPUSHPTR(ptr2); - SSPUSHINT(type); + SSPUSHUV(type); } void @@ -644,7 +644,7 @@ Perl_save_helem_flags(pTHX_ HV *hv, SV *key, SV **sptr, const U32 flags) SSPUSHPTR(SvREFCNT_inc_simple(hv)); SSPUSHPTR(newSVsv(key)); SSPUSHPTR(SvREFCNT_inc(*sptr)); - SSPUSHINT(SAVEt_HELEM); + SSPUSHUV(SAVEt_HELEM); save_scalar_at(sptr, flags); if (flags & SAVEf_KEEPOLDELEM) return; @@ -681,7 +681,7 @@ Perl_save_alloc(pTHX_ I32 size, I32 pad) PL_savestack_ix += elems; SSPUSHINT(elems); - SSPUSHINT(SAVEt_ALLOC); + SSPUSHUV(SAVEt_ALLOC); return start; } @@ -705,9 +705,11 @@ Perl_leave_scope(pTHX_ I32 base) DEBUG_l(Perl_deb(aTHX_ "savestack: releasing items %ld -> %ld\n", (long)PL_savestack_ix, (long)base)); while (PL_savestack_ix > base) { + UV uv = SSPOPUV; + const U8 type = (U8)uv & SAVE_MASK; TAINT_NOT; - switch (SSPOPINT) { + switch (type) { case SAVEt_ITEM: /* normal string */ value = MUTABLE_SV(SSPOPPTR); sv = MUTABLE_SV(SSPOPPTR); diff --git a/scope.h b/scope.h index 808108e..8763f34 100644 --- a/scope.h +++ b/scope.h @@ -59,6 +59,9 @@ #define SAVEf_SETMAGIC 1 #define SAVEf_KEEPOLDELEM 2 +#define SAVE_TIGHT_SHIFT 6 +#define SAVE_MASK 0x3F + #define save_aelem(av,idx,sptr) save_aelem_flags(av,idx,sptr,SAVEf_SETMAGIC) #define save_helem(hv,key,sptr) save_helem_flags(hv,key,sptr,SAVEf_SETMAGIC) @@ -72,6 +75,7 @@ #define SSPUSHLONG(i) (PL_savestack[PL_savestack_ix++].any_long = (long)(i)) #define SSPUSHBOOL(p) (PL_savestack[PL_savestack_ix++].any_bool = (p)) #define SSPUSHIV(i) (PL_savestack[PL_savestack_ix++].any_iv = (IV)(i)) +#define SSPUSHUV(u) (PL_savestack[PL_savestack_ix++].any_uv = (UV)(u)) #define SSPUSHPTR(p) (PL_savestack[PL_savestack_ix++].any_ptr = (void*)(p)) #define SSPUSHDPTR(p) (PL_savestack[PL_savestack_ix++].any_dptr = (p)) #define SSPUSHDXPTR(p) (PL_savestack[PL_savestack_ix++].any_dxptr = (p)) @@ -79,6 +83,7 @@ #define SSPOPLONG (PL_savestack[--PL_savestack_ix].any_long) #define SSPOPBOOL (PL_savestack[--PL_savestack_ix].any_bool) #define SSPOPIV (PL_savestack[--PL_savestack_ix].any_iv) +#define SSPOPUV (PL_savestack[--PL_savestack_ix].any_uv) #define SSPOPPTR (PL_savestack[--PL_savestack_ix].any_ptr) #define SSPOPDPTR (PL_savestack[--PL_savestack_ix].any_dptr) #define SSPOPDXPTR (PL_savestack[--PL_savestack_ix].any_dxptr) @@ -192,7 +197,7 @@ scope has the given name. Name must be a literal string. STMT_START { \ SSCHECK(2); \ SSPUSHINT(PL_stack_sp - PL_stack_base); \ - SSPUSHINT(SAVEt_STACK_POS); \ + SSPUSHUV(SAVEt_STACK_POS); \ } STMT_END #define SAVEOP() save_op() @@ -222,7 +227,7 @@ scope has the given name. Name must be a literal string. SSCHECK(3); \ SSPUSHINT(cxstack[cxstack_ix].blk_oldsp); \ SSPUSHINT(cxstack_ix); \ - SSPUSHINT(SAVEt_STACK_CXPOS); \ + SSPUSHUV(SAVEt_STACK_CXPOS); \ } STMT_END #define SAVEPARSER(p) save_pushptr((p), SAVEt_PARSER) diff --git a/sv.c b/sv.c index 2e3ba69..31db315 100644 --- a/sv.c +++ b/sv.c @@ -11430,6 +11430,8 @@ Perl_si_dup(pTHX_ PERL_SI *si, CLONE_PARAMS* param) #define TOPLONG(ss,ix) ((ss)[ix].any_long) #define POPIV(ss,ix) ((ss)[--(ix)].any_iv) #define TOPIV(ss,ix) ((ss)[ix].any_iv) +#define POPUV(ss,ix) ((ss)[--(ix)].any_uv) +#define TOPUV(ss,ix) ((ss)[ix].any_uv) #define POPBOOL(ss,ix) ((ss)[--(ix)].any_bool) #define TOPBOOL(ss,ix) ((ss)[ix].any_bool) #define POPPTR(ss,ix) ((ss)[--(ix)].any_ptr) @@ -11502,8 +11504,10 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) Newxz(nss, max, ANY); while (ix > 0) { - const I32 type = POPINT(ss,ix); - TOPINT(nss,ix) = type; + const UV uv = POPUV(ss,ix); + const U8 type = (U8)uv & SAVE_MASK; + + TOPUV(nss,ix) = uv; switch (type) { case SAVEt_HELEM: /* hash element */ sv = (const SV *)POPPTR(ss,ix);