Skip to content

Commit 8062a6e

Browse files
committed
Support EXTENDED_ARG
1 parent 76fac7b commit 8062a6e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Python/optimizer.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@ translate_bytecode_to_trace(
412412
ADD_TO_TRACE(SAVE_IP, (int)(instr - (_Py_CODEUNIT *)code->co_code_adaptive));
413413
int opcode = instr->op.code;
414414
uint64_t operand = instr->op.arg;
415+
int extras = 0;
416+
while (opcode == EXTENDED_ARG) {
417+
instr++;
418+
extras += 1;
419+
opcode = instr->op.code;
420+
operand = (operand << 8) | instr->op.arg;
421+
}
415422
switch (opcode) {
416423
case LOAD_FAST_LOAD_FAST:
417424
case STORE_FAST_LOAD_FAST:
@@ -458,6 +465,15 @@ translate_bytecode_to_trace(
458465
int offset = expansion->uops[i].offset;
459466
switch (expansion->uops[i].size) {
460467
case 0:
468+
if (extras && OPCODE_HAS_JUMP(opcode)) {
469+
if (opcode == JUMP_BACKWARD_NO_INTERRUPT) {
470+
operand -= extras;
471+
}
472+
else {
473+
assert(opcode != JUMP_BACKWARD);
474+
operand += extras;
475+
}
476+
}
461477
break;
462478
case 1:
463479
operand = read_u16(&instr[offset].cache);

0 commit comments

Comments
 (0)