Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2d61cc

Browse files
committed
Support EXTENDED_ARG
1 parent e7cd557 commit c2d61cc

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
@@ -408,6 +408,13 @@ translate_bytecode_to_trace(
408408
ADD_TO_TRACE(SAVE_IP, (int)(instr - (_Py_CODEUNIT *)code->co_code_adaptive));
409409
int opcode = instr->op.code;
410410
uint64_t operand = instr->op.arg;
411+
int extras = 0;
412+
while (opcode == EXTENDED_ARG) {
413+
instr++;
414+
extras += 1;
415+
opcode = instr->op.code;
416+
operand = (operand << 8) | instr->op.arg;
417+
}
411418
switch (opcode) {
412419
case LOAD_FAST_LOAD_FAST:
413420
case STORE_FAST_LOAD_FAST:
@@ -454,6 +461,15 @@ translate_bytecode_to_trace(
454461
int offset = expansion->uops[i].offset;
455462
switch (expansion->uops[i].size) {
456463
case 0:
464+
if (extras && OPCODE_HAS_JUMP(opcode)) {
465+
if (opcode == JUMP_BACKWARD_NO_INTERRUPT) {
466+
operand -= extras;
467+
}
468+
else {
469+
assert(opcode != JUMP_BACKWARD);
470+
operand += extras;
471+
}
472+
}
457473
break;
458474
case 1:
459475
operand = read_u16(&instr[offset].cache);

0 commit comments

Comments
 (0)