X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pad.c;h=3b52c201c727bb920c1d3f6d617266d58fbd4a00;hb=326b5008ebd8d91bf6b00d96127d2d711c9f2132;hp=10c82c5dc0ecf2779ed67f326610636e5d8c7c85;hpb=b37c2d43c8bccbefe3985273e9661833102148d0;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pad.c b/pad.c index 10c82c5..3b52c20 100644 --- a/pad.c +++ b/pad.c @@ -109,11 +109,17 @@ to be generated in evals, such as #include "EXTERN.h" #define PERL_IN_PAD_C #include "perl.h" +#include "keywords.h" #define PAD_MAX 999999999 - +#ifdef PERL_MAD +void pad_peg(const char* s) { + static int pegcnt; + pegcnt++; +} +#endif /* =for apidoc pad_new @@ -233,6 +239,7 @@ Perl_pad_undef(pTHX_ CV* cv) I32 ix; const PADLIST * const padlist = CvPADLIST(cv); + pad_peg("pad_undef"); if (!padlist) return; if (SvIS_FREED(padlist)) /* may be during global destruction */ @@ -281,7 +288,7 @@ Perl_pad_undef(pTHX_ CV* cv) CvWEAKOUTSIDE_off(innercv); CvOUTSIDE(innercv) = outercv; CvOUTSIDE_SEQ(innercv) = seq; - SvREFCNT_inc_void_NN(outercv); + SvREFCNT_inc_simple_void_NN(outercv); } else { CvOUTSIDE(innercv) = NULL; @@ -327,7 +334,7 @@ If fake, it means we're cloning an existing entry */ PADOFFSET -Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake) +Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake, bool state) { dVAR; const PADOFFSET offset = pad_alloc(OP_PADSV, SVs_PADMY); @@ -346,7 +353,10 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake if (ourstash) { SvPAD_OUR_on(namesv); OURSTASH_set(namesv, ourstash); - SvREFCNT_inc_void_NN(ourstash); + SvREFCNT_inc_simple_void_NN(ourstash); + } + else if (state) { + SvPAD_STATE_on(namesv); } av_store(PL_comppad_name, offset, namesv); @@ -468,6 +478,7 @@ Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type) dVAR; PADOFFSET ix; SV* const name = newSV(0); + pad_peg("add_anon"); sv_upgrade(name, SVt_PVNV); sv_setpvn(name, "&", 1); SvIV_set(name, -1); @@ -532,7 +543,7 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash) break; /* "our" masking "our" */ Perl_warner(aTHX_ packWARN(WARN_MISC), "\"%s\" variable %s masks earlier declaration in same %s", - (is_our ? "our" : "my"), + (is_our ? "our" : PL_in_my == KEY_my ? "my" : "state"), name, (SvIVX(sv) == PAD_MAX ? "scope" : "statement")); --off; @@ -584,9 +595,10 @@ Perl_pad_findmy(pTHX_ const char *name) const AV *nameav; SV **name_svp; - offset = pad_findlex(name, PL_compcv, PL_cop_seqmax, 1, + pad_peg("pad_findmy"); + offset = pad_findlex(name, PL_compcv, PL_cop_seqmax, 1, NULL, &out_sv, &out_flags); - if (offset != NOT_IN_PAD) + if ((PADOFFSET)offset != NOT_IN_PAD) return offset; /* look for an our that's being introduced; this allows @@ -806,7 +818,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, if (!CvOUTSIDE(cv)) return NOT_IN_PAD; - + /* out_capture non-null means caller wants us to capture lex; in * addition we capture ourselves unless it's an ANON/format */ new_capturep = out_capture ? out_capture : @@ -814,9 +826,9 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, offset = pad_findlex(name, CvOUTSIDE(cv), CvOUTSIDE_SEQ(cv), 1, new_capturep, out_name_sv, out_flags); - if (offset == NOT_IN_PAD) + if ((PADOFFSET)offset == NOT_IN_PAD) return NOT_IN_PAD; - + /* found in an outer CV. Add appropriate fake entry to this pad */ /* don't add new fake entries (via eval) to CVs that we have already @@ -837,7 +849,8 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, SvPAD_TYPED(*out_name_sv) ? SvSTASH(*out_name_sv) : NULL, OURSTASH(*out_name_sv), - 1 /* fake */ + 1, /* fake */ + 0 /* not a state variable */ ); new_namesv = AvARRAY(PL_comppad_name)[new_offset]; @@ -845,7 +858,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, SvNV_set(new_namesv, (NV)0); if (SvPAD_OUR(new_namesv)) { - /*EMPTY*/; /* do nothing */ + NOOP; /* do nothing */ } else if (CvLATE(cv)) { /* delayed creation - just note the offset within parent pad */ @@ -1023,7 +1036,8 @@ Perl_pad_leavemy(pTHX) if (sv && sv != &PL_sv_undef && !SvFAKE(sv) && ckWARN_d(WARN_INTERNAL)) Perl_warner(aTHX_ packWARN(WARN_INTERNAL), - "%"SVf" never introduced", sv); + "%"SVf" never introduced", + (void*)sv); } } /* "Deintroduce" my variables that are leaving with this scope. */ @@ -1485,7 +1499,7 @@ Perl_cv_clone(pTHX_ CV *proto) } else { assert(!SvPADSTALE(sv)); - SvREFCNT_inc_simple_void(sv); + SvREFCNT_inc_simple_void_NN(sv); } } if (!sv) { @@ -1502,7 +1516,7 @@ Perl_cv_clone(pTHX_ CV *proto) } } else if (IS_PADGV(ppad[ix]) || IS_PADCONST(ppad[ix])) { - sv = SvREFCNT_inc(ppad[ix]); + sv = SvREFCNT_inc_NN(ppad[ix]); } else { sv = newSV(0); @@ -1618,7 +1632,7 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth) } } else if (IS_PADGV(oldpad[ix]) || IS_PADCONST(oldpad[ix])) { - av_store(newpad, ix, SvREFCNT_inc(oldpad[ix])); + av_store(newpad, ix, SvREFCNT_inc_NN(oldpad[ix])); } else { /* save temporaries on recursion? */