Skip to content

Commit b0e6192

Browse files
committed
mro.xs: switch Perl_croak(aTHX) to Perl_croak_nocontext()
-less machine code on threaded perls for branches that will never execute in normal production code, each aTHX_, is a CPU's mov, push, load, or store machine code op (3-4 bytes typically, worst case 7 or 8 bytes).
1 parent 8b524d3 commit b0e6192

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

ext/mro/mro.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use warnings;
1212

1313
# mro.pm versions < 1.00 reserved for MRO::Compat
1414
# for partial back-compat to 5.[68].x
15-
our $VERSION = '1.29';
15+
our $VERSION = '1.30';
1616

1717
require XSLoader;
1818
XSLoader::load('mro');

ext/mro/mro.xs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, U32 level)
4343
stashhek = HvENAME_HEK(stash);
4444
if (!stashhek) stashhek = HvNAME_HEK(stash);
4545
if (!stashhek)
46-
Perl_croak(aTHX_ "Can't linearize anonymous symbol table");
46+
Perl_croak_nocontext("Can't linearize anonymous symbol table");
4747

4848
if (level > 100)
49-
Perl_croak(aTHX_ "Recursive inheritance detected in package '%" HEKf
49+
Perl_croak_nocontext("Recursive inheritance detected in package '%" HEKf
5050
"'",
5151
HEKfARG(stashhek));
5252

@@ -263,7 +263,7 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, U32 level)
263263
SvREFCNT_dec(retval);
264264
Safefree(heads);
265265

266-
Perl_croak(aTHX_ "%" SVf, SVfARG(errmsg));
266+
Perl_croak_nocontext("%" SVf, SVfARG(errmsg));
267267
}
268268
}
269269
}
@@ -323,7 +323,7 @@ mro_get_linear_isa(...)
323323
else if(items > 1) {
324324
const struct mro_alg *const algo = Perl_mro_get_from_name(aTHX_ ST(1));
325325
if (!algo)
326-
Perl_croak(aTHX_ "Invalid mro name: '%" SVf "'", ST(1));
326+
Perl_croak_nocontext("Invalid mro name: '%" SVf "'", ST(1));
327327
RETVAL = algo->resolve(aTHX_ class_stash, 0);
328328
}
329329
else {
@@ -346,7 +346,7 @@ mro_set_mro(...)
346346

347347
classname = ST(0);
348348
class_stash = gv_stashsv(classname, GV_ADD);
349-
if(!class_stash) Perl_croak(aTHX_ "Cannot create class: '%" SVf "'!", SVfARG(classname));
349+
if(!class_stash) Perl_croak_nocontext("Cannot create class: '%" SVf "'!", SVfARG(classname));
350350
meta = HvMROMETA(class_stash);
351351

352352
Perl_mro_set_mro(aTHX_ meta, ST(1));
@@ -496,7 +496,7 @@ mro__nextcan(...)
496496

497497
hvname = HvNAME_get(selfstash);
498498
if (!hvname)
499-
Perl_croak(aTHX_ "Can't use anonymous symbol table for method lookup");
499+
Perl_croak_nocontext("Can't use anonymous symbol table for method lookup");
500500

501501
/* This block finds the contextually-enclosing fully-qualified subname,
502502
much like looking at (caller($i))[3] until you find a real sub that
@@ -509,7 +509,7 @@ mro__nextcan(...)
509509
/* we may be in a higher stacklevel, so dig down deeper */
510510
while (cxix < 0) {
511511
if(top_si->si_type == PERLSI_MAIN)
512-
Perl_croak(aTHX_ "next::method/next::can/maybe::next::method must be used in method context");
512+
Perl_croak_nocontext("next::method/next::can/maybe::next::method must be used in method context");
513513
top_si = top_si->si_prev;
514514
ccstack = top_si->si_cxstack;
515515
cxix = __dopoptosub_at(ccstack, top_si->si_cxix);
@@ -548,7 +548,7 @@ mro__nextcan(...)
548548
subname = strrchr(fq_subname, ':');
549549
}
550550
if(!subname)
551-
Perl_croak(aTHX_ "next::method/next::can/maybe::next::method cannot find enclosing method");
551+
Perl_croak_nocontext("next::method/next::can/maybe::next::method cannot find enclosing method");
552552

553553
subname_utf8 = SvUTF8(sv) ? 1 : 0;
554554
subname++;
@@ -576,7 +576,7 @@ mro__nextcan(...)
576576
SV* const val = HeVAL(cache_entry);
577577
if(val == &PL_sv_undef) {
578578
if(throw_nomethod)
579-
Perl_croak(aTHX_
579+
Perl_croak_nocontext(
580580
"No next::method '%" SVf "' found for %" HEKf,
581581
SVfARG(newSVpvn_flags(subname, subname_len,
582582
SVs_TEMP | ( subname_utf8 ? SVf_UTF8 : 0 ) )),
@@ -658,7 +658,7 @@ mro__nextcan(...)
658658

659659
(void)hv_store_ent(nmcache, sv, &PL_sv_undef, 0);
660660
if(throw_nomethod)
661-
Perl_croak(aTHX_ "No next::method '%" SVf "' found for %" HEKf,
661+
Perl_croak_nocontext("No next::method '%" SVf "' found for %" HEKf,
662662
SVfARG(newSVpvn_flags(subname, subname_len,
663663
SVs_TEMP | ( subname_utf8 ? SVf_UTF8 : 0 ) )),
664664
HEKfARG( HvNAME_HEK(selfstash) ));

0 commit comments

Comments
 (0)