dyllongagnier
2021-3-2 22:40:45

One optimization that I think is amenable to JIT in Racket is monomorphization of generics. i.e., replace some function which is completely generic with a version that assumes a type for some argument but checks said type at the start of the function, falling back to the slow general function if this assumption fails. Obviously this probably doesn’t make much sense for functions, but it might make sense for generics/objects in order to avoid symbol resolution and vtable lookups.


dyllongagnier
2021-3-2 22:44:28

Racket doesn’t seem very clever at the moment regarding optimization here from the benchmarks I’ve run. Another related optimization would be detecting if a higher order function keeps getting passed the same thunk and then trying to inline said thunk.


samth
2021-3-3 00:55:41

An aggressive jit can do quite well for Racket; see my paper on Pycket in ICFP 2015 for more on this.