While I don't expect any contentious debates here, I would suggest that the following details be called out explicitly in the specification, to avoid any uncertainty or surprises:
(1) When a module's import that has been satisfied at compile time is again provided at instantiation time, the copy provided at instantiation time is ignored.
For example, for a module with:
(import "wasm:js-string" "equals" ...)
that's instantiated with:
let module = new WebAssembly.Module(..., {builtins: ["js-string"]});
let instance = new WebAssembly.Instance(module, {
get "js-string"() {
throw "unreachable";
}
});
let instance2 = new WebAssembly.Instance(module, {
"js-string": {
get equals() { throw "unreachable"; }
}
});
no exception is thrown.
(2) When a module attempts to import a function at compile time that isn't being provided by the engine it is running on, then this import simply and silently remains unsatisfied until regular instantiation time, for example:
(import "wasm:js-string" "nonexistent" ...)
let module = new WebAssembly.Module(..., {builtins: ["js-string"]});
let import_has_been_retrieved = false;
let instance = new WebAssembly.Instance(module, {
"js-string": {
get nonexistent() { import_has_been_retrieved = true; return () => 42; },
}
}
assert(import_has_been_retrieved);
(3) When builtins are exported and inspected from JavaScript, they must have names. Presumably these names match their name within the respective collection, for example:
let module = new WebAssembly.Module(..., {builtins: ["js-string"]});
let instance = new WebAssembly.Instance(module);
assert(instance.exports.foo.name === "equals");
While I don't expect any contentious debates here, I would suggest that the following details be called out explicitly in the specification, to avoid any uncertainty or surprises:
(1) When a module's import that has been satisfied at compile time is again provided at instantiation time, the copy provided at instantiation time is ignored. For example, for a module with:
(import "wasm:js-string" "equals" ...)
that's instantiated with:no exception is thrown.
(2) When a module attempts to import a function at compile time that isn't being provided by the engine it is running on, then this import simply and silently remains unsatisfied until regular instantiation time, for example:
(import "wasm:js-string" "nonexistent" ...)
(3) When builtins are exported and inspected from JavaScript, they must have names. Presumably these names match their name within the respective collection, for example: