ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Faster/Faster.xs
Revision: 1.1
Committed: Thu Mar 9 04:41:21 2006 UTC (18 years, 3 months ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# Content
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4
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
20 // this is, of course, a slower entersub
21 static OP *
22 faster_entersub (pTHX)
23 {
24 dSP;
25 dTOPss;
26
27 if (SvTYPE (sv) == SVt_PVGV)
28 sv = GvCV (sv);
29
30 if (sv)
31 {
32 sv_dump (sv);
33 // only once for now
34 PL_op->op_ppaddr = old_entersub;
35
36 // only simple cv calls for now
37 if (!PL_perldb && SvTYPE (sv) == SVt_PVCV && !CvXSUB (sv))
38 {
39 sv = newSViv (PTR2IV (sv));
40 ENTER;
41 SAVETMPS;
42 PUSHMARK (SP);
43 // emulate B::CV typemap entry we don't have
44 XPUSHs (sv_2mortal (sv_bless (newRV_noinc (sv), gv_stashpv ("B::CV", 1))));
45 PUTBACK;
46 call_pv ("Faster::entersub", G_VOID|G_DISCARD);
47 SPAGAIN;
48 FREETMPS;
49 LEAVE;
50 }
51 }
52
53 return old_entersub (aTHX);
54 }
55
56 MODULE = Faster PACKAGE = Faster
57
58 void
59 hook_entersub ()
60 CODE:
61 old_entersub = PL_ppaddr [OP_ENTERSUB];
62 PL_ppaddr [OP_ENTERSUB] = faster_entersub;
63
64