ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Faster/Faster.xs
(Generate patch)

Comparing Faster/Faster.xs (file contents):
Revision 1.1 by root, Thu Mar 9 04:41:21 2006 UTC vs.
Revision 1.2 by root, Thu Mar 9 06:03:12 2006 UTC

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
5static OP *(*old_entersub)(pTHX); 5static OP *(*old_entersub)(pTHX);
6
7static void
8traverse (OP *op)
9{
10}
11
12static void
13analyze (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
21static OP * 8static OP *
22faster_entersub (pTHX) 9faster_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
56MODULE = Faster PACKAGE = Faster 44MODULE = Faster PACKAGE = Faster
57 45
46PROTOTYPES: ENABLE
47
48IV
49ppaddr (int optype)
50 CODE:
51 RETVAL = optype == OP_ENTERSUB
52 ? old_entersub
53 : PL_ppaddr [optype];
54 OUTPUT:
55 RETVAL
56
58void 57void
59hook_entersub () 58hook_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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines