diff options
author | Guido van Rossum <guido@python.org> | 2023-07-06 23:46:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-06 23:46:06 (GMT) |
commit | e1d45b8ed43e1590862319fec33539f8adbc0849 (patch) | |
tree | 2a6a80fda614860c65bb8e4e3f8bc91f4e5b92d5 /Python/optimizer.c | |
parent | c60df361ce2d734148d503f4a711e67c110fe223 (diff) | |
download | cpython-e1d45b8ed43e1590862319fec33539f8adbc0849.zip cpython-e1d45b8ed43e1590862319fec33539f8adbc0849.tar.gz cpython-e1d45b8ed43e1590862319fec33539f8adbc0849.tar.bz2 |
gh-104584: Handle EXTENDED_ARG in superblock creation (#106489)
With test.
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r-- | Python/optimizer.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index d2fdca5..db117bb 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -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); |