ocaml-wasm / wasm_of_ocaml

Other
249 stars 9 forks source link

JS Builtins #89

Open vouillon opened 1 month ago

vouillon commented 1 month ago

We are using a number of JavaScript functions to implement functionalities that are available in JavaScript but not directly in Wasm or for interoperability. We should make sure that they are well optimized. A way to achieve this is to push for proposals similar to the JS String Builtins to get them optimized. We could either champion other builtins proposals or at least help design them.

V8 currently has three mechanisms to optimize imported JavaScript functions.

The latest mechanism seems best since it explicitly specifies which functions are expected to be optimized by the engine.

We would like these operations to be optimized:

Possibly also:

Regarding array buffers, the DataView API seems the simplest and most flexible (compared to support all the different kinds of typed arrays). One should probably add a way to read and write numbers using the native byte order so that one can reproduce typed array operations. One also needs a way to copy to and from a Wasm array.