| 1 |
|
| #include <xs.h> |
| 2 |
|
| #include <stdlib.h> |
| 3 |
|
| |
| 4 |
|
| using namespace xs; |
| 5 |
|
| |
| 6 |
|
| static peep_t prev_rpeepp; |
| 7 |
|
| |
| 8 |
|
| static int post = 0; |
| 9 |
|
| |
| 10 |
22532 |
| OP* intercepted_entersub(pTHX) { |
| 11 |
22532 |
| auto ret = PL_ppaddr[OP_ENTERSUB](aTHX); |
| 12 |
22524 |
| ++post; |
| 13 |
22524 |
| return ret; |
| 14 |
|
| } |
| 15 |
|
| |
| 16 |
18269 |
| static void my_rpeep(pTHX_ OP *first) |
| 17 |
|
| { |
| 18 |
633707 |
| auto mark = [] (OP* it) { |
| 19 |
633707 |
▶ | if (it->op_type == OP_ENTERSUB) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (it->op_type == OP_ENTERSUB) { |
15271 |
618436 |
633707 |
|
| 20 |
15271 |
| it->op_ppaddr = &intercepted_entersub; |
| 21 |
|
| } |
| 22 |
633707 |
| }; |
| 23 |
|
| OP *o, *t; |
| 24 |
331000 |
▶ | for(t = o = first; o; o = o->op_next, t = t->op_next) { |
Branch: 1 branch
| Branch | True | False | Total |
| for(t = o = first; o; o = o->op_next, t = t->op_next) { |
320976 |
10024 |
331000 |
|
| 25 |
320976 |
| mark(o); |
| 26 |
320976 |
| o = o->op_next; |
| 27 |
320976 |
▶ | if(!o || o == t) break; |
Branch: 2 branches
| Branch | True | False | Total |
| if(!o || o == t) break; |
312771 |
8205 |
320976 |
| if(!o || o == t) break; |
312731 |
40 |
312771 |
|
| 28 |
312731 |
| mark(o); |
| 29 |
|
| } |
| 30 |
18269 |
▶ | prev_rpeepp(aTHX_ first); |
Branch: 1 branch
| Branch | True | False | Total |
| prev_rpeepp(aTHX_ first); |
18269 |
0 |
18269 |
|
| 31 |
18269 |
| } |
| 32 |
|
| |
| 33 |
|
| MODULE = MyTest PACKAGE = MyTest |
| 34 |
|
| PROTOTYPES: DISABLE |
| 35 |
|
| |
| 36 |
|
| |
| 37 |
|
| BOOT { |
| 38 |
8 |
| prev_rpeepp = PL_rpeepp; |
| 39 |
8 |
| PL_rpeepp = my_rpeep; |
| 40 |
|
| } |
| 41 |
|
| |
| 42 |
|
| int marker() { |
| 43 |
60 |
▶ | RETVAL = post; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = post; |
58 |
2 |
60 |
|
| 44 |
|
| } |
| 45 |
|
| |
| 46 |
|
| void test() { |
| 47 |
|
| // no-op |
| 48 |
|
| } |