From 6997e77bdf2297375962aaf82876da4e7ecdd61a Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Wed, 14 Dec 2022 11:12:53 +0000 Subject: GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code unit. (GH-100223) --- Objects/codeobject.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Objects') diff --git a/Objects/codeobject.c b/Objects/codeobject.c index c92c7deaf8..f455cc603a 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; } -- cgit v1.2.1