xs/xop.xs

filter: Statementstmt 100% 19 / 19 Branchbran 50.0% 39 / 78 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 59.7% 58 / 97 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/sa/sa_format.h ↑ Summary include/sa/sa_time.h »
1 # The op layer's Perl-visible ends: what it hooked, and what it did.
2  
3 MODULE = Shared::Arena PACKAGE = Shared::Arena PREFIX = sax_
4  
5 # hooked / hits / delegated / method-op only
6 #
7 # The fourth is call sites where another dist already owned the entersub, so
8 # only the method op is ours. Those never reach a door and so never count a
9 # hit, which is worth knowing before reading the third number as a problem.
10 void
11 sax__xop_stats(...)
12 PPCODE:
13 15 ▶ EXTEND(SP, 4);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 4); 0 15 15
14 15 mPUSHi(sa_xop_hook);
15 15 mPUSHi(sa_xop_hits);
16 15 mPUSHi(sa_xop_miss);
17 15 mPUSHi(sa_xop_meth);
18  
19 void
20 sax__xop_reset(...)
21 CODE:
22 13 sa_xop_hits = sa_xop_miss = 0;
23  
24 MODULE = Shared::Arena PACKAGE = Shared::Arena
25  
26 BOOT:
27 {
28 134 sa_stash_cache = gv_stashpv("Shared::Arena::Cache", GV_ADD);
29 134 sa_stash_map = gv_stashpv("Shared::Arena::Map", GV_ADD);
30 134 sa_stash_bloom = gv_stashpv("Shared::Arena::Bloom", GV_ADD);
31 134 sa_stash_hist = gv_stashpv("Shared::Arena::Histogram", GV_ADD);
32 134 sa_stash_ring = gv_stashpv("Shared::Arena::Ring", GV_ADD);
33 134 sa_stash_rate = gv_stashpv("Shared::Arena::Rate", GV_ADD);
34 134 sa_stash_cms = gv_stashpv("Shared::Arena::CountMin", GV_ADD);
35 134 sa_stash_cuckoo = gv_stashpv("Shared::Arena::Cuckoo", GV_ADD);
36  
37 /* Two things per door: the GLOB, whose current CV the method op pushes so
38 * a monkeypatch takes effect, and the CV that was in it at BOOT, which the
39 * entersub op compares against and never calls. A reference is held on the
40 * original so that deleting the sub cannot free the CV and let a later
41 * allocation reuse the address and pass an identity check it should fail. */
42 #define SA_DOOR_BOOT(door, path) \
43 sa_gv_##door = gv_fetchpv(path, 0, SVt_PVCV); \
44 if (sa_gv_##door) { \
45 sa_cv_##door = GvCV(sa_gv_##door); \
46 if (sa_cv_##door) SvREFCNT_inc((SV *)sa_cv_##door); \
47 }
48 134 ▶ SA_DOORS(SA_DOOR_BOOT)
Branch: 36 branches
BranchTrueFalseTotal
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
SA_DOORS(SA_DOOR_BOOT) 134 0 134
49 #undef SA_DOOR_BOOT
50  
51 /* An off switch, because the hook is not free for programs that get
52 * nothing from it: every `->get` and `->set` in the process pays a
53 * nanosecond or two to be declined. Set SHARED_ARENA_NO_XOP=1 and every
54 * door goes through the ordinary XSUB, which is what it did before this
55 * file existed. Read once, here, because the rewriting happens at compile
56 * time and there is nothing to switch later. */
57 134 ▶ if (!getenv("SHARED_ARENA_NO_XOP")
Branch: 1 branch
BranchTrueFalseTotal
if (!getenv("SHARED_ARENA_NO_XOP") 134 0 134
58 134 ▶ && PL_check[OP_ENTERSUB] != sa_ck_entersub) {
Branch: 1 branch
BranchTrueFalseTotal
&& PL_check[OP_ENTERSUB] != sa_ck_entersub) { 134 0 134
59 134 sa_prev_ck_entersub = PL_check[OP_ENTERSUB];
60 134 PL_check[OP_ENTERSUB] = sa_ck_entersub;
61 }
62 }
« include/sa/sa_format.h ↑ Summary include/sa/sa_time.h »