Currently the compilation of recursive modules is horrific and cannot be understood at all by inline_and_simplify.
One way to improve that would be to do the 'preallocate then patch' transformation later in the compilation chain. Since making the preallocated blocks requires the size and tag of the value, it would need to propagate some informations on the shape of those values.
The required steps are:
add some way to annotate shape on let_rec constructs
compile recursive modules as let_rec with this annotation
port the camlinternalmod stuffs to the flambda_to_clambda pass
Example that should benefit a lot:
simple recursive toplevel modules will just end up as a large let_rec_symbol
recursive modules with functors can have the functor inlined and have everything fit in the previous case.
Currently the compilation of recursive modules is horrific and cannot be understood at all by inline_and_simplify.
One way to improve that would be to do the 'preallocate then patch' transformation later in the compilation chain. Since making the preallocated blocks requires the size and tag of the value, it would need to propagate some informations on the shape of those values.
The required steps are:
Example that should benefit a lot: