include/store/store_core.h

filter: Statementstmt 92.5% 148 / 160 Branchbran 82.6% 114 / 138 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 87.9% 262 / 298 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/store/store_history.h ↑ Summary include/store/store_hamt.h »
1 #ifndef STORE_CORE_H
2 #define STORE_CORE_H
3  
4 /* The cell: one value, and the one place it changes.
5 *
6 * ---- the handle --------------------------------------------------------
7 *
8 * A store is a blessed reference to a scalar that carries the C struct in
9 * ext magic, marked by the address of a vtable in this file: HAMT's handle,
10 * for HAMT's reasons. Magic cannot be forged from Perl or carried through a
11 * serialiser, so an object without it is simply not a store and every method
12 * says so; the struct is released when the scalar is freed, so there is no
13 * DESTROY to call twice or to shadow in a subclass; and a new thread does
14 * not get the handle, by CLONE_SKIP and, failing that, by a dup hook that
15 * empties the clone's magic. */
16  
17 /* Not during global destruction: by then perl is freeing every scalar in an
18 * order of its own, and one this store still holds may already be gone. */
19 282273 static void store_sv_release(pTHX_ SV *sv) {
20 282273 ▶ if (sv && !PL_dirty) SvREFCNT_dec(sv);
Branch: 2 branches
BranchTrueFalseTotal
if (sv && !PL_dirty) SvREFCNT_dec(sv); 277807 4466 282273
if (sv && !PL_dirty) SvREFCNT_dec(sv); 277807 0 277807
21 282273 }
22  
23 typedef struct store {
24 SV *value; /* the current value: owned, read-only, never NULL */
25 hamt_vec *past; /* the values before it, oldest first: never NULL */
26 hamt_vec *future; /* the values undone, the next one to redo last */
27 size_t limit; /* the most steps `past` keeps, when `limited` */
28 size_t past_skip; /* its oldest steps, beyond the limit, not yet cut */
29 int limited;
30  
31 /* Phase 05: the watchers, in the order they were added, and the changes
32 * waiting to be told to them. A watcher removed during a round is left
33 * in place with no code and swept out when the round is over. */
34 struct store_watcher *watchers;
35 size_t nwatchers, cwatchers, live_watchers;
36 UV next_id;
37 struct store_change *queue;
38 size_t qhead, qlen, qcap;
39 int delivering;
40  
41 /* Phase 06: the sub a new value must satisfy, or NULL; and whether it
42 * is running, when nothing may change the store. */
43 SV *validator;
44 state_store_validate_fn cvalidator; /* or one from the C ABI */
45 void *cvalidator_ud;
46 int validating;
47  
48 /* Phase 07: how many transactions are open. Inside one, a change records
49 * no step and is told to nobody: the transaction does both, once, when
50 * the outermost one ends. */
51 int txn_depth;
52  
53 /* Phase 08: named values, or NULL until the first is named. */
54 hamt_map *checkpoints;
55 } store;
56  
57 /* A croak for what cannot be done inside a transaction. */
58 65036 static void store_check_no_txn(pTHX_ const store *s, const char *what) {
59 65036 ▶ if (s->txn_depth) croak("%s: not inside a transaction", what);
Branch: 1 branch
BranchTrueFalseTotal
if (s->txn_depth) croak("%s: not inside a transaction", what); 5 65031 65036
60 65031 }
61  
62 /* A validator from Perl: a code reference, or undef for none. The CV, not
63 * the reference to it. */
64 255 static SV *store_validator_arg(pTHX_ SV *sv, const char *what) {
65 255 SvGETMAGIC(sv);
66 255 ▶ if (!SvOK(sv)) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (!SvOK(sv)) return NULL; 6 249 255
67 249 ▶ if (!SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVCV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVCV) 245 4 249
if (!SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVCV) 4 241 245
68 8 croak("%s: the validator is not a code reference", what);
69 241 return SvRV(sv);
70 }
71  
72 /* A croak for anything that would change the store while its validator is
73 * deciding whether a change may be made. */
74 396630 static void store_check_mutable(pTHX_ const store *s, const char *what) {
75 396630 ▶ if (s->validating) croak("%s: the validator may not change the store", what);
Branch: 1 branch
BranchTrueFalseTotal
if (s->validating) croak("%s: the validator may not change the store", what); 12 396618 396630
76 396618 }
77  
78 /* Ask the validator - a Perl sub, or a C function and its data - whether
79 * `candidate` may replace `old` in the store `storerv` refers to, or in no
80 * store yet when it is undef. 1 yes, 0 no; a Perl validator that dies goes
81 * on up as it is. `flag`, when given, is set for as long as the validator
82 * runs and put back however it ends. */
83 974 static int store_validate(pTHX_ SV *validator, state_store_validate_fn cfn, void *cud,
84 SV *candidate, SV *old, SV *storerv, int *flag) {
85 974 SV *args[3], *result, *err = NULL;
86 int ok;
87  
88 974 args[0] = candidate;
89 974 args[1] = old;
90 974 args[2] = storerv;
91 974 ENTER;
92 974 SAVETMPS;
93 974 ▶ if (flag) { SAVEINT(*flag); *flag = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if (flag) { SAVEINT(*flag); *flag = 1; } 348 626 974
94 974 ▶ if (cfn) {
Branch: 1 branch
BranchTrueFalseTotal
if (cfn) { 306 668 974
95 306 ok = cfn(aTHX_ cud, candidate, old, storerv) ? 1 : 0;
96 }
97 else {
98 668 err = store_call(aTHX_ validator, args, 3, G_SCALAR, &result, NULL);
99 668 ▶ ok = !err && SvTRUE(result);
Branch: 2 branches
BranchTrueFalseTotal
ok = !err && SvTRUE(result); 661 7 668
ok = !err && SvTRUE(result); 451 210 661
100 668 ▶ if (err) SvREFCNT_inc_simple_void_NN(err);
Branch: 1 branch
BranchTrueFalseTotal
if (err) SvREFCNT_inc_simple_void_NN(err); 7 661 668
101 }
102 974 ▶ FREETMPS;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; 668 306 974
103 974 LEAVE;
104 974 ▶ if (err) store_rethrow(aTHX_ sv_2mortal(err));
Branch: 1 branch
BranchTrueFalseTotal
if (err) store_rethrow(aTHX_ sv_2mortal(err)); 7 967 974
105 967 return ok;
106 }
107  
108 /* A watcher is a Perl sub or, from the C ABI, a function and its data.
109 * One removed has neither. */
110 typedef struct store_watcher {
111 UV id;
112 SV *code;
113 state_store_watch_fn cfn;
114 void *ud;
115 } store_watcher;
116 typedef struct store_change { SV *was; SV *now; } store_change;
117  
118 /* A change to be told to the watchers once the store has settled: both
119 * values held by the queue until it has been. Nothing is queued when nobody
120 * is watching. */
121 251163 static void store_enqueue(pTHX_ store *s, SV *was, SV *now) {
122 251163 ▶ if (!s->live_watchers || s->txn_depth) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!s->live_watchers || s->txn_depth) return; 33677 217486 251163
if (!s->live_watchers || s->txn_depth) return; 171 33506 33677
123 33506 ▶ if (s->qhead + s->qlen == s->qcap) {
Branch: 1 branch
BranchTrueFalseTotal
if (s->qhead + s->qlen == s->qcap) { 187 33319 33506
124 187 ▶ if (s->qhead) {
Branch: 1 branch
BranchTrueFalseTotal
if (s->qhead) { 90 97 187
125 90 ▶ Move(s->queue + s->qhead, s->queue, s->qlen, store_change);
Branch: 1 branch
BranchTrueFalseTotal
Move(s->queue + s->qhead, s->queue, s->qlen, store_change); 0 90 90
126 90 s->qhead = 0;
127 }
128 else {
129 97 ▶ s->qcap = s->qcap ? s->qcap * 2 : 4;
Branch: 1 branch
BranchTrueFalseTotal
s->qcap = s->qcap ? s->qcap * 2 : 4; 12 85 97
130 97 ▶ Renew(s->queue, s->qcap, store_change);
Branch: 1 branch
BranchTrueFalseTotal
Renew(s->queue, s->qcap, store_change); 0 97 97
131 }
132 }
133 33506 s->queue[s->qhead + s->qlen].was = SvREFCNT_inc_simple_NN(was);
134 33506 s->queue[s->qhead + s->qlen].now = SvREFCNT_inc_simple_NN(now);
135 33506 s->qlen++;
136 }
137  
138 /* Everything the watchers held, given back: for a store being freed, and
139 * for a round abandoned. */
140 2 static void store_queue_clear(pTHX_ store *s) {
141 10002 ▶ while (s->qlen) {
Branch: 1 branch
BranchTrueFalseTotal
while (s->qlen) { 10000 2 10002
142 10000 store_change c = s->queue[s->qhead++];
143 10000 s->qlen--;
144 10000 store_sv_release(aTHX_ c.was);
145 10000 store_sv_release(aTHX_ c.now);
146 }
147 2 s->qhead = 0;
148 2 }
149  
150 /* `v` with only its last `keep` values, as a new vector; or NULL when it
151 * already has no more than that, or, with *nomem set, when there was no
152 * memory to make one. The values dropped are the oldest. */
153 3298 static hamt_vec *store_trimmed(pTHX_ const hamt_vec *v, size_t keep, int *nomem) {
154 3298 size_t have = (STORE_HAMT->vec_count)(aTHX_ v);
155 hamt_vec *t;
156 3298 int status = HAMT_ABI_OK;
157  
158 3298 *nomem = 0;
159 3298 ▶ if (have <= keep) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (have <= keep) return NULL; 57 3241 3298
160 3241 t = (STORE_HAMT->vec_slice)(aTHX_ v, have - keep, keep, &status);
161 3241 ▶ if (!t) *nomem = 1;
Branch: 1 branch
BranchTrueFalseTotal
if (!t) *nomem = 1; 0 3241 3241
162 3241 return t;
163 }
164  
165 /* Under a limit the past is not cut on every change: it is let grow to the
166 * limit and this many steps more, then cut back to the limit in one go. A
167 * cut is a slice of the vector, and one change in 32 paying for it costs a
168 * small fraction of every change paying for it (bench/limit.pl). The steps
169 * beyond the limit are never offered to undo, so what can be undone is
170 * exact; they only stay alive a little longer. */
171 #define STORE_TRIM_SLACK 32
172  
173 /* How many steps can be undone: the past, less its oldest steps beyond the
174 * limit that have not been cut yet. */
175 360940 static size_t store_past_len(pTHX_ const store *s) {
176 360940 return (STORE_HAMT->vec_count)(aTHX_ s->past) - s->past_skip;
177 }
178  
179 /* How many of the oldest steps of `past` are beyond the limit, once steps
180 * have been pushed onto it: those it already had, and any more the pushes
181 * took it over by. */
182 192120 static size_t store_skip_after(const store *s, size_t count, size_t skip) {
183 192120 ▶ if (s->limited && count - skip > s->limit) skip = count - s->limit;
Branch: 2 branches
BranchTrueFalseTotal
if (s->limited && count - skip > s->limit) skip = count - s->limit; 128515 63605 192120
if (s->limited && count - skip > s->limit) skip = count - s->limit; 109638 18877 128515
184 192120 return skip;
185 }
186  
187 /* A past about to have a step pushed onto it, cut back first if it has
188 * outgrown the limit by the slack: a new vector of the newest `limit - 1`,
189 * or NULL when no cut is due. *nomem as store_trimmed. */
190 126090 static hamt_vec *store_room(pTHX_ const store *s, const hamt_vec *past, int *nomem) {
191 126090 *nomem = 0;
192 126090 ▶ if ((STORE_HAMT->vec_count)(aTHX_ past) < s->limit + STORE_TRIM_SLACK) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if ((STORE_HAMT->vec_count)(aTHX_ past) < s->limit + STORE_TRIM_SLACK) return NULL; 122854 3236 126090
193 3236 return store_trimmed(aTHX_ past, s->limit - 1, nomem);
194 }
195  
196 4494 static int store_magic_free(pTHX_ SV *sv, MAGIC *mg) {
197 4494 store *s = (store *)mg->mg_ptr;
198 PERL_UNUSED_ARG(sv);
199 4494 ▶ if (s) {
Branch: 1 branch
BranchTrueFalseTotal
if (s) { 4494 0 4494
200 4494 SV *value = s->value;
201 4494 hamt_vec *past = s->past, *future = s->future;
202 4494 store_watcher *w = s->watchers;
203 4494 SV *s_validator = s->validator;
204 4494 hamt_map *s_checkpoints = s->checkpoints;
205 4494 store_change *q = s->queue;
206 4494 size_t nw = s->nwatchers, qhead = s->qhead, qlen = s->qlen, i;
207 4494 mg->mg_ptr = NULL;
208 /* The struct goes before the values: releasing one can run its
209 * DESTROY, and by then there must be nothing half-gone. */
210 4494 store_free(aTHX_ s);
211 4494 store_sv_release(aTHX_ value);
212 4494 ▶ for (i = 0; i < qlen; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < qlen; i++) { 0 4494 4494
213 0 store_sv_release(aTHX_ q[qhead + i].was);
214 0 store_sv_release(aTHX_ q[qhead + i].now);
215 }
216 4541 ▶ for (i = 0; i < nw; i++) store_sv_release(aTHX_ w[i].code);
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < nw; i++) store_sv_release(aTHX_ w[i].code); 47 4494 4541
217 4494 Safefree(q);
218 4494 Safefree(w);
219 4494 store_sv_release(aTHX_ s_validator);
220 4494 ▶ if (s_checkpoints) (STORE_HAMT->map_release)(aTHX_ s_checkpoints);
Branch: 1 branch
BranchTrueFalseTotal
if (s_checkpoints) (STORE_HAMT->map_release)(aTHX_ s_checkpoints); 65 4429 4494
221 4494 ▶ if (past) (STORE_HAMT->vec_release)(aTHX_ past);
Branch: 1 branch
BranchTrueFalseTotal
if (past) (STORE_HAMT->vec_release)(aTHX_ past); 4494 0 4494
222 4494 ▶ if (future) (STORE_HAMT->vec_release)(aTHX_ future);
Branch: 1 branch
BranchTrueFalseTotal
if (future) (STORE_HAMT->vec_release)(aTHX_ future); 4494 0 4494
223 }
224 4494 return 0;
225 }
226  
227 0 static int store_magic_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param) {
228 PERL_UNUSED_CONTEXT;
229 PERL_UNUSED_ARG(param);
230 0 mg->mg_ptr = NULL;
231 0 return 0;
232 }
233  
234 static MGVTBL store_vtbl = {
235 NULL, NULL, NULL, NULL, store_magic_free, NULL, store_magic_dup, NULL
236 };
237  
238 /* The struct behind an object, or a croak that names the method. */
239 449679 static store *store_handle(pTHX_ SV *sv, const char *what) {
240 449679 ▶ if (SvROK(sv) && SvTYPE(SvRV(sv)) >= SVt_PVMG) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(sv) && SvTYPE(SvRV(sv)) >= SVt_PVMG) { 449669 10 449679
if (SvROK(sv) && SvTYPE(SvRV(sv)) >= SVt_PVMG) { 449669 0 449669
241 MAGIC *mg;
242 449675 ▶ for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) {
Branch: 1 branch
BranchTrueFalseTotal
for (mg = SvMAGIC(SvRV(sv)); mg; mg = mg->mg_moremagic) { 449657 18 449675
243 449657 ▶ if (mg->mg_type != PERL_MAGIC_ext || mg->mg_virtual != &store_vtbl) continue;
Branch: 2 branches
BranchTrueFalseTotal
if (mg->mg_type != PERL_MAGIC_ext || mg->mg_virtual != &store_vtbl) continue; 449654 3 449657
if (mg->mg_type != PERL_MAGIC_ext || mg->mg_virtual != &store_vtbl) continue; 3 449651 449654
244 449651 ▶ if (!mg->mg_ptr) croak("%s: this store belongs to another thread", what);
Branch: 1 branch
BranchTrueFalseTotal
if (!mg->mg_ptr) croak("%s: this store belongs to another thread", what); 0 449651 449651
245 449651 return (store *)mg->mg_ptr;
246 }
247 }
248 28 croak("%s: not a store", what);
249 return NULL;
250 }
251  
252 /* The class to bless into: the one named, or the one an object is in. */
253 4341 static HV *store_class_stash(pTHX_ SV *klass) {
254 4341 ▶ if (SvROK(klass) && SvOBJECT(SvRV(klass))) return SvSTASH(SvRV(klass));
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(klass) && SvOBJECT(SvRV(klass))) return SvSTASH(SvRV(klass)); 4 4337 4341
if (SvROK(klass) && SvOBJECT(SvRV(klass))) return SvSTASH(SvRV(klass)); 4 0 4
255 4337 return gv_stashsv(klass, GV_ADD);
256 }
257  
258 /* A value as it is kept: a copy, read-only, so that every holder of it sees
259 * what was stored and nothing written through an alias since. A reference
260 * copied this way is a second reference to the same thing, which is what
261 * makes a HAMT container in a store still that container. */
262 261093 static SV *store_copy_in(pTHX_ SV *in) {
263 261093 SV *c = newSVsv(in);
264 261093 SvREADONLY_on(c);
265 261093 return c;
266 }
267  
268 /* A new object of the class behind `stash`, mortal, holding `initial`. */
269 4494 static SV *store_new(pTHX_ HV *stash, SV *initial, store **out) {
270 store *s;
271 hamt_vec *past, *future;
272 SV *inner, *rv;
273 MAGIC *mg;
274  
275 4494 past = (STORE_HAMT->vec_new)(aTHX);
276 4494 ▶ future = past ? (STORE_HAMT->vec_new)(aTHX) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
future = past ? (STORE_HAMT->vec_new)(aTHX) : NULL; 4494 0 4494
277 4494 ▶ if (!future) {
Branch: 1 branch
BranchTrueFalseTotal
if (!future) { 0 4494 4494
278 0 ▶ if (past) (STORE_HAMT->vec_release)(aTHX_ past);
Branch: 1 branch
BranchTrueFalseTotal
if (past) (STORE_HAMT->vec_release)(aTHX_ past); 0 0 0
279 0 croak("State::Store::new: out of memory");
280 }
281 4494 s = (store *)store_alloc(aTHX_ sizeof(store));
282 4494 s->past = past;
283 4494 s->future = future;
284 4494 s->value = store_copy_in(aTHX_ initial);
285 4494 inner = newSV(0);
286 4494 mg = sv_magicext(inner, NULL, PERL_MAGIC_ext, &store_vtbl, (const char *)s, 0);
287 4494 mg->mg_flags |= MGf_DUP;
288 4494 rv = sv_2mortal(newRV_noinc(inner));
289 4494 sv_bless(rv, stash);
290 4494 *out = s;
291 4494 return rv;
292 }
293  
294 /* The stored scalar itself, mortal, kept alive past the store by a
295 * reference of its own. */
296 114370 static SV *store_get(pTHX_ const store *s) {
297 114370 return sv_2mortal(SvREFCNT_inc_simple_NN(s->value));
298 }
299  
300 /* The one place a new value arrives. 1 if it did, 0 if `in` is the value
301 * already held, as HAMT's value_equal has it: the same scalar, two
302 * references to one thing, or two non-references that are the same string.
303 * A change that is no change records nothing and leaves the redo stack.
304 * The validator is asked when `validate` is set: by set and swap, not by a
305 * restore, whose value was accepted when it was stored. -1 if it refused,
306 * with nothing changed.
307 *
308 * A tied or otherwise magical `in` is read once, here, and the rest works
309 * on what was read.
310 *
311 * The value displaced goes onto the past, and the future is emptied. All
312 * that can fail is allocated before anything changes, so running out of
313 * memory croaks with the store as it was. What is let go is let go last,
314 * when the store already holds the new value: releasing it can run a
315 * DESTROY, and that may use this store. */
316 216579 static int store_put(pTHX_ store *s, SV *in, SV *storerv, int validate, const char *what) {
317 SV *old;
318 216579 hamt_vec *fresh = NULL, *dead = NULL, *room = NULL, *dead_past = NULL;
319 216579 ▶ int record = !s->txn_depth && (!s->limited || s->limit > 0), nomem = 0;
Branch: 3 branches
BranchTrueFalseTotal
int record = !s->txn_depth && (!s->limited || s->limit > 0), nomem = 0; 212237 4342 216579
int record = !s->txn_depth && (!s->limited || s->limit > 0), nomem = 0; 147206 65031 212237
int record = !s->txn_depth && (!s->limited || s->limit > 0), nomem = 0; 126092 21114 147206
320  
321 SV *candidate;
322  
323 216579 store_check_mutable(aTHX_ s, what);
324 216578 ▶ if (SvGMAGICAL(in)) in = store_read_once(aTHX_ in);
Branch: 1 branch
BranchTrueFalseTotal
if (SvGMAGICAL(in)) in = store_read_once(aTHX_ in); 2 216576 216578
325 216578 ▶ if ((STORE_HAMT->value_equal)(aTHX_ s->value, in)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if ((STORE_HAMT->value_equal)(aTHX_ s->value, in)) return 0; 3440 213138 216578
326  
327 /* The validator is shown the very scalar that will be stored, and
328 * decides before anything is allocated or changed. */
329 213138 candidate = sv_2mortal(store_copy_in(aTHX_ in));
330 213138 ▶ if (validate && (s->validator || s->cvalidator)
Branch: 3 branches
BranchTrueFalseTotal
if (validate && (s->validator || s->cvalidator) 213074 64 213138
if (validate && (s->validator || s->cvalidator) 213032 42 213074
if (validate && (s->validator || s->cvalidator) 306 212726 213032
331 348 ▶ && !store_validate(aTHX_ s->validator, s->cvalidator, s->cvalidator_ud,
Branch: 1 branch
BranchTrueFalseTotal
&& !store_validate(aTHX_ s->validator, s->cvalidator, s->cvalidator_ud, 57 285 342
332 candidate, s->value, storerv, &s->validating))
333 57 return -1;
334  
335 213075 ▶ if ((STORE_HAMT->vec_count)(aTHX_ s->future)) {
Branch: 1 branch
BranchTrueFalseTotal
if ((STORE_HAMT->vec_count)(aTHX_ s->future)) { 12197 200878 213075
336 12197 fresh = (STORE_HAMT->vec_new)(aTHX);
337 12197 ▶ if (!fresh) croak("%s: out of memory", what);
Branch: 1 branch
BranchTrueFalseTotal
if (!fresh) croak("%s: out of memory", what); 0 12197 12197
338 }
339 /* When a cut is due, the past is cut to leave room for one more before
340 * anything is pushed, so that a failure leaves it as it was. */
341 213075 ▶ if (record && s->limited) {
Branch: 2 branches
BranchTrueFalseTotal
if (record && s->limited) { 187620 25455 213075
if (record && s->limited) { 126036 61584 187620
342 126036 room = store_room(aTHX_ s, s->past, &nomem);
343 126036 ▶ if (nomem) {
Branch: 1 branch
BranchTrueFalseTotal
if (nomem) { 0 126036 126036
344 0 ▶ if (fresh) (STORE_HAMT->vec_release)(aTHX_ fresh);
Branch: 1 branch
BranchTrueFalseTotal
if (fresh) (STORE_HAMT->vec_release)(aTHX_ fresh); 0 0 0
345 0 croak("%s: out of memory", what);
346 }
347 }
348 213075 ▶ if (record && (STORE_HAMT->vec_push)(aTHX_ room ? room : s->past, s->value) != HAMT_ABI_OK) {
Branch: 3 branches
BranchTrueFalseTotal
if (record && (STORE_HAMT->vec_push)(aTHX_ room ? room : s->past, s->value) != HAMT_ABI_OK) { 187620 25455 213075
if (record && (STORE_HAMT->vec_push)(aTHX_ room ? room : s->past, s->value) != HAMT_ABI_OK) { 184384 3236 187620
if (record && (STORE_HAMT->vec_push)(aTHX_ room ? room : s->past, s->value) != HAMT_ABI_OK) { 0 187620 187620
349 0 ▶ if (room) (STORE_HAMT->vec_release)(aTHX_ room);
Branch: 1 branch
BranchTrueFalseTotal
if (room) (STORE_HAMT->vec_release)(aTHX_ room); 0 0 0
350 0 ▶ if (fresh) (STORE_HAMT->vec_release)(aTHX_ fresh);
Branch: 1 branch
BranchTrueFalseTotal
if (fresh) (STORE_HAMT->vec_release)(aTHX_ fresh); 0 0 0
351 0 croak("%s: out of memory", what);
352 }
353  
354 213075 old = s->value;
355 213075 s->value = SvREFCNT_inc_simple_NN(candidate);
356 213075 ▶ if (fresh) { dead = s->future; s->future = fresh; }
Branch: 1 branch
BranchTrueFalseTotal
if (fresh) { dead = s->future; s->future = fresh; } 12197 200878 213075
357 213075 ▶ if (room) { dead_past = s->past; s->past = room; s->past_skip = 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (room) { dead_past = s->past; s->past = room; s->past_skip = 0; } 3236 209839 213075
358 213075 ▶ if (record) s->past_skip = store_skip_after(s, (STORE_HAMT->vec_count)(aTHX_ s->past), s->past_skip);
Branch: 1 branch
BranchTrueFalseTotal
if (record) s->past_skip = store_skip_after(s, (STORE_HAMT->vec_count)(aTHX_ s->past), s->past_skip); 187620 25455 213075
359  
360 213075 store_enqueue(aTHX_ s, old, s->value);
361 213075 store_sv_release(aTHX_ old);
362 213075 ▶ if (dead) (STORE_HAMT->vec_release)(aTHX_ dead);
Branch: 1 branch
BranchTrueFalseTotal
if (dead) (STORE_HAMT->vec_release)(aTHX_ dead); 12197 200878 213075
363 213075 ▶ if (dead_past) (STORE_HAMT->vec_release)(aTHX_ dead_past);
Branch: 1 branch
BranchTrueFalseTotal
if (dead_past) (STORE_HAMT->vec_release)(aTHX_ dead_past); 3236 209839 213075
364 213075 return 1;
365 }
366  
367 #endif
« include/store/store_history.h ↑ Summary include/store/store_hamt.h »