8000 Improve internal API for fetching original instruction, replacing `_Py_GetBaseOpcode` · Issue #122390 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Improve internal API for fetching original instruction, replacing _Py_GetBaseOpcode #122390

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

Closed
markshannon opened this issue < 8000 relative-time datetime="2024-07-29T09:52:14Z" class="no-wrap">Jul 29, 2024 · 0 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@markshannon
Copy link
Member
markshannon commented Jul 29, 2024

The function _Py_GetBaseOpcode returns the original opcode for an instruction, even if that instruction has been instrumented.
However it doesn't work for ENTER_EXECUTOR and doesn't allow for the op.arg to have been changed.

We should add a new _Py_GetBaseInstruction which handles ENTER_EXECUTOR as well, and is efficient enough to use in the few places where it is used outside of an assert, such as in is_resume which is used in gen_close.

The new API will be either

_Py_CODEUNIT _Py_GetBaseInstruction(PyCodeObject *code, int i)

or

_Py_CODEUNIT _Py_GetBaseInstruction(PyCodeObject *code, _Py_CODEUNIT *)

depending on which is the most convenient for the current use cases.

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

2 participants
0