From 11bb08e4ec7b546d57b0ab7a8f199747bef6e422 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 12 Feb 2025 10:16:43 -0800 Subject: GH-129715: Don't project traces that return to an unknown caller (GH-130024) --- .../Core_and_Builtins/2025-02-11-22-20-21.gh-issue-129715.mopO8n.rst | 1 + Python/instrumentation.c | 3 +-- Python/optimizer.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-02-11-22-20-21.gh-issue-129715.mopO8n.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-02-11-22-20-21.gh-issue-129715.mopO8n.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-02-11-22-20-21.gh-issue-129715.mopO8n.rst new file mode 100644 index 0000000..e71602b --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-02-11-22-20-21.gh-issue-129715.mopO8n.rst @@ -0,0 +1 @@ +Improve the experimental JIT's handling of returns to unknown callers. diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 0e7b481..12fd35f 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -185,8 +185,7 @@ is_instrumented(int opcode) { assert(opcode != 0); assert(opcode != RESERVED); - assert(opcode != ENTER_EXECUTOR); - return opcode >= MIN_INSTRUMENTED_OPCODE; + return opcode != ENTER_EXECUTOR && opcode >= MIN_INSTRUMENTED_OPCODE; } #ifndef NDEBUG diff --git a/Python/optimizer.c b/Python/optimizer.c index bef5728..d86d58d 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -671,7 +671,7 @@ translate_bytecode_to_trace( if (trace_stack_depth == 0) { DPRINTF(2, "Trace stack underflow\n"); OPT_STAT_INC(trace_stack_underflow); - goto done; + return 0; } } uint32_t orig_oparg = oparg; // For OPARG_TOP/BOTTOM -- cgit v0.12