diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2023-10-24 20:27:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-24 20:27:42 (GMT) |
commit | e5168ff3f8abe651d0a96d9e2d49028183e21b15 (patch) | |
tree | 88848e19dfca490bba80f7f712fef2678dfcf5ac /Python/optimizer.c | |
parent | c0ea67dd0d67a8ac59c61c777eae26288d3ac0f6 (diff) | |
download | cpython-e5168ff3f8abe651d0a96d9e2d49028183e21b15.zip cpython-e5168ff3f8abe651d0a96d9e2d49028183e21b15.tar.gz cpython-e5168ff3f8abe651d0a96d9e2d49028183e21b15.tar.bz2 |
GH-109214: _SET_IP before _PUSH_FRAME (but not _POP_FRAME) (GH-111001)
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r-- | Python/optimizer.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index 8d19de2..3dfd4f3 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -701,7 +701,9 @@ pop_jump_if_bool: case OPARG_BOTTOM: // Second half of super-instr oparg = orig_oparg & 0xF; break; - case OPARG_SET_IP: // op==_SET_IP; oparg=next instr + case OPARG_SET_IP: // uop=_SET_IP; oparg=next_instr-1 + // The number of caches is smuggled in via offset: + assert(offset == _PyOpcode_Caches[_PyOpcode_Deopt[opcode]]); oparg = INSTR_IP(instr + offset, code); uop = _SET_IP; break; @@ -850,11 +852,7 @@ remove_unneeded_uops(_PyUOpInstruction *trace, int trace_length) bool need_ip = true; for (int pc = 0; pc < trace_length; pc++) { int opcode = trace[pc].opcode; - if (opcode == _SAVE_CURRENT_IP) { - // Special case: never remove preceding _SET_IP - last_set_ip = -1; - } - else if (opcode == _SET_IP) { + if (opcode == _SET_IP) { if (!need_ip && last_set_ip >= 0) { trace[last_set_ip].opcode = NOP; } @@ -866,8 +864,8 @@ remove_unneeded_uops(_PyUOpInstruction *trace, int trace_length) break; } else { - // If opcode has ERROR or DEOPT, set need_up to true - if (_PyOpcode_opcode_metadata[opcode].flags & (HAS_ERROR_FLAG | HAS_DEOPT_FLAG)) { + // If opcode has ERROR or DEOPT, set need_ip to true + if (_PyOpcode_opcode_metadata[opcode].flags & (HAS_ERROR_FLAG | HAS_DEOPT_FLAG) || opcode == _PUSH_FRAME) { need_ip = true; } } |