xs/accessors.h

filter: Statementstmt 85.2% 259 / 304 Branchbran 62.3% 106 / 170 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 77.0% 365 / 474 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/installer.h ↑ Summary xs/util.h »
1 #ifndef __INHERITED_XS_IMPL_H_
2 #define __INHERITED_XS_IMPL_H_
3  
4 #include "fimpl.h"
5 #include "util.h"
6 #include "op.h"
7  
8 /*
9 These macroses impose the following rules:
10 - SP is at the start of the args list
11 - SP may become invalid afterwards, so don't touch it
12 - PL_stack_sp is updated when needed
13  
14 The latter may be not that obvious, but it's a result of a callback doing
15 dirty stack work for us. Note that only essential cleanup is done
16 after call_sv().
17 */
18  
19 #define TYPE_INHERITED (type == InheritedCb || type == InheritedCbNamed)
20  
21 #define PUSH_PAYLOAD_KEY \
22 /* METHOD_NAMED path won't give us a free SP slot */ \
23 EXTEND(SP, items + 1); \
24 *(SP += items + 1) = payload->hash_key; \
25 PUTBACK; \
26 /*
27 re-enable when messing with stack for tests
28 assert(PL_curstackinfo->si_stack_hwm >= PL_stack_sp - PL_stack_base);
29 */ \
30  
31  
32 #define CALL_READ_CB(result) \
33 if (TYPE_INHERITED && payload->read_cb) { \
34 ENTER; \
35 PUSHMARK(SP); \
36 *(SP+1) = sv_2mortal(newSVsv(result)); \
37 if (type == InheritedCbNamed) { \
38 PUSH_PAYLOAD_KEY; \
39 } \
40 call_sv(payload->read_cb, G_SCALAR); \
41 LEAVE; \
42 } else { \
43 *(SP+1) = sv_2mortal(newSVsv(result)); \
44 } \
45  
46 #define CALL_WRITE_CB(slot, need_alloc) \
47 if (TYPE_INHERITED && payload->write_cb) { \
48 ENTER; \
49 PUSHMARK(SP); \
50 if (type == InheritedCbNamed) { \
51 PUSH_PAYLOAD_KEY; \
52 } \
53 call_sv(payload->write_cb, G_SCALAR); \
54 SPAGAIN; \
55 LEAVE; \
56 if (need_alloc) slot = newSV(0); \
57 sv_setsv(slot, *SP); \
58 *SP = slot; \
59 } else { \
60 if (need_alloc) slot = newSV(0); \
61 sv_setsv(slot, *(SP+2)); \
62 PUSHs(slot); \
63 PUTBACK; \
64 } \
65  
66 #define CALL_WRITE_WEAKEN(slot) \
67 if (opts & IsWeak) sv_rvweaken(slot)
68  
69 #define READONLY_TYPE_ASSERT \
70 assert(type == Inherited || type == PrivateClass || type == ObjectOnly || type == LazyClass)
71  
72 #define READONLY_CROAK_CHECK \
73 if (!TYPE_INHERITED && (opts & IsReadonly)) { \
74 READONLY_TYPE_ASSERT; \
75 croak("Can't set value in readonly accessor"); \
76 return; \
77 } \
78  
79 #define SET_GVGP_FLAGS(glob, sv)\
80 if (SvOK(sv)) { \
81 GvGPFLAGS_on(glob); \
82 \
83 } else { \
84 GvGPFLAGS_off(glob); \
85 GvLINE(glob) = 0; \
86 } \
87  
88 template <bool overflow> static
89 SV*
90 193 CAIXS_icache_get(pTHX_ HV* stash, GV* glob) {
91 193 ▶ const struct mro_meta* stash_meta = HvMROMETA(stash);
Branch: 2 branches
BranchTrueFalseTotal
const struct mro_meta* stash_meta = HvMROMETA(stash); 160 1 161
const struct mro_meta* stash_meta = HvMROMETA(stash); 31 1 32
92 193 const long long curgen = (long long)PL_sub_generation + stash_meta->pkg_gen;
93  
94 193 ▶ if (GvLINE(glob) == curgen || GvGPFLAGS(glob)) return GvSV(glob);
Branch: 4 branches
BranchTrueFalseTotal
if (GvLINE(glob) == curgen || GvGPFLAGS(glob)) return GvSV(glob); 91 70 161
if (GvLINE(glob) == curgen || GvGPFLAGS(glob)) return GvSV(glob); 70 21 91
if (GvLINE(glob) == curgen || GvGPFLAGS(glob)) return GvSV(glob); 32 0 32
if (GvLINE(glob) == curgen || GvGPFLAGS(glob)) return GvSV(glob); 5 27 32
95 21 ▶ if (overflow && UNLIKELY(curgen > ((U32)1 << 31) - 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (overflow && UNLIKELY(curgen > ((U32)1 << 31) - 1)) { 0 21 21
96 0 warn("MRO cache generation 31 bit wraparound");
97 0 PL_sub_generation = 0;
98 }
99  
100 48 return NULL;
101 }
102  
103 static SV*
104 21 CAIXS_icache_update(pTHX_ HV* stash, GV* glob, SV* pkg_key) {
105 21 AV* supers = mro_get_linear_isa(stash);
106 /*
107 First entry in the 'mro_get_linear_isa' list is the 'stash' itself.
108 It's already been tested, so ajust both counter and iterator to skip over it.
109 */
110 21 SSize_t fill = AvFILLp(supers);
111 21 SV** supers_list = AvARRAY(supers);
112  
113 SV* elem;
114 21 SV* result = NULL;
115  
116 21 GV* stack[fill + 1];
117 #ifdef DEBUGGING
118 memzero(stack, (fill + 1) * sizeof(GV*));
119 #endif
120 21 stack[fill] = glob;
121  
122 56 ▶ while (result == NULL && --fill >= 0) {
Branch: 3 branches
BranchTrueFalseTotal
while (result == NULL && --fill >= 0) { 51 5 56
while (result == NULL && --fill >= 0) { 35 16 51
while (result == NULL && --fill >= 0) { 35 21 56
123 35 elem = *(++supers_list);
124 assert(elem); /* mro_get_linear_isa returns dense array */
125  
126 35 HV* next_stash = gv_stashsv(elem, 0);
127 /*
128 Skip entries for empty stashes to save some memory.
129 This may result in gaps in the 'stack' array, but we don't care.
130 */
131 35 ▶ if (LIKELY(next_stash != NULL)) {
Branch: 1 branch
BranchTrueFalseTotal
if (LIKELY(next_stash != NULL)) { 32 3 35
132 32 GV* next_gv = CAIXS_fetch_glob(aTHX_ next_stash, pkg_key);
133 32 stack[fill] = next_gv;
134  
135 32 result = CAIXS_icache_get<false>(aTHX_ next_stash, next_gv);
136 }
137 }
138  
139 21 ▶ if (UNLIKELY(result == NULL)) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNLIKELY(result == NULL)) { 16 5 21
140 assert(fill == -1);
141  
142 /* Since we don't force stash creation in the above loop, do it here */
143 16 HV* root_stash = gv_stashsv(*supers_list, GV_ADD);
144 16 stack[0] = CAIXS_fetch_glob(aTHX_ root_stash, pkg_key);
145  
146 assert(stack[0]);
147 16 ▶ result = GvSVn(stack[0]); /* undef from root */
Branch: 1 branch
BranchTrueFalseTotal
result = GvSVn(stack[0]); /* undef from root */ 2 14 16
148 16 GvGPFLAGS_on(stack[0]); /* yeah, valid 'undef', to speed up lookups later */
149 }
150  
151 21 GV* cur_gv = stack[AvFILLp(supers)];
152 assert(cur_gv && cur_gv == glob);
153  
154 21 ▶ const struct mro_meta* stash_meta = HvMROMETA(GvSTASH(cur_gv));
Branch: 1 branch
BranchTrueFalseTotal
const struct mro_meta* stash_meta = HvMROMETA(GvSTASH(cur_gv)); 21 0 21
155 21 const U32 curgen = PL_sub_generation + stash_meta->pkg_gen;
156 21 GvLINE(cur_gv) = curgen & (((U32)1 << 31) - 1); /* perl may lack 'gp_flags' field, so we must care about the highest bit */
157  
158 /* copy-by-reference */
159 21 SV** sv_slot = &GvSV(cur_gv);
160  
161 21 SvREFCNT_inc_simple_void_NN(result);
162 21 SvREFCNT_dec(*sv_slot);
163 21 *sv_slot = result;
164  
165 21 return result;
166 21 }
167  
168 static void
169 47 CAIXS_icache_clear(pTHX_ HV* stash, SV* pkg_key, SV* base_sv) {
170 47 ▶ SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash));
Branch: 25 branches
BranchTrueFalseTotal
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 0 47 47
SV** svp = hv_fetchhek(PL_isarev, HvENAME_HEK(stash)); 47 0 47
171 47 ▶ if (svp) {
Branch: 1 branch
BranchTrueFalseTotal
if (svp) { 3 44 47
172 3 HV* isarev = (HV*)*svp;
173  
174 3 ▶ if (HvUSEDKEYS(isarev)) {
Branch: 2 branches
BranchTrueFalseTotal
if (HvUSEDKEYS(isarev)) { 0 3 3
if (HvUSEDKEYS(isarev)) { 3 0 3
175 3 STRLEN hvmax = HvMAX(isarev);
176 3 HE** hvarr = HvARRAY(isarev);
177  
178 3 SV* pl_yes = &PL_sv_yes; /* not that I care much about ithreads, but still */
179 27 ▶ for (STRLEN bucket_num = 0; bucket_num <= hvmax; ++bucket_num) {
Branch: 1 branch
BranchTrueFalseTotal
for (STRLEN bucket_num = 0; bucket_num <= hvmax; ++bucket_num) { 24 3 27
180 28 ▶ for (const HE* he = hvarr[bucket_num]; he; he = HeNEXT(he)) {
Branch: 1 branch
BranchTrueFalseTotal
for (const HE* he = hvarr[bucket_num]; he; he = HeNEXT(he)) { 4 24 28
181 assert(HeVAL(he) == &PL_sv_placeholder || HeVAL(he) == &PL_sv_yes);
182  
183 4 ▶ if (HeVAL(he) == pl_yes) { /* mro_core.c stores only them */
Branch: 1 branch
BranchTrueFalseTotal
if (HeVAL(he) == pl_yes) { /* mro_core.c stores only them */ 4 0 4
184 /* access PL_stashcache through HEK interface directly here? */
185 4 HEK* hkey = HeKEY_hek(he);
186 4 HV* revstash = gv_stashpvn(HEK_KEY(hkey), HEK_LEN(hkey), HEK_UTF8(hkey) | GV_ADD);
187 4 GV* revglob = CAIXS_fetch_glob(aTHX_ revstash, pkg_key);
188  
189 4 ▶ if (base_sv == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (base_sv == NULL) { 4 0 4
190 /* invalidates all non-root nodes */
191 4 ▶ if (!GvGPFLAGS(revglob)) GvLINE(revglob) = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!GvGPFLAGS(revglob)) GvLINE(revglob) = 0; 4 0 4
192  
193 } else {
194 /* since all the cache elements point to the same sv, invalidate only it's copies */
195 0 ▶ if (GvSV(revglob) == base_sv) {
Branch: 1 branch
BranchTrueFalseTotal
if (GvSV(revglob) == base_sv) { 0 0 0
196 assert(!GvGPFLAGS(revglob));
197 0 GvLINE(revglob) = 0;
198 }
199 }
200 }
201 }
202 }
203 }
204 }
205 47 }
206  
207 template <AccessorOpts opts>
208 struct FImpl<Constructor, opts> {
209 25 static void CAIXS_accessor(pTHX_ SV** SP, CV* cv, HV* stash) {
210 25 dAXMARK; dITEMS;
211  
212 25 CAIXS_install_entersub<Constructor, opts>(aTHX);
213 25 ▶ if (UNLIKELY(!items)) croak("Usage: $obj->constructor or __PACKAGE__->constructor");
Branch: 1 branch
BranchTrueFalseTotal
if (UNLIKELY(!items)) croak("Usage: $obj->constructor or __PACKAGE__->constructor"); 1 24 25
214  
215 24 PL_stack_sp = ++MARK; /* PUTBACK */
216  
217 24 ▶ if (!stash) stash = CAIXS_find_stash(aTHX_ *MARK, cv);
Branch: 1 branch
BranchTrueFalseTotal
if (!stash) stash = CAIXS_find_stash(aTHX_ *MARK, cv); 18 6 24
218 24 SV** ret = MARK++;
219  
220 SV* self;
221 24 ▶ if (items == 2 && SvROK(*MARK) && SvTYPE(SvRV(*MARK)) == SVt_PVHV) {
Branch: 3 branches
BranchTrueFalseTotal
if (items == 2 && SvROK(*MARK) && SvTYPE(SvRV(*MARK)) == SVt_PVHV) { 10 14 24
if (items == 2 && SvROK(*MARK) && SvTYPE(SvRV(*MARK)) == SVt_PVHV) { 8 2 10
if (items == 2 && SvROK(*MARK) && SvTYPE(SvRV(*MARK)) == SVt_PVHV) { 7 1 8
222 7 self = *MARK;
223  
224 17 ▶ } else if (items == 2 && !SvOK(*MARK)) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (items == 2 && !SvOK(*MARK)) { 3 14 17
} else if (items == 2 && !SvOK(*MARK)) { 1 2 3
225 1 self = sv_2mortal(newRV_noinc((SV*)newHV()));
226  
227 16 ▶ } else if ((items & 1) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
} else if ((items & 1) == 0) { 3 13 16
228 3 croak("Odd number of elements in hash constructor");
229  
230 } else {
231 13 HV* hash = newHV();
232  
233 30 ▶ while (MARK < SP) {
Branch: 1 branch
BranchTrueFalseTotal
while (MARK < SP) { 17 13 30
234 17 SV* key = *MARK++;
235 /* Don't bother with retval here, as in pp_anonhash */
236 17 hv_store_ent(hash, key, newSVsv(*MARK++), 0);
237 }
238  
239 13 self = sv_2mortal(newRV_noinc((SV*)hash));
240 }
241  
242 21 sv_bless(self, stash);
243 21 *ret = self;
244 21 return;
245 }};
246  
247 template <AccessorOpts opts>
248 struct FImpl<LazyClass, opts> {
249 0 static void CAIXS_accessor(pTHX_ SV** SP, CV* cv, HV* stash) {
250 0 dAXMARK; dITEMS;
251  
252 0 ▶ if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor");
Branch: 4 branches
BranchTrueFalseTotal
if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor"); 0 1 1
if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor"); 0 0 0
if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor"); 0 206 206
if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor"); 0 4 4
253 0 shared_keys* payload = CAIXS_find_payload(cv);
254  
255 0 ▶ if (items > 1) {
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1) { 0 1 1
if (items > 1) { 0 0 0
if (items > 1) { 2 204 206
if (items > 1) { 1 3 4
256 0 const int type = LazyClass; /* for READONLY_CROAK_CHECK */
257 0 READONLY_CROAK_CHECK;
258  
259 0 ▶ PUSHMARK(SP - items); /* our dAXMARK has popped one */
Branch: 2 branches
BranchTrueFalseTotal
PUSHMARK(SP - items); /* our dAXMARK has popped one */ 0 0 0
PUSHMARK(SP - items); /* our dAXMARK has popped one */ 0 2 2
260 0 FImpl<PrivateClass, opts>::CAIXS_accessor(aTHX_ SP, cv, stash);
261  
262 } else {
263 0 ENTER;
264 0 if (opts & IsWeak) SAVETMPS;
265 0 ▶ PUSHMARK(--SP); /* SP -= items */
Branch: 4 branches
BranchTrueFalseTotal
PUSHMARK(--SP); /* SP -= items */ 0 1 1
PUSHMARK(--SP); /* SP -= items */ 0 0 0
PUSHMARK(--SP); /* SP -= items */ 0 204 204
PUSHMARK(--SP); /* SP -= items */ 0 3 3
266 0 call_sv(payload->lazy_cb, G_SCALAR);
267 0 SPAGAIN;
268  
269 0 sv_setsv(payload->storage, *SP);
270 0 *SP = payload->storage;
271  
272 if (opts & IsWeak) {
273 0 CALL_WRITE_WEAKEN(payload->storage);
274 0 ▶ FREETMPS; /* that's done to immediately free stored value if it's only hard reference had been held on the stack */
Branch: 2 branches
BranchTrueFalseTotal
FREETMPS; /* that's done to immediately free stored value if it's only hard reference had been held on the stack */ 1 0 1
FREETMPS; /* that's done to immediately free stored value if it's only hard reference had been held on the stack */ 0 0 0
275 }
276  
277 0 LEAVE;
278 }
279  
280 /* Lazy getter may call setter, and so we'd end up here twice, but SvREFCNT_dec is required only once */
281 0 ▶ if (payload->lazy_cb) {
Branch: 4 branches
BranchTrueFalseTotal
if (payload->lazy_cb) { 1 0 1
if (payload->lazy_cb) { 0 0 0
if (payload->lazy_cb) { 205 1 206
if (payload->lazy_cb) { 3 0 3
282 0 CvXSUB(cv) = (XSUBADDR_t)&CAIXS_entersub_wrapper<PrivateClass, opts>;
283 0 SvREFCNT_dec_NN(payload->lazy_cb);
284 0 payload->lazy_cb = NULL;
285 }
286  
287 0 return;
288 }};
289  
290 template <AccessorOpts opts>
291 struct FImpl<PrivateClass, opts> {
292 0 static void CAIXS_accessor(pTHX_ SV** SP, CV* cv, HV* stash) {
293 0 dAXMARK; dITEMS;
294 0 SP -= items;
295  
296 0 ▶ if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor");
Branch: 4 branches
BranchTrueFalseTotal
if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor"); 0 5 5
if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor"); 0 0 0
if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor"); 1 57 58
if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor"); 0 27 27
297  
298 0 CAIXS_install_entersub<PrivateClass, opts>(aTHX);
299 0 shared_keys* payload = CAIXS_find_payload(cv);
300  
301 0 const int type = PrivateClass; /* for CALL_*_CB */
302  
303 0 ▶ if (items == 1) {
Branch: 4 branches
BranchTrueFalseTotal
if (items == 1) { 3 2 5
if (items == 1) { 0 0 0
if (items == 1) { 37 20 57
if (items == 1) { 19 8 27
304 0 CALL_READ_CB(payload->storage);
305 0 return;
306 }
307  
308 0 READONLY_CROAK_CHECK;
309 22 CALL_WRITE_CB(payload->storage, 0);
310 2 CALL_WRITE_WEAKEN(payload->storage);
311 22 return;
312 }};
313  
314 /* covers type = {Inherited, InheritedCb, InheritedCbNamed, ObjectOnly} */
315 template <AccessorType type, AccessorOpts opts>
316 struct FImpl {
317 486 static void CAIXS_accessor(pTHX_ SV** SP, CV* cv, HV* stash) {
318 486 dAXMARK; dITEMS;
319 486 SP -= items;
320  
321 486 if (UNLIKELY(!items)) croak("Usage: $obj->accessor or __PACKAGE__->accessor");
322  
323 485 CAIXS_install_entersub<type, opts>(aTHX);
324 485 shared_keys* payload = CAIXS_find_payload(cv);
325  
326 485 SV* self = *(SP+1);
327 485 if (SvROK(self)) {
328 278 HV* obj = (HV*)SvRV(self);
329 278 if (UNLIKELY(SvTYPE((SV*)obj) != SVt_PVHV)) {
330 4 croak("Inherited accessors work only with hash-based objects");
331 }
332  
333 274 if (items > 1) {
334 4 READONLY_CROAK_CHECK;
335  
336 SV* new_value;
337 91 CALL_WRITE_CB(new_value, 1);
338 70 if (UNLIKELY(!hv_store_ent(obj, payload->hash_key, new_value, 0))) {
339 0 SvREFCNT_dec_NN(new_value);
340 0 croak("Can't store new hash value");
341 }
342 3 CALL_WRITE_WEAKEN(new_value);
343 69 return;
344
345 } else {
346 179 HE* hent = hv_fetch_ent(obj, payload->hash_key, 0, 0);
347 179 if (hent) {
348 140 CALL_READ_CB(HeVAL(hent));
349 139 return;
350  
351 } else if (type == ObjectOnly) {
352 1 CALL_READ_CB(&PL_sv_undef);
353 1 return;
354 }
355 }
356 }
357  
358 if (type == ObjectOnly) {
359 1 croak("Can't use object accessor on non-object");
360 return; /* gcc detects unreachability even with bare croak(), but it won't hurt */
361 }
362  
363 /* Couldn't find value in the object, so initiate a package lookup. */
364  
365 244 if (!stash) stash = CAIXS_find_stash(aTHX_ self, cv);
366  
367 244 if (items > 1) {
368 0 READONLY_CROAK_CHECK;
369  
370 82 GV* glob = CAIXS_fetch_glob(aTHX_ stash, payload->pkg_key);
371 82 SV* new_value = GvSV(glob);
372  
373 82 if (!GvGPFLAGS(glob)) {
374 /*
375 When this is an already calculated cache point (new_value != NULL),
376 wipe will be performed only to the 'new_value' copies. Otherwise,
377 erase the whole cache.
378 */
379 47 CAIXS_icache_clear(aTHX_ stash, payload->pkg_key, new_value);
380 47 SvREFCNT_dec(new_value);
381  
382 47 GvSV(glob) = newSV(0);
383 47 new_value = GvSV(glob);
384  
385 } else {
386 assert(new_value);
387 }
388  
389 82 CALL_WRITE_CB(new_value, 0);
390 58 SET_GVGP_FLAGS(glob, new_value);
391 1 CALL_WRITE_WEAKEN(new_value);
392  
393 58 return;
394 }
395  
396 162 GV* glob = CAIXS_fetch_glob(aTHX_ stash, payload->pkg_key);
397 161 SV* result = CAIXS_icache_get<true>(aTHX_ stash, glob);
398  
399 /* lazy cache builder */
400 161 if (!result) result = CAIXS_icache_update(aTHX_ stash, glob, payload->pkg_key);
401  
402 161 CALL_READ_CB(result);
403 117 return;
404 }};
405  
406 #endif /* __INHERITED_XS_IMPL_H_ */
« xs/installer.h ↑ Summary xs/util.h »