From dd8be0e4430f49fe482092c3539ee727c1309a4a Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Wed, 27 Oct 2010 15:21:40 +0100 Subject: [PATCH] Using ALIAS B::OP::{opt,spare,type} can be implemented as 1 XS function. This reduces the object code size by almost 2K on this platform. --- ext/B/B.xs | 57 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/ext/B/B.xs b/ext/B/B.xs index 6049669..9906dd2 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -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 -- 2.7.4