Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ urlPrefix: https://webassembly.github.io/spec/core/; spec: WebAssembly; type: df
url: syntax/types.html#syntax-reftype
text: reftype
text: funcref
text: anyref
text: exnref
text: externref
text: ref
Expand Down Expand Up @@ -989,8 +990,8 @@ Immediately after a WebAssembly [=memory.grow=] |x| instruction executes, perfor
enum TableKind {
"externref",
"anyfunc",
// Note: More values may be added in future iterations,
// e.g., typed function references, typed GC references
"funcref",
"anyref",
};

dictionary TableDescriptor {
Expand Down Expand Up @@ -1125,6 +1126,8 @@ enum ValueType {
"v128",
"externref",
"anyfunc",
"funcref",
"anyref",
};
</pre>

Expand Down Expand Up @@ -1175,8 +1178,9 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
1. If |s| equals "f32", return [=f32=].
1. If |s| equals "f64", return [=f64=].
1. If |s| equals "v128", return [=v128=].
1. If |s| equals "anyfunc", return [=funcref=].
1. If |s| equals "anyfunc" or |s| equals "funcref", return [=funcref=].
1. If |s| equals "externref", return [=externref=].
1. If |s| equals "anyref", return [=anyref=].
1. Assert: This step is not reached.
</div>

Expand Down
24 changes: 24 additions & 0 deletions test/js-api/global/constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,27 @@ test(() => {
let global = new WebAssembly.Global({value: "externref"});
assert_Global(global, undefined);
}, "externref global with default value");

test(() => {
let global = new WebAssembly.Global({value: "funcref"});
assert_Global(global, null);
}, "funcref global with default value");

test(() => {
let global = new WebAssembly.Global({value: "anyfunc"});
assert_Global(global, null);
}, "anyfunc remains an alias of funcref");

test(() => {
let global = new WebAssembly.Global({value: "anyref"});
assert_Global(global, null);
}, "anyref global with default value");

test(() => {
let global = new WebAssembly.Global({value: "anyref"}, null);
assert_Global(global, null);
}, "anyref global with null");

test(() => {
assert_throws_js(TypeError, () => new WebAssembly.Global({value: "anyref"}, {}));
}, "anyref global rejects a plain object");
10 changes: 10 additions & 0 deletions test/js-api/table/constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,13 @@ test(() => {
const argument = { "element": "i32", "initial": 3n, "maximum": 10 };
assert_throws_js(TypeError, () => new WebAssembly.Table(argument));
}, "initialize table with a wrong maximum type (i64)");

test(() => {
const table = new WebAssembly.Table({element: "funcref", initial: 1});
assert_equals(table.get(0), null);
}, "funcref table with default value");

test(() => {
const table = new WebAssembly.Table({element: "anyref", initial: 1});
assert_equals(table.get(0), null);
}, "anyref table with default value");
Loading