gh-104584: Handle EXTENDED_ARG in superblock creation (#106489)

With test.
This commit is contained in:
Guido van Rossum 2023-07-06 16:46:06 -07:00 committed by GitHub
parent c60df361ce
commit e1d45b8ed4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 0 deletions

View file

@ -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);