X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=scope.c;h=20e027ff8e82d207c2bbaeffc68891a80ff7207d;hb=fb6e4a4e4598d2f4d2f011525b2ff33f3b73f007;hp=87a0ee3d9a833f96ebd1ee2d49e3b240228f547b;hpb=85fbaab29c398adbb5b4445d3ed41e0a96364ce4;p=p5sagit%2Fp5-mst-13.2.git diff --git a/scope.c b/scope.c index 87a0ee3..20e027f 100644 --- a/scope.c +++ b/scope.c @@ -9,8 +9,10 @@ */ /* - * "For the fashion of Minas Tirith was such that it was built on seven - * levels..." + * For the fashion of Minas Tirith was such that it was built on seven + * levels... + * + * [p.751 of _The Lord of the Rings_, V/i: "Minas Tirith"] */ /* This file contains functions to manipulate several of Perl's stacks; @@ -162,7 +164,7 @@ Perl_free_tmps(pTHX) } STATIC SV * -S_save_scalar_at(pTHX_ SV **sptr) +S_save_scalar_at(pTHX_ SV **sptr, const U32 flags) { dVAR; SV * const osv = *sptr; @@ -177,11 +179,21 @@ S_save_scalar_at(pTHX_ SV **sptr) (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT; PL_tainted = oldtainted; } - mg_localize(osv, sv); + mg_localize(osv, sv, (flags & SAVEf_SETMAGIC) != 0); } return sv; } +void +Perl_save_pushptrptr(pTHX_ void *const ptr1, void *const ptr2, const int type) +{ + dVAR; + SSCHECK(3); + SSPUSHPTR(ptr1); + SSPUSHPTR(ptr2); + SSPUSHINT(type); +} + SV * Perl_save_scalar(pTHX_ GV *gv) { @@ -193,11 +205,8 @@ Perl_save_scalar(pTHX_ GV *gv) PL_localizing = 1; SvGETMAGIC(*sptr); PL_localizing = 0; - SSCHECK(3); - SSPUSHPTR(SvREFCNT_inc_simple(gv)); - SSPUSHPTR(SvREFCNT_inc(*sptr)); - SSPUSHINT(SAVEt_SV); - return save_scalar_at(sptr); + save_pushptrptr(SvREFCNT_inc_simple(gv), SvREFCNT_inc(*sptr), SAVEt_SV); + return save_scalar_at(sptr, SAVEf_SETMAGIC); /* XXX - FIXME - see #60360 */ } /* Like save_sptr(), but also SvREFCNT_dec()s the new value. Can be used to @@ -209,10 +218,7 @@ Perl_save_generic_svref(pTHX_ SV **sptr) PERL_ARGS_ASSERT_SAVE_GENERIC_SVREF; - SSCHECK(3); - SSPUSHPTR(sptr); - SSPUSHPTR(SvREFCNT_inc(*sptr)); - SSPUSHINT(SAVEt_GENERIC_SVREF); + save_pushptrptr(sptr, SvREFCNT_inc(*sptr), SAVEt_GENERIC_SVREF); } /* Like save_pptr(), but also Safefree()s the new value if it is different @@ -225,10 +231,7 @@ Perl_save_generic_pvref(pTHX_ char **str) PERL_ARGS_ASSERT_SAVE_GENERIC_PVREF; - SSCHECK(3); - SSPUSHPTR(*str); - SSPUSHPTR(str); - SSPUSHINT(SAVEt_GENERIC_PVREF); + save_pushptrptr(*str, str, SAVEt_GENERIC_PVREF); } /* Like save_generic_pvref(), but uses PerlMemShared_free() rather than Safefree(). @@ -241,10 +244,7 @@ Perl_save_shared_pvref(pTHX_ char **str) PERL_ARGS_ASSERT_SAVE_SHARED_PVREF; - SSCHECK(3); - SSPUSHPTR(str); - SSPUSHPTR(*str); - SSPUSHINT(SAVEt_SHARED_PVREF); + save_pushptrptr(str, *str, SAVEt_SHARED_PVREF); } /* set the SvFLAGS specified by mask to the values in val */ @@ -270,10 +270,7 @@ Perl_save_gp(pTHX_ GV *gv, I32 empty) PERL_ARGS_ASSERT_SAVE_GP; - SSGROW(3); - SSPUSHPTR(SvREFCNT_inc(gv)); - SSPUSHPTR(GvGP(gv)); - SSPUSHINT(SAVEt_GP); + save_pushptrptr(SvREFCNT_inc(gv), GvGP(gv), SAVEt_GP); if (empty) { GP *gp = Perl_newGP(aTHX_ gv); @@ -311,15 +308,12 @@ Perl_save_ary(pTHX_ GV *gv) if (!AvREAL(oav) && AvREIFY(oav)) av_reify(oav); - SSCHECK(3); - SSPUSHPTR(gv); - SSPUSHPTR(oav); - SSPUSHINT(SAVEt_AV); + save_pushptrptr(gv, oav, SAVEt_AV); GvAV(gv) = NULL; av = GvAVn(gv); if (SvMAGIC(oav)) - mg_localize((SV*)oav, (SV*)av); + mg_localize(MUTABLE_SV(oav), MUTABLE_SV(av), TRUE); return av; } @@ -331,15 +325,12 @@ Perl_save_hash(pTHX_ GV *gv) PERL_ARGS_ASSERT_SAVE_HASH; - SSCHECK(3); - SSPUSHPTR(gv); - SSPUSHPTR(ohv = GvHVn(gv)); - SSPUSHINT(SAVEt_HV); + save_pushptrptr(gv, (ohv = GvHVn(gv)), SAVEt_HV); GvHV(gv) = NULL; hv = GvHVn(gv); if (SvMAGIC(ohv)) - mg_localize((SV*)ohv, (SV*)hv); + mg_localize(MUTABLE_SV(ohv), MUTABLE_SV(hv), TRUE); return hv; } @@ -351,36 +342,42 @@ Perl_save_item(pTHX_ register SV *item) PERL_ARGS_ASSERT_SAVE_ITEM; - SSCHECK(3); - SSPUSHPTR(item); /* remember the pointer */ - SSPUSHPTR(sv); /* remember the value */ - SSPUSHINT(SAVEt_ITEM); + save_pushptrptr(item, /* remember the pointer */ + sv, /* remember the value */ + SAVEt_ITEM); } void -Perl_save_int(pTHX_ int *intp) +Perl_save_bool(pTHX_ bool *boolp) { dVAR; - PERL_ARGS_ASSERT_SAVE_INT; + PERL_ARGS_ASSERT_SAVE_BOOL; SSCHECK(3); - SSPUSHINT(*intp); - SSPUSHPTR(intp); - SSPUSHINT(SAVEt_INT); + SSPUSHBOOL(*boolp); + SSPUSHPTR(boolp); + SSPUSHINT(SAVEt_BOOL); } void -Perl_save_bool(pTHX_ bool *boolp) +Perl_save_pushi32ptr(pTHX_ const I32 i, void *const ptr, const int type) { dVAR; + SSCHECK(3); + SSPUSHINT(i); + SSPUSHPTR(ptr); + SSPUSHINT(type); +} - PERL_ARGS_ASSERT_SAVE_BOOL; +void +Perl_save_int(pTHX_ int *intp) +{ + dVAR; - SSCHECK(3); - SSPUSHBOOL(*boolp); - SSPUSHPTR(boolp); - SSPUSHINT(SAVEt_BOOL); + PERL_ARGS_ASSERT_SAVE_INT; + + save_pushi32ptr(*intp, intp, SAVEt_INT); } void @@ -390,10 +387,7 @@ Perl_save_I8(pTHX_ I8 *bytep) PERL_ARGS_ASSERT_SAVE_I8; - SSCHECK(3); - SSPUSHINT(*bytep); - SSPUSHPTR(bytep); - SSPUSHINT(SAVEt_I8); + save_pushi32ptr(*bytep, bytep, SAVEt_I8); } void @@ -403,10 +397,7 @@ Perl_save_I16(pTHX_ I16 *intp) PERL_ARGS_ASSERT_SAVE_I16; - SSCHECK(3); - SSPUSHINT(*intp); - SSPUSHPTR(intp); - SSPUSHINT(SAVEt_I16); + save_pushi32ptr(*intp, intp, SAVEt_I16); } void @@ -416,10 +407,7 @@ Perl_save_I32(pTHX_ I32 *intp) PERL_ARGS_ASSERT_SAVE_I32; - SSCHECK(3); - SSPUSHINT(*intp); - SSPUSHPTR(intp); - SSPUSHINT(SAVEt_I32); + save_pushi32ptr(*intp, intp, SAVEt_I32); } /* Cannot use save_sptr() to store a char* since the SV** cast will @@ -432,10 +420,7 @@ Perl_save_pptr(pTHX_ char **pptr) PERL_ARGS_ASSERT_SAVE_PPTR; - SSCHECK(3); - SSPUSHPTR(*pptr); - SSPUSHPTR(pptr); - SSPUSHINT(SAVEt_PPTR); + save_pushptrptr(*pptr, pptr, SAVEt_PPTR); } void @@ -445,10 +430,7 @@ Perl_save_vptr(pTHX_ void *ptr) PERL_ARGS_ASSERT_SAVE_VPTR; - SSCHECK(3); - SSPUSHPTR(*(char**)ptr); - SSPUSHPTR(ptr); - SSPUSHINT(SAVEt_VPTR); + save_pushptrptr(*(char**)ptr, ptr, SAVEt_VPTR); } void @@ -458,10 +440,7 @@ Perl_save_sptr(pTHX_ SV **sptr) PERL_ARGS_ASSERT_SAVE_SPTR; - SSCHECK(3); - SSPUSHPTR(*sptr); - SSPUSHPTR(sptr); - SSPUSHINT(SAVEt_SPTR); + save_pushptrptr(*sptr, sptr, SAVEt_SPTR); } void @@ -483,10 +462,7 @@ Perl_save_hptr(pTHX_ HV **hptr) PERL_ARGS_ASSERT_SAVE_HPTR; - SSCHECK(3); - SSPUSHPTR(*hptr); - SSPUSHPTR(hptr); - SSPUSHINT(SAVEt_HPTR); + save_pushptrptr(*hptr, hptr, SAVEt_HPTR); } void @@ -496,49 +472,16 @@ Perl_save_aptr(pTHX_ AV **aptr) PERL_ARGS_ASSERT_SAVE_APTR; - SSCHECK(3); - SSPUSHPTR(*aptr); - SSPUSHPTR(aptr); - SSPUSHINT(SAVEt_APTR); -} - -void -Perl_save_freesv(pTHX_ SV *sv) -{ - dVAR; - SSCHECK(2); - SSPUSHPTR(sv); - SSPUSHINT(SAVEt_FREESV); + save_pushptrptr(*aptr, aptr, SAVEt_APTR); } void -Perl_save_mortalizesv(pTHX_ SV *sv) +Perl_save_pushptr(pTHX_ void *const ptr, const int type) { dVAR; - - PERL_ARGS_ASSERT_SAVE_MORTALIZESV; - SSCHECK(2); - SSPUSHPTR(sv); - SSPUSHINT(SAVEt_MORTALIZESV); -} - -void -Perl_save_freeop(pTHX_ OP *o) -{ - dVAR; - SSCHECK(2); - SSPUSHPTR(o); - SSPUSHINT(SAVEt_FREEOP); -} - -void -Perl_save_freepv(pTHX_ char *pv) -{ - dVAR; - SSCHECK(2); - SSPUSHPTR(pv); - SSPUSHINT(SAVEt_FREEPV); + SSPUSHPTR(ptr); + SSPUSHINT(type); } void @@ -562,11 +505,18 @@ Perl_save_delete(pTHX_ HV *hv, char *key, I32 klen) PERL_ARGS_ASSERT_SAVE_DELETE; - SSCHECK(4); - SSPUSHINT(klen); - SSPUSHPTR(key); - SSPUSHPTR(SvREFCNT_inc_simple(hv)); - SSPUSHINT(SAVEt_DELETE); + save_pushptri32ptr(key, klen, SvREFCNT_inc_simple(hv), SAVEt_DELETE); +} + +void +Perl_save_adelete(pTHX_ AV *av, I32 key) +{ + dVAR; + + PERL_ARGS_ASSERT_SAVE_ADELETE; + + SvREFCNT_inc_void(av); + save_pushi32ptr(key, av, SAVEt_ADELETE); } void @@ -593,6 +543,35 @@ Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p) } void +Perl_save_hints(pTHX) +{ + dVAR; + if (PL_compiling.cop_hints_hash) { + HINTS_REFCNT_LOCK; + PL_compiling.cop_hints_hash->refcounted_he_refcnt++; + HINTS_REFCNT_UNLOCK; + } + if (PL_hints & HINT_LOCALIZE_HH) { + save_pushptri32ptr(GvHV(PL_hintgv), PL_hints, + PL_compiling.cop_hints_hash, SAVEt_HINTS); + GvHV(PL_hintgv) = Perl_hv_copy_hints_hv(aTHX_ GvHV(PL_hintgv)); + } else { + save_pushi32ptr(PL_hints, PL_compiling.cop_hints_hash, SAVEt_HINTS); + } +} + +static void +S_save_pushptri32ptr(pTHX_ void *const ptr1, const I32 i, void *const ptr2, + const int type) +{ + SSCHECK(4); + SSPUSHPTR(ptr1); + SSPUSHINT(i); + SSPUSHPTR(ptr2); + SSPUSHINT(type); +} + +void Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr) { dVAR; @@ -601,15 +580,12 @@ Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr) PERL_ARGS_ASSERT_SAVE_AELEM; SvGETMAGIC(*sptr); - SSCHECK(4); - SSPUSHPTR(SvREFCNT_inc_simple(av)); - SSPUSHINT(idx); - SSPUSHPTR(SvREFCNT_inc(*sptr)); - SSPUSHINT(SAVEt_AELEM); + save_pushptri32ptr(SvREFCNT_inc_simple(av), idx, SvREFCNT_inc(*sptr), + SAVEt_AELEM); /* if it gets reified later, the restore will have the wrong refcnt */ if (!AvREAL(av) && AvREIFY(av)) SvREFCNT_inc_void(*sptr); - save_scalar_at(sptr); + save_scalar_at(sptr, SAVEf_SETMAGIC); /* XXX - FIXME - see #60360 */ sv = *sptr; /* If we're localizing a tied array element, this new sv * won't actually be stored in the array - so it won't get @@ -620,12 +596,12 @@ Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr) } void -Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr) +Perl_save_helem_flags(pTHX_ HV *hv, SV *key, SV **sptr, const U32 flags) { dVAR; SV *sv; - PERL_ARGS_ASSERT_SAVE_HELEM; + PERL_ARGS_ASSERT_SAVE_HELEM_FLAGS; SvGETMAGIC(*sptr); SSCHECK(4); @@ -633,7 +609,7 @@ Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr) SSPUSHPTR(newSVsv(key)); SSPUSHPTR(SvREFCNT_inc(*sptr)); SSPUSHINT(SAVEt_HELEM); - save_scalar_at(sptr); + save_scalar_at(sptr, flags); sv = *sptr; /* If we're localizing a tied hash element, this new sv * won't actually be stored in the hash - so it won't get @@ -651,20 +627,8 @@ Perl_save_svref(pTHX_ SV **sptr) PERL_ARGS_ASSERT_SAVE_SVREF; SvGETMAGIC(*sptr); - SSCHECK(3); - SSPUSHPTR(sptr); - SSPUSHPTR(SvREFCNT_inc(*sptr)); - SSPUSHINT(SAVEt_SVREF); - return save_scalar_at(sptr); -} - -void -Perl_save_op(pTHX) -{ - dVAR; - SSCHECK(2); - SSPUSHPTR(PL_op); - SSPUSHINT(SAVEt_OP); + save_pushptrptr(sptr, SvREFCNT_inc(*sptr), SAVEt_SVREF); + return save_scalar_at(sptr, SAVEf_SETMAGIC); /* XXX - FIXME - see #60360 */ } I32 @@ -695,24 +659,28 @@ Perl_leave_scope(pTHX_ I32 base) void* ptr; register char* str; I32 i; + /* Localise the effects of the TAINT_NOT inside the loop. */ + const bool was = PL_tainted; if (base < -1) Perl_croak(aTHX_ "panic: corrupt saved stack index"); while (PL_savestack_ix > base) { + TAINT_NOT; + switch (SSPOPINT) { case SAVEt_ITEM: /* normal string */ - value = (SV*)SSPOPPTR; - sv = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); + sv = MUTABLE_SV(SSPOPPTR); sv_replace(sv,value); PL_localizing = 2; SvSETMAGIC(sv); PL_localizing = 0; break; case SAVEt_SV: /* scalar reference */ - value = (SV*)SSPOPPTR; - gv = (GV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); + gv = MUTABLE_GV(SSPOPPTR); ptr = &GvSV(gv); - av = (AV*)gv; /* what to refcnt_dec */ + av = MUTABLE_AV(gv); /* what to refcnt_dec */ restore_sv: sv = *(SV**)ptr; *(SV**)ptr = value; @@ -745,7 +713,7 @@ Perl_leave_scope(pTHX_ I32 base) } break; case SAVEt_GENERIC_SVREF: /* generic sv */ - value = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); ptr = SSPOPPTR; sv = *(SV**)ptr; *(SV**)ptr = value; @@ -753,28 +721,28 @@ Perl_leave_scope(pTHX_ I32 base) SvREFCNT_dec(value); break; case SAVEt_AV: /* array reference */ - av = (AV*)SSPOPPTR; - gv = (GV*)SSPOPPTR; + av = MUTABLE_AV(SSPOPPTR); + gv = MUTABLE_GV(SSPOPPTR); if (GvAV(gv)) { SvREFCNT_dec(GvAV(gv)); } GvAV(gv) = av; if (SvMAGICAL(av)) { PL_localizing = 2; - SvSETMAGIC((SV*)av); + SvSETMAGIC(MUTABLE_SV(av)); PL_localizing = 0; } break; case SAVEt_HV: /* hash reference */ hv = MUTABLE_HV(SSPOPPTR); - gv = (GV*)SSPOPPTR; + gv = MUTABLE_GV(SSPOPPTR); if (GvHV(gv)) { SvREFCNT_dec(GvHV(gv)); } GvHV(gv) = hv; if (SvMAGICAL(hv)) { PL_localizing = 2; - SvSETMAGIC((SV*)hv); + SvSETMAGIC(MUTABLE_SV(hv)); PL_localizing = 0; } break; @@ -800,7 +768,7 @@ Perl_leave_scope(pTHX_ I32 base) break; case SAVEt_SPTR: /* SV* reference */ ptr = SSPOPPTR; - *(SV**)ptr = (SV*)SSPOPPTR; + *(SV**)ptr = MUTABLE_SV(SSPOPPTR); break; case SAVEt_VPTR: /* random* reference */ case SAVEt_PPTR: /* char* reference */ @@ -813,11 +781,11 @@ Perl_leave_scope(pTHX_ I32 base) break; case SAVEt_APTR: /* AV* reference */ ptr = SSPOPPTR; - *(AV**)ptr = (AV*)SSPOPPTR; + *(AV**)ptr = MUTABLE_AV(SSPOPPTR); break; case SAVEt_GP: /* scalar reference */ ptr = SSPOPPTR; - gv = (GV*)SSPOPPTR; + gv = MUTABLE_GV(SSPOPPTR); gp_free(gv); GvGP(gv) = (GP*)ptr; /* putting a method back into circulation ("local")*/ @@ -827,11 +795,11 @@ Perl_leave_scope(pTHX_ I32 base) break; case SAVEt_FREESV: ptr = SSPOPPTR; - SvREFCNT_dec((SV*)ptr); + SvREFCNT_dec(MUTABLE_SV(ptr)); break; case SAVEt_MORTALIZESV: ptr = SSPOPPTR; - sv_2mortal((SV*)ptr); + sv_2mortal(MUTABLE_SV(ptr)); break; case SAVEt_FREEOP: ptr = SSPOPPTR; @@ -872,7 +840,7 @@ Perl_leave_scope(pTHX_ I32 base) case SVt_NULL: break; case SVt_PVAV: - av_clear((AV*)sv); + av_clear(MUTABLE_AV(sv)); break; case SVt_PVHV: hv_clear(MUTABLE_HV(sv)); @@ -888,8 +856,8 @@ Perl_leave_scope(pTHX_ I32 base) else { /* Someone has a claim on this, so abandon it. */ const U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP); switch (SvTYPE(sv)) { /* Console ourselves with a new value */ - case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break; - case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break; + case SVt_PVAV: *(SV**)ptr = MUTABLE_SV(newAV()); break; + case SVt_PVHV: *(SV**)ptr = MUTABLE_SV(newHV()); break; default: *(SV**)ptr = newSV(0); break; } SvREFCNT_dec(sv); /* Cast current value to the winds. */ @@ -901,11 +869,19 @@ Perl_leave_scope(pTHX_ I32 base) case SAVEt_DELETE: ptr = SSPOPPTR; hv = MUTABLE_HV(ptr); + i = SSPOPINT; ptr = SSPOPPTR; - (void)hv_delete(hv, (char*)ptr, (I32)SSPOPINT, G_DISCARD); + (void)hv_delete(hv, (char*)ptr, i, G_DISCARD); SvREFCNT_dec(hv); Safefree(ptr); break; + case SAVEt_ADELETE: + ptr = SSPOPPTR; + av = MUTABLE_AV(ptr); + i = SSPOPINT; + (void)av_delete(av, i, G_DISCARD); + SvREFCNT_dec(av); + break; case SAVEt_DESTRUCTOR_X: ptr = SSPOPPTR; (*SSPOPDXPTR)(aTHX_ ptr); @@ -924,16 +900,16 @@ Perl_leave_scope(pTHX_ I32 base) cxstack[i].blk_oldsp = SSPOPINT; break; case SAVEt_AELEM: /* array element */ - value = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); i = SSPOPINT; - av = (AV*)SSPOPPTR; + av = MUTABLE_AV(SSPOPPTR); ptr = av_fetch(av,i,1); if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */ SvREFCNT_dec(value); if (ptr) { sv = *(SV**)ptr; if (sv && sv != &PL_sv_undef) { - if (SvTIED_mg((SV*)av, PERL_MAGIC_tied)) + if (SvTIED_mg((const SV *)av, PERL_MAGIC_tied)) SvREFCNT_inc_void_NN(sv); goto restore_sv; } @@ -942,23 +918,22 @@ Perl_leave_scope(pTHX_ I32 base) SvREFCNT_dec(value); break; case SAVEt_HELEM: /* hash element */ - value = (SV*)SSPOPPTR; - sv = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); + sv = MUTABLE_SV(SSPOPPTR); hv = MUTABLE_HV(SSPOPPTR); ptr = hv_fetch_ent(hv, sv, 1, 0); + SvREFCNT_dec(sv); if (ptr) { const SV * const oval = HeVAL((HE*)ptr); if (oval && oval != &PL_sv_undef) { ptr = &HeVAL((HE*)ptr); - if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) + if (SvTIED_mg((const SV *)hv, PERL_MAGIC_tied)) SvREFCNT_inc_void(*(SV**)ptr); - SvREFCNT_dec(sv); - av = (AV*)hv; /* what to refcnt_dec */ + av = MUTABLE_AV(hv); /* what to refcnt_dec */ goto restore_sv; } } SvREFCNT_dec(hv); - SvREFCNT_dec(sv); SvREFCNT_dec(value); break; case SAVEt_OP: @@ -966,14 +941,14 @@ Perl_leave_scope(pTHX_ I32 base) break; case SAVEt_HINTS: if ((PL_hints & HINT_LOCALIZE_HH) && GvHV(PL_hintgv)) { - SvREFCNT_dec((SV*)GvHV(PL_hintgv)); + SvREFCNT_dec(MUTABLE_SV(GvHV(PL_hintgv))); GvHV(PL_hintgv) = NULL; } - *(I32*)&PL_hints = (I32)SSPOPINT; Perl_refcounted_he_free(aTHX_ PL_compiling.cop_hints_hash); PL_compiling.cop_hints_hash = (struct refcounted_he *) SSPOPPTR; + *(I32*)&PL_hints = (I32)SSPOPINT; if (PL_hints & HINT_LOCALIZE_HH) { - SvREFCNT_dec((SV*)GvHV(PL_hintgv)); + SvREFCNT_dec(MUTABLE_SV(GvHV(PL_hintgv))); GvHV(PL_hintgv) = MUTABLE_HV(SSPOPPTR); assert(GvHV(PL_hintgv)); } else if (!GvHV(PL_hintgv)) { @@ -1016,14 +991,14 @@ Perl_leave_scope(pTHX_ I32 base) 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; + *svp = MUTABLE_SV(SSPOPPTR); } break; case SAVEt_SAVESWITCHSTACK: { dSP; - AV* const t = (AV*)SSPOPPTR; - AV* const f = (AV*)SSPOPPTR; + AV *const t = MUTABLE_AV(SSPOPPTR); + AV *const f = MUTABLE_AV(SSPOPPTR); SWITCHSTACK(t,f); PL_curstackinfo->si_stack = f; } @@ -1032,7 +1007,7 @@ Perl_leave_scope(pTHX_ I32 base) { const U32 val = (U32)SSPOPINT; const U32 mask = (U32)SSPOPINT; - sv = (SV*)SSPOPPTR; + sv = MUTABLE_SV(SSPOPPTR); SvFLAGS(sv) &= ~mask; SvFLAGS(sv) |= val; } @@ -1041,15 +1016,15 @@ Perl_leave_scope(pTHX_ I32 base) /* This would be a mathom, but Perl_save_svref() calls a static function, S_save_scalar_at(), so has to stay in this file. */ case SAVEt_SVREF: /* scalar reference */ - value = (SV*)SSPOPPTR; + value = MUTABLE_SV(SSPOPPTR); ptr = SSPOPPTR; av = NULL; /* what to refcnt_dec */ goto restore_sv; /* These are only saved in mathoms.c */ case SAVEt_NSTAB: - gv = (GV*)SSPOPPTR; - (void)sv_clear((SV*)gv); + gv = MUTABLE_GV(SSPOPPTR); + (void)sv_clear(MUTABLE_SV(gv)); break; case SAVEt_LONG: /* long reference */ ptr = SSPOPPTR; @@ -1110,6 +1085,8 @@ Perl_leave_scope(pTHX_ I32 base) Perl_croak(aTHX_ "panic: leave_scope inconsistency"); } } + + PL_tainted = was; } void