From a8675724ad9cc8e76acde8fe6fd160576958b96a Mon Sep 17 00:00:00 2001 From: Richard Leach Date: Sun, 10 Nov 2024 17:10:53 +0000 Subject: [PATCH] croak squash --- embed.fnc | 6 +++--- embed.h | 2 +- proto.h | 10 +++++----- sv.c | 17 +++++++++-------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/embed.fnc b/embed.fnc index 481c30fc45fa..9c0cf9542547 100644 --- a/embed.fnc +++ b/embed.fnc @@ -5811,6 +5811,9 @@ S |void |assert_uft8_cache_coherent \ |STRLEN from_cache \ |STRLEN real \ |NN SV * const sv +S |void |croak_sv_setsv_flags \ + |NN SV * const dsv \ + |NN SV * const ssv S |bool |curse |NN SV * const sv \ |const bool check_refcnt RS |STRLEN |expect_number |NN const char ** const pattern @@ -5870,9 +5873,6 @@ ST |STRLEN |sv_pos_u2b_midway \ |NN const U8 *send \ |STRLEN uoffset \ |const STRLEN uend -S |void |sv_setsv_flags_croak \ - |NN SV * const dsv \ - |NN SV * const ssv i |void |sv_unglob |NN SV * const sv \ |U32 flags RTi |char * |uiv_2buf |NN char * const buf \ diff --git a/embed.h b/embed.h index 106447033f53..245c80152f8f 100644 --- a/embed.h +++ b/embed.h @@ -2157,6 +2157,7 @@ # define F0convert S_F0convert # define anonymise_cv_maybe(a,b) S_anonymise_cv_maybe(aTHX_ a,b) # define assert_uft8_cache_coherent(a,b,c,d) S_assert_uft8_cache_coherent(aTHX_ a,b,c,d) +# define croak_sv_setsv_flags(a,b) S_croak_sv_setsv_flags(aTHX_ a,b) # define curse(a,b) S_curse(aTHX_ a,b) # define expect_number(a) S_expect_number(aTHX_ a) # define find_array_subscript(a,b) S_find_array_subscript(aTHX_ a,b) @@ -2174,7 +2175,6 @@ # define sv_pos_u2b_cached(a,b,c,d,e,f,g) S_sv_pos_u2b_cached(aTHX_ a,b,c,d,e,f,g) # define sv_pos_u2b_forwards S_sv_pos_u2b_forwards # define sv_pos_u2b_midway S_sv_pos_u2b_midway -# define sv_setsv_flags_croak(a,b) S_sv_setsv_flags_croak(aTHX_ a,b) # define sv_unglob(a,b) S_sv_unglob(aTHX_ a,b) # define uiv_2buf S_uiv_2buf # define utf8_mg_len_cache_update(a,b,c) S_utf8_mg_len_cache_update(aTHX_ a,b,c) diff --git a/proto.h b/proto.h index 32b41aac1a19..6b29f958b223 100644 --- a/proto.h +++ b/proto.h @@ -8923,6 +8923,11 @@ S_assert_uft8_cache_coherent(pTHX_ const char * const func, STRLEN from_cache, S # define PERL_ARGS_ASSERT_ASSERT_UFT8_CACHE_COHERENT \ assert(func); assert(sv) +STATIC void +S_croak_sv_setsv_flags(pTHX_ SV * const dsv, SV * const ssv); +# define PERL_ARGS_ASSERT_CROAK_SV_SETSV_FLAGS \ + assert(dsv); assert(ssv) + STATIC bool S_curse(pTHX_ SV * const sv, const bool check_refcnt); # define PERL_ARGS_ASSERT_CURSE \ @@ -9015,11 +9020,6 @@ S_sv_pos_u2b_midway(const U8 * const start, const U8 *send, STRLEN uoffset, cons # define PERL_ARGS_ASSERT_SV_POS_U2B_MIDWAY \ assert(start); assert(send) -STATIC void -S_sv_setsv_flags_croak(pTHX_ SV * const dsv, SV * const ssv); -# define PERL_ARGS_ASSERT_SV_SETSV_FLAGS_CROAK \ - assert(dsv); assert(ssv) - STATIC void S_utf8_mg_len_cache_update(pTHX_ SV * const sv, MAGIC ** const mgp, const STRLEN ulen); # define PERL_ARGS_ASSERT_UTF8_MG_LEN_CACHE_UPDATE \ diff --git a/sv.c b/sv.c index e17eac7694f9..36131608315e 100644 --- a/sv.c +++ b/sv.c @@ -4281,7 +4281,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags) #endif */ if (UNLIKELY(both_type == SVTYPEMASK)) { - sv_setsv_flags_croak(dsv, ssv); + croak_sv_setsv_flags(dsv, ssv); NOT_REACHED; } @@ -4383,7 +4383,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags) invlist_clone(ssv, dsv); return; default: - sv_setsv_flags_croak(dsv, ssv); + croak_sv_setsv_flags(dsv, ssv); NOT_REACHED; /* NOTREACHED */ case SVt_REGEXP: @@ -4437,7 +4437,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags) else if (UNLIKELY(dtype == SVt_PVAV || dtype == SVt_PVHV || dtype == SVt_PVFM)) { - sv_setsv_flags_croak(dsv, ssv); + croak_sv_setsv_flags(dsv, ssv); NOT_REACHED; } else if (sflags & SVf_ROK) { if (isGV_with_GP(dsv) @@ -17725,8 +17725,9 @@ Perl_report_uninit(pTHX_ const SV *uninit_sv) * The main aim is to keep Perl_sv_setsv_flags as slim as possible and this * includes keeping the call sites for this function small. */ -void S_sv_setsv_flags_croak(pTHX_ SV * const dsv, SV * const ssv) +void S_croak_sv_setsv_flags(pTHX_ SV * const dsv, SV * const ssv) { + OP *op = PL_op; if (SvIS_FREED(dsv)) { Perl_croak(aTHX_ "panic: attempt to copy value %" SVf " to a freed scalar %p", SVfARG(ssv), (void *)dsv); @@ -17739,17 +17740,17 @@ void S_sv_setsv_flags_croak(pTHX_ SV * const dsv, SV * const ssv) if (SvTYPE(ssv) > SVt_PVLV) { const char * const type = sv_reftype(ssv,0); - if (PL_op) + if (op) /* diag_listed_as: Bizarre copy of %s */ - Perl_croak(aTHX_ "Bizarre copy of %s in %s", type, OP_DESC(PL_op)); + Perl_croak(aTHX_ "Bizarre copy of %s in %s", type, OP_DESC(op)); else Perl_croak(aTHX_ "Bizarre copy of %s", type); } const char * const type = sv_reftype(dsv,0); - if (PL_op) + if (op) /* diag_listed_as: Cannot copy to %s */ - Perl_croak(aTHX_ "Cannot copy to %s in %s", type, OP_DESC(PL_op)); + Perl_croak(aTHX_ "Cannot copy to %s in %s", type, OP_DESC(op)); else Perl_croak(aTHX_ "Cannot copy to %s", type);