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:
Ken Jin 2023-08-16 02:04:17 +08:00 committed by GitHub
parent 34e1917912
commit e28b0dc86d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 1118 additions and 9 deletions

View file

@ -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);")