diff options
author | David Mitchell <davem@iabyn.com> | 2019-09-17 14:20:40 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2019-09-19 08:42:46 +0100 |
commit | 740449bf2292b54e1824f48789ef1a15877469d5 (patch) | |
tree | 779b4f0cc325d4c946583d021a2dc15ce53cd42d /cop.h | |
parent | 20550e1aa3f65750f061802d4df74a3faaf463a9 (diff) | |
download | perl-740449bf2292b54e1824f48789ef1a15877469d5.tar.gz |
add PL_curstackinfo->si_cxsubix field
This tracks the most recent sub/eval/format context pushed onto the
context stack. Then make dopopto_cursub use it.
The previous value is saved in the cxt struct, and is restored whenever
the context is popped.
This adds a tiny overhead for every sub call, but speeds up other
operations, such as determining the caller context when returning a
value from a sub - this has to be dpne for every sub call where the last
expression is context sensitive, so its often a win.
Diffstat (limited to 'cop.h')
-rw-r--r-- | cop.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -585,6 +585,7 @@ C<*len>. Upon return, C<*flags> will be set to either C<SVf_UTF8> or 0. /* subroutine context */ struct block_sub { OP * retop; /* op to execute on exit from sub */ + I32 old_cxsubix; /* previous value of si_cxsubix */ /* Above here is the same for sub, format and eval. */ PAD *prevcomppad; /* the caller's PL_comppad */ CV * cv; @@ -597,6 +598,7 @@ struct block_sub { /* format context */ struct block_format { OP * retop; /* op to execute on exit from sub */ + I32 old_cxsubix; /* previous value of si_cxsubix */ /* Above here is the same for sub, format and eval. */ PAD *prevcomppad; /* the caller's PL_comppad */ CV * cv; @@ -663,6 +665,7 @@ struct block_format { /* eval context */ struct block_eval { OP * retop; /* op to execute on exit from eval */ + I32 old_cxsubix; /* previous value of si_cxsubix */ /* Above here is the same for sub, format and eval. */ SV * old_namesv; OP * old_eval_root; @@ -1026,6 +1029,7 @@ struct stackinfo { struct stackinfo * si_next; I32 si_cxix; /* current context index */ I32 si_cxmax; /* maximum allocated index */ + I32 si_cxsubix; /* topmost sub/eval/format */ I32 si_type; /* type of runlevel */ I32 si_markoff; /* offset where markstack begins for us. * currently used only with DEBUGGING, @@ -1072,6 +1076,7 @@ typedef struct stackinfo PERL_SI; } \ next->si_type = type; \ next->si_cxix = -1; \ + next->si_cxsubix = -1; \ PUSHSTACK_INIT_HWM(next); \ AvFILLp(next->si_stack) = 0; \ SWITCHSTACK(PL_curstack,next->si_stack); \ |