Skip to content

Commit

Permalink
Add POP_DEAD_INPUTS
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Dec 4, 2024
1 parent c8f8428 commit 3bfbf91
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Tools/cases_generator/generators_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Tools/cases_generator/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3bfbf91

Please sign in to comment.