Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-126612: Include stack effects of uops when computing maximum stack depth #126894

Merged
merged 8 commits into from
Nov 26, 2024

Conversation

mpage
Copy link
Contributor

@mpage mpage commented Nov 16, 2024

UOPs may want to pass values on the stack. This is currently only guaranteed to be possible if the net stack effect of the instruction is greater than the number of values that need to be passed.

To ensure there is sufficient space on the stack for values passed between uops, we:

  1. Compute the set of stack effects for each instruction by computing the stack effect after each uop in the instruction.
  2. Collect the set of stack effects for all instructions in a family.
  3. Generate a function that computes the maximum stack effect for each instruction. The maximum stack effect for a generic instruction is the maximum of all instructions in the family.
  4. Use the maximum stack effect when computing the maximum stack depth of a function.

UOPs may want to pass values on the stack. This is currently only guaranteed
to be possible if the net stack effect of the instruction is greater than
the number of values that need to be passed.

To ensure there is sufficient space on the stack for values passed between
uops, we:

1. Compute the set of stack effects for each instruction by computing the
   stack effect after each uop in the instruction.
2. Collect the set of stack effects for all instructions in a family.
3. Generate a function that computes the maximum stack effect for each
   instruction. The maximum stack effect for a generic instruction is
   the maximum of all instructions in the family.
4. Use the maximum stack effect when computing the maximum stack depth
   of a function.
@mpage
Copy link
Contributor Author

mpage commented Nov 16, 2024

@markshannon - This is the generic solution for passing values between uops (rather than always reserving extra space on the stack) we chatted about at the last faster-cpython sync.

@mpage mpage marked this pull request as ready for review November 20, 2024 18:01
Python/flowgraph.c Outdated Show resolved Hide resolved
Python/flowgraph.c Outdated Show resolved Hide resolved
@iritkatriel iritkatriel merged commit 193890c into python:main Nov 26, 2024
50 checks passed
@mpage mpage deleted the gh-126612-uop-pass-values branch November 26, 2024 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants