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

Remove irregular stack effects #105678

Closed
markshannon opened this issue Jun 12, 2023 · 2 comments
Closed

Remove irregular stack effects #105678

markshannon opened this issue Jun 12, 2023 · 2 comments
Labels
performance Performance or resource usage

Comments

@markshannon
Copy link
Member

markshannon commented Jun 12, 2023

As we move towards generating more components from the instruction definition file (bytecodes.c), it helps if the instructions have regular formats and stack effects.
Currently the stack effects can be simple, variable, conditional or complex.

  • Simple: Does not depend on the operand (oparg)
  • Variable: Either pops or pushes oparg * k items.
  • Conditional: Pushes a value conditional on oparg & 1
  • Complex: The stack effect depends on a set of flags embedded in oparg.

We can easily get rid of the complex case. There are only two cases, MAKE_FUNCTION and FORMAT_VALUE. Both can easily broken down into simple (and faster) parts.

We might want to get rid of condition stack effects, as it would simplify things, but performance may suffer as both LOAD_GLOBAL and LOAD_ATTR are conditional and they are performance critical.

Linked PRs

@gvanrossum
Copy link
Member

@markshannon Can this be closed yet? I doubt that we'll be removing conditional stack effects (at least conditional pushes). Note that we now support conditional pushes in the final op of a macro. (If needed the same approach could be used to support conditional pops in the first op.)

@markshannon
Copy link
Member Author

markshannon commented Jun 19, 2023

Yes, this can be closed.
We might want to remove conditional stack effects in the future, but not now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

2 participants