[exploration] Experiment with intrinsic functions
Categories
(Core :: JavaScript: WebAssembly, task, P3)
Tracking
()
People
(Reporter: lth, Unassigned)
References
(Blocks 1 open bug)
Details
Background here is the discussion on https://github.com/mozilla-extensions/bergamot-browser-extension/issues/75.
Consider:
(import "mozilla:maybe-intrinsic" "mmul8sat"
(func (param $dest i32) (param $src1 i32) (param $src2 i32) (param $destRows i32) (param $destCols i32)))
which expresses the API to a matrix multiply of 8-bit numbers with saturation: destination and source pointers and the size of the destination matrix, from which the sizes of the source matrices should be derivable, if memory serves.
When linking, the client would supply an actual wasm function conforming to this API but the VM would be at liberty to instead link in a built-in function performing an optimized matrix multiply (even one specialized to the hardware). What would this require?
The target function itself would perform bounds checking before the operation, but since we control the code we could trust it to get that right. The function could also check eg alignment and error out if the alignment is not correct.
For a fixed set of intrinsics we could perhaps go via the existing instance-call mechanism, so there would be very little code to write. The main problem might be that we resolve this at link time, and it may be better for there to be a custom stub for that reason. So we'd need a stub.
I know there's been some discussions about intrinsic imports and it would be valuable to dig those up before going much further.
| Reporter | ||
Updated•4 years ago
|
Description
•