https://webassembly.github.io/reference-types/js-api/index.html#dom-global-global
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 });
Created attachment 418433 [details] Patch
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`.
Created attachment 418707 [details] Patch
Comment on attachment 418707 [details] Patch r=me
Committed r272071: <https://trac.webkit.org/changeset/272071> All reviewed patches have been landed. Closing bug and clearing flags on attachment 418707 [details].
<rdar://problem/73763872>
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.
Committed r272119: <https://trac.webkit.org/changeset/272119>