mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
GH-108035: Remove the _PyCFrame
struct as it is no longer needed for performance. (GH-108036)
This commit is contained in:
parent
33e6e3fec0
commit
006e44f950
21 changed files with 66 additions and 103 deletions
|
@ -72,7 +72,6 @@ dummy_func(
|
|||
_PyInterpreterFrame *frame,
|
||||
unsigned char opcode,
|
||||
unsigned int oparg,
|
||||
_PyCFrame cframe,
|
||||
_Py_CODEUNIT *next_instr,
|
||||
PyObject **stack_pointer,
|
||||
PyObject *kwnames,
|
||||
|
@ -134,8 +133,7 @@ dummy_func(
|
|||
}
|
||||
|
||||
inst(RESUME, (--)) {
|
||||
assert(tstate->cframe == &cframe);
|
||||
assert(frame == cframe.current_frame);
|
||||
assert(frame == tstate->current_frame);
|
||||
/* Possibly combine this with eval breaker */
|
||||
if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) {
|
||||
int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp);
|
||||
|
@ -752,9 +750,8 @@ dummy_func(
|
|||
inst(INTERPRETER_EXIT, (retval --)) {
|
||||
assert(frame == &entry_frame);
|
||||
assert(_PyFrame_IsIncomplete(frame));
|
||||
/* Restore previous cframe and return. */
|
||||
tstate->cframe = cframe.previous;
|
||||
assert(tstate->cframe->current_frame == frame->previous);
|
||||
/* Restore previous frame and return. */
|
||||
tstate->current_frame = frame->previous;
|
||||
assert(!_PyErr_Occurred(tstate));
|
||||
tstate->c_recursion_remaining += PY_EVAL_C_STACK_UNITS;
|
||||
return retval;
|
||||
|
@ -768,7 +765,7 @@ dummy_func(
|
|||
assert(frame != &entry_frame);
|
||||
// GH-99729: We need to unlink the frame *before* clearing it:
|
||||
_PyInterpreterFrame *dying = frame;
|
||||
frame = cframe.current_frame = dying->previous;
|
||||
frame = tstate->current_frame = dying->previous;
|
||||
_PyEvalFrameClearAndPop(tstate, dying);
|
||||
frame->prev_instr += frame->return_offset;
|
||||
_PyFrame_StackPush(frame, retval);
|
||||
|
@ -787,7 +784,7 @@ dummy_func(
|
|||
assert(frame != &entry_frame);
|
||||
// GH-99729: We need to unlink the frame *before* clearing it:
|
||||
_PyInterpreterFrame *dying = frame;
|
||||
frame = cframe.current_frame = dying->previous;
|
||||
frame = tstate->current_frame = dying->previous;
|
||||
_PyEvalFrameClearAndPop(tstate, dying);
|
||||
frame->prev_instr += frame->return_offset;
|
||||
_PyFrame_StackPush(frame, retval);
|
||||
|
@ -803,7 +800,7 @@ dummy_func(
|
|||
assert(frame != &entry_frame);
|
||||
// GH-99729: We need to unlink the frame *before* clearing it:
|
||||
_PyInterpreterFrame *dying = frame;
|
||||
frame = cframe.current_frame = dying->previous;
|
||||
frame = tstate->current_frame = dying->previous;
|
||||
_PyEvalFrameClearAndPop(tstate, dying);
|
||||
frame->prev_instr += frame->return_offset;
|
||||
_PyFrame_StackPush(frame, retval);
|
||||
|
@ -823,7 +820,7 @@ dummy_func(
|
|||
assert(frame != &entry_frame);
|
||||
// GH-99729: We need to unlink the frame *before* clearing it:
|
||||
_PyInterpreterFrame *dying = frame;
|
||||
frame = cframe.current_frame = dying->previous;
|
||||
frame = tstate->current_frame = dying->previous;
|
||||
_PyEvalFrameClearAndPop(tstate, dying);
|
||||
frame->prev_instr += frame->return_offset;
|
||||
_PyFrame_StackPush(frame, retval);
|
||||
|
@ -1019,7 +1016,7 @@ dummy_func(
|
|||
gen->gi_exc_state.previous_item = NULL;
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
_PyInterpreterFrame *gen_frame = frame;
|
||||
frame = cframe.current_frame = frame->previous;
|
||||
frame = tstate->current_frame = frame->previous;
|
||||
gen_frame->previous = NULL;
|
||||
_PyFrame_StackPush(frame, retval);
|
||||
goto resume_frame;
|
||||
|
@ -1038,7 +1035,7 @@ dummy_func(
|
|||
gen->gi_exc_state.previous_item = NULL;
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
_PyInterpreterFrame *gen_frame = frame;
|
||||
frame = cframe.current_frame = frame->previous;
|
||||
frame = tstate->current_frame = frame->previous;
|
||||
gen_frame->previous = NULL;
|
||||
_PyFrame_StackPush(frame, retval);
|
||||
goto resume_frame;
|
||||
|
@ -2207,10 +2204,10 @@ dummy_func(
|
|||
OBJECT_STAT_INC(optimization_attempts);
|
||||
frame = _PyOptimizer_BackEdge(frame, here, next_instr, stack_pointer);
|
||||
if (frame == NULL) {
|
||||
frame = cframe.current_frame;
|
||||
frame = tstate->current_frame;
|
||||
goto resume_with_error;
|
||||
}
|
||||
assert(frame == cframe.current_frame);
|
||||
assert(frame == tstate->current_frame);
|
||||
here[1].cache &= ((1 << OPTIMIZER_BITS_IN_COUNTER) -1);
|
||||
goto resume_frame;
|
||||
}
|
||||
|
@ -2238,7 +2235,7 @@ dummy_func(
|
|||
Py_INCREF(executor);
|
||||
frame = executor->execute(executor, frame, stack_pointer);
|
||||
if (frame == NULL) {
|
||||
frame = cframe.current_frame;
|
||||
frame = tstate->current_frame;
|
||||
goto resume_with_error;
|
||||
}
|
||||
goto resume_frame;
|
||||
|
@ -2993,12 +2990,11 @@ dummy_func(
|
|||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
new_frame->previous = frame;
|
||||
CALL_STAT_INC(inlined_py_calls);
|
||||
frame = tstate->current_frame = new_frame;
|
||||
#if TIER_ONE
|
||||
frame = cframe.current_frame = new_frame;
|
||||
goto start_frame;
|
||||
#endif
|
||||
#if TIER_TWO
|
||||
frame = tstate->cframe->current_frame = new_frame;
|
||||
ERROR_IF(_Py_EnterRecursivePy(tstate), exit_unwind);
|
||||
stack_pointer = _PyFrame_GetStackPointer(frame);
|
||||
ip_offset = (_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive;
|
||||
|
@ -3135,7 +3131,7 @@ dummy_func(
|
|||
/* Link frames */
|
||||
init_frame->previous = shim;
|
||||
shim->previous = frame;
|
||||
frame = cframe.current_frame = init_frame;
|
||||
frame = tstate->current_frame = init_frame;
|
||||
CALL_STAT_INC(inlined_py_calls);
|
||||
/* Account for pushing the extra frame.
|
||||
* We don't check recursion depth here,
|
||||
|
@ -3598,7 +3594,7 @@ dummy_func(
|
|||
assert(frame != &entry_frame);
|
||||
_PyInterpreterFrame *prev = frame->previous;
|
||||
_PyThreadState_PopFrame(tstate, frame);
|
||||
frame = cframe.current_frame = prev;
|
||||
frame = tstate->current_frame = prev;
|
||||
_PyFrame_StackPush(frame, (PyObject *)gen);
|
||||
goto resume_frame;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue