kellysmith12.21
2021-2-27 19:36:09

Does Racket CS have the features necessary features to “straightforwardly” support a hybrid of ahead-of-time and just-in-time compilation? In particular, the majority of a module is compiled upfront, but select, localized portions are deferred for JIT compilation.


mflatt
2021-2-27 19:51:20

It depends on exactly what you have in mind. You can always use eval to implement a JIT-like layer. You can also get Racket CS to use JIT mode at the granularity of a module by setting PLT_CS_JIT when compiling the module (and that JIT mode essentially uses eval when a JIT-mode function is called).


kellysmith12.21
2021-2-27 20:09:52

I was thinking that, in the context of optimization, some programs really benefit from JIT compilation, but, in general, the overhead of JIT on a program can negate the benefits of the optimizations. So, I have a hypothesis that small fragments of a program could be handled by a JIT, when static analysis can’t optimize much, to get the best of both AOT and JIT.


kellysmith12.21
2021-2-27 20:14:33

I’ve no clue if that idea would actually hold up.


samth
2021-2-28 00:39:49

I think neither Racket BC nor CS are well suited to do this easily. You really want to aggressively optimize the jitted part, based on values already available, but the compiler is not set up to do this. You could probably extend some parts of the compiler to help you, but it would be significant work.


kellysmith12.21
2021-2-28 00:57:23

Oh well :shrug: I figured it’d be worth checking.


samth
2021-2-28 01:09:55

I think the idea is reasonable (and is borne out in lots of JIT systems) and you could investigate it in the context of Racket but you’d have to do a lot of compiler work


kellysmith12.21
2021-2-28 03:55:19

I’m presently not qualified to try forking the compiler, so I’ll shelve that idea for a later date.