Add attributes to the JIT optimizer DSL #132967
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
topic-JIT
type-feature
A feature request or enhancement
Feature or enhancement
Proposal:
Partially discussed here: faster-cpython/ideas#728
We want to teach the JIT types optimizer the types of its stack variables. This, when combined with
pure
operations, will allow us to shift more things to the DSL. There are numerous benefits to moving things to the DSL:pure
operations don't check for their types before executing them. In a simple uop format, this is safe, but it's not robust if we change the uop format or project more advanced uops.The implementation will only affect
optimizer_bytecodes.c
. There has been some discussion about the growing complexity ofbytecodes.c
. Since this is also specific to the types specializer, we should keep it out ofbytecodes.c
.Consider the following:
Current:
New:
This isn't very powerful on it's own, but when combined with the
pure
optimization, it will allow us to validate properly advanced pure uops before evaluating them.Consider the following code right now:
The constant eval part doesn't check for matching types first. This is currently safe as
_BINARY_OP_ADD_INT
always follows a guard in tier 1. However, it's not safe once we do things like combining specialization passes (#128939), reorganizing them, or introducing more advanced pure uops. it would be tedious and error-prone to handwrite these checks ourselves. When thepure
optimization is combined with the type attributes, or with const attributes, they will be able to automatically validate themselves.Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: