Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-109094: replace frame->prev_instr by frame->instr_ptr#109095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
637b5daffb980c82a5b921fc0df16bbb1c2be6d428bbe8e2c50a1f3a4beb50b8e4a31058d3bc5909de930a06b75da6c97b6488d696c684b0b6a8b0c1ceeba1371fa66557f36fcb223659875704aea21a6b2221d17078fe53ac7cc65a672a44fd470ed676f9c1afba528b1643aa386dee32b2cfdadd2321218228b0d0c25d4418fc4e07b415cb96aa0729944f44e37eeb3b55ee6f0fe7b2cf7e9466005cec9a9601764bd3730e74deb63c8da8bade188b14bded1387ed9c10b8d287c1a5363979641bba62d363fc3efa8eab86cf45f19da0c0cbee4f83a9a029a44f4db62ca8ce3fa0423488e5e785f08bc012f9113fcfc47d79610776474e33fcbc3a2043c833511bef6a855888ccbe6ed55f048b7f86a7c6d69da0da356b0089b30e1ab25d3e0b86dd0b24697d152602986b9c91eb2a41bd0be391dddc0f3c25b56617d60661dad05a5103b0b68e5496a996c8574469855513a0cf9ec982f9d9d95b63dff2d149b578e266File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -58,26 +58,16 @@ typedef struct _PyInterpreterFrame{ | ||
| PyObject *f_builtins; /* Borrowed reference. Only valid if not on C stack */ | ||
| PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */ | ||
| PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */ | ||
| // NOTE: This is not necessarily the last instruction started in the given | ||
| // frame. Rather, it is the code unit *prior to* the *next* instruction. For | ||
| // example, it may be an inline CACHE entry, an instruction we just jumped | ||
| // over, or (in the case of a newly-created frame) a totally invalid value: | ||
| _Py_CODEUNIT *prev_instr; | ||
| _Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to begin) */ | ||
| int stacktop; /* Offset of TOS from localsplus */ | ||
| /* 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; | ||
| uint16_t return_offset; /* Only relevant during a function call */ | ||
| char owner; | ||
| /* Locals and stack */ | ||
| PyObject *localsplus[1]; | ||
| } _PyInterpreterFrame; | ||
| #define _PyInterpreterFrame_LASTI(IF) \ | ||
| ((int)((IF)->prev_instr - _PyCode_CODE(_PyFrame_GetCode(IF)))) | ||
| ((int)((IF)->instr_ptr - _PyCode_CODE(_PyFrame_GetCode(IF)))) | ||
| static inline PyCodeObject *_PyFrame_GetCode(_PyInterpreterFrame *f){ | ||
| assert(PyCode_Check(f->f_executable)); | ||
| @@ -134,7 +124,7 @@ _PyFrame_Initialize( | ||
| frame->f_locals = locals; | ||
| frame->stacktop = code->co_nlocalsplus; | ||
| frame->frame_obj = NULL; | ||
| frame->prev_instr = _PyCode_CODE(code) - 1; | ||
| frame->instr_ptr = _PyCode_CODE(code); | ||
| frame->return_offset = 0; | ||
| frame->owner = FRAME_OWNED_BY_THREAD; | ||
| @@ -185,7 +175,7 @@ _PyFrame_IsIncomplete(_PyInterpreterFrame *frame) | ||
| return true; | ||
| } | ||
| return frame->owner != FRAME_OWNED_BY_GENERATOR && | ||
| frame->prev_instr < _PyCode_CODE(_PyFrame_GetCode(frame)) + _PyFrame_GetCode(frame)->_co_firsttraceable; | ||
| frame->instr_ptr < _PyCode_CODE(_PyFrame_GetCode(frame)) + _PyFrame_GetCode(frame)->_co_firsttraceable; | ||
iritkatriel marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| static inline _PyInterpreterFrame * | ||
| @@ -297,7 +287,7 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int | ||
| frame->f_locals = NULL; | ||
| frame->stacktop = code->co_nlocalsplus + stackdepth; | ||
| frame->frame_obj = NULL; | ||
| frame->prev_instr = _PyCode_CODE(code); | ||
| frame->instr_ptr = _PyCode_CODE(code); | ||
| frame->owner = FRAME_OWNED_BY_THREAD; | ||
| frame->return_offset = 0; | ||
| return frame; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Replace ``prev_instr`` on the interpreter frame by ``instr_ptr`` which | ||
| points to the beginning of the instruction that is currently executing (or | ||
| will execute once the frame resumes). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,6 +9,7 @@ | ||
| #include "pycore_genobject.h" // struct _Py_async_gen_state | ||
| #include "pycore_modsupport.h" // _PyArg_CheckPositional() | ||
| #include "pycore_object.h" // _PyObject_GC_UNTRACK() | ||
| #include "pycore_opcode_metadata.h" // _PyOpcode_Caches | ||
| #include "pycore_pyerrors.h" // _PyErr_ClearExcState() | ||
| #include "pycore_pystate.h" // _PyThreadState_GET() | ||
| @@ -362,8 +363,7 @@ _PyGen_yf(PyGenObject *gen) | ||
| assert(_PyCode_CODE(_PyGen_GetCode(gen))[0].op.code != SEND); | ||
| return NULL; | ||
| } | ||
| _Py_CODEUNIT next = frame->prev_instr[1]; | ||
| if (!is_resume(&next) || next.op.arg < 2) | ||
| if (!is_resume(frame->instr_ptr) || frame->instr_ptr->op.arg < 2) | ||
| { | ||
| /* Not in a yield from */ | ||
| return NULL; | ||
| @@ -398,9 +398,12 @@ gen_close(PyGenObject *gen, PyObject *args) | ||
| _PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe; | ||
| /* It is possible for the previous instruction to not be a | ||
| * YIELD_VALUE if the debugger has changed the lineno. */ | ||
| if (err == 0 && is_yield(frame->prev_instr)){ | ||
| assert(is_resume(frame->prev_instr + 1)); | ||
| int exception_handler_depth = frame->prev_instr[0].op.arg; | ||
| assert(_PyOpcode_Caches[YIELD_VALUE] == 0); | ||
| assert(_PyOpcode_Caches[INSTRUMENTED_YIELD_VALUE] == 0); | ||
| if (err == 0 && is_yield(frame->instr_ptr - 1)){ | ||
iritkatriel marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page.
iritkatriel marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| _Py_CODEUNIT *yield_instr = frame->instr_ptr - 1; | ||
| assert(is_resume(frame->instr_ptr)); | ||
| int exception_handler_depth = yield_instr->op.arg; | ||
| assert(exception_handler_depth > 0); | ||
| /* We can safely ignore the outermost try block | ||
| * as it automatically generated to handle | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.