Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Rename anyfunc to funcref in js-api tests #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ Immediately after a WebAssembly [=memory.grow=] instruction executes, perform th
enum TableKind {
"nullref",
"anyref",
"anyfunc",
"funcref",
// Note: More values may be added in future iterations,
// e.g., typed function references, typed GC references
};
Expand Down
2 changes: 1 addition & 1 deletion interpreter/script/js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let spectest = {
global_i32: 666,
global_f32: 666,
global_f64: 666,
table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'anyfunc'}),
table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'funcref'}),
memory: new WebAssembly.Memory({initial: 1, maximum: 2})
};

Expand Down
6 changes: 3 additions & 3 deletions proposals/bulk-memory-operations/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ of `expr`s instead of function indices.
| - | - | - | - |
| flags | `varuint32` | always | Flags for passive and presence of fields below, only values of 0, 1, and 2 are valid |
| index | `varuint32`? | flags = 2 | Table index; 0 if the field is not present |
| element_type | `elem_type`? | flags = 1 | element type of this segment; `anyfunc` if not present |
| element_type | `elem_type`? | flags = 1 | element type of this segment; `funcref` if not present |
| offset | `init_expr`? | flags != 1 | an `i32` initializer expression for offset |
| count | `varuint32` | always | number of elements |
| elems | `varuint32*` | flags != 1 | sequence of function indices |
Expand All @@ -228,9 +228,9 @@ Another way of looking at it:

| Flags | Active? | index | element_type | offset |
| - | - | - | - | - |
| 0 | Active | Always 0 | Always `anyfunc` | Present |
| 0 | Active | Always 0 | Always `funcref` | Present |
| 1 | Passive | - | Present | - |
| 2 | Active | Present | Always `anyfunc` | Present |
| 2 | Active | Present | Always `funcref` | Present |

An `elem_expr` is like an `init_expr`, but can only contain expressions of the following sequences:

