Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate compilation: generate and use cross module information regarding function arity #92

Open
vouillon opened this issue Oct 4, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@vouillon
Copy link
Collaborator

vouillon commented Oct 4, 2024

We could improve the code generated when compiling cmo files if we knew the arity of the functions exported by each module. This would allow to call functions directly rather than going through an helper function which manages currying. When the function is known, one could also export the corresponding Wasm function so that it can be directly accessed without going through the toplevel module and the closure.

In order for this to work with submodules and functors, we need to know which blocks are immutable (see #91). Alternatively, in the case of functors, it might be possible to refine the escape analysis to recognize that a fresh block returned by a function cannot be mutated by other callers.

This is wasm_of_ocaml counterpart to ocsigen/js_of_ocaml/issues/550. @hhugo has written a draft implementation for js_of_ocaml in ocsigen/js_of_ocaml#1594.

@vouillon vouillon added the enhancement New feature or request label Oct 4, 2024
@OlivierNicole
Copy link
Collaborator

Does this require modifying ocamlc?

@vouillon
Copy link
Collaborator Author

vouillon commented Nov 5, 2024

Without modifying ocamlc, we can get the arity of functions at toplevel, and maybe in functors.
If ocamlc is modified, so that we know with blocks are immutable, we can also deal with submodules. (Otherwise, we don't know whether a block containing functions is a module or a structure with possibly mutable fields.)

@hhugo
Copy link
Contributor

hhugo commented Nov 7, 2024

Here is a experimental (and WIP) support for shapes inside dune ocaml/dune#10767.
I've just rebased it on top of the wasm support in dune.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants