| 1 |
|
| #include "next.h" |
| 2 |
|
| #include <string> |
| 3 |
|
| #include <stdexcept> |
| 4 |
|
| |
| 5 |
|
| namespace xs { |
| 6 |
|
| |
| 7 |
|
| static MGVTBL c3_marker; |
| 8 |
|
| |
| 9 |
|
| #ifndef FORCEINLINE |
| 10 |
|
| # if defined(_MSC_VER) |
| 11 |
|
| # define FORCEINLINE __forceinline |
| 12 |
|
| # elif defined(__GNUC_) && _GNUC__ > 3 |
| 13 |
|
| # define FORCEINLINE inline _attribute_ ((_always_inline_)) |
| 14 |
|
| # else |
| 15 |
|
| # define FORCEINLINE inline |
| 16 |
|
| # endif |
| 17 |
|
| #endif |
| 18 |
|
| |
| 19 |
|
| #if PERL_VERSION >= 20 |
| 20 |
|
| #define HvSUPERCACHE(hv) (HvMROMETA(stash)->super) |
| 21 |
|
| #else |
| 22 |
|
| #define HvSUPERCACHE(hv) (HvAUX(stash)->xhv_super) |
| 23 |
|
| #endif |
| 24 |
|
| |
| 25 |
63 |
| static FORCEINLINE I32 __dopoptosub_at (const PERL_CONTEXT* cxstk, I32 startingblock) { |
| 26 |
|
| I32 i; |
| 27 |
69 |
▶ | for (i = startingblock; i >= 0; --i) if (CxTYPE(cxstk+i) == CXt_SUB) return i; |
Branch: 2 branches
| Branch | True | False | Total |
| for (i = startingblock; i >= 0; --i) if (CxTYPE(cxstk+i) == CXt_SUB) return i; |
62 |
6 |
68 |
| for (i = startingblock; i >= 0; --i) if (CxTYPE(cxstk+i) == CXt_SUB) return i; |
68 |
1 |
69 |
|
| 28 |
1 |
| return i; |
| 29 |
|
| } |
| 30 |
|
| |
| 31 |
|
| // finds the contextually-enclosing fully-qualified subname, much like looking at (caller($i))[3] until you find a real sub that isn't ANON, etc |
| 32 |
56 |
| static FORCEINLINE GV* _find_sub (SV** fqnp) { |
| 33 |
|
| dTHX; |
| 34 |
56 |
| const PERL_SI* top_si = PL_curstackinfo; |
| 35 |
56 |
| const PERL_CONTEXT* ccstack = cxstack; |
| 36 |
56 |
| I32 cxix = __dopoptosub_at(ccstack, cxstack_ix); |
| 37 |
|
| |
| 38 |
|
| for (;;) { |
| 39 |
|
| /* we may be in a higher stacklevel, so dig down deeper */ |
| 40 |
63 |
▶ | while (cxix < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (cxix < 0) { |
1 |
62 |
63 |
|
| 41 |
1 |
▶ | if (top_si->si_type == PERLSI_MAIN) throw std::logic_error("next::method/next::can/maybe::next::method must be used in method context"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (top_si->si_type == PERLSI_MAIN) throw std::logic_error("next::method/next::can/maybe::next::method must be used in method context"); |
1 |
0 |
1 |
| if (top_si->si_type == PERLSI_MAIN) throw std::logic_error("next::method/next::can/maybe::next::method must be used in method context"); |
1 |
0 |
1 |
|
| 42 |
0 |
| top_si = top_si->si_prev; |
| 43 |
0 |
| ccstack = top_si->si_cxstack; |
| 44 |
0 |
| cxix = __dopoptosub_at(ccstack, top_si->si_cxix); |
| 45 |
|
| } |
| 46 |
|
| |
| 47 |
62 |
▶ | if (PL_DBsub && GvCV(PL_DBsub)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (PL_DBsub && GvCV(PL_DBsub)) { |
62 |
0 |
62 |
| if (PL_DBsub && GvCV(PL_DBsub)) { |
0 |
62 |
62 |
|
| 48 |
0 |
▶ | if (ccstack[cxix].blk_sub.cv == GvCV(PL_DBsub)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ccstack[cxix].blk_sub.cv == GvCV(PL_DBsub)) { |
0 |
0 |
0 |
|
| 49 |
0 |
| cxix = __dopoptosub_at(ccstack, cxix - 1); |
| 50 |
0 |
| continue; |
| 51 |
|
| } |
| 52 |
0 |
| const I32 dbcxix = __dopoptosub_at(ccstack, cxix - 1); |
| 53 |
0 |
▶ | if (dbcxix >= 0 && ccstack[dbcxix].blk_sub.cv == GvCV(PL_DBsub)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (dbcxix >= 0 && ccstack[dbcxix].blk_sub.cv == GvCV(PL_DBsub)) { |
0 |
0 |
0 |
| if (dbcxix >= 0 && ccstack[dbcxix].blk_sub.cv == GvCV(PL_DBsub)) { |
0 |
0 |
0 |
|
| 54 |
0 |
▶ | if (CxTYPE((PERL_CONTEXT*)(&ccstack[dbcxix])) != CXt_SUB) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (CxTYPE((PERL_CONTEXT*)(&ccstack[dbcxix])) != CXt_SUB) { |
0 |
0 |
0 |
|
| 55 |
0 |
| cxix = dbcxix; |
| 56 |
0 |
| continue; |
| 57 |
|
| } |
| 58 |
|
| } |
| 59 |
|
| } |
| 60 |
|
| |
| 61 |
|
| /* we found a real sub here */ |
| 62 |
62 |
| CV* cv = ccstack[cxix].blk_sub.cv; |
| 63 |
62 |
| GV* gv = CvGV(cv); |
| 64 |
62 |
| HV* stash = GvSTASH(gv); |
| 65 |
|
| |
| 66 |
62 |
| MAGIC* mg = mg_findext((SV*)gv, PERL_MAGIC_ext, &c3_marker); |
| 67 |
62 |
▶ | if (mg && (HV*)mg->mg_ptr == stash) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (mg && (HV*)mg->mg_ptr == stash) { |
10 |
52 |
62 |
| if (mg && (HV*)mg->mg_ptr == stash) { |
10 |
0 |
10 |
|
| 68 |
10 |
| *fqnp = mg->mg_obj; |
| 69 |
10 |
| return gv; |
| 70 |
|
| } |
| 71 |
|
| |
| 72 |
52 |
▶ | if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
Branch: 9 branches
| Branch | True | False | Total |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
52 |
0 |
52 |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
52 |
0 |
52 |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
52 |
0 |
52 |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
0 |
52 |
52 |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
52 |
0 |
52 |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
0 |
52 |
52 |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
52 |
0 |
52 |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
11 |
41 |
52 |
| if (!stash || !HvNAME(stash) || (GvNAMELEN(gv) == 8 && !memcmp(GvNAME(gv), "__ANON__", 8))) { // ANON sub |
7 |
4 |
11 |
|
| 73 |
7 |
| cxix = __dopoptosub_at(ccstack, cxix - 1); |
| 74 |
7 |
| continue; |
| 75 |
|
| } |
| 76 |
|
| |
| 77 |
45 |
| return gv; |
| 78 |
7 |
| } |
| 79 |
|
| } |
| 80 |
|
| |
| 81 |
55 |
| static FORCEINLINE SV* _make_shared_fqn (pTHX_ GV* gv) { |
| 82 |
55 |
| HV* stash = GvSTASH(gv); |
| 83 |
55 |
▶ | STRLEN pkglen = HvNAMELEN(stash); |
Branch: 5 branches
| Branch | True | False | Total |
| STRLEN pkglen = HvNAMELEN(stash); |
55 |
0 |
55 |
| STRLEN pkglen = HvNAMELEN(stash); |
55 |
0 |
55 |
| STRLEN pkglen = HvNAMELEN(stash); |
0 |
55 |
55 |
| STRLEN pkglen = HvNAMELEN(stash); |
55 |
0 |
55 |
| STRLEN pkglen = HvNAMELEN(stash); |
0 |
55 |
55 |
|
| 84 |
55 |
| STRLEN fqnlen = pkglen + GvNAMELEN(gv) + 2; |
| 85 |
55 |
| std::string fqn; |
| 86 |
55 |
▶ | fqn.reserve(fqnlen+1); |
Branch: 1 branch
| Branch | True | False | Total |
| fqn.reserve(fqnlen+1); |
55 |
0 |
55 |
|
| 87 |
55 |
▶ | fqn.append(HvNAME(stash), pkglen); |
Branch: 6 branches
| Branch | True | False | Total |
| fqn.append(HvNAME(stash), pkglen); |
55 |
0 |
55 |
| fqn.append(HvNAME(stash), pkglen); |
55 |
0 |
55 |
| fqn.append(HvNAME(stash), pkglen); |
0 |
55 |
55 |
| fqn.append(HvNAME(stash), pkglen); |
55 |
0 |
55 |
| fqn.append(HvNAME(stash), pkglen); |
0 |
55 |
55 |
| fqn.append(HvNAME(stash), pkglen); |
55 |
0 |
55 |
|
| 88 |
55 |
▶ | fqn += "::"; |
Branch: 1 branch
| Branch | True | False | Total |
| fqn += "::"; |
55 |
0 |
55 |
|
| 89 |
55 |
▶ | fqn.append(GvNAME(gv), GvNAMELEN(gv)); |
Branch: 1 branch
| Branch | True | False | Total |
| fqn.append(GvNAME(gv), GvNAMELEN(gv)); |
55 |
0 |
55 |
|
| 90 |
110 |
▶ | return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
Branch: 9 branches
| Branch | True | False | Total |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
55 |
0 |
55 |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
55 |
0 |
55 |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
0 |
55 |
55 |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
55 |
0 |
55 |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
0 |
55 |
55 |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
0 |
55 |
55 |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
33 |
22 |
55 |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
0 |
33 |
33 |
| return newSVpvn_share(fqn.c_str(), (HvNAMEUTF8(stash) || GvNAMEUTF8(gv)) ? -(I32)fqnlen : (I32)fqnlen, 0); |
55 |
0 |
55 |
|
| 91 |
55 |
| } |
| 92 |
|
| |
| 93 |
2 |
| static FORCEINLINE void _throw_no_next_method (HV* selfstash, GV* context) { |
| 94 |
4 |
▶ | std::string subname(GvNAME(context), GvNAMELEN(context)); |
Branch: 1 branch
| Branch | True | False | Total |
| std::string subname(GvNAME(context), GvNAMELEN(context)); |
2 |
0 |
2 |
|
| 95 |
2 |
▶ | std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
Branch: 11 branches
| Branch | True | False | Total |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
2 |
0 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
2 |
0 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
2 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
2 |
0 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
2 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
2 |
0 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
2 |
0 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
2 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
2 |
0 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
2 |
2 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
2 |
0 |
2 |
|
| 96 |
6 |
▶ | throw std::logic_error(std::string("No next::method '") + subname + "' found for " + stashname); |
Branch: 5 branches
| Branch | True | False | Total |
| throw std::logic_error(std::string("No next::method '") + subname + "' found for " + stashname); |
2 |
0 |
2 |
| throw std::logic_error(std::string("No next::method '") + subname + "' found for " + stashname); |
2 |
0 |
2 |
| throw std::logic_error(std::string("No next::method '") + subname + "' found for " + stashname); |
2 |
0 |
2 |
| throw std::logic_error(std::string("No next::method '") + subname + "' found for " + stashname); |
2 |
0 |
2 |
| throw std::logic_error(std::string("No next::method '") + subname + "' found for " + stashname); |
2 |
0 |
2 |
|
| 97 |
4 |
| } |
| 98 |
|
| |
| 99 |
139 |
| static FORCEINLINE CV* _method (HV* selfstash, GV* context, SV* fqnsv) { |
| 100 |
139 |
▶ | if (!fqnsv) { // cache FQN SV with shared COW hash of current sub in magic to perform hash lookup with precomputed hash |
Branch: 1 branch
| Branch | True | False | Total |
| if (!fqnsv) { // cache FQN SV with shared COW hash of current sub in magic to perform hash lookup with precomputed hash |
129 |
10 |
139 |
|
| 101 |
129 |
| HV* stash = GvSTASH(context); |
| 102 |
129 |
| MAGIC* mg = mg_findext((SV*)context, PERL_MAGIC_ext, &c3_marker); |
| 103 |
129 |
▶ | if (!mg || (HV*)mg->mg_ptr != stash) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!mg || (HV*)mg->mg_ptr != stash) { |
74 |
55 |
129 |
| if (!mg || (HV*)mg->mg_ptr != stash) { |
0 |
74 |
74 |
|
| 104 |
|
| dTHX; |
| 105 |
55 |
▶ | if (mg) sv_unmagicext((SV*)context, PERL_MAGIC_ext, &c3_marker); |
Branch: 1 branch
| Branch | True | False | Total |
| if (mg) sv_unmagicext((SV*)context, PERL_MAGIC_ext, &c3_marker); |
0 |
55 |
55 |
|
| 106 |
55 |
| bool had_magic = SvRMAGICAL(context); |
| 107 |
55 |
| fqnsv = _make_shared_fqn(aTHX_ context); |
| 108 |
55 |
| mg = sv_magicext((SV*)context, fqnsv, PERL_MAGIC_ext, &c3_marker, (const char*)stash, 0); |
| 109 |
55 |
| mg->mg_flags |= MGf_REFCOUNTED; |
| 110 |
55 |
▶ | if (!had_magic) SvRMAGICAL_off(context); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!had_magic) SvRMAGICAL_off(context); |
0 |
55 |
55 |
|
| 111 |
|
| } |
| 112 |
129 |
| fqnsv = mg->mg_obj; |
| 113 |
|
| } |
| 114 |
|
| |
| 115 |
|
| dTHX; |
| 116 |
139 |
▶ | struct mro_meta* selfmeta = HvMROMETA(selfstash); |
Branch: 1 branch
| Branch | True | False | Total |
| struct mro_meta* selfmeta = HvMROMETA(selfstash); |
138 |
1 |
139 |
|
| 117 |
139 |
| HV* nmcache = selfmeta->mro_nextmethod; |
| 118 |
139 |
▶ | if (nmcache) { // Use the cached coderef if it exists |
Branch: 1 branch
| Branch | True | False | Total |
| if (nmcache) { // Use the cached coderef if it exists |
119 |
20 |
139 |
|
| 119 |
119 |
| HE* he = hv_fetch_ent(nmcache, fqnsv, 0, 0); |
| 120 |
119 |
▶ | if (he) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (he) { |
80 |
39 |
119 |
|
| 121 |
80 |
| SV* const val = HeVAL(he); |
| 122 |
80 |
▶ | return val == &PL_sv_undef ? NULL : (CV*)val; |
Branch: 1 branch
| Branch | True | False | Total |
| return val == &PL_sv_undef ? NULL : (CV*)val; |
69 |
11 |
80 |
|
| 123 |
|
| } |
| 124 |
|
| } |
| 125 |
20 |
| else nmcache = selfmeta->mro_nextmethod = newHV(); //Initialize the next::method cache for this stash if necessary |
| 126 |
|
| |
| 127 |
|
| /* beyond here is just for cache misses, so perf isn't as critical */ |
| 128 |
59 |
| HV* stash = GvSTASH(context); |
| 129 |
59 |
| char* subname = GvNAME(context); |
| 130 |
59 |
| STRLEN subname_len = GvNAMELEN(context); |
| 131 |
59 |
| bool subname_utf8 = GvNAMEUTF8(context); |
| 132 |
59 |
▶ | char* stashname = HvNAME(stash); |
Branch: 5 branches
| Branch | True | False | Total |
| char* stashname = HvNAME(stash); |
59 |
0 |
59 |
| char* stashname = HvNAME(stash); |
59 |
0 |
59 |
| char* stashname = HvNAME(stash); |
0 |
59 |
59 |
| char* stashname = HvNAME(stash); |
59 |
0 |
59 |
| char* stashname = HvNAME(stash); |
0 |
59 |
59 |
|
| 133 |
59 |
▶ | STRLEN stashname_len = HvNAMELEN(stash); |
Branch: 5 branches
| Branch | True | False | Total |
| STRLEN stashname_len = HvNAMELEN(stash); |
59 |
0 |
59 |
| STRLEN stashname_len = HvNAMELEN(stash); |
59 |
0 |
59 |
| STRLEN stashname_len = HvNAMELEN(stash); |
0 |
59 |
59 |
| STRLEN stashname_len = HvNAMELEN(stash); |
59 |
0 |
59 |
| STRLEN stashname_len = HvNAMELEN(stash); |
0 |
59 |
59 |
|
| 134 |
|
| |
| 135 |
|
| /* has ourselves at the top of the list */ |
| 136 |
59 |
| const mro_alg*const algo = Perl_mro_get_from_name(aTHX_ sv_2mortal(newSVpvs("c3"))); |
| 137 |
59 |
| AV* linear_av = algo->resolve(aTHX_ selfstash, 0); |
| 138 |
59 |
| SV** linear_svp = AvARRAY(linear_av); |
| 139 |
59 |
| I32 entries = AvFILLp(linear_av) + 1; |
| 140 |
|
| |
| 141 |
|
| /* Walk down our MRO, skipping everything up to the contextually enclosing class */ |
| 142 |
90 |
▶ | while (entries--) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (entries--) { |
89 |
1 |
90 |
|
| 143 |
89 |
| SV*const linear_sv = *linear_svp++; |
| 144 |
|
| assert(linear_sv); |
| 145 |
89 |
▶ | if (SvCUR(linear_sv) == stashname_len && !memcmp(SvPVX(linear_sv), stashname, stashname_len)) break; |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvCUR(linear_sv) == stashname_len && !memcmp(SvPVX(linear_sv), stashname, stashname_len)) break; |
86 |
3 |
89 |
| if (SvCUR(linear_sv) == stashname_len && !memcmp(SvPVX(linear_sv), stashname, stashname_len)) break; |
58 |
28 |
86 |
|
| 146 |
|
| } |
| 147 |
|
| |
| 148 |
|
| /* Now search the remainder of the MRO for the same method name as the contextually enclosing method */ |
| 149 |
59 |
▶ | if (entries > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (entries > 0) { |
57 |
2 |
59 |
|
| 150 |
94 |
▶ | while (entries--) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (entries--) { |
86 |
8 |
94 |
|
| 151 |
86 |
| SV*const linear_sv = *linear_svp++; |
| 152 |
|
| assert(linear_sv); |
| 153 |
86 |
| HV* curstash = gv_stashsv(linear_sv, 0); |
| 154 |
|
| |
| 155 |
86 |
▶ | if (!curstash) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!curstash) { |
0 |
86 |
86 |
|
| 156 |
0 |
▶ | if (ckWARN(WARN_SYNTAX)) Perl_warner(aTHX_ |
Branch: 1 branch
| Branch | True | False | Total |
| if (ckWARN(WARN_SYNTAX)) Perl_warner(aTHX_ |
0 |
0 |
0 |
|
| 157 |
|
| packWARN(WARN_SYNTAX), "Can't locate package %" SVf " for @%" HEKf "::ISA", |
| 158 |
0 |
▶ | (void*)linear_sv, HEKfARG( HvNAME_HEK(selfstash) ) |
Branch: 3 branches
| Branch | True | False | Total |
| (void*)linear_sv, HEKfARG( HvNAME_HEK(selfstash) ) |
0 |
0 |
0 |
| (void*)linear_sv, HEKfARG( HvNAME_HEK(selfstash) ) |
0 |
0 |
0 |
| (void*)linear_sv, HEKfARG( HvNAME_HEK(selfstash) ) |
0 |
0 |
0 |
|
| 159 |
|
| ); |
| 160 |
0 |
| continue; |
| 161 |
|
| } |
| 162 |
|
| |
| 163 |
86 |
▶ | GV** gvp = (GV**)hv_fetch(curstash, subname, subname_utf8 ? -(I32)subname_len : (I32)subname_len, 0); |
Branch: 1 branch
| Branch | True | False | Total |
| GV** gvp = (GV**)hv_fetch(curstash, subname, subname_utf8 ? -(I32)subname_len : (I32)subname_len, 0); |
29 |
57 |
86 |
|
| 164 |
86 |
▶ | if (!gvp) continue; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!gvp) continue; |
37 |
49 |
86 |
|
| 165 |
|
| |
| 166 |
49 |
| GV* candidate = *gvp; |
| 167 |
|
| assert(candidate); |
| 168 |
|
| |
| 169 |
49 |
▶ | if (SvTYPE(candidate) != SVt_PVGV) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTYPE(candidate) != SVt_PVGV) |
0 |
49 |
49 |
|
| 170 |
0 |
▶ | gv_init_pvn(candidate, curstash, subname, subname_len, GV_ADDMULTI|(subname_utf8 ? SVf_UTF8 : 0)); |
Branch: 1 branch
| Branch | True | False | Total |
| gv_init_pvn(candidate, curstash, subname, subname_len, GV_ADDMULTI|(subname_utf8 ? SVf_UTF8 : 0)); |
0 |
0 |
0 |
|
| 171 |
|
| |
| 172 |
|
| /* Notably, we only look for real entries, not method cache |
| 173 |
|
| entries, because in C3 the method cache of a parent is not |
| 174 |
|
| valid for the child */ |
| 175 |
|
| CV* cand_cv; |
| 176 |
49 |
▶ | if (SvTYPE(candidate) == SVt_PVGV && (cand_cv = GvCV(candidate)) && !GvCVGEN(candidate)) { |
Branch: 4 branches
| Branch | True | False | Total |
| if (SvTYPE(candidate) == SVt_PVGV && (cand_cv = GvCV(candidate)) && !GvCVGEN(candidate)) { |
49 |
0 |
49 |
| if (SvTYPE(candidate) == SVt_PVGV && (cand_cv = GvCV(candidate)) && !GvCVGEN(candidate)) { |
49 |
0 |
49 |
| if (SvTYPE(candidate) == SVt_PVGV && (cand_cv = GvCV(candidate)) && !GvCVGEN(candidate)) { |
49 |
0 |
49 |
| if (SvTYPE(candidate) == SVt_PVGV && (cand_cv = GvCV(candidate)) && !GvCVGEN(candidate)) { |
49 |
0 |
49 |
|
| 177 |
49 |
| SvREFCNT_inc_simple_void_NN(MUTABLE_SV(cand_cv)); |
| 178 |
49 |
| hv_store_ent(nmcache, fqnsv, MUTABLE_SV(cand_cv), 0); |
| 179 |
49 |
| return cand_cv; |
| 180 |
|
| } |
| 181 |
|
| } |
| 182 |
|
| } |
| 183 |
|
| |
| 184 |
10 |
| hv_store_ent(nmcache, fqnsv, &PL_sv_undef, 0); |
| 185 |
10 |
| return NULL; |
| 186 |
|
| } |
| 187 |
|
| |
| 188 |
15 |
| CV* next::method (HV* selfstash) { |
| 189 |
15 |
| SV* fqn = NULL; |
| 190 |
15 |
▶ | GV* context = _find_sub(&fqn); |
Branch: 1 branch
| Branch | True | False | Total |
| GV* context = _find_sub(&fqn); |
15 |
0 |
15 |
|
| 191 |
30 |
▶ | return _method(selfstash, context, fqn); |
Branch: 1 branch
| Branch | True | False | Total |
| return _method(selfstash, context, fqn); |
15 |
0 |
15 |
|
| 192 |
|
| } |
| 193 |
|
| |
| 194 |
41 |
| CV* next::method_strict (HV* selfstash) { |
| 195 |
41 |
| SV* fqn = NULL; |
| 196 |
41 |
▶ | GV* context = _find_sub(&fqn); |
Branch: 1 branch
| Branch | True | False | Total |
| GV* context = _find_sub(&fqn); |
40 |
1 |
41 |
|
| 197 |
40 |
▶ | CV* ret = _method(selfstash, context, fqn); |
Branch: 1 branch
| Branch | True | False | Total |
| CV* ret = _method(selfstash, context, fqn); |
40 |
0 |
40 |
|
| 198 |
40 |
▶ | if (!ret) _throw_no_next_method(selfstash, context); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!ret) _throw_no_next_method(selfstash, context); |
2 |
38 |
40 |
| if (!ret) _throw_no_next_method(selfstash, context); |
0 |
2 |
2 |
|
| 199 |
38 |
| return ret; |
| 200 |
|
| } |
| 201 |
|
| |
| 202 |
0 |
| CV* next::method (HV* selfstash, GV* context) { return _method(selfstash, context, NULL); } |
| 203 |
|
| |
| 204 |
0 |
| CV* next::method_strict (HV* selfstash, GV* context) { |
| 205 |
0 |
| CV* ret = _method(selfstash, context, NULL); |
| 206 |
0 |
▶ | if (!ret) _throw_no_next_method(selfstash, context); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!ret) _throw_no_next_method(selfstash, context); |
0 |
0 |
0 |
|
| 207 |
0 |
| return ret; |
| 208 |
|
| } |
| 209 |
|
| |
| 210 |
312 |
| static FORCEINLINE CV* _super_method (HV* selfstash, GV* context) { |
| 211 |
|
| //omit comparing strings for speed |
| 212 |
|
| dTHX; |
| 213 |
312 |
▶ | if (HvMROMETA(selfstash)->mro_which->length != 3) return _method(selfstash, context, NULL); // C3 |
Branch: 2 branches
| Branch | True | False | Total |
| if (HvMROMETA(selfstash)->mro_which->length != 3) return _method(selfstash, context, NULL); // C3 |
312 |
0 |
312 |
| if (HvMROMETA(selfstash)->mro_which->length != 3) return _method(selfstash, context, NULL); // C3 |
84 |
228 |
312 |
|
| 214 |
|
| // DFS |
| 215 |
228 |
| HV* stash = GvSTASH(context); |
| 216 |
228 |
| HEK* hek = GvNAME_HEK(context); |
| 217 |
228 |
▶ | HV* cache = HvSUPERCACHE(stash); |
Branch: 1 branch
| Branch | True | False | Total |
| HV* cache = HvSUPERCACHE(stash); |
228 |
0 |
228 |
|
| 218 |
228 |
▶ | if (cache) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cache) { |
224 |
4 |
228 |
|
| 219 |
224 |
| const HE* const he = (HE*)hv_common(cache, NULL, HEK_KEY(hek), HEK_LEN(hek), HEK_UTF8(hek), 0, NULL, HEK_HASH(hek)); |
| 220 |
224 |
▶ | if (he) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (he) { |
218 |
6 |
224 |
|
| 221 |
218 |
| GV* gv = MUTABLE_GV(HeVAL(he)); |
| 222 |
218 |
▶ | if (isGV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) return GvCV(gv); |
Branch: 5 branches
| Branch | True | False | Total |
| if (isGV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) return GvCV(gv); |
218 |
0 |
218 |
| if (isGV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) return GvCV(gv); |
218 |
0 |
218 |
| if (isGV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) return GvCV(gv); |
218 |
0 |
218 |
| if (isGV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) return GvCV(gv); |
218 |
0 |
218 |
| if (isGV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) return GvCV(gv); |
218 |
0 |
218 |
|
| 223 |
|
| } |
| 224 |
|
| } |
| 225 |
10 |
| GV* ret = gv_fetchmethod_pvn_flags(stash, HEK_KEY(hek), HEK_LEN(hek), GV_AUTOLOAD|GV_SUPER); |
| 226 |
10 |
▶ | return ret ? (isGV(ret) ? GvCV(ret) : (CV*)ret) : NULL; |
Branch: 2 branches
| Branch | True | False | Total |
| return ret ? (isGV(ret) ? GvCV(ret) : (CV*)ret) : NULL; |
9 |
1 |
10 |
| return ret ? (isGV(ret) ? GvCV(ret) : (CV*)ret) : NULL; |
9 |
0 |
9 |
|
| 227 |
|
| } |
| 228 |
|
| |
| 229 |
180 |
| CV* super::method (HV* selfstash, GV* context) { return _super_method(selfstash, context); } |
| 230 |
|
| |
| 231 |
132 |
| CV* super::method_strict (HV* selfstash, GV* context) { |
| 232 |
132 |
| CV* ret = _super_method(selfstash, context); |
| 233 |
132 |
▶ | if (!ret) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!ret) { |
0 |
132 |
132 |
|
| 234 |
0 |
▶ | std::string subname(GvNAME(context), GvNAMELEN(context)); |
Branch: 1 branch
| Branch | True | False | Total |
| std::string subname(GvNAME(context), GvNAMELEN(context)); |
0 |
0 |
0 |
|
| 235 |
0 |
▶ | std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
Branch: 11 branches
| Branch | True | False | Total |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
| std::string stashname(HvNAME(selfstash), HvNAMELEN(selfstash)); |
0 |
0 |
0 |
|
| 236 |
0 |
▶ | throw std::logic_error(std::string("No super::") + subname + " found for " + stashname); |
Branch: 5 branches
| Branch | True | False | Total |
| throw std::logic_error(std::string("No super::") + subname + " found for " + stashname); |
0 |
0 |
0 |
| throw std::logic_error(std::string("No super::") + subname + " found for " + stashname); |
0 |
0 |
0 |
| throw std::logic_error(std::string("No super::") + subname + " found for " + stashname); |
0 |
0 |
0 |
| throw std::logic_error(std::string("No super::") + subname + " found for " + stashname); |
0 |
0 |
0 |
| throw std::logic_error(std::string("No super::") + subname + " found for " + stashname); |
0 |
0 |
0 |
|
| 237 |
|
| } |
| 238 |
132 |
| return ret; |
| 239 |
|
| } |
| 240 |
|
| |
| 241 |
|
| } |