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
I'm concerned about the interaction between this proposal and the JSPI, in particular about the behavior of new WebAssembly.Function(sig, new WebAssembly.Suspending(jsFunc)). I believe the two specs as they currently exist says this should throw an error, because IsCallable(new WebAssembly.Suspending(jsFunc)) should return false and then new Webassembly.Function should fail step 1 "Assert: =IsCallable=".
In v8 the current implementation seems to just delete the new WebAssembly.Suspending(jsFunc).
What I would like is for new WebAssembly.Function(sig, func) to behave like reexporting the function, basically the following pseudocode from #16:
functionwasmFunctionPolyfill({ parameters, results },f){constbuilder=newWasmModuleBuilder();constfunctionIndex=builder.addImport("env","f",{ parameters, results });builder.addExport("exportedFunction",functionIndex);constbuffer=builder.toBuffer();constmodule=newWebAssembly.Module(buffer);constinstance=newWebAssembly.Instance(module,{"env": { f }});returninstance.exports.exportedFunction;}
To update the spec so that new WebAssembly.Function behaves like the above wasmFunctionPolyfill when passed a suspendable object I think we would need something like the following diff:
--- a/document/js-api/index.bs+++ b/document/js-api/index.bs@@ -1319,8 +1319,13 @@ The <dfn method for="Function">type()</dfn> method steps are:
</div>
<div algorithm>
- To <dfn>construct a new WebAssembly Function</dfn> from a JavaScript [=callable=] object |callable| and {{FunctionType}} |signature|, perform the following steps:+ To <dfn>construct a new WebAssembly Function</dfn> from a JavaScript [=callable=] or [=suspendable=] object |callable| and {{FunctionType}} |signature|, perform the following steps:+ 1. If |callable| has a \[[wrappedFunction]] internal slot:+ 1. Let |func| be |callable|'s \[[wrappedFunction]] slot.+ 1. Assert [=IsCallable=](|func|).+ 1. Create [=a new suspending function=] from |func| and |functype|, and let |funcaddr| be the result.+ 1. Return the result of creating [=a new Exported Function=] from |funcaddr|.
1. Assert: [=IsCallable=](|callable|).
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
1. Let |signature| be «[ "{{FunctionType/parameters}}" → |parameters|, "{{FunctionType/results}}" → |results| ]».
I'm concerned about the interaction between this proposal and the JSPI, in particular about the behavior of
new WebAssembly.Function(sig, new WebAssembly.Suspending(jsFunc))
. I believe the two specs as they currently exist says this should throw an error, becauseIsCallable(new WebAssembly.Suspending(jsFunc))
should returnfalse
and thennew Webassembly.Function
should fail step 1 "Assert: =IsCallable=".In v8 the current implementation seems to just delete the
new WebAssembly.Suspending(jsFunc)
.What I would like is for
new WebAssembly.Function(sig, func)
to behave like reexporting the function, basically the following pseudocode from #16:To update the spec so that
new WebAssembly.Function
behaves like the abovewasmFunctionPolyfill
when passed a suspendable object I think we would need something like the following diff:xrefs:
the jspi issue
the v8 issue.
The text was updated successfully, but these errors were encountered: