What is the status of JIT compilation for OCaml today?

My intent was to try the small DSL with a couple of operations (functions) which are kind of commutative, but reordering of arguments should matter for performance. No mainstream constructions like ints, bools, or branching is planned for this DSL

Maybe I actually need an offline PGO instead of JIT…

To be sure I understand well: you (will) have a DSL that is evaluated by an OCaml interpreter and you would like to be able to specialize the execution of some DSL constructions when you know (potentially at runtime) what argument reordering will be the most efficient?

I have a DSL as shallow embedding to OCaml. OCaml functions call predefined DSL builtins, and I want to reorder arguments of this builtins using the information about OCaml functions’ arguments. This reordering could not be done via ahead-of-time compilation, because it depends actual values of OCaml functions’ arguments.

Thank you for these details.
The question that comes to my mind is: for how long is the “reordered function call” valid?
(for example, JIT will be more interesting if it is “one specialization per program execution and many calls” whereas, I believe, counterproductive if it is “compute it every time the primitive is called”).

Just in case, would you mind sharing the code if it is open source?

GitHub - Kakadu/relational_appendo We probably should continue discussion there, instead of this topic.

I can’t answer it yet. I’m currently interesting how JITting is going to be implemented technically. Discovering right heuristics is another big topic…