From faa4724a28c7c95f793b32234e7ead1ccc46ac9e Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 2 Aug 2025 14:41:27 -0600 Subject: [PATCH] Remove customized ARGS_ASSERT macros These existed because they exceeded the rudimentary capabilities of the generated ARGS_ASSERT macros. But the previous commit generalized that capability, so they can change to use that. This moves the three extant customized macros to use the new facility, removing the need for overriding things The customized PERL_ARGS_ASSERT_ISA_LOOKUP was out-of-date, missing an assertion that got added, without the macro getting updated. This new scheme will prevent that from happening in the future. --- embed.fnc | 21 ++++++++++++--------- gv.c | 7 ++----- proto.h | 8 +++++++- universal.c | 13 ++----------- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/embed.fnc b/embed.fnc index 89533d2f35..ba86b15fe7 100644 --- a/embed.fnc +++ b/embed.fnc @@ -4537,11 +4537,12 @@ op |void |sv_add_backref |NN SV * const tsv \ |NN SV * const sv #endif #if defined(PERL_IN_GV_C) || defined(PERL_IN_UNIVERSAL_C) -EGdp |HV * |gv_stashsvpvn_cached \ - |SV *namesv \ - |const char *name \ +Edp |HV * |gv_stashsvpvn_cached \ + |NULLOK SV *namesv \ + |NULLOK const char *name \ |U32 namelen \ - |I32 flags + |I32 flags \ + assert(namesv || name) #endif #if defined(PERL_IN_HV_C) Sx |void |clear_placeholders \ @@ -6120,17 +6121,19 @@ S |I32 |utf16_textfilter \ # endif #endif /* defined(PERL_IN_TOKE_C) */ #if defined(PERL_IN_UNIVERSAL_C) -GS |bool |isa_lookup |NULLOK NOCHECK HV *stash \ +S |bool |isa_lookup |NN HV *stash \ |NULLOK SV *namesv \ |NULLOK const char *name \ |STRLEN len \ - |U32 flags -GS |bool |sv_derived_from_svpvn \ - |NULLOK SV *sv \ + |U32 flags \ + assert(namesv || name) +S |bool |sv_derived_from_svpvn \ + |NN SV *sv \ |NULLOK SV *namesv \ |NULLOK const char *name \ |const STRLEN len \ - |U32 flags + |U32 flags \ + assert(namesv || name) #endif #if defined(PERL_IN_UTF8_C) RS |UV |check_locale_boundary_crossing \ diff --git a/gv.c b/gv.c index a5960c82f8..e494bc3096 100644 --- a/gv.c +++ b/gv.c @@ -1691,17 +1691,14 @@ reasons. =cut */ -#define PERL_ARGS_ASSERT_GV_STASHSVPVN_CACHED \ - assert(namesv || name) - HV* Perl_gv_stashsvpvn_cached(pTHX_ SV *namesv, const char *name, U32 namelen, I32 flags) { + PERL_ARGS_ASSERT_GV_STASHSVPVN_CACHED; + HV* stash; HE* he; - PERL_ARGS_ASSERT_GV_STASHSVPVN_CACHED; - he = (HE *)hv_common( PL_stashcache, namesv, name, namelen, (flags & SVf_UTF8) ? HVhek_UTF8 : 0, 0, NULL, 0 diff --git a/proto.h b/proto.h index ca17ecfe74..41eabb9a75 100644 --- a/proto.h +++ b/proto.h @@ -6950,6 +6950,8 @@ Perl_sv_add_backref(pTHX_ SV * const tsv, SV * const sv) PERL_CALLCONV HV * Perl_gv_stashsvpvn_cached(pTHX_ SV *namesv, const char *name, U32 namelen, I32 flags) __attribute__visibility__("hidden"); +# define PERL_ARGS_ASSERT_GV_STASHSVPVN_CACHED \ + assert(namesv || name) #endif #if defined(PERL_IN_HV_C) @@ -9470,11 +9472,15 @@ S_utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen); #if defined(PERL_IN_UNIVERSAL_C) STATIC bool S_isa_lookup(pTHX_ HV *stash, SV *namesv, const char *name, STRLEN len, U32 flags); +# define PERL_ARGS_ASSERT_ISA_LOOKUP \ + assert(stash); assert(SvTYPE(stash) == SVt_PVHV); assert(namesv || name) STATIC bool S_sv_derived_from_svpvn(pTHX_ SV *sv, SV *namesv, const char *name, const STRLEN len, U32 flags); +# define PERL_ARGS_ASSERT_SV_DERIVED_FROM_SVPVN \ + assert(sv); assert(namesv || name) -#endif +#endif /* defined(PERL_IN_UNIVERSAL_C) */ #if defined(PERL_IN_UTF8_C) STATIC UV S__to_utf8_case(pTHX_ const UV original, const U8 *p, U8 *ustrp, STRLEN *lenp, SV *invlist, const I32 * const invmap, const U32 * const * const aux_tables, const U8 * const aux_table_lengths, const char * const normal); diff --git a/universal.c b/universal.c index d60bf9585e..34e5e66690 100644 --- a/universal.c +++ b/universal.c @@ -39,20 +39,15 @@ * The main guts of traverse_isa was actually copied from gv_fetchmeth */ -#define PERL_ARGS_ASSERT_ISA_LOOKUP \ - assert(stash); \ - assert(namesv || name) - - STATIC bool S_isa_lookup(pTHX_ HV *stash, SV *namesv, const char * name, STRLEN len, U32 flags) { + PERL_ARGS_ASSERT_ISA_LOOKUP; + const struct mro_meta *const meta = HvMROMETA(stash); HV *isa = meta->isa; const HV *our_stash; - PERL_ARGS_ASSERT_ISA_LOOKUP; - if (!isa) { (void)mro_get_linear_isa(stash); isa = meta->isa; @@ -83,10 +78,6 @@ S_isa_lookup(pTHX_ HV *stash, SV *namesv, const char * name, STRLEN len, U32 fla return FALSE; } -#define PERL_ARGS_ASSERT_SV_DERIVED_FROM_SVPVN \ - assert(sv); \ - assert(namesv || name) - STATIC bool S_sv_derived_from_svpvn(pTHX_ SV *sv, SV *namesv, const char * name, const STRLEN len, U32 flags) {