diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-01-24 13:57:20 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-24 13:57:20 +0000 |
commit | 493b0a3c46c2cc9f06bf88c450ded6aa981c4fd3 (patch) | |
tree | 7d6dfdd735cd260a345eb8489b3d7976428943eb /cop.h | |
parent | c25bf6989edf21dd302c4e306179cfffbc11bb5f (diff) | |
download | perl-493b0a3c46c2cc9f06bf88c450ded6aa981c4fd3.tar.gz |
In struct block_loop, merge itermax and iterlval into a union
lval_max_u, as CXt_LOOP_LAZYIV doesn't use iterlval and the other
LOOP types don't use itermax. This reduces struct block_loop by 1 IV.
As it's the largest component of the unions making up struct context,
this reduces struct context. On ILP32 it will now be 56 bytes, down
from the 64 of 5.10.x, as I've already removed the element 'label'.
p4raw-id: //depot/perl@33063
Diffstat (limited to 'cop.h')
-rw-r--r-- | cop.h | 28 |
1 files changed, 10 insertions, 18 deletions
@@ -443,9 +443,14 @@ struct block_loop { SV ** itervar; #endif SV * itersave; + union { /* (from inspection of source code) for a .. range of strings this is the current string. */ - SV * iterlval; + SV * iterlval; + /* (from inspection of source code) for a .. range of numbers this is the + maximum value. */ + IV itermax; + } lval_max_u; union { /* (from inspection of source code) for a foreach loop this is the array being iterated over. For a .. range of numbers it's the current value. @@ -456,19 +461,7 @@ struct block_loop { IV itermin; } ary_min_u; IV iterix; - /* (from inspection of source code) for a .. range of numbers this is the - maximum value. */ - IV itermax; }; -/* It might be possible to squeeze this structure further. As best I can tell - itermax and iterlval are never used at the same time, so it might be possible - to make them into a union. However, I'm not confident that there are enough - flag bits/NULLable pointers in this structure alone to encode which is - active. There is, however, U8 of space free in struct block, which could be - used. Right now it may not be worth squeezing this structure further, as it's - the largest part of struct block, and currently struct block is 64 bytes on - an ILP32 system, which will give good cache alignment. -*/ #ifdef USE_ITHREADS # define CxITERVAR(c) \ @@ -508,7 +501,7 @@ struct block_loop { cx->blk_loop.resetsp = s - PL_stack_base; \ cx->blk_loop.my_op = cLOOP; \ PUSHLOOP_OP_NEXT; \ - cx->blk_loop.iterlval = NULL; \ + cx->blk_loop.lval_max_u.iterlval = NULL; \ cx->blk_loop.ary_min_u.iterary = NULL; \ CX_ITERDATA_SET(cx,NULL); @@ -516,15 +509,14 @@ struct block_loop { cx->blk_loop.resetsp = s - PL_stack_base; \ cx->blk_loop.my_op = cLOOP; \ PUSHLOOP_OP_NEXT; \ - cx->blk_loop.iterlval = NULL; \ + cx->blk_loop.lval_max_u.iterlval = NULL; \ cx->blk_loop.ary_min_u.iterary = NULL; \ cx->blk_loop.iterix = -1; \ CX_ITERDATA_SET(cx,dat); #define POPLOOP(cx) \ - if (CxTYPE(cx) == CXt_LOOP_LAZYIV) \ - assert(!cx->blk_loop.iterlval); \ - SvREFCNT_dec(cx->blk_loop.iterlval); \ + if (CxTYPE(cx) != CXt_LOOP_LAZYIV) \ + SvREFCNT_dec(cx->blk_loop.lval_max_u.iterlval); \ if (CxITERVAR(cx)) { \ if (SvPADMY(cx->blk_loop.itersave)) { \ SV ** const s_v_p = CxITERVAR(cx); \ |