From 2e707ee66f484c11d4548011911ad17bec2063b9 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 3 Aug 2021 10:31:26 -0700 Subject: Don't generate entry point when PC != 0 If we hit this at PC > 0 (ie. with an optional argument) the provided types and context are likely incorrect and it is likely this block can't be used. --- yjit_core.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'yjit_core.c') diff --git a/yjit_core.c b/yjit_core.c index 45386dea23..95bdcc1fa4 100644 --- a/yjit_core.c +++ b/yjit_core.c @@ -613,6 +613,12 @@ block_t* gen_block_version(blockid_t blockid, const ctx_t* start_ctx, rb_executi // Generate a block version that is an entry point inserted into an iseq uint8_t* gen_entry_point(const rb_iseq_t *iseq, uint32_t insn_idx, rb_execution_context_t *ec) { + // If we aren't at PC 0, don't generate code + // See yjit_pc_guard + if (iseq->body->iseq_encoded != ec->cfp->pc) { + return NULL; + } + // The entry context makes no assumptions about types blockid_t blockid = { iseq, insn_idx }; -- cgit v1.2.3