Expand Down
2 changes: 1 addition & 1 deletion test/harness/async_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function reinitializeRegistry() {
table: new WebAssembly.Table({
initial: 10,
maximum: 20,
element: "anyfunc"
element: "funcref"
}),
memory: new WebAssembly.Memory({ initial: 1, maximum: 2 })
};
Expand Down
2 changes: 1 addition & 1 deletion test/harness/sync_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function reinitializeRegistry() {
global_i32: 666,
global_f32: 666,
global_f64: 666,
table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'anyfunc'}),
table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'funcref'}),
memory: new WebAssembly.Memory({initial: 1, maximum: 2})
};
let handler = {
Expand Down
2 changes: 1 addition & 1 deletion test/js-api/instanceTestFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const instanceTestFactory = [
"fn": function() {},
"global": 0,
"memory": new WebAssembly.Memory({ "initial": 64, maximum: 128 }),
"table": new WebAssembly.Table({ "element": "anyfunc", "initial": 64, maximum: 128 }),
"table": new WebAssembly.Table({ "element": "funcref", "initial": 64, maximum: 128 }),
},
get "module2"() {
assert_unreached("Should not get modules that are not imported");
Expand Down
22 changes: 11 additions & 11 deletions test/js-api/table/constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test(() => {
}, "No arguments");

test(() => {
const argument = { "element": "anyfunc", "initial": 0 };
const argument = { "element": "funcref", "initial": 0 };
assert_throws(new TypeError(), () => WebAssembly.Table(argument));
}, "Calling");

Expand Down Expand Up @@ -54,7 +54,7 @@ test(() => {
}, "Invalid descriptor argument");

test(() => {
assert_throws(new TypeError(), () => new WebAssembly.Table({ "element": "anyfunc", "initial": undefined }));
assert_throws(new TypeError(), () => new WebAssembly.Table({ "element": "funcref", "initial": undefined }));
}, "Undefined initial value in descriptor");

test(() => {
Expand All @@ -72,32 +72,32 @@ const outOfRangeValues = [

for (const value of outOfRangeValues) {
test(() => {
assert_throws(new TypeError(), () => new WebAssembly.Table({ "element": "anyfunc", "initial": value }));
assert_throws(new TypeError(), () => new WebAssembly.Table({ "element": "funcref", "initial": value }));
}, `Out-of-range initial value in descriptor: ${format_value(value)}`);

test(() => {
assert_throws(new TypeError(), () => new WebAssembly.Table({ "element": "anyfunc", "initial": 0, "maximum": value }));
assert_throws(new TypeError(), () => new WebAssembly.Table({ "element": "funcref", "initial": 0, "maximum": value }));
}, `Out-of-range maximum value in descriptor: ${format_value(value)}`);
}

test(() => {
assert_throws(new RangeError(), () => new WebAssembly.Table({ "element": "anyfunc", "initial": 10, "maximum": 9 }));
assert_throws(new RangeError(), () => new WebAssembly.Table({ "element": "funcref", "initial": 10, "maximum": 9 }));
}, "Initial value exceeds maximum");

test(() => {
const argument = { "element": "anyfunc", "initial": 0 };
const argument = { "element": "funcref", "initial": 0 };
const table = new WebAssembly.Table(argument);
assert_Table(table, { "length": 0 });
}, "Basic (zero)");

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_Table(table, { "length": 5 });
}, "Basic (non-zero)");

test(() => {
const argument = { "element": "anyfunc", "initial": 0 };
const argument = { "element": "funcref", "initial": 0 };
const table = new WebAssembly.Table(argument, {});
assert_Table(table, { "length": 0 });
}, "Stray argument");
Expand All @@ -110,7 +110,7 @@ test(() => {
get(o, x) {
switch (x) {
case "element":
return "anyfunc";
return "funcref";
case "initial":
case "maximum":
return 0;
Expand All @@ -126,7 +126,7 @@ test(() => {
test(() => {
const table = new WebAssembly.Table({
"element": {
toString() { return "anyfunc"; },
toString() { return "funcref"; },
},
"initial": 1,
});
Expand Down Expand Up @@ -162,7 +162,7 @@ test(() => {
return {
toString() {
order.push("element toString");
return "anyfunc";
return "funcref";
},
};
},
Expand Down
24 changes: 12 additions & 12 deletions test/js-api/table/get-set.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ setup(() => {
});

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_throws(new TypeError(), () => table.get());
}, "Missing arguments: get");
Expand Down Expand Up @@ -53,7 +53,7 @@ test(t => {
}, "Branding: get");

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_throws(new TypeError(), () => table.set());
assert_throws(new TypeError(), () => table.set(0));
Expand Down Expand Up @@ -85,7 +85,7 @@ test(t => {
}, "Branding: set");

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, [null, null, null, null, null]);

Expand All @@ -102,7 +102,7 @@ test(() => {
}, "Basic");

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, [null, null, null, null, null]);

Expand All @@ -120,7 +120,7 @@ test(() => {
}, "Growing");

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, [null, null, null, null, null]);

Expand All @@ -134,7 +134,7 @@ test(() => {
}, "Setting out-of-bounds");

test(() => {
const argument = { "element": "anyfunc", "initial": 1 };
const argument = { "element": "funcref", "initial": 1 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, [null]);

Expand All @@ -156,7 +156,7 @@ test(() => {
}, "Setting non-function");

test(() => {
const argument = { "element": "anyfunc", "initial": 1 };
const argument = { "element": "funcref", "initial": 1 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, [null]);

Expand All @@ -166,7 +166,7 @@ test(() => {
}, "Setting non-wasm function");

test(() => {
const argument = { "element": "anyfunc", "initial": 1 };
const argument = { "element": "funcref", "initial": 1 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, [null]);

Expand All @@ -189,20 +189,20 @@ const outOfRangeValues = [

for (const value of outOfRangeValues) {
test(() => {
const argument = { "element": "anyfunc", "initial": 1 };
const argument = { "element": "funcref", "initial": 1 };
const table = new WebAssembly.Table(argument);
assert_throws(new TypeError(), () => table.get(value));
}, `Getting out-of-range argument: ${format_value(value)}`);

test(() => {
const argument = { "element": "anyfunc", "initial": 1 };
const argument = { "element": "funcref", "initial": 1 };
const table = new WebAssembly.Table(argument);
assert_throws(new TypeError(), () => table.set(value, null));
}, `Setting out-of-range argument: ${format_value(value)}`);
}

test(() => {
const argument = { "element": "anyfunc", "initial": 1 };
const argument = { "element": "funcref", "initial": 1 };
const table = new WebAssembly.Table(argument);
let called = 0;
const value = {
Expand All @@ -217,7 +217,7 @@ test(() => {

test(() => {
const {fn} = functions;
const argument = { "element": "anyfunc", "initial": 1 };
const argument = { "element": "funcref", "initial": 1 };
const table = new WebAssembly.Table(argument);

assert_equals(table.get(0, {}), null);
Expand Down
12 changes: 6 additions & 6 deletions test/js-api/table/grow.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function nulls(n) {
}

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_throws(new TypeError(), () => table.grow());
}, "Missing arguments");
Expand Down Expand Up @@ -37,7 +37,7 @@ test(t => {
}, "Branding");

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, nulls(5), "before");

Expand All @@ -47,7 +47,7 @@ test(() => {
}, "Basic");

test(() => {
const argument = { "element": "anyfunc", "initial": 3, "maximum": 5 };
const argument = { "element": "funcref", "initial": 3, "maximum": 5 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, nulls(3), "before");

Expand All @@ -57,7 +57,7 @@ test(() => {
}, "Reached maximum");

test(() => {
const argument = { "element": "anyfunc", "initial": 2, "maximum": 5 };
const argument = { "element": "funcref", "initial": 2, "maximum": 5 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, nulls(2), "before");

Expand All @@ -79,14 +79,14 @@ const outOfRangeValues = [

for (const value of outOfRangeValues) {
test(() => {
const argument = { "element": "anyfunc", "initial": 1 };
const argument = { "element": "funcref", "initial": 1 };
const table = new WebAssembly.Table(argument);
assert_throws(new TypeError(), () => table.grow(value));
}, `Out-of-range argument: ${format_value(value)}`);
}

test(() => {
const argument = { "element": "anyfunc", "initial": 5 };
const argument = { "element": "funcref", "initial": 5 };
const table = new WebAssembly.Table(argument);
assert_equal_to_array(table, nulls(5), "before");

Expand Down
6 changes: 3 additions & 3 deletions test/js-api/table/length.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test(() => {
}, "Branding");

test(() => {
const argument = { "element": "anyfunc", "initial": 2 };
const argument = { "element": "funcref", "initial": 2 };
const table = new WebAssembly.Table(argument);
assert_equals(table.length, 2, "Initial length");

Expand All @@ -41,15 +41,15 @@ test(() => {
}, "Stray argument");

test(() => {
const argument = { "element": "anyfunc", "initial": 2 };
const argument = { "element": "funcref", "initial": 2 };
const table = new WebAssembly.Table(argument);
assert_equals(table.length, 2, "Initial length");
table.length = 4;
assert_equals(table.length, 2, "Should not change the length");
}, "Setting (sloppy mode)");

test(() => {
const argument = { "element": "anyfunc", "initial": 2 };
const argument = { "element": "funcref", "initial": 2 };
const table = new WebAssembly.Table(argument);
assert_equals(table.length, 2, "Initial length");
assert_throws(new TypeError(), () => {
Expand Down
2 changes: 1 addition & 1 deletion test/js-api/table/toString.any.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// META: global=jsshell

test(() => {
const argument = { "element": "anyfunc", "initial": 0 };
const argument = { "element": "funcref", "initial": 0 };
const table = new WebAssembly.Table(argument);
assert_class_string(table, "WebAssembly.Table");
}, "Object.prototype.toString on an Table");
2 changes: 1 addition & 1 deletion test/meta/generate_memory_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ print(
(assert_trap (invoke "test") "out of bounds")
`);

// invalid argument types. TODO: can add anyfunc etc here.
// invalid argument types. TODO: can add funcref etc here.
{
const tys = ['i32', 'f32', 'i64', 'f64'];

Expand Down