mirror of
https://github.com/python/cpython
synced 2026-09-29 09:40:29 +03:00
gh-106581: Project through calls (#108067)
This finishes the work begun in gh-107760. When, while projecting a superblock, we encounter a call to a short, simple function, the superblock will now enter the function using `_PUSH_FRAME`, continue through it, and leave it using `_POP_FRAME`, and then continue through the original code. Multiple frame pushes and pops are even possible. It is also possible to stop appending to the superblock in the middle of a called function, when running out of space or encountering an unsupported bytecode.
This commit is contained in:
parent
292a22bdc2
commit
61c7249759
16 changed files with 409 additions and 109 deletions
|
|
@ -364,10 +364,12 @@ class Analyzer:
|
|||
case Instruction() as instr:
|
||||
part, offset = self.analyze_instruction(instr, offset)
|
||||
parts.append(part)
|
||||
flags.add(instr.instr_flags)
|
||||
if instr.name != "SAVE_IP":
|
||||
# SAVE_IP in a macro is a no-op in Tier 1
|
||||
flags.add(instr.instr_flags)
|
||||
case _:
|
||||
typing.assert_never(component)
|
||||
format = "IB"
|
||||
format = "IB" if flags.HAS_ARG_FLAG else "IX"
|
||||
if offset:
|
||||
format += "C" + "0" * (offset - 1)
|
||||
return MacroInstruction(macro.name, format, flags, macro, parts, offset)
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ def write_components(
|
|||
poke.as_stack_effect(lax=True),
|
||||
)
|
||||
|
||||
if mgr.instr.name == "_PUSH_FRAME":
|
||||
if mgr.instr.name in ("_PUSH_FRAME", "_POP_FRAME"):
|
||||
# Adjust stack to min_offset (input effects materialized)
|
||||
out.stack_adjust(mgr.min_offset.deep, mgr.min_offset.high)
|
||||
# Use clone() since adjust_inverse() mutates final_offset
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue