You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
For imported math functions, it generates a small Wasm function that implement it (I believe this function can then get inlined).
It recognizes imported functions such as Function.prototype.call.bind(DataView.prototype.getInt8) and generates inlined code (with Turboshaft).
The JS String Builtins proposal allows to import a standardized sets of functions to manipulate strings.
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:
UTF-8 encoding / decoding.
Math functions, from the Math object as well as the JavaScript remainder operator.
Functions to access array buffers.
Possibly also:
Conversion functions: between JS numbers and Wasm floats and i32, between booleans and i32.
Equality functions, method calls, array creation and access (I'm not sure this makes sense, though, since these are optimized in JS by tracing the execution and generating specialized code depending on what it really manipulated, which we probably don't want to to in Wasm).
Operations on Map and WeakMap objects.
BigInt operations (for zarith).
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.
The text was updated successfully, but these errors were encountered:
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.
Function.prototype.call.bind(DataView.prototype.getInt8)
and generates inlined code (with Turboshaft).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:
Math
object as well as the JavaScript remainder operator.Possibly also:
Map
andWeakMap
objects.BigInt
operations (forzarith
).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.The text was updated successfully, but these errors were encountered: