mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +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
|
@ -263,22 +263,32 @@ write_instr(_Py_CODEUNIT *codestr, struct instr *instruction, int ilen)
|
|||
int caches = _PyOpcode_Caches[opcode];
|
||||
switch (ilen - caches) {
|
||||
case 4:
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 24) & 0xFF);
|
||||
codestr->opcode = EXTENDED_ARG;
|
||||
codestr->oparg = (oparg >> 24) & 0xFF;
|
||||
codestr++;
|
||||
/* fall through */
|
||||
case 3:
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 16) & 0xFF);
|
||||
codestr->opcode = EXTENDED_ARG;
|
||||
codestr->oparg = (oparg >> 16) & 0xFF;
|
||||
codestr++;
|
||||
/* fall through */
|
||||
case 2:
|
||||
*codestr++ = _Py_MAKECODEUNIT(EXTENDED_ARG, (oparg >> 8) & 0xFF);
|
||||
codestr->opcode = EXTENDED_ARG;
|
||||
codestr->oparg = (oparg >> 8) & 0xFF;
|
||||
codestr++;
|
||||
/* fall through */
|
||||
case 1:
|
||||
*codestr++ = _Py_MAKECODEUNIT(opcode, oparg & 0xFF);
|
||||
codestr->opcode = opcode;
|
||||
codestr->oparg = oparg & 0xFF;
|
||||
codestr++;
|
||||
break;
|
||||
default:
|
||||
Py_UNREACHABLE();
|
||||
}
|
||||
while (caches--) {
|
||||
*codestr++ = _Py_MAKECODEUNIT(CACHE, 0);
|
||||
codestr->opcode = CACHE;
|
||||
codestr->oparg = 0;
|
||||
codestr++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue