Description
We should remove the conditional stack effects in instruction definitions in bytecodes.c
Conditional stack effects already complicate code generation and that is only going to get worse with top-of-stack caching and other interpreter/JIT optimizations.
There were two reasons for having conditional stack effects:
- Ease of porting the old ceval code to bytecodes.c
- Performance
Reason 1 no longer applies. Instructions are much more regular now and it isn't that much work to remove the remaining conditional stack effects.
That leaves performance. I experimentally removed the conditional stack effects for LOAD_GLOBAL
and LOAD_ATTR
which is the worse possible case for performance as it makes no attempt to mitigate the extra dispatch costs and possibly worse specialization.
The results are here
Overall we see a 0.8% slowdown. It seems that specialization is not significantly worse, but there is a large increase in PUSH_NULL
following LOAD_GLOBAL
that appears to responsible for the slowdown. An extra specialization should fix that.