diff options
author | Mark Shannon <mark@hotpy.org> | 2024-08-01 23:19:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 23:19:05 (GMT) |
commit | df13a1821a90fcfb75eca59aad6af1f0893b1e77 (patch) | |
tree | e917574fea945573980717b4823202049568893e /Python/optimizer.c | |
parent | fda6bd842a2b93a501526f1b830eb900d935ac73 (diff) | |
download | cpython-df13a1821a90fcfb75eca59aad6af1f0893b1e77.zip cpython-df13a1821a90fcfb75eca59aad6af1f0893b1e77.tar.gz cpython-df13a1821a90fcfb75eca59aad6af1f0893b1e77.tar.bz2 |
GH-118095: Add tier two support for BINARY_SUBSCR_GETITEM (GH-120793)
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r-- | Python/optimizer.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index 9d03813..e9cbfc5 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -795,6 +795,7 @@ translate_bytecode_to_trace( assert(i + 1 == nuops); if (opcode == FOR_ITER_GEN || opcode == LOAD_ATTR_PROPERTY || + opcode == BINARY_SUBSCR_GETITEM || opcode == SEND_GEN) { DPRINTF(2, "Bailing due to dynamic target\n"); @@ -921,7 +922,9 @@ done: 2 * INSTR_IP(initial_instr, code)); return 0; } - if (trace[trace_length-1].opcode != _JUMP_TO_TOP) { + if (!is_terminator(&trace[trace_length-1])) { + /* Allow space for _EXIT_TRACE */ + max_length += 2; ADD_TO_TRACE(_EXIT_TRACE, 0, 0, target); } DPRINTF(1, @@ -1102,7 +1105,7 @@ sanity_check(_PyExecutorObject *executor) CHECK(inst->format == UOP_FORMAT_JUMP); CHECK(inst->error_target < executor->code_size); } - if (opcode == _JUMP_TO_TOP || opcode == _EXIT_TRACE) { + if (is_terminator(inst)) { ended = true; i++; break; @@ -1207,8 +1210,7 @@ int effective_trace_length(_PyUOpInstruction *buffer, int length) if (opcode == _NOP) { nop_count++; } - if (opcode == _EXIT_TRACE || - opcode == _JUMP_TO_TOP) { + if (is_terminator(&buffer[i])) { return i+1-nop_count; } } @@ -1257,7 +1259,7 @@ uop_optimize( else if (oparg < _PyUop_Replication[opcode]) { buffer[pc].opcode = opcode + oparg + 1; } - else if (opcode == _JUMP_TO_TOP || opcode == _EXIT_TRACE) { + else if (is_terminator(&buffer[pc])) { break; } assert(_PyOpcode_uop_name[buffer[pc].opcode]); |