Open
Description
In https://github.com/scala/scala/compare/2.13.x...retronym:faster/transformer-faster?expand=1, I demonstrate an idea I've had for a while to try to optimize our compiler "middle end".
- Replace the
atOwner
idiom inTransformers
withpushOwner
/popOwner
. Subclasses can customise these and stack context intoArrayBuffer
. This will be allocation free, as opposed to the closures that currently need to be allocated to pass toatOwner
. - Avoid the indirection through the bridges implied by
api.Transformer
to reduce the Java stack depth during transforms (making stack traces easier to read, cheaper to collect in profiles, and maybe more inlinable)
This might also lead to a way for us to have a lighter weight localTyper
, without a full Typer/Context
combo.
- Verify correctness of the patch (
partest --pos
works so far) - Benchmark the change for compile speed and allocation rate
- Look at the stack traces of the transform for user friendliness
The followup idea is the try to tag each Type
and Tree
subclass with an Int
and replace our pattern matches on these with a @switch
match.