From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sat, 18 Oct 2025 22:01:47 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/main' into tracing_jit X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d6f1db8184e17c7b5d7dac827569e1e607c3312;p=thirdparty%2FPython%2Fcpython.git Merge remote-tracking branch 'upstream/main' into tracing_jit --- 8d6f1db8184e17c7b5d7dac827569e1e607c3312 diff --cc Python/optimizer.c index 824f67d0a126,6ad912474485..a6d9c7904ee6 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@@ -115,13 -112,14 +115,14 @@@ uop_optimize(_PyInterpreterFrame *frame // gh-137573: inlining this function causes stack overflows Py_NO_INLINE int _PyOptimizer_Optimize( - _PyInterpreterFrame *frame, _Py_CODEUNIT *start, - _PyExecutorObject **executor_ptr, int chain_depth) + _PyInterpreterFrame *frame, PyThreadState *tstate) { - _PyStackRef *stack_pointer = frame->stackpointer; PyInterpreterState *interp = _PyInterpreterState_GET(); + int chain_depth = tstate->interp->jit_state.jit_tracer_initial_chain_depth; assert(interp->jit); assert(!interp->compiling); + assert(tstate->interp->jit_state.jit_tracer_initial_stack_depth >= 0); + #ifndef Py_GIL_DISABLED interp->compiling = true; // The first executor in a chain and the MAX_CHAIN_DEPTH'th executor *must* // make progress in order to avoid infinite loops or excessively-long @@@ -171,20 -152,18 +172,23 @@@ interp->compiling = false; return 0; } - insert_executor(code, start, index, *executor_ptr); + insert_executor(code, start, index, executor); } else { - (*executor_ptr)->vm_data.code = NULL; + executor->vm_data.code = NULL; + } + if (chain_depth > 0) { + _PyExitData *prev_exit = tstate->interp->jit_state.jit_tracer_previous_exit; + assert(prev_exit != NULL); + prev_exit->executor = executor;; } - (*executor_ptr)->vm_data.chain_depth = chain_depth; - assert((*executor_ptr)->vm_data.valid); + executor->vm_data.chain_depth = chain_depth; + assert(executor->vm_data.valid); interp->compiling = false; return 1; + #else + return 0; + #endif } static _PyExecutorObject *