mirror of
https://github.com/python/cpython.git
synced 2025-08-23 10:16:01 +00:00
gh-104584: Handle EXTENDED_ARG in superblock creation (#106489)
With test.
This commit is contained in:
parent
c60df361ce
commit
e1d45b8ed4
2 changed files with 72 additions and 0 deletions
|
@ -412,6 +412,13 @@ translate_bytecode_to_trace(
|
|||
ADD_TO_TRACE(SAVE_IP, (int)(instr - (_Py_CODEUNIT *)code->co_code_adaptive));
|
||||
int opcode = instr->op.code;
|
||||
uint64_t operand = instr->op.arg;
|
||||
int extras = 0;
|
||||
while (opcode == EXTENDED_ARG) {
|
||||
instr++;
|
||||
extras += 1;
|
||||
opcode = instr->op.code;
|
||||
operand = (operand << 8) | instr->op.arg;
|
||||
}
|
||||
switch (opcode) {
|
||||
case LOAD_FAST_LOAD_FAST:
|
||||
case STORE_FAST_LOAD_FAST:
|
||||
|
@ -458,6 +465,15 @@ translate_bytecode_to_trace(
|
|||
int offset = expansion->uops[i].offset;
|
||||
switch (expansion->uops[i].size) {
|
||||
case 0:
|
||||
if (extras && OPCODE_HAS_JUMP(opcode)) {
|
||||
if (opcode == JUMP_BACKWARD_NO_INTERRUPT) {
|
||||
operand -= extras;
|
||||
}
|
||||
else {
|
||||
assert(opcode != JUMP_BACKWARD);
|
||||
operand += extras;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
operand = read_u16(&instr[offset].cache);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue