Skip to content
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

bpo-46841: Add a _Py_SET_OPCODE macro #31780

Merged
merged 2 commits into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ typedef uint16_t _Py_CODEUNIT;
# define _Py_MAKECODEUNIT(opcode, oparg) ((opcode)|((oparg)<<8))
#endif

#define _Py_SET_OPCODE(word, opcode) (((uint8_t *)&(word))[0] = (opcode))
sweeneyde marked this conversation as resolved.
Show resolved Hide resolved
brandtbucher marked this conversation as resolved.
Show resolved Hide resolved


/* Bytecode object */
struct PyCodeObject {
Expand Down
2 changes: 1 addition & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -5517,7 +5517,7 @@ opname ## _miss: \
_Py_CODEUNIT *counter = (_Py_CODEUNIT *)next_instr; \
*counter -= 1; \
if (*counter == 0) { \
next_instr[-1] = _Py_MAKECODEUNIT(opname ## _ADAPTIVE, _Py_OPARG(next_instr[-1])); \
_Py_SET_OPCODE(next_instr[-1], opname ## _ADAPTIVE); \
STAT_INC(opname, deopt); \
*counter = ADAPTIVE_CACHE_BACKOFF; \
} \
Expand Down
Loading