Add framework for generating modules for intrinsic functions
Categories
(Core :: JavaScript: WebAssembly, task, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox92 | --- | fixed |
People
(Reporter: rhunt, Assigned: rhunt)
References
Details
Attachments
(1 file)
Implement a framework for generating a wasm module that can be instantiated with a memory to provide an instance that exports an intrinsic function that can be linked against.
Assignee | ||
Comment 1•4 years ago
|
||
This commit implements a framework for creating 'intrinsics' which are
natively implemented functions that are exposable as wasm functions
that can be called or linked against. A simple 8-bit dot product for
vectors is implemented as a proof of concept.
The basic API is:
let module = wasmIntrinsicI8Dot(); // WebAssembly.Module
let memory = new WebAssembly.Module({ initial: pageSize });
let instance = new WebAssembly.Instance(module,
{ "": { memory } });
instance.exports.i8dot(dest, src1, src2, len);
The implementation is mainly done through CompileIntrisicModule
which
manually builds a ModuleEnvironment with an imported memory, and a single
exported function which is of the bytecode form:
(func (params ...)
local.get 0
...
local.get n
private_intrinsic_opcode
)
The private_intrinsic_opcode is implemented as an instance call. An
additional heap base parameter is added which allows quick bounds
checking, similar to Instance::memory32Copy.
A followup will implement the intrinsic for the firefox
translations project.
Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Comment 3•4 years ago
|
||
bugherder |
Description
•