You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Constant evaluate/propagate pure ops automatically #132732
@brandtbucher pointed out that we could automatically evaluate pure ops in the JIT.
Back when I originally envisioned this in the JIT optimizer, it was way simpler. Right now we have stackrefs which complicate things a little.
The main idea is that fully pure bytecodes can just run their body in the JIT optimizer, allowing for automatic constant prop/evaluation. This also cuts down code duplication and also the amount of human error from manually writing constant propagation code.
We'd have to replace all the stackref functions with the appropriate sym accessing functions, either through macros or the cases generator.
Just talked with @savannahostrowski, she's going to modify the cases generator to replace the entire instruction when constant evaluation produces an immortal value.
@savannahostrowski we still have this left #136048 . The problem is with these constant propagation, the optimizer can now error, and we need to handle that properly.
Activity
brandtbucher commentedon Apr 24, 2025
Two follow-ups to this:
pure_guard, which evaluates guards in the optimizer and removes the op if it doesn't deopt.pureinstructions with_POP_TOP_*_LOAD_CONST_INLINE_BORROWor whatever if the result is immortal.gh-132732: Automatically constant evaluate pure operations (GH-132733)
pythongh-132732: Treat `bytes` as constants in `_Py_uop_sym_is_safe_c…
gh-132732: JIT: Only allow compact ints in pure evaluation (GH-136040)
brandtbucher commentedon Jun 27, 2025
Just talked with @savannahostrowski, she's going to modify the cases generator to replace the entire instruction when constant evaluation produces an immortal value.
gh-132732: Fix up pure types in JIT (GH-136050)
pythongh-132732: Automatically constant evaluate pure operations (pyt…
pythongh-132732: JIT: Only allow compact ints in pure evaluation (pyt…
pythongh-132732: Fix up pure types in JIT (pythonGH-136050)
pythongh-132732: Automatically constant evaluate pure operations (pyt…
pythongh-132732: JIT: Only allow compact ints in pure evaluation (pyt…
4 remaining items
pythongh-132732: Fix up pure types in JIT (pythonGH-136050)
pythongh-132732: Automatically constant evaluate pure operations (pyt…
pythongh-132732: JIT: Only allow compact ints in pure evaluation (pyt…
pythongh-132732: Fix up pure types in JIT (pythonGH-136050)
pythonGH-132732: Use pure op machinery to optimize `COMPARE_OP_INT/FL…
GH-132732: Use pure op machinery to optimize various instructions wit…
savannahostrowski commentedon Sep 15, 2025
@Fidget-Spinner @brandtbucher Are we good to close this out after #137577 or is there more I should work on here? 😈
Fidget-Spinner commentedon Sep 15, 2025
@savannahostrowski we still have this left #136048 . The problem is with these constant propagation, the optimizer can now error, and we need to handle that properly.
GH-132732: Remove textwrap import (#138933)
savannahostrowski commentedon Sep 15, 2025
Ah! I missed that. I'll reassign this issue to you, and you can close it out when that lands.
gh-132732: Clear errors in JIT optimizer on error (GH-136048)
Fidget-Spinner commentedon Sep 15, 2025
This is done! Thanks Savannah!