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

Comparing Faster/Faster.xs (file contents):
Revision 1.7 by root, Fri Mar 10 22:18:39 2006 UTC vs.
Revision 1.10 by root, Sat Feb 21 05:55:52 2009 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
5#include <fcntl.h>
6#include <unistd.h>
4 7
5typedef CV *B__CV; 8typedef CV *B__CV;
6 9
7static OP *(*old_entersub)(pTHX); 10static OP *(*old_entersub)(pTHX);
8 11
9// this is, of course, a slower entersub 12// this is, of course, a slower entersub
10static OP * 13static OP *
11faster_entersub (pTHX) 14faster_entersub (pTHX)
12{ 15{
13 dSP; 16 static int in_perl;
14 dTOPss;
15 17
16 if (SvTYPE (sv) == SVt_PVGV) 18 if (!PL_compcv || in_perl) // only when not compiling, reduces recompiling due to op-address-shift
17 sv = (SV *)GvCV (sv); 19 {
20 dSP;
21 dTOPss;
18 22
19 if (sv) 23 ++in_perl;
20 {
21 // only once for now
22 PL_op->op_ppaddr = old_entersub;
23 24
24 // only simple cv calls for now 25 if (SvTYPE (sv) == SVt_PVGV)
25 if (!PL_perldb && !PL_tainting 26 sv = (SV *)GvCV (sv);
26 && SvTYPE (sv) == SVt_PVCV && !CvXSUB (sv) 27
27 && CvSTART (sv) // must exist 28 if (sv)
28 && CvSTART (sv)->op_type != OP_NULL) // shield against compiling an already-compiled op
29 { 29 {
30 SV *bsv = newSViv (PTR2IV (sv)); 30 // only once for now
31 PL_op->op_ppaddr = old_entersub;
31 32
33 // only simple cv calls for now
34 if (!PL_perldb && !PL_tainting
35 && SvTYPE (sv) == SVt_PVCV && !CvISXSUB (sv)
36 && CvSTART (sv) // must exist
37 && CvSTART (sv)->op_type != OP_NULL) // shield against compiling an already-compiled op
38 {
39 SV *bsv = newSViv (PTR2IV (sv));
40
32 ENTER; 41 ENTER;
33 SAVETMPS; 42 SAVETMPS;
34 PUSHMARK (SP); 43 PUSHMARK (SP);
35 // emulate B::CV typemap entry we don't have 44 // emulate B::CV typemap entry we don't have
36 XPUSHs (sv_2mortal (sv_bless (newRV_noinc (bsv), gv_stashpv ("B::CV", 1)))); 45 XPUSHs (sv_2mortal (sv_bless (newRV_noinc (bsv), gv_stashpv ("B::CV", 1))));
37 PUTBACK; 46 PUTBACK;
38 call_pv ("Faster::entersub", G_VOID|G_DISCARD|G_EVAL); 47 call_pv ("Faster::entersub", G_VOID|G_DISCARD|G_EVAL);
39 SPAGAIN; 48 SPAGAIN;
40 FREETMPS; 49 FREETMPS;
41 LEAVE; 50 LEAVE;
51 }
42 } 52 }
53
54 --in_perl;
43 } 55 }
44 56
45 return old_entersub (aTHX); 57 return old_entersub (aTHX);
46} 58}
47 59
80 op->op_ppaddr = ptr; 92 op->op_ppaddr = ptr;
81 93
82 CvSTART (cv) = op; 94 CvSTART (cv) = op;
83} 95}
84 96
97bool
98fcntl_lock (int fd)
99 CODE:
100{
101 struct flock lck;
102 lck.l_type = F_WRLCK;
103 lck.l_whence = SEEK_SET;
104 lck.l_start = 0;
105 lck.l_len = 0;
85 106
107 RETVAL = fcntl (fd, F_SETLKW, &lck) == 0;
108}
109 OUTPUT:
110 RETVAL
111
112
113

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines