mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
GH-103488: Use return-offset, not yield-offset. (GH-103502)
* Use return-offset, not yield-offset, so that instruction pointer is correct when sending to a generator or coroutine.
This commit is contained in:
parent
4307feaddc
commit
efb8a2553c
6 changed files with 455 additions and 414 deletions
|
@ -61,7 +61,13 @@ typedef struct _PyInterpreterFrame {
|
|||
// over, or (in the case of a newly-created frame) a totally invalid value:
|
||||
_Py_CODEUNIT *prev_instr;
|
||||
int stacktop; /* Offset of TOS from localsplus */
|
||||
uint16_t yield_offset;
|
||||
/* The return_offset determines where a `RETURN` should go in the caller,
|
||||
* relative to `prev_instr`.
|
||||
* It is only meaningful to the callee,
|
||||
* so it needs to be set in any CALL (to a Python function)
|
||||
* or SEND (to a coroutine or generator).
|
||||
* If there is no callee, then it is meaningless. */
|
||||
uint16_t return_offset;
|
||||
char owner;
|
||||
/* Locals and stack */
|
||||
PyObject *localsplus[1];
|
||||
|
@ -121,7 +127,7 @@ _PyFrame_Initialize(
|
|||
frame->stacktop = code->co_nlocalsplus;
|
||||
frame->frame_obj = NULL;
|
||||
frame->prev_instr = _PyCode_CODE(code) - 1;
|
||||
frame->yield_offset = 0;
|
||||
frame->return_offset = 0;
|
||||
frame->owner = FRAME_OWNED_BY_THREAD;
|
||||
|
||||
for (int i = null_locals_from; i < code->co_nlocalsplus; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue