diff options
author | Mark Shannon <mark@hotpy.org> | 2022-12-14 11:12:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-14 11:12:53 (GMT) |
commit | 6997e77bdf2297375962aaf82876da4e7ecdd61a (patch) | |
tree | 7f6540eecbb66fd373b22e944163bdcb436f245b /Objects/codeobject.c | |
parent | 985a71032bf055240e61259285a0b4925c925383 (diff) | |
download | cpython-6997e77bdf2297375962aaf82876da4e7ecdd61a.zip cpython-6997e77bdf2297375962aaf82876da4e7ecdd61a.tar.gz cpython-6997e77bdf2297375962aaf82876da4e7ecdd61a.tar.bz2 |
GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code unit. (GH-100223)
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r-- | Objects/codeobject.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index c92c7de..f455cc6 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -1520,9 +1520,10 @@ deopt_code(_Py_CODEUNIT *instructions, Py_ssize_t len) _Py_CODEUNIT instruction = instructions[i]; int opcode = _PyOpcode_Deopt[_Py_OPCODE(instruction)]; int caches = _PyOpcode_Caches[opcode]; - instructions[i] = _Py_MAKECODEUNIT(opcode, _Py_OPARG(instruction)); + instructions[i].opcode = opcode; while (caches--) { - instructions[++i] = _Py_MAKECODEUNIT(CACHE, 0); + instructions[++i].opcode = CACHE; + instructions[i].oparg = 0; } } } @@ -1775,9 +1776,9 @@ code_richcompare(PyObject *self, PyObject *other, int op) for (int i = 0; i < Py_SIZE(co); i++) { _Py_CODEUNIT co_instr = _PyCode_CODE(co)[i]; _Py_CODEUNIT cp_instr = _PyCode_CODE(cp)[i]; - _Py_SET_OPCODE(co_instr, _PyOpcode_Deopt[_Py_OPCODE(co_instr)]); - _Py_SET_OPCODE(cp_instr, _PyOpcode_Deopt[_Py_OPCODE(cp_instr)]); - eq = co_instr == cp_instr; + co_instr.opcode = _PyOpcode_Deopt[_Py_OPCODE(co_instr)]; + cp_instr.opcode =_PyOpcode_Deopt[_Py_OPCODE(cp_instr)]; + eq = co_instr.cache == cp_instr.cache; if (!eq) { goto unequal; } |