]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Trace through BINARY_OP_SUBSCR_GETITEM
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Mon, 20 Oct 2025 01:52:00 +0000 (02:52 +0100)
committerKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Mon, 20 Oct 2025 01:52:00 +0000 (02:52 +0100)
Include/internal/pycore_optimizer.h
Python/bytecodes.c
Python/ceval.c
Python/ceval_macros.h
Python/generated_cases.c.h
Python/generated_tracer_cases.c.h
Python/optimizer.c
Tools/cases_generator/tier1_generator.py

index ca9f9702df4cdf2e73edc29b852d0e6a677e17ea..d9a47cf056f96be248ebc2feff4e581d51a3d5f7 100644 (file)
@@ -367,6 +367,7 @@ _PyJIT_translate_single_bytecode_to_trace(
     _Py_CODEUNIT *next_instr,
     PyCodeObject *code,
     PyFunctionObject *func,
+    int old_stack_level,
     int opcode,
     int oparg,
     int jump_taken);
index 42e323e3a4181a27945f2753daab1f36b5a2596b..9ef58978d88f17af694b81dfbbb671a391917b89 100644 (file)
@@ -2985,6 +2985,7 @@ dummy_func(
                 int _jump_taken = false;
                 PyCodeObject *old_code = _PyFrame_GetCode(frame);
                 PyFunctionObject *old_func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
+                int _old_stack_level = 0;
                 TRACING_DISPATCH();
             }
             else {
index b16fcdb51cd9b40e00de1715eb60c76d060b7fcd..08add3f75cd5297a6328f6f18b002655860690b5 100644 (file)
@@ -986,12 +986,12 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
 
 #if _Py_TIER2
 // 1 for trace full, 0 for successful write.
-static int
-add_to_code_trace(PyThreadState *tstate, _PyInterpreterFrame *frame, PyCodeObject *old_code, PyFunctionObject *old_func, _Py_CODEUNIT *this_instr, _Py_CODEUNIT *next_instr, int opcode, int oparg, int jump_taken)
+static inline int
+add_to_code_trace(PyThreadState *tstate, _PyInterpreterFrame *frame, PyCodeObject *old_code, PyFunctionObject *old_func, int old_stack_level, _Py_CODEUNIT *this_instr, _Py_CODEUNIT *next_instr, int opcode, int oparg, int jump_taken)
 {
     assert(frame != NULL);
     assert(tstate->interp->jit_state.jit_tracer_code_curr_size < UOP_MAX_TRACE_LENGTH);
-    return !_PyJIT_translate_single_bytecode_to_trace(tstate, frame, this_instr, next_instr, old_code, old_func, opcode, oparg, jump_taken);
+    return !_PyJIT_translate_single_bytecode_to_trace(tstate, frame, this_instr, next_instr, old_code, old_func, old_stack_level, opcode, oparg, jump_taken);
 }
 #endif
 
index 3adbadab4c53443d6372ba5c173eb00b55aed993..18ccc3dc7bf88cbd91d920ac16814b37de10fe27 100644 (file)
         if (_is_sys_tracing) { \
             LEAVE_TRACING(); \
         } \
-        else if ((IS_JIT_TRACING() && add_to_code_trace(tstate, frame, old_code, old_func, this_instr, next_instr, opcode, oparg, _jump_taken))) { \
+        else if ((IS_JIT_TRACING() && add_to_code_trace(tstate, frame, old_code, old_func, _old_stack_level, this_instr, next_instr, opcode, oparg, _jump_taken))) { \
             BAIL_TRACING_NO_DISPATCH(); \
         } \
     } while (0);
index bd043ae7285d95392b6bd8cd10c1a1483bbbc77d..b9ba4ca57cbef5f96db715d7b97e378a63ef6d70 100644 (file)
                     int _jump_taken = false;
                     PyCodeObject *old_code = _PyFrame_GetCode(frame);
                     PyFunctionObject *old_func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
+                    int _old_stack_level = 0;
                     TRACING_DISPATCH();
                 }
                 else {
index 75e86d9c76d3cd02de7281f7cedc85ea7328b800..ff7b91cc239e7eea9298993c902a1ea2fe9015c9 100644 (file)
@@ -26,6 +26,8 @@
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef lhs;
             _PyStackRef rhs;
             _PyStackRef res;
@@ -96,6 +98,8 @@
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef left;
             _PyStackRef right;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef nos;
             _PyStackRef dict_st;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef container;
             _PyStackRef getitem;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef tos;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_BINARY_OP == 5, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef container;
             _PyStackRef start;
             _PyStackRef stop;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef str;
             _PyStackRef *format;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *values;
             _PyStackRef list;
             values = &stack_pointer[-oparg];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *values;
             _PyStackRef map;
             values = &stack_pointer[-oparg*2];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *values;
             _PyStackRef set;
             values = &stack_pointer[-oparg];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *args;
             _PyStackRef slice;
             args = &stack_pointer[-oparg];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *pieces;
             _PyStackRef str;
             pieces = &stack_pointer[-oparg];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef strings;
             _PyStackRef interpolations;
             _PyStackRef template;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *values;
             _PyStackRef tup;
             values = &stack_pointer[-oparg];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             assert(0 && "Executing a cache.");
             Py_FatalError("Executing a cache.");
             TRACING_DISPATCH();
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = CALL;
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = CALL_FUNCTION_EX;
             _PyStackRef func;
             _PyStackRef callargs;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef res;
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value2_st;
             _PyStackRef value1_st;
             _PyStackRef res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef null;
             _PyStackRef callable;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = CALL_KW;
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = CALL_KW_NON_PY;
             static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
             _PyStackRef callable;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL_KW == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef null;
             _PyStackRef callable;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = CALL_NON_PY_GENERAL;
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef null;
             _PyStackRef callable;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef null;
             _PyStackRef callable;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CALL == 3, "incorrect cache size");
             _PyStackRef null;
             _PyStackRef callable;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef exc_value_st;
             _PyStackRef match_type_st;
             _PyStackRef rest;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef left;
             _PyStackRef right;
             _PyStackRef b;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef sub_iter;
             _PyStackRef last_sent_val;
             _PyStackRef exc_value_st;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef left;
             _PyStackRef right;
             _PyStackRef res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_COMPARE_OP == 1, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_COMPARE_OP == 1, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_COMPARE_OP == 1, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef right;
             _PyStackRef left;
             _PyStackRef b;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CONTAINS_OP == 1, "incorrect cache size");
             _PyStackRef tos;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_CONTAINS_OP == 1, "incorrect cache size");
             _PyStackRef tos;
             _PyStackRef left;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef result;
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef bottom;
             _PyStackRef top;
             bottom = stack_pointer[-1 - (oparg-1)];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             PyCodeObject *co = _PyFrame_GetCode(frame);
             assert(PyStackRef_FunctionCheck(frame->f_funcobj));
             PyFunctionObject *func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef owner;
             owner = stack_pointer[-1];
             PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             PyObject *cell = PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg));
             PyObject *oldobj = PyCell_SwapTakeRef((PyCellObject *)cell, NULL);
             if (oldobj == NULL) {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef v = GETLOCAL(oparg);
             if (PyStackRef_IsNull(v)) {
                 _PyFrame_SetStackPointer(frame, stack_pointer);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
             _PyFrame_SetStackPointer(frame, stack_pointer);
             int err = PyDict_Pop(GLOBALS(), name, NULL);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
             PyObject *ns = LOCALS();
             int err;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef container;
             _PyStackRef sub;
             sub = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef callable;
             _PyStackRef dict;
             _PyStackRef update;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef dict;
             _PyStackRef update;
             update = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef awaitable_st;
             _PyStackRef exc_st;
             exc_st = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             value = stack_pointer[-1];
             stack_pointer += -1;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef receiver;
             _PyStackRef value;
             _PyStackRef val;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = ENTER_EXECUTOR;
             #ifdef _Py_TIER2
             PyCodeObject *code = _PyFrame_GetCode(frame);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef should_be_none;
             should_be_none = stack_pointer[-1];
             if (!PyStackRef_IsNone(should_be_none)) {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = EXTENDED_ARG;
             assert(oparg);
             opcode = next_instr->op.code;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef res;
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef fmt_spec;
             _PyStackRef res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef iter;
             _PyStackRef null_or_index;
             _PyStackRef next;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
             _PyStackRef iter;
             _PyStackRef gen_frame;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
             _PyStackRef iter;
             _PyStackRef null_or_index;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
             _PyStackRef iter;
             _PyStackRef next;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size");
             _PyStackRef iter;
             _PyStackRef null_or_index;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef obj;
             _PyStackRef iter;
             obj = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef aiter;
             _PyStackRef awaitable;
             aiter = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef iterable;
             _PyStackRef iter;
             iterable = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef iterable;
             _PyStackRef iter;
             _PyStackRef index_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef obj;
             _PyStackRef len;
             obj = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef iterable;
             _PyStackRef iter;
             iterable = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef from;
             _PyStackRef res;
             from = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef level;
             _PyStackRef fromlist;
             _PyStackRef res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = INSTRUMENTED_CALL;
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = INSTRUMENTED_CALL_FUNCTION_EX;
             _PyStackRef func;
             _PyStackRef callargs;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = INSTRUMENTED_CALL_KW;
             _PyStackRef callable;
             _PyStackRef self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef awaitable_st;
             _PyStackRef exc_st;
             // _MONITOR_END_ASYNC_FOR
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef receiver;
             _PyStackRef value;
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef receiver;
             _PyStackRef value;
             _PyStackRef val;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef iter;
             _PyStackRef null_or_index;
             _PyStackRef next;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = INSTRUMENTED_INSTRUCTION;
             _PyFrame_SetStackPointer(frame, stack_pointer);
             int next_opcode = _Py_call_instrumentation_instruction(
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             /* Skip 1 cache entry */
             // _CHECK_PERIODIC
             {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             INSTRUMENTED_JUMP(this_instr, next_instr + oparg, PY_MONITORING_EVENT_JUMP);
             TRACING_DISPATCH();
         }
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = INSTRUMENTED_LINE;
             int original_opcode = 0;
             if (tstate->tracing) {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = INSTRUMENTED_LOAD_SUPER_ATTR;
             _PyStackRef global_super_st;
             _PyStackRef class_st;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             (void)this_instr;
             INSTRUMENTED_JUMP(prev_instr, next_instr, PY_MONITORING_EVENT_BRANCH_LEFT);
             TRACING_DISPATCH();
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef iter;
             _PyStackRef index_or_null;
             index_or_null = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef cond;
             /* Skip 1 cache entry */
             cond = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             /* Skip 1 cache entry */
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             /* Skip 1 cache entry */
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef cond;
             /* Skip 1 cache entry */
             cond = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             // _LOAD_BYTECODE
             {
                 #ifdef Py_GIL_DISABLED
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef val;
             _PyStackRef retval;
             _PyStackRef res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef val;
             _PyStackRef retval;
             _PyStackRef value;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef retval;
             retval = stack_pointer[-1];
             assert(frame->owner == FRAME_OWNED_BY_INTERPRETER);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef left;
             _PyStackRef right;
             _PyStackRef b;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             /* Skip 1 cache entry */
             // _SPECIALIZE_JUMP_BACKWARD
             {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(1 == 1, "incorrect cache size");
             /* Skip 1 cache entry */
             // _CHECK_PERIODIC
                     int _jump_taken = false;
                     PyCodeObject *old_code = _PyFrame_GetCode(frame);
                     PyFunctionObject *old_func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
+                    int _old_stack_level = 0;
                     TRACING_DISPATCH();
                 }
                 else {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             assert(oparg <= INSTR_OFFSET());
             JUMPBY(-oparg);
             TRACING_DISPATCH();
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(1 == 1, "incorrect cache size");
             /* Skip 1 cache entry */
             // _CHECK_PERIODIC
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             JUMPBY(oparg);
             TRACING_DISPATCH();
         }
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef list;
             _PyStackRef v;
             v = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef list_st;
             _PyStackRef iterable_st;
             iterable_st = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef owner;
             _PyStackRef *attr;
             _PyStackRef *self_or_null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             /* Skip 1 cache entry */
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef new_frame;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef attr;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef bc;
             PyObject *bc_o;
             _PyFrame_SetStackPointer(frame, stack_pointer);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             assert(oparg < NUM_COMMON_CONSTANTS);
             value = PyStackRef_FromPyObjectNew(tstate->interp->common_consts[oparg]);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             PyObject *obj = GETITEM(FRAME_CO_CONSTS, oparg);
             value = PyStackRef_FromPyObjectBorrow(obj);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             PyCellObject *cell = (PyCellObject *)PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg));
             _PyFrame_SetStackPointer(frame, stack_pointer);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
             value = PyStackRef_DUP(GETLOCAL(oparg));
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             value = GETLOCAL(oparg);
             GETLOCAL(oparg) = PyStackRef_NULL;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
             value = PyStackRef_Borrow(GETLOCAL(oparg));
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value1;
             _PyStackRef value2;
             uint32_t oparg1 = oparg >> 4;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef value_s = GETLOCAL(oparg);
             if (PyStackRef_IsNull(value_s)) {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value1;
             _PyStackRef value2;
             uint32_t oparg1 = oparg >> 4;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef class_dict_st;
             _PyStackRef value;
             class_dict_st = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef mod_or_class_dict;
             _PyStackRef v;
             mod_or_class_dict = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *res;
             _PyStackRef *null;
             // _SPECIALIZE_LOAD_GLOBAL
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
             _PyStackRef res;
             _PyStackRef *null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size");
             _PyStackRef res;
             _PyStackRef *null;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef locals;
             PyObject *l = LOCALS();
             if (l == NULL) {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef v;
             PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
             _PyFrame_SetStackPointer(frame, stack_pointer);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             assert(oparg < _PY_NSMALLPOSINTS);
             PyObject *obj = (PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS + oparg];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef self;
             _PyStackRef *method_and_self;
             // _INSERT_NULL
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             opcode = LOAD_SUPER_ATTR;
             _PyStackRef global_super_st;
             _PyStackRef class_st;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR == 1, "incorrect cache size");
             _PyStackRef global_super_st;
             _PyStackRef class_st;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR == 1, "incorrect cache size");
             _PyStackRef global_super_st;
             _PyStackRef class_st;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             PyObject *initial = PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg));
             PyObject *cell = PyCell_New(initial);
             if (cell == NULL) {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef codeobj_st;
             _PyStackRef func;
             codeobj_st = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef dict_st;
             _PyStackRef key;
             _PyStackRef value;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef subject;
             _PyStackRef type;
             _PyStackRef names;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef subject;
             _PyStackRef keys;
             _PyStackRef values_or_none;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef subject;
             _PyStackRef res;
             subject = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef subject;
             _PyStackRef res;
             subject = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             TRACING_DISPATCH();
         }
 
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             TRACING_DISPATCH();
         }
 
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef exc_value;
             exc_value = stack_pointer[-1];
             _PyErr_StackItem *exc_info = tstate->exc_info;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef iter;
             _PyStackRef index_or_null;
             index_or_null = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef cond;
             /* Skip 1 cache entry */
             cond = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef b;
             _PyStackRef cond;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef b;
             _PyStackRef cond;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef cond;
             /* Skip 1 cache entry */
             cond = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             value = stack_pointer[-1];
             stack_pointer += -1;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef exc;
             _PyStackRef prev_exc;
             _PyStackRef new_exc;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef res;
             res = PyStackRef_NULL;
             stack_pointer[0] = res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *args;
             args = &stack_pointer[-oparg];
             assert(oparg < 3);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef *values;
             _PyStackRef exc_st;
             exc_st = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             assert(0 && "Executing RESERVED instruction.");
             Py_FatalError("Executing RESERVED instruction.");
             TRACING_DISPATCH();
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             // _LOAD_BYTECODE
             {
                 #ifdef Py_GIL_DISABLED
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(0 == 0, "incorrect cache size");
             #if defined(__EMSCRIPTEN__)
             if (_Py_emscripten_signal_clock == 0) {
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef res;
             assert(PyStackRef_FunctionCheck(frame->f_funcobj));
             PyFunctionObject *func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef retval;
             _PyStackRef res;
             retval = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef receiver;
             _PyStackRef v;
             _PyStackRef retval;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_SEND == 1, "incorrect cache size");
             _PyStackRef receiver;
             _PyStackRef v;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             PyObject *ann_dict;
             if (LOCALS() == NULL) {
                 _PyFrame_SetStackPointer(frame, stack_pointer);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef set;
             _PyStackRef v;
             v = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef attr_st;
             _PyStackRef func_in;
             _PyStackRef func_out;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef set;
             _PyStackRef iterable;
             iterable = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef owner;
             _PyStackRef v;
             // _SPECIALIZE_STORE_ATTR
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef value;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef value;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_STORE_ATTR == 4, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef value;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef v;
             v = stack_pointer[-1];
             PyCellObject *cell = (PyCellObject *)PyStackRef_AsPyObjectBorrow(GETLOCAL(oparg));
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             value = stack_pointer[-1];
             _PyStackRef tmp = GETLOCAL(oparg);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value1;
             _PyStackRef value2;
             value1 = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value2;
             _PyStackRef value1;
             value1 = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef v;
             v = stack_pointer[-1];
             PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef v;
             v = stack_pointer[-1];
             PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef v;
             _PyStackRef container;
             _PyStackRef start;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef container;
             _PyStackRef sub;
             _PyStackRef v;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_STORE_SUBSCR == 1, "incorrect cache size");
             _PyStackRef nos;
             _PyStackRef value;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_STORE_SUBSCR == 1, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef nos;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef bottom;
             _PyStackRef top;
             top = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef res;
             // _SPECIALIZE_TO_BOOL
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
             _PyStackRef owner;
             _PyStackRef value;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
             _PyStackRef value;
             /* Skip 1 cache entry */
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
             _PyStackRef tos;
             _PyStackRef value;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_TO_BOOL == 3, "incorrect cache size");
             _PyStackRef value;
             _PyStackRef res;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef res;
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef res;
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef value;
             _PyStackRef res;
             value = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef seq;
             _PyStackRef *top;
             seq = stack_pointer[-1];
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef seq;
             _PyStackRef *top;
             // _SPECIALIZE_UNPACK_SEQUENCE
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size");
             _PyStackRef tos;
             _PyStackRef seq;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size");
             _PyStackRef tos;
             _PyStackRef seq;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size");
             _PyStackRef tos;
             _PyStackRef seq;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef exit_func;
             _PyStackRef exit_self;
             _PyStackRef lasti;
             (void)old_func;
             int _jump_taken = false;
             (void)_jump_taken;
+            int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;
+            (void)(_old_stack_level);
             _PyStackRef retval;
             _PyStackRef value;
             retval = stack_pointer[-1];
index 24e3d0614a2a7651754db4b77f6b15ba888a7912..f20b669cfb859d08b3364013df98e108ec340800 100644 (file)
@@ -564,6 +564,7 @@ _PyJIT_translate_single_bytecode_to_trace(
     _Py_CODEUNIT *next_instr,
     PyCodeObject *old_code,
     PyFunctionObject *func,
+    int old_stack_level,
     int opcode,
     int oparg,
     int jump_taken)
@@ -615,8 +616,8 @@ _PyJIT_translate_single_bytecode_to_trace(
         // If we haven't guarded the IP, then it's untraceable.
         (frame != tstate->interp->jit_state.jit_tracer_current_frame && !needs_guard_ip) ||
         (oparg > 0xFFFF) ||
-        // TODO (gh-140277): The constituent uops are invalid.
-        opcode == BINARY_OP_SUBSCR_GETITEM ||
+        // TODO (gh-140277): The constituent use one extra stack slot. So we need to check for heaedroom.
+        (opcode == BINARY_OP_SUBSCR_GETITEM && old_stack_level + 1 > old_code->co_stacksize)||
         // Exception stuff, could be handled in the future maybe?
         opcode == WITH_EXCEPT_START || opcode == RERAISE || opcode == CLEANUP_THROW || opcode == PUSH_EXC_INFO ||
         frame->owner >= FRAME_OWNED_BY_INTERPRETER
index 939035332cba72014d3a9a7fe58d9ae5d2c7cfc5..c77074f656c9e0c18ff219e868ef6f2655c32ad9 100644 (file)
@@ -260,6 +260,8 @@ def generate_tier1_cases(
             out.emit(f"(void)old_func;\n")
             out.emit(f"int _jump_taken = false;\n")
             out.emit(f"(void)_jump_taken;\n")
+            out.emit(f"int _old_stack_level = !PyStackRef_IsNull(frame->f_executable) ? STACK_LEVEL() : 0;\n")
+            out.emit(f"(void)(_old_stack_level);\n")
         if inst.properties.uses_opcode:
             out.emit(f"opcode = {name};\n")
         if inst.family is not None: