diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 1942eb3bb4039d..d523340c5d485b 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2174,8 +2174,7 @@ dummy_func( PyObject *attr_o = FT_ATOMIC_LOAD_PTR_RELAXED(ep->me_value); DEAD(mod_keys); // Clear mod_keys from stack in case we need to deopt - SAVE_STACK(); - RELOAD_STACK(); + POP_DEAD_INPUTS(); DEOPT_IF(attr_o == NULL); #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&ep->me_value, attr_o, &attr); diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 8f762c6c1c1d49..daf0f37c0bf967 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -2681,8 +2681,6 @@ // Clear mod_keys from stack in case we need to deopt stack_pointer += -1; assert(WITHIN_STACK_BOUNDS()); - _PyFrame_SetStackPointer(frame, stack_pointer); - stack_pointer = _PyFrame_GetStackPointer(frame); if (attr_o == NULL) { UOP_STAT_INC(uopcode, miss); JUMP_TO_JUMP_TARGET(); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 6a2ce425f3c4c6..74a488a271bbbb 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -5581,8 +5581,6 @@ PyDictUnicodeEntry *ep = DK_UNICODE_ENTRIES(mod_keys) + index; PyObject *attr_o = FT_ATOMIC_LOAD_PTR_RELAXED(ep->me_value); // Clear mod_keys from stack in case we need to deopt - _PyFrame_SetStackPointer(frame, stack_pointer); - stack_pointer = _PyFrame_GetStackPointer(frame); DEOPT_IF(attr_o == NULL, LOAD_ATTR); #ifdef Py_GIL_DISABLED int increfed = _Py_TryIncrefCompareStackRef(&ep->me_value, attr_o, &attr); diff --git a/Tools/cases_generator/generators_common.py b/Tools/cases_generator/generators_common.py index dad2557e97a948..41d3152800b675 100644 --- a/Tools/cases_generator/generators_common.py +++ b/Tools/cases_generator/generators_common.py @@ -120,6 +120,7 @@ def __init__(self, out: CWriter): "PyStackRef_AsPyObjectSteal": self.stackref_steal, "DISPATCH": self.dispatch, "INSTRUCTION_SIZE": self.instruction_size, + "POP_DEAD_INPUTS": self.pop_dead_inputs, } self.out = out @@ -348,6 +349,19 @@ def save_stack( self.emit_save(storage) return True + def pop_dead_inputs( + self, + tkn: Token, + tkn_iter: TokenIterator, + uop: Uop, + storage: Storage, + inst: Instruction | None, + ) -> None: + next(tkn_iter) + next(tkn_iter) + next(tkn_iter) + storage.pop_dead_inputs(self.out) + def emit_reload(self, storage: Storage) -> None: storage.reload(self.out) self._print_storage(storage) diff --git a/Tools/cases_generator/stack.py b/Tools/cases_generator/stack.py index 286f47d0cfb11b..9471fe0e56f7d8 100644 --- a/Tools/cases_generator/stack.py +++ b/Tools/cases_generator/stack.py @@ -512,6 +512,10 @@ def flush(self, out: CWriter, cast_type: str = "uintptr_t", extract_bits: bool = self._push_defined_outputs() self.stack.flush(out, cast_type, extract_bits) + def pop_dead_inputs(self, out: CWriter, cast_type: str = "uintptr_t", extract_bits: bool = True) -> None: + self.clear_dead_inputs() + self.stack.flush(out, cast_type, extract_bits) + def save(self, out: CWriter) -> None: assert self.spilled >= 0 if self.spilled == 0: