mirror of
https://github.com/python/cpython.git
synced 2025-10-25 18:54:53 +00:00
GH-137959: Replace shim code in jitted code with a single trampoline function. (GH-137961)
This commit is contained in:
parent
c056a089d8
commit
a8d9d94784
17 changed files with 166 additions and 104 deletions
|
|
@ -275,7 +275,8 @@ maybe_lltrace_resume_frame(_PyInterpreterFrame *frame, PyObject *globals)
|
|||
}
|
||||
int r = PyDict_Contains(globals, &_Py_ID(__lltrace__));
|
||||
if (r < 0) {
|
||||
return -1;
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
int lltrace = r * 5; // Levels 1-4 only trace uops
|
||||
if (!lltrace) {
|
||||
|
|
@ -1109,11 +1110,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(_Py_TIER2) && !defined(_Py_JIT)
|
||||
/* Tier 2 interpreter state */
|
||||
_PyExecutorObject *current_executor = NULL;
|
||||
const _PyUOpInstruction *next_uop = NULL;
|
||||
#endif
|
||||
#if Py_TAIL_CALL_INTERP
|
||||
# if Py_STATS
|
||||
return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, 0, lastopcode);
|
||||
|
|
@ -1126,14 +1122,41 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
|
|||
#endif
|
||||
|
||||
|
||||
early_exit:
|
||||
assert(_PyErr_Occurred(tstate));
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
|
||||
// GH-99729: We need to unlink the frame *before* clearing it:
|
||||
_PyInterpreterFrame *dying = frame;
|
||||
frame = tstate->current_frame = dying->previous;
|
||||
_PyEval_FrameClearAndPop(tstate, dying);
|
||||
frame->return_offset = 0;
|
||||
assert(frame->owner == FRAME_OWNED_BY_INTERPRETER);
|
||||
/* Restore previous frame and exit */
|
||||
tstate->current_frame = frame->previous;
|
||||
return NULL;
|
||||
}
|
||||
#ifdef _Py_TIER2
|
||||
|
||||
// Tier 2 is also here!
|
||||
enter_tier_two:
|
||||
|
||||
#ifdef _Py_JIT
|
||||
assert(0);
|
||||
_PyJitEntryFuncPtr _Py_jit_entry = _Py_LazyJitTrampoline;
|
||||
#else
|
||||
_PyJitEntryFuncPtr _Py_jit_entry = _PyTier2Interpreter;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_Py_TIER2) && !defined(_Py_JIT)
|
||||
|
||||
_Py_CODEUNIT *
|
||||
_PyTier2Interpreter(
|
||||
_PyExecutorObject *current_executor, _PyInterpreterFrame *frame,
|
||||
_PyStackRef *stack_pointer, PyThreadState *tstate
|
||||
) {
|
||||
const _PyUOpInstruction *next_uop;
|
||||
int oparg;
|
||||
tier2_start:
|
||||
|
||||
next_uop = current_executor->trace;
|
||||
assert(next_uop->opcode == _START_EXECUTOR || next_uop->opcode == _COLD_EXIT);
|
||||
|
||||
#undef LOAD_IP
|
||||
#define LOAD_IP(UNUSED) (void)0
|
||||
|
|
@ -1151,7 +1174,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
|
|||
#undef ENABLE_SPECIALIZATION_FT
|
||||
#define ENABLE_SPECIALIZATION_FT 0
|
||||
|
||||
; // dummy statement after a label, before a declaration
|
||||
uint16_t uopcode;
|
||||
#ifdef Py_STATS
|
||||
int lastuop = 0;
|
||||
|
|
@ -1225,24 +1247,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
|
|||
next_uop = current_executor->trace + target;
|
||||
goto tier2_dispatch;
|
||||
|
||||
#endif // _Py_JIT
|
||||
|
||||
}
|
||||
#endif // _Py_TIER2
|
||||
|
||||
early_exit:
|
||||
assert(_PyErr_Occurred(tstate));
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
|
||||
// GH-99729: We need to unlink the frame *before* clearing it:
|
||||
_PyInterpreterFrame *dying = frame;
|
||||
frame = tstate->current_frame = dying->previous;
|
||||
_PyEval_FrameClearAndPop(tstate, dying);
|
||||
frame->return_offset = 0;
|
||||
assert(frame->owner == FRAME_OWNED_BY_INTERPRETER);
|
||||
/* Restore previous frame and exit */
|
||||
tstate->current_frame = frame->previous;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef DO_NOT_OPTIMIZE_INTERP_LOOP
|
||||
# pragma optimize("", on)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue