mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
GH-96421: Insert shim frame on entry to interpreter (GH-96319)
* Adds EXIT_INTERPRETER instruction to exit PyEval_EvalDefault() * Simplifies RETURN_VALUE, YIELD_VALUE and RETURN_GENERATOR instructions as they no longer need to check for entry frames.
This commit is contained in:
parent
dbf2faf579
commit
1e197e63e2
24 changed files with 450 additions and 346 deletions
|
@ -80,6 +80,7 @@ _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest)
|
|||
static void
|
||||
take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
|
||||
{
|
||||
assert(frame->owner != FRAME_OWNED_BY_CSTACK);
|
||||
assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
|
||||
assert(frame->owner != FRAME_CLEARED);
|
||||
Py_ssize_t size = ((char*)&frame->localsplus[frame->stacktop]) - (char *)frame;
|
||||
|
@ -99,7 +100,9 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
|
|||
while (prev && _PyFrame_IsIncomplete(prev)) {
|
||||
prev = prev->previous;
|
||||
}
|
||||
frame->previous = NULL;
|
||||
if (prev) {
|
||||
assert(prev->owner != FRAME_OWNED_BY_CSTACK);
|
||||
/* Link PyFrameObjects.f_back and remove link through _PyInterpreterFrame.previous */
|
||||
PyFrameObject *back = _PyFrame_GetFrameObject(prev);
|
||||
if (back == NULL) {
|
||||
|
@ -111,7 +114,6 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
|
|||
else {
|
||||
f->f_back = (PyFrameObject *)Py_NewRef(back);
|
||||
}
|
||||
frame->previous = NULL;
|
||||
}
|
||||
if (!_PyObject_GC_IS_TRACKED((PyObject *)f)) {
|
||||
_PyObject_GC_TRACK((PyObject *)f);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue