#include "EXTERN.h" #include "perl.h" #include "XSUB.h" static OP *(*old_entersub)(pTHX); static void traverse (OP *op) { } static void analyze (CV *cv) { OP *op = CvSTART (cv); traverse (op); } // this is, of course, a slower entersub static OP * faster_entersub (pTHX) { dSP; dTOPss; if (SvTYPE (sv) == SVt_PVGV) sv = GvCV (sv); if (sv) { sv_dump (sv); // only once for now PL_op->op_ppaddr = old_entersub; // only simple cv calls for now if (!PL_perldb && SvTYPE (sv) == SVt_PVCV && !CvXSUB (sv)) { sv = newSViv (PTR2IV (sv)); ENTER; SAVETMPS; PUSHMARK (SP); // emulate B::CV typemap entry we don't have XPUSHs (sv_2mortal (sv_bless (newRV_noinc (sv), gv_stashpv ("B::CV", 1)))); PUTBACK; call_pv ("Faster::entersub", G_VOID|G_DISCARD); SPAGAIN; FREETMPS; LEAVE; } } return old_entersub (aTHX); } MODULE = Faster PACKAGE = Faster void hook_entersub () CODE: old_entersub = PL_ppaddr [OP_ENTERSUB]; PL_ppaddr [OP_ENTERSUB] = faster_entersub;