mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
GH-127705: Use _PyStackRef
s in the default build. (GH-127875)
This commit is contained in:
parent
7cc99a54b7
commit
2bef8ea8ea
21 changed files with 688 additions and 254 deletions
|
@ -50,24 +50,23 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
|
|||
{
|
||||
assert(frame->owner < FRAME_OWNED_BY_INTERPRETER);
|
||||
assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
|
||||
Py_ssize_t size = ((char*)frame->stackpointer) - (char *)frame;
|
||||
memcpy((_PyInterpreterFrame *)f->_f_frame_data, frame, size);
|
||||
frame = (_PyInterpreterFrame *)f->_f_frame_data;
|
||||
frame->stackpointer = (_PyStackRef *)(((char *)frame) + size);
|
||||
frame->f_executable = PyStackRef_DUP(frame->f_executable);
|
||||
f->f_frame = frame;
|
||||
frame->owner = FRAME_OWNED_BY_FRAME_OBJECT;
|
||||
if (_PyFrame_IsIncomplete(frame)) {
|
||||
_PyInterpreterFrame *new_frame = (_PyInterpreterFrame *)f->_f_frame_data;
|
||||
_PyFrame_Copy(frame, new_frame);
|
||||
// _PyFrame_Copy takes the reference to the executable,
|
||||
// so we need to restore it.
|
||||
frame->f_executable = PyStackRef_DUP(new_frame->f_executable);
|
||||
f->f_frame = new_frame;
|
||||
new_frame->owner = FRAME_OWNED_BY_FRAME_OBJECT;
|
||||
if (_PyFrame_IsIncomplete(new_frame)) {
|
||||
// This may be a newly-created generator or coroutine frame. Since it's
|
||||
// dead anyways, just pretend that the first RESUME ran:
|
||||
PyCodeObject *code = _PyFrame_GetCode(frame);
|
||||
frame->instr_ptr =
|
||||
_PyFrame_GetBytecode(frame) + code->_co_firsttraceable + 1;
|
||||
PyCodeObject *code = _PyFrame_GetCode(new_frame);
|
||||
new_frame->instr_ptr =
|
||||
_PyFrame_GetBytecode(new_frame) + code->_co_firsttraceable + 1;
|
||||
}
|
||||
assert(!_PyFrame_IsIncomplete(frame));
|
||||
assert(!_PyFrame_IsIncomplete(new_frame));
|
||||
assert(f->f_back == NULL);
|
||||
_PyInterpreterFrame *prev = _PyFrame_GetFirstComplete(frame->previous);
|
||||
frame->previous = NULL;
|
||||
if (prev) {
|
||||
assert(prev->owner < FRAME_OWNED_BY_INTERPRETER);
|
||||
/* Link PyFrameObjects.f_back and remove link through _PyInterpreterFrame.previous */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue