summaryrefslogtreecommitdiff
path: root/cop.h
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-10-17 12:56:15 +0100
committerDavid Mitchell <davem@iabyn.com>2016-02-03 09:18:30 +0000
commit1bef65a2c897ceb4139a39df14a8514b260493bd (patch)
tree84844d6a1097fd8fee39e093df06f2bc043955c8 /cop.h
parent8a1f10dd1e1964fa64cd0dff7196cf3f1f503ae1 (diff)
downloadperl-1bef65a2c897ceb4139a39df14a8514b260493bd.tar.gz
Eliminate cx->blk_loop.resetsp
Of all the loop types, only CXt_LOOP_LIST, i.e. for (1,2,3) {}, needs to keep anything on the stack, i.e. for all the others, cx->blk_loop.resetsp can always equal cx->blk_oldsp. For CXt_LOOP_LIST, the same value as resetsp is stored as blk_loop.state_u.stack.basesp. So we can eliminate the resetsp field. This is good as the loop substruct is the largest (ITHREADS) or joint largest with eval (non-threaded). Also, we now don't have to store that value for non-CXt_LOOP_LIST loops. The downside is we now have to choose between basesp and oldsp in pp_leaveloop and pp_last, based on CX type.
Diffstat (limited to 'cop.h')
-rw-r--r--cop.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/cop.h b/cop.h
index 05458c54af..252eeb93b0 100644
--- a/cop.h
+++ b/cop.h
@@ -762,7 +762,6 @@ struct block_eval {
/* loop context */
struct block_loop {
- I32 resetsp;
LOOP * my_op; /* My op, that contains redo, next and last ops. */
union { /* different ways of locating the iteration variable */
SV **svp; /* for lexicals: address of pad slot */
@@ -808,8 +807,7 @@ struct block_loop {
#define CxPOPSUB_DONE 0x100
-#define PUSHLOOP_PLAIN(cx, s) \
- cx->blk_loop.resetsp = s - PL_stack_base; \
+#define PUSHLOOP_PLAIN(cx) \
cx->blk_loop.my_op = cLOOP; \
cx->blk_loop.state_u.ary.ary = NULL; \
cx->blk_loop.state_u.ary.ix = 0; \
@@ -823,8 +821,7 @@ struct block_loop {
# define PUSHLOOP_FOR_setpad(c) NOOP
#endif
-#define PUSHLOOP_FOR(cx, ivar, isave, s) \
- cx->blk_loop.resetsp = s - PL_stack_base; \
+#define PUSHLOOP_FOR(cx, ivar, isave) \
cx->blk_loop.my_op = cLOOP; \
cx->blk_loop.itervar_u.svp = (SV**)(ivar); \
cx->cx_old_savestack_ix = PL_savestack_ix; \
@@ -884,7 +881,7 @@ struct block {
U8 blku_type; /* what kind of context this is */
U8 blku_gimme; /* is this block running in list context? */
U16 blku_u16; /* used by block_sub and block_eval (so far) */
- I32 blku_oldsp; /* stack pointer to copy stuff down to */
+ I32 blku_oldsp; /* current sp floor: where nextstate pops to */
COP * blku_oldcop; /* old curcop pointer */
I32 blku_oldmarksp; /* mark stack index */
I32 blku_oldscopesp; /* scope stack index */