mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-107557: Setup abstract interpretation (#107847)
Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com> Co-authored-by: Jules <57632293+juliapoo@users.noreply.github.com>
This commit is contained in:
parent
34e1917912
commit
e28b0dc86d
21 changed files with 1118 additions and 9 deletions
|
@ -391,3 +391,32 @@ def write_components(
|
|||
poke.as_stack_effect(),
|
||||
poke.effect,
|
||||
)
|
||||
|
||||
|
||||
def write_single_instr_for_abstract_interp(
|
||||
instr: Instruction, out: Formatter
|
||||
):
|
||||
try:
|
||||
_write_components_for_abstract_interp(
|
||||
[Component(instr, instr.active_caches)],
|
||||
out,
|
||||
)
|
||||
except AssertionError as err:
|
||||
raise AssertionError(f"Error writing abstract instruction {instr.name}") from err
|
||||
|
||||
|
||||
def _write_components_for_abstract_interp(
|
||||
parts: list[Component],
|
||||
out: Formatter,
|
||||
):
|
||||
managers = get_managers(parts)
|
||||
for mgr in managers:
|
||||
if mgr is managers[-1]:
|
||||
out.stack_adjust(mgr.final_offset.deep, mgr.final_offset.high)
|
||||
# Use clone() since adjust_inverse() mutates final_offset
|
||||
mgr.adjust_inverse(mgr.final_offset.clone())
|
||||
# NULL out the output stack effects
|
||||
for poke in mgr.pokes:
|
||||
if not poke.effect.size and poke.effect.name not in mgr.instr.unmoved_names:
|
||||
out.emit(f"PARTITIONNODE_OVERWRITE((_Py_PARTITIONNODE_t *)"
|
||||
f"PARTITIONNODE_NULLROOT, PEEK(-({poke.offset.as_index()})), true);")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue