summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2023-01-19 14:11:28 +0000
committerYves Orton <demerphq@gmail.com>2023-02-28 20:53:51 +0800
commitfecade69c526caa9c157a2405486b9089047fc72 (patch)
treed51961de6f06d4700c5bc8f6d6d96e855018999a /pp_ctl.c
parent214a9432e04871da2b88eba02ea3f1148a99f9c8 (diff)
downloadperl-fecade69c526caa9c157a2405486b9089047fc72.tar.gz
eval_sv(): call pp_entereval() via runops
Like the previous commit which did it for amagic_call() and call_sv(), this commit makes executing the faked-up OP_ENTEREVAL be executed as part of the runops loop rather than as a separate call. This is to allow shortly fixing up for a reference-counted stack. (CALLRUNOPS() will reify the stack if necessary, while the raw call to pp_entereval() won't fix up the stack unless its part of the runops loop too.) However, this is a bit more complex than call_sv() etc in that there is a good reason for calling pp_entereval() separately. The faked up OP_ENTEREVAL has its op_next set to NULL - this is the op which would normally be returned on failure of the eval compilation. By seeing whether the retuned value from pp_entereval() is NULL or not, eval_sv() can tell whether compilation failed. On the other hand, if pp_entereval() was made to be called as part of the runops loop, then the runops loop *always* finishes with PL_op set to NULL. So we can no lo longer distinguish between compile-failed and compile-succeeded-and-eval-ran-to-completion. This commit moves the entereval into the runops loop, but restores the ability to distinguish in a slightly hacky way. It adds a new private flag for OP_ENTEREVAL - OPpEVAL_EVALSV - which indicates to pp_entereval() that it was called from eval_sv(). And of course eval_sv() sets this flag on the OPpEVAL_EVALSV op it fakes up. If pp_entereval() fails to compile, then if that flag is set, it pushes a null pointer onto the argument stack before returning. Thus by checking whether *PL_stack_sp is NULL or not on return from CALLRUNOPS(), eval_sv() regains the ability to distinguish the two cases.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index c41084d6a2..7e03d2018b 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -5116,6 +5116,9 @@ PP(pp_entereval)
} else if (!saved_delete) {
(void)hv_delete(PL_defstash, tmpbuf, len, G_DISCARD);
}
+ if (PL_op->op_private & OPpEVAL_EVALSV)
+ /* signal compiletime failure to our eval_sv() caller */
+ *++PL_stack_sp = NULL;
return PL_op->op_next;
}
}