diff options
author | David Mitchell <davem@iabyn.com> | 2012-11-25 23:08:11 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2012-12-04 10:22:20 +0000 |
commit | 03dba56127506a6979ee0298da57d71840dee39d (patch) | |
tree | 9ea5b5599689de08be766807e2adba6105d1dc59 /scope.h | |
parent | d172696c35223548e4cde3868d91bd72b7c7c195 (diff) | |
download | perl-03dba56127506a6979ee0298da57d71840dee39d.tar.gz |
refactor Perl_leave_scope
This is a large and hot function. The main problem with it is that
there is code to pop a few args repeated in just about every branch.
Also, there are a whole bunch of local vars (sv, av, hv, gv etc)
that are never all used simultaneously, but are really just there for
casting convenience. Together, they defeat the compiler's register
allocation algorithms (well, they did for gcc anyway).
We fix this by just declaring three general vars, arg0,1,2 of type ANY, and
move the popping code to above the switch(). We sort the SAVEt_*
indices in order of number of args, so it's quick to determine how many
args we need to pop for a particular type.
Together with the previous commits which added the SS_ADD_* macros, this
reduces the size of scope.o (-O2, gcc x86_64) by about 9% (threaded)
or 17% (unthreaded), and seems to speed up simple loops / function calls
by around 5%.
Diffstat (limited to 'scope.h')
-rw-r--r-- | scope.h | 123 |
1 files changed, 71 insertions, 52 deletions
@@ -8,58 +8,77 @@ * */ -#define SAVEt_ITEM 0 -#define SAVEt_SV 1 -#define SAVEt_AV 2 -#define SAVEt_HV 3 -#define SAVEt_INT 4 -#define SAVEt_LONG 5 -#define SAVEt_I32 6 -#define SAVEt_IV 7 -#define SAVEt_SPTR 8 -#define SAVEt_APTR 9 -#define SAVEt_HPTR 10 -#define SAVEt_PPTR 11 -#define SAVEt_NSTAB 12 -#define SAVEt_SVREF 13 -#define SAVEt_GP 14 -#define SAVEt_FREESV 15 -#define SAVEt_FREEOP 16 -#define SAVEt_FREEPV 17 -#define SAVEt_CLEARSV 18 -#define SAVEt_DELETE 19 -#define SAVEt_DESTRUCTOR 20 -#define SAVEt_REGCONTEXT 21 -#define SAVEt_STACK_POS 22 -#define SAVEt_I16 23 -#define SAVEt_AELEM 24 -#define SAVEt_HELEM 25 -#define SAVEt_OP 26 -#define SAVEt_HINTS 27 -#define SAVEt_ALLOC 28 -#define SAVEt_GENERIC_SVREF 29 -#define SAVEt_DESTRUCTOR_X 30 -#define SAVEt_VPTR 31 -#define SAVEt_I8 32 -#define SAVEt_COMPPAD 33 -#define SAVEt_GENERIC_PVREF 34 -#define SAVEt_PADSV_AND_MORTALIZE 35 -#define SAVEt_MORTALIZESV 36 -#define SAVEt_SHARED_PVREF 37 -#define SAVEt_BOOL 38 -#define SAVEt_SET_SVFLAGS 39 -#define SAVEt_SAVESWITCHSTACK 40 -#define SAVEt_RE_STATE 42 -#define SAVEt_COMPILE_WARNINGS 43 -#define SAVEt_STACK_CXPOS 44 -#define SAVEt_PARSER 45 -#define SAVEt_ADELETE 46 -#define SAVEt_I32_SMALL 47 -#define SAVEt_INT_SMALL 48 -#define SAVEt_GVSV 49 -#define SAVEt_FREECOPHH 50 -#define SAVEt_CLEARPADRANGE 51 -#define SAVEt_GVSLOT 52 +/* *** these are ordered by number of of auto-popped args */ + +/* zero args */ + +#define SAVEt_ALLOC 0 +#define SAVEt_CLEARPADRANGE 1 +#define SAVEt_CLEARSV 2 +#define SAVEt_REGCONTEXT 3 +#define SAVEt_RE_STATE 4 + +#define SAVEt_ARG0_MAX 4 + +/* one arg */ + +#define SAVEt_BOOL 5 +#define SAVEt_COMPILE_WARNINGS 6 +#define SAVEt_COMPPAD 7 +#define SAVEt_FREECOPHH 8 +#define SAVEt_FREEOP 9 +#define SAVEt_FREEPV 10 +#define SAVEt_FREESV 11 +#define SAVEt_I16 12 +#define SAVEt_I32_SMALL 13 +#define SAVEt_I8 14 +#define SAVEt_INT_SMALL 15 +#define SAVEt_MORTALIZESV 16 +#define SAVEt_NSTAB 17 +#define SAVEt_OP 18 +#define SAVEt_PARSER 19 +#define SAVEt_STACK_POS 20 + +#define SAVEt_ARG1_MAX 20 + +/* two args */ + +#define SAVEt_ADELETE 21 +#define SAVEt_APTR 22 +#define SAVEt_AV 23 +#define SAVEt_DESTRUCTOR 24 +#define SAVEt_DESTRUCTOR_X 25 +#define SAVEt_GENERIC_PVREF 26 +#define SAVEt_GENERIC_SVREF 27 +#define SAVEt_GP 28 +#define SAVEt_GVSV 29 +#define SAVEt_HINTS 30 +#define SAVEt_HPTR 31 +#define SAVEt_HV 32 +#define SAVEt_I32 33 +#define SAVEt_INT 34 +#define SAVEt_ITEM 35 +#define SAVEt_IV 36 +#define SAVEt_LONG 37 +#define SAVEt_PPTR 38 +#define SAVEt_SAVESWITCHSTACK 39 +#define SAVEt_SHARED_PVREF 40 +#define SAVEt_SPTR 41 +#define SAVEt_STACK_CXPOS 42 +#define SAVEt_SV 43 +#define SAVEt_SVREF 44 +#define SAVEt_VPTR 45 + +#define SAVEt_ARG2_MAX 45 + +/* three args */ + +#define SAVEt_AELEM 46 +#define SAVEt_DELETE 47 +#define SAVEt_HELEM 48 +#define SAVEt_PADSV_AND_MORTALIZE 49 +#define SAVEt_SET_SVFLAGS 50 +#define SAVEt_GVSLOT 51 #define SAVEf_SETMAGIC 1 #define SAVEf_KEEPOLDELEM 2 |