mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
GH-100222: Redefine _Py_CODEUNIT as a union to clarify structure of code unit. (GH-100223)
This commit is contained in:
parent
985a71032b
commit
6997e77bdf
9 changed files with 150 additions and 134 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue