-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interaction between WebAssembly.Suspending
and WebAssembly.Function
?
#41
Comments
new WebAssembly.Suspending(func) does NOT return a function value! Note that WebAssembly.Function is part of a different proposal that is still in phase 3. |
So according to the current spec, if I want to use a suspending function wasmFunctionPolyfill({ parameters, results }, f) {
const builder = new WasmModuleBuilder();
const functionIndex = builder.addImport("env", "f", { parameters, results });
builder.addExport("exportedFunction", functionIndex);
const buffer = builder.toBuffer();
const module = new WebAssembly.Module(buffer);
const instance = new WebAssembly.Instance(module, {"env": { f } });
return instance.exports.exportedFunction;
} With language to that effect in the reflection proposal, compliant implementers of both would be forced to make them interact the way that makes sense. |
I guess v8 is also not implementing the current spec for type reflection as it is written because as I read it:
So that assertion should fail and it should throw. The current behavior of the v8 implementation is as follows:
Explicitly what I would like is for that language to say:
|
When trying to put a suspending function into a
WebAssembly.Table
, I found that in the current v8 implementation,WebAssembly.Function
removes thesuspending
. I made a v8 bug report here with a full reproduction.And then have a wasm module that does:
Instead of logging
7
, it logsPromise {<pending>}
.If I compose them the other way
It raises
TypeError: WebAssembly.Table.set(): Argument 1 is invalid for table: function-typed object must be null (if nullable) or a Wasm function object
.Does the spec have anything to say about the expected interaction of
WebAssembly.Function
andWebAssembly.Table
? I should think at leastnew WebAssembly.Function(sig, new WebAssembly.Suspending(func))
should be required to work in a compliant implementation.The text was updated successfully, but these errors were encountered: