From 4870fd2e1aacb81b8c21021c5f89e0b612e637f2 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Mon, 19 Feb 2024 20:51:36 +0000 Subject: [PATCH] Remove the tombstone-related code from pad.h + pad.c This was a short-lived experimental feature intended to implement removal of lexical symbols, in order to provide syntax like `no builtin ...` or to remove implied imported builtins on a change of prevailing `use VERSION`. The model of removing a lexical has proven to be too subtle and complex to implement as well as raising various awkward questions about the semantics, so we decided to remove it again in Perl 5.39.8. There is now no longer any code that uses PADNAMEf_TOMBSTONE. As PADNAMEf_TOMBSTONE was only added in earlier in the 5.39.x developent series, there is no need to retain the constants in .h files for compatibility or to reserve the numbers for them. They have never appeared in a stable release of Perl. --- pad.c | 45 ++++++++++++++------------------------------- pad.h | 8 -------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/pad.c b/pad.c index 5c509b79dc2b..651ff4bbc0b2 100644 --- a/pad.c +++ b/pad.c @@ -401,8 +401,7 @@ Perl_cv_undef_flags(pTHX_ CV *cv, U32 flags) SV ** const curpad = AvARRAY(comppad); for (ix = PadnamelistMAX(comppad_name); ix > 0; ix--) { PADNAME * const name = namepad[ix]; - if (name && PadnamePV(name) && *PadnamePV(name) == '&' && - !PadnameIsTOMBSTONE(name)) { + if (name && PadnamePV(name) && *PadnamePV(name) == '&') { CV * const innercv = MUTABLE_CV(curpad[ix]); if (PadnameIsOUR(name) && CvCLONED(&cvbody)) { assert(!innercv); @@ -540,7 +539,7 @@ pad (via L) and then stores a name for that entry. C is adopted and becomes the name entry; it must already contain the name string. C and C and the C -and C flags get added to C. +flag gets added to C. None of the other processing of L is done. Returns the offset of the allocated pad slot. @@ -574,9 +573,6 @@ S_pad_alloc_name(pTHX_ PADNAME *name, U32 flags, HV *typestash, assert(HvSTASH_IS_CLASS(PL_curstash)); class_add_field(PL_curstash, name); } - if (flags & padadd_TOMBSTONE) { - PadnameFLAGS(name) |= PADNAMEf_TOMBSTONE; - } padnamelist_store(PL_comppad_name, offset, name); if (PadnameLEN(name) > 1) @@ -603,7 +599,6 @@ flags can be OR'ed together: padadd_STATE variable will retain value persistently padadd_NO_DUP_CHECK skip check for lexical shadowing padadd_FIELD specifies that the lexical is a field for a class - padadd_TOMBSTONE sets the PadnameIsTOMBSTONE flag on the new name =cut */ @@ -617,13 +612,13 @@ Perl_pad_add_name_pvn(pTHX_ const char *namepv, STRLEN namelen, PERL_ARGS_ASSERT_PAD_ADD_NAME_PVN; - if (flags & ~(padadd_OUR|padadd_STATE|padadd_NO_DUP_CHECK|padadd_FIELD|padadd_TOMBSTONE)) + if (flags & ~(padadd_OUR|padadd_STATE|padadd_NO_DUP_CHECK|padadd_FIELD)) Perl_croak(aTHX_ "panic: pad_add_name_pvn illegal flag bits 0x%" UVxf, (UV)flags); name = newPADNAMEpvn(namepv, namelen); - if ((flags & (padadd_NO_DUP_CHECK|padadd_TOMBSTONE)) == 0) { + if ((flags & (padadd_NO_DUP_CHECK)) == 0) { ENTER; SAVEFREEPADNAME(name); /* in case of fatal warnings */ /* check for duplicate declaration */ @@ -641,23 +636,16 @@ Perl_pad_add_name_pvn(pTHX_ const char *namepv, STRLEN namelen, if (!PL_min_intro_pending) PL_min_intro_pending = offset; PL_max_intro_pending = offset; - if(!(flags & padadd_TOMBSTONE)) { - /* if it's not a simple scalar, replace with an AV or HV */ - assert(SvTYPE(PL_curpad[offset]) == SVt_NULL); - assert(SvREFCNT(PL_curpad[offset]) == 1); - if (namelen != 0 && *namepv == '@') - sv_upgrade(PL_curpad[offset], SVt_PVAV); - else if (namelen != 0 && *namepv == '%') - sv_upgrade(PL_curpad[offset], SVt_PVHV); - else if (namelen != 0 && *namepv == '&') - sv_upgrade(PL_curpad[offset], SVt_PVCV); - assert(SvPADMY(PL_curpad[offset])); - } - else { - /* tombstone has no SV */ - SvREFCNT_dec(PL_curpad[offset]); - PL_curpad[offset] = NULL; - } + /* if it's not a simple scalar, replace with an AV or HV */ + assert(SvTYPE(PL_curpad[offset]) == SVt_NULL); + assert(SvREFCNT(PL_curpad[offset]) == 1); + if (namelen != 0 && *namepv == '@') + sv_upgrade(PL_curpad[offset], SVt_PVAV); + else if (namelen != 0 && *namepv == '%') + sv_upgrade(PL_curpad[offset], SVt_PVHV); + else if (namelen != 0 && *namepv == '&') + sv_upgrade(PL_curpad[offset], SVt_PVCV); + assert(SvPADMY(PL_curpad[offset])); DEBUG_Xv(PerlIO_printf(Perl_debug_log, "Pad addname: %ld \"%s\" new lex=0x%" UVxf "\n", (long)offset, PadnamePV(name), @@ -904,7 +892,6 @@ S_pad_check_dup(pTHX_ PADNAME *name, U32 flags, const HV *ourstash) if (pn && PadnameLEN(pn) == PadnameLEN(name) && !PadnameOUTER(pn) - && !PadnameIsTOMBSTONE(pn) && ( COP_SEQ_RANGE_LOW(pn) == PERL_PADSEQ_INTRO || COP_SEQ_RANGE_HIGH(pn) == PERL_PADSEQ_INTRO) && memEQ(PadnamePV(pn), PadnamePV(name), PadnameLEN(name))) @@ -1171,10 +1158,6 @@ S_pad_findlex(pTHX_ const char *namepv, STRLEN namelen, U32 flags, const CV* cv, fake_offset = 0; *out_name = name_p[offset]; /* return the name */ - if (PadnameIsTOMBSTONE(*out_name)) - /* is this a lexical import that has been deleted? */ - return NOT_IN_PAD; - if (PadnameIsFIELD(*out_name) && !fieldok) croak("Field %" SVf " is not accessible outside a method", SVfARG(PadnameSV(*out_name))); diff --git a/pad.h b/pad.h index 283938f2d106..049c48005e88 100644 --- a/pad.h +++ b/pad.h @@ -150,7 +150,6 @@ typedef enum { * sub, but only one level up */ #define padadd_FIELD 0x10 /* set PADNAMEt_FIELD */ #define padfind_FIELD_OK 0x20 /* pad_findlex is permitted to see fields */ -#define padadd_TOMBSTONE 0x40 /* set PadnameIsTOMBSTONE on the new entry */ /* ASSERT_CURPAD_LEGAL and ASSERT_CURPAD_ACTIVE respectively determine * whether PL_comppad and PL_curpad are consistent and whether they have @@ -263,11 +262,6 @@ Whether this is a "state" variable. Whether this is a "field" variable. PADNAMEs where this is true will have additional information available via C. -=for apidoc m|bool|PadnameIsTOMBSTONE|PADNAME * pn -Whether this pad entry is a tombstone. Such an entry indicates that a -previously-valid pad entry has now been deleted within this scope, and -should be ignored. - =for apidoc m|HV *|PadnameTYPE|PADNAME * pn The stash associated with a typed lexical. This returns the C<%Foo::> hash for C. @@ -360,7 +354,6 @@ Restore the old pad saved into the local variable C by C #define PadnameIsSTATE(pn) (PadnameFLAGS(pn) & PADNAMEf_STATE) #define PadnameLVALUE(pn) (PadnameFLAGS(pn) & PADNAMEf_LVALUE) #define PadnameIsFIELD(pn) (PadnameFLAGS(pn) & PADNAMEf_FIELD) -#define PadnameIsTOMBSTONE(pn) (PadnameFLAGS(pn) & PADNAMEf_TOMBSTONE) #define PadnameLVALUE_on(pn) (PadnameFLAGS(pn) |= PADNAMEf_LVALUE) #define PadnameIsSTATE_on(pn) (PadnameFLAGS(pn) |= PADNAMEf_STATE) @@ -371,7 +364,6 @@ Restore the old pad saved into the local variable C by C #define PADNAMEf_TYPED 0x08 /* for B; unused by core */ #define PADNAMEf_OUR 0x10 /* for B; unused by core */ #define PADNAMEf_FIELD 0x20 /* field var */ -#define PADNAMEf_TOMBSTONE 0x40 /* padname has been deleted */ /* backward compatibility */ #ifndef PERL_CORE