X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/c902d85e7652ab578dceefc793d634241321e990..7c9af400d53ed211683a6973da00aaefb34255d3:/pad.c?ds=sidebyside diff --git a/pad.c b/pad.c index 082dc66..d2b6c4f 100644 --- a/pad.c +++ b/pad.c @@ -58,7 +58,8 @@ AV which is @_. Other entries are storage for variables and op targets. Iterating over the PADNAMELIST iterates over all possible pad items. Pad slots for targets (SVs_PADTMP) and GVs end up having &PL_sv_no "names", while slots for constants have &PL_sv_no "names" (see -pad_alloc()). +pad_alloc()). That &PL_sv_no is used is an implementation detail subject +to change. To test for it, use C. Only my/our variable (SvPADMY/PADNAME_isOUR) slots get valid names. The rest are op targets/GVs/constants which are statically allocated @@ -283,6 +284,7 @@ Perl_pad_new(pTHX_ int flags) else { av_store(pad, 0, NULL); padname = newAV(); + AvPAD_NAMELIST_on(padname); } /* Most subroutines never recurse, hence only need 2 entries in the padlist @@ -573,6 +575,7 @@ S_pad_alloc_name(pTHX_ SV *namesv, U32 flags, HV *typestash, HV *ourstash) } av_store(PL_comppad_name, offset, namesv); + PadnamelistMAXNAMED(PL_comppad_name) = offset; return offset; } @@ -768,7 +771,7 @@ Perl_pad_alloc(pTHX_ I32 optype, U32 tmptype) continue; sv = *av_fetch(PL_comppad, PL_padix, TRUE); if (!(SvFLAGS(sv) & (SVs_PADTMP | SVs_PADMY)) && - !IS_PADGV(sv) && !IS_PADCONST(sv)) + !IS_PADGV(sv)) break; } if (tmptype & SVf_READONLY) { @@ -1177,7 +1180,7 @@ S_pad_findlex(pTHX_ const char *namepv, STRLEN namelen, U32 flags, const CV* cv, const AV * const nameav = PadlistARRAY(padlist)[0]; SV * const * const name_svp = AvARRAY(nameav); - for (offset = AvFILLp(nameav); offset > 0; offset--) { + for (offset = PadnamelistMAXNAMED(nameav); offset > 0; offset--) { const SV * const namesv = name_svp[offset]; if (namesv && PadnameLEN(namesv) == namelen && sv_eq_pvn_flags(aTHX_ namesv, namepv, namelen, @@ -1638,8 +1641,6 @@ Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust) "Pad 0x%"UVxf"[0x%"UVxf"] swipe: %ld\n", PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long)po)); - if (PL_curpad[po] && !SvPADMY(PL_curpad[po])) - SvPADTMP_off(PL_curpad[po]); if (refadjust) SvREFCNT_dec(PL_curpad[po]);