1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | static OP *(*old_entersub)(pTHX); |
5 | static OP *(*old_entersub)(pTHX); |
6 | |
|
|
7 | static void |
|
|
8 | traverse (OP *op) |
|
|
9 | { |
|
|
10 | } |
|
|
11 | |
|
|
12 | static void |
|
|
13 | analyze (CV *cv) |
|
|
14 | { |
|
|
15 | OP *op = CvSTART (cv); |
|
|
16 | |
|
|
17 | traverse (op); |
|
|
18 | } |
|
|
19 | |
6 | |
20 | // this is, of course, a slower entersub |
7 | // this is, of course, a slower entersub |
21 | static OP * |
8 | static OP * |
22 | faster_entersub (pTHX) |
9 | faster_entersub (pTHX) |
23 | { |
10 | { |
24 | dSP; |
11 | dSP; |
25 | dTOPss; |
12 | dTOPss; |
26 | |
13 | |
27 | if (SvTYPE (sv) == SVt_PVGV) |
14 | if (SvTYPE (sv) == SVt_PVGV) |
28 | sv = GvCV (sv); |
15 | sv = (SV *)GvCV (sv); |
29 | |
16 | |
30 | if (sv) |
17 | if (sv) |
31 | { |
18 | { |
32 | sv_dump (sv); |
|
|
33 | // only once for now |
19 | // only once for now |
34 | PL_op->op_ppaddr = old_entersub; |
20 | PL_op->op_ppaddr = old_entersub; |
35 | |
21 | |
36 | // only simple cv calls for now |
22 | // only simple cv calls for now |
|
|
23 | if (!PL_perldb && !PL_tainting |
37 | if (!PL_perldb && SvTYPE (sv) == SVt_PVCV && !CvXSUB (sv)) |
24 | && SvTYPE (sv) == SVt_PVCV && !CvXSUB (sv)) |
38 | { |
25 | { |
39 | sv = newSViv (PTR2IV (sv)); |
26 | sv = newSViv (PTR2IV (sv)); |
|
|
27 | |
40 | ENTER; |
28 | ENTER; |
41 | SAVETMPS; |
29 | SAVETMPS; |
42 | PUSHMARK (SP); |
30 | PUSHMARK (SP); |
43 | // emulate B::CV typemap entry we don't have |
31 | // emulate B::CV typemap entry we don't have |
44 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc (sv), gv_stashpv ("B::CV", 1)))); |
32 | XPUSHs (sv_2mortal (sv_bless (newRV_noinc (sv), gv_stashpv ("B::CV", 1)))); |
… | |
… | |
53 | return old_entersub (aTHX); |
41 | return old_entersub (aTHX); |
54 | } |
42 | } |
55 | |
43 | |
56 | MODULE = Faster PACKAGE = Faster |
44 | MODULE = Faster PACKAGE = Faster |
57 | |
45 | |
|
|
46 | PROTOTYPES: ENABLE |
|
|
47 | |
|
|
48 | IV |
|
|
49 | ppaddr (int optype) |
|
|
50 | CODE: |
|
|
51 | RETVAL = optype == OP_ENTERSUB |
|
|
52 | ? old_entersub |
|
|
53 | : PL_ppaddr [optype]; |
|
|
54 | OUTPUT: |
|
|
55 | RETVAL |
|
|
56 | |
58 | void |
57 | void |
59 | hook_entersub () |
58 | hook_entersub () |
60 | CODE: |
59 | CODE: |
61 | old_entersub = PL_ppaddr [OP_ENTERSUB]; |
60 | old_entersub = PL_ppaddr [OP_ENTERSUB]; |
62 | PL_ppaddr [OP_ENTERSUB] = faster_entersub; |
61 | PL_ppaddr [OP_ENTERSUB] = faster_entersub; |