This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Using ALIAS B::OP::{opt,spare,type} can be implemented as 1 XS function.
authorNicholas Clark <nick@ccl4.org>
Wed, 27 Oct 2010 14:21:40 +0000 (15:21 +0100)
committerNicholas Clark <nick@ccl4.org>
Wed, 27 Oct 2010 14:21:40 +0000 (15:21 +0100)
This reduces the object code size by almost 2K on this platform.

ext/B/B.xs

index 6049669..9906dd2 100644 (file)
@@ -835,15 +835,8 @@ threadsv_names()
 #define OP_sibling(o)  o->op_sibling
 #define OP_desc(o)     (char *)PL_op_desc[o->op_type]
 #define OP_targ(o)     o->op_targ
-#define OP_type(o)     o->op_type
-#if PERL_VERSION >= 9
-#  define OP_opt(o)    o->op_opt
-#else
-#  define OP_seq(o)    o->op_seq
-#endif
 #define OP_flags(o)    o->op_flags
 #define OP_private(o)  o->op_private
-#define OP_spare(o)    o->op_spare
 
 MODULE = B     PACKAGE = B::OP         PREFIX = OP_
 
@@ -893,21 +886,45 @@ PADOFFSET
 OP_targ(o)
        B::OP           o
 
-U16
-OP_type(o)
-       B::OP           o
-
 #if PERL_VERSION >= 9
-
-U16
-OP_opt(o)
+#  These 3 are all bitfields, so we can't take their addresses.
+UV
+OP_type(o)
        B::OP           o
+    ALIAS:
+       opt = 1
+       spare = 2
+    CODE:
+       switch(ix) {
+         case 1:
+           RETVAL = o->op_opt;
+           break;
+         case 2:
+           RETVAL = o->op_spare;
+           break;
+         default:
+           RETVAL = o->op_type;
+       }
+    OUTPUT:
+       RETVAL
 
 #else
 
-U16
-OP_seq(o)
+UV
+OP_type(o)
        B::OP           o
+    ALIAS:
+       seq = 1
+    CODE:
+       switch(ix) {
+         case 1:
+           RETVAL = o->op_seq;
+           break;
+         default:
+           RETVAL = o->op_type;
+       }
+    OUTPUT:
+       RETVAL
 
 #endif
 
@@ -919,14 +936,6 @@ U8
 OP_private(o)
        B::OP           o
 
-#if PERL_VERSION >= 9
-
-U16
-OP_spare(o)
-       B::OP           o
-
-#endif
-
 void
 OP_oplist(o)
        B::OP           o