mirror of
https://github.com/python/cpython.git
synced 2025-08-24 02:35:59 +00:00
GH-118095: Handle RETURN_GENERATOR
in tier 2 (GH-118180)
This commit is contained in:
parent
10bb90ed49
commit
f180b31e76
16 changed files with 143 additions and 81 deletions
43
Python/executor_cases.c.h
generated
43
Python/executor_cases.c.h
generated
|
@ -988,12 +988,7 @@
|
|||
_PyFrame_StackPush(frame, retval);
|
||||
LOAD_SP();
|
||||
LOAD_IP(frame->return_offset);
|
||||
#if LLTRACE && TIER_ONE
|
||||
lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
|
||||
if (lltrace < 0) {
|
||||
goto exit_unwind;
|
||||
}
|
||||
#endif
|
||||
LLTRACE_RESUME_FRAME();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3213,12 +3208,7 @@
|
|||
tstate->py_recursion_remaining--;
|
||||
LOAD_SP();
|
||||
LOAD_IP(0);
|
||||
#if LLTRACE && TIER_ONE
|
||||
lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
|
||||
if (lltrace < 0) {
|
||||
goto exit_unwind;
|
||||
}
|
||||
#endif
|
||||
LLTRACE_RESUME_FRAME();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3833,6 +3823,35 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _RETURN_GENERATOR: {
|
||||
PyObject *res;
|
||||
assert(PyFunction_Check(frame->f_funcobj));
|
||||
PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj;
|
||||
PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func);
|
||||
if (gen == NULL) {
|
||||
JUMP_TO_ERROR();
|
||||
}
|
||||
assert(EMPTY());
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
_PyInterpreterFrame *gen_frame = (_PyInterpreterFrame *)gen->gi_iframe;
|
||||
frame->instr_ptr++;
|
||||
_PyFrame_Copy(frame, gen_frame);
|
||||
assert(frame->frame_obj == NULL);
|
||||
gen->gi_frame_state = FRAME_CREATED;
|
||||
gen_frame->owner = FRAME_OWNED_BY_GENERATOR;
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
res = (PyObject *)gen;
|
||||
_PyInterpreterFrame *prev = frame->previous;
|
||||
_PyThreadState_PopFrame(tstate, frame);
|
||||
frame = tstate->current_frame = prev;
|
||||
LOAD_IP(frame->return_offset);
|
||||
LOAD_SP();
|
||||
LLTRACE_RESUME_FRAME();
|
||||
stack_pointer[0] = res;
|
||||
stack_pointer += 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case _BUILD_SLICE: {
|
||||
PyObject *step = NULL;
|
||||
PyObject *stop;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue