WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
220914
[JSC] WebAssembly.Global should support Funcref and Externref
https://bugs.webkit.org/show_bug.cgi?id=220914
Summary
[JSC] WebAssembly.Global should support Funcref and Externref
Yusuke Suzuki
Reported
2021-01-25 03:48:14 PST
https://webassembly.github.io/reference-types/js-api/index.html#dom-global-global
Attachments
Patch
(6.25 KB, patch)
2021-01-26 09:48 PST
,
Dmitry
no flags
Details
Formatted Diff
Diff
Patch
(10.81 KB, patch)
2021-01-28 23:44 PST
,
Dmitry
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2021-01-25 03:50:03 PST
Note, 1. Wasm::Global itself supports externref / funcref already. 2. But JS binding around WebAssembly.Global does not support it (e.g. new WebAssembly.Global({ type: "externref", mutable: true });
Dmitry
Comment 2
2021-01-26 09:48:25 PST
Created
attachment 418433
[details]
Patch
Yusuke Suzuki
Comment 3
2021-01-26 11:59:10 PST
Comment on
attachment 418433
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=418433&action=review
r=me with comments.
> Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp:146 > + RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
Use `RETURN_IF_EXCEPTION(throwScope, {});` in newer code.
> Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp:151 > + if (type == Wasm::Type::Funcref && argument.isUndefined()) > + argument = jsNull();
Can we share this "default value" part with WasmTable etc.?
> Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp:152 > + jsWebAssemblyGlobal->global()->set(globalObject, argument);
Insert `RETURN_IF_EXCEPTION(throwScope, { });` after calling a function which takes `globalObject` as a first parameter (this is a rough indicator of "it can throw").
> Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp:154 > + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsWebAssemblyGlobal));
RELEASE_AND_RETURN is not necessary if the evaluated part will not throw. Let's use `return`.
> JSTests/wasm/references/globals.js:42 > + assert.throws(() => new WebAssembly.Global({ value: "anyfunc", mutable: true }, new Pelmen(calories)), WebAssembly.RuntimeError, "Funcref must be an exported wasm function (evaluating 'new WebAssembly.Global({ value: \"anyfunc\", mutable: true }, new Pelmen(calories))')");
Let's add a test, setting a wrong value via `.value = xxx`.
Dmitry
Comment 4
2021-01-28 23:44:20 PST
Created
attachment 418707
[details]
Patch
Yusuke Suzuki
Comment 5
2021-01-29 11:09:14 PST
Comment on
attachment 418707
[details]
Patch r=me
EWS
Comment 6
2021-01-29 11:26:42 PST
Committed
r272071
: <
https://trac.webkit.org/changeset/272071
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 418707
[details]
.
Radar WebKit Bug Importer
Comment 7
2021-01-29 11:27:14 PST
<
rdar://problem/73763872
>
Yusuke Suzuki
Comment 8
2021-01-30 10:50:01 PST
Oops! ::set should not be used since mutability can be an immutable. In that case, assertion hits.
https://results.webkit.org/?suite=layout-tests&test=imported%2Fw3c%2Fweb-platform-tests%2Fwasm%2Fjsapi%2Fglobal%2Ftype.tentative.any.html
I'll fix.
Yusuke Suzuki
Comment 9
2021-01-30 11:51:23 PST
Committed
r272119
: <
https://trac.webkit.org/changeset/272119
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug