Speeding up XSUB calls up to 66%
Ilya Zakharevich [Fri, 27 Aug 1999 03:33:01 +0000 (23:33 -0400)]
To: perl5-porters@perl.org (Mailing list Perl5)
Message-Id: <199908270733.DAA16927@monk.mps.ohio-state.edu>

Addendum: it's "only" 33% speedup.

p4raw-id: //depot/cfgperl@4044

dump.c
op.c
op.h
pp.h

diff --git a/dump.c b/dump.c
index ac6a07e..0e7de38 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -472,8 +472,11 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, OP *o)
                    sv_catpv(tmpsv, ",AMPER");
                if (o->op_private & OPpENTERSUB_DB)
                    sv_catpv(tmpsv, ",DB");
+               if (o->op_private & OPpENTERSUB_HASTARG)
+                   sv_catpv(tmpsv, ",HASTARG");
            }
-           switch (o->op_private & OPpDEREF) {
+           else 
+               switch (o->op_private & OPpDEREF) {
            case OPpDEREF_SV:
                sv_catpv(tmpsv, ",SV");
                break;
diff --git a/op.c b/op.c
index 42ed8b2..8ff0353 100644 (file)
--- a/op.c
+++ b/op.c
@@ -5624,6 +5624,7 @@ Perl_ck_subr(pTHX_ OP *o)
     I32 arg = 0;
     STRLEN n_a;
 
+    o->op_private |= OPpENTERSUB_HASTARG;
     for (cvop = o2; cvop->op_sibling; cvop = cvop->op_sibling) ;
     if (cvop->op_type == OP_RV2CV) {
        SVOP* tmpop;
diff --git a/op.h b/op.h
index dd6307c..d1e2f27 100644 (file)
--- a/op.h
+++ b/op.h
@@ -117,13 +117,14 @@ typedef U32 PADOFFSET;
 /* Private for OP_REPEAT */
 #define OPpREPEAT_DOLIST       64      /* List replication. */
 
-/* Private for OP_ENTERSUB, OP_RV2?V, OP_?ELEM */
+/* Private for OP_RV2?V, OP_?ELEM */
 #define OPpDEREF               (32|64) /* Want ref to something: */
 #define OPpDEREF_AV            32      /*   Want ref to AV. */
 #define OPpDEREF_HV            64      /*   Want ref to HV. */
 #define OPpDEREF_SV            (32|64) /*   Want ref to SV. */
   /* OP_ENTERSUB only */
 #define OPpENTERSUB_DB         16      /* Debug subroutine. */
+#define OPpENTERSUB_HASTARG    32      /* Called from OP tree. */
   /* OP_RV2CV only */
 #define OPpENTERSUB_AMPER      8       /* Used & form to call. */
 #define OPpENTERSUB_NOPAREN    128     /* bare sub call (without parens) */
diff --git a/pp.h b/pp.h
index ec701f3..11dd9d0 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -49,6 +49,8 @@
 
 #define dTARG SV *targ
 
+#define dXS_TARGET SV * targ = (PL_op->op_private & OPpENTERSUB_HASTARG ? PAD_SV(PL_op->op_targ) : sv_newmortal())
+
 #define NORMAL PL_op->op_next
 #define DIE return Perl_die