Changeset 246589 in webkit


Ignore:
Timestamp:
Jun 19, 2019 8:36:46 AM (5 years ago)
Author:
Justin Michaud
Message:

[WASM-References] Rename anyfunc to funcref
https://bugs.webkit.org/show_bug.cgi?id=198983

Reviewed by Yusuke Suzuki.

JSTests:

  • wasm/function-tests/basic-element.js:
  • wasm/function-tests/context-switch.js:

(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
(makeInstance):
(assert.eq.makeInstance):

  • wasm/function-tests/exceptions.js:

(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):

  • wasm/function-tests/grow-memory-2.js:

(assert.eq.instance.exports.foo):

  • wasm/function-tests/nameSection.js:

(const.compile):

  • wasm/function-tests/stack-overflow.js:

(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
(assertOverflows.makeInstance):

  • wasm/function-tests/table-basic-2.js:

(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):

  • wasm/function-tests/table-basic.js:

(import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):

  • wasm/function-tests/trap-from-start-async.js:
  • wasm/function-tests/trap-from-start.js:
  • wasm/js-api/Module.exports.js:

(assert.truthy):

  • wasm/js-api/Module.imports.js:

(assert.truthy):

  • wasm/js-api/call-indirect.js:

(const.oneTable):
(const.multiTable):
(multiTable.const.makeTable):
(multiTable):
(multiTable.Polyphic2Import):
(multiTable.VirtualImport):

  • wasm/js-api/element-data.js:
  • wasm/js-api/element.js:

(assert.throws.new.WebAssembly.Module.builder.WebAssembly):
(assert.throws):
(badInstantiation.makeModule):
(badInstantiation.test):
(badInstantiation):

  • wasm/js-api/extension-MemoryMode.js:
  • wasm/js-api/table.js:

(new.WebAssembly.Module):
(assert.throws):
(assertBadTableImport):
(assert.throws.WebAssembly.Table.prototype.grow):
(new.WebAssembly.Table):
(assertBadTable):
(assert.truthy):

  • wasm/js-api/test_basic_api.js:

(const.c.in.constructorProperties.switch):

  • wasm/js-api/unique-signature.js:

(CallIndirectWithDuplicateSignatures):

  • wasm/js-api/wrapper-function.js:
  • wasm/modules/table.wat:
  • wasm/modules/wasm-imports-js-re-exports-wasm-exports/imports.wat:
  • wasm/modules/wasm-imports-js-re-exports-wasm-exports/sum.wat:
  • wasm/modules/wasm-imports-wasm-exports/imports.wat:
  • wasm/modules/wasm-imports-wasm-exports/sum.wat:
  • wasm/references/anyref_table.js:
  • wasm/references/anyref_table_import.js:

(doSet):
(assert.throws):

  • wasm/references/func_ref.js:

(makeFuncrefIdent):
(assert.eq.instance.exports.fix):
(GetLocal.0.I32Const.0.TableSet.0.End.End.WebAssembly.assert.throws):
(GetLocal.0.I32Const.0.TableSet.0.End.End.WebAssembly):
(let.importedFun.of):
(makeAnyfuncIdent): Deleted.
(makeAnyfuncIdent.fun): Deleted.

  • wasm/references/multitable.js:

(assert.eq):
(assert.throws):

  • wasm/references/table_misc.js:

(GetLocal.0.TableFill.0.End.End.WebAssembly):

  • wasm/references/validation.js:

(assert.throws.new.WebAssembly.Module.bin):
(assert.throws):

  • wasm/spec-harness/index.js:
  • wasm/spec-harness/wasm-constants.js:
  • wasm/spec-harness/wasm-module-builder.js:

(WasmModuleBuilder.prototype.toArray):

  • wasm/spec-harness/wast.js:

(elem_type):
(string_of_elem_type):
(string_of_table_type):

  • wasm/spec-tests/jsapi.js:
  • wasm/stress/wasm-table-grow-initialize.js:
  • wasm/wasm.json:

Source/JavaScriptCore:

Anyfunc should become funcref since it was renamed in the spec. We should also support the string 'anyfunc' in the table constructor since this is
the only non-binary-format place where it is exposed to users.

  • wasm/WasmAirIRGenerator.cpp:

(JSC::Wasm::AirIRGenerator::gFuncref):
(JSC::Wasm::AirIRGenerator::tmpForType):
(JSC::Wasm::AirIRGenerator::emitCCall):
(JSC::Wasm::AirIRGenerator::moveOpForValueType):
(JSC::Wasm::AirIRGenerator::AirIRGenerator):
(JSC::Wasm::AirIRGenerator::addLocal):
(JSC::Wasm::AirIRGenerator::addConstant):
(JSC::Wasm::AirIRGenerator::addRefFunc):
(JSC::Wasm::AirIRGenerator::addReturn):
(JSC::Wasm::AirIRGenerator::gAnyfunc): Deleted.

  • wasm/WasmCallingConvention.h:

(JSC::Wasm::CallingConventionAir::marshallArgument const):
(JSC::Wasm::CallingConventionAir::setupCall const):

  • wasm/WasmExceptionType.h:
  • wasm/WasmFormat.h:

(JSC::Wasm::isValueType):
(JSC::Wasm::isSubtype):
(JSC::Wasm::TableInformation::wasmType const):

  • wasm/WasmFunctionParser.h:

(JSC::Wasm::FunctionParser<Context>::parseExpression):

  • wasm/WasmSectionParser.cpp:

(JSC::Wasm::SectionParser::parseTableHelper):
(JSC::Wasm::SectionParser::parseElement):
(JSC::Wasm::SectionParser::parseInitExpr):

  • wasm/WasmValidate.cpp:

(JSC::Wasm::Validate::addRefFunc):

  • wasm/js/JSToWasm.cpp:

(JSC::Wasm::createJSToWasmWrapper):

  • wasm/js/WasmToJS.cpp:

(JSC::Wasm::wasmToJS):

  • wasm/js/WebAssemblyFunction.cpp:

(JSC::callWebAssemblyFunction):
(JSC::WebAssemblyFunction::jsCallEntrypointSlow):

  • wasm/js/WebAssemblyModuleRecord.cpp:

(JSC::WebAssemblyModuleRecord::link):

  • wasm/js/WebAssemblyTableConstructor.cpp:

(JSC::constructJSWebAssemblyTable):

  • wasm/wasm.json:
Location:
trunk
Files:
53 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r246577 r246589  
     12019-06-19  Justin Michaud  <justin_michaud@apple.com>
     2
     3        [WASM-References] Rename anyfunc to funcref
     4        https://bugs.webkit.org/show_bug.cgi?id=198983
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * wasm/function-tests/basic-element.js:
     9        * wasm/function-tests/context-switch.js:
     10        (import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
     11        (makeInstance):
     12        (assert.eq.makeInstance):
     13        * wasm/function-tests/exceptions.js:
     14        (import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
     15        * wasm/function-tests/grow-memory-2.js:
     16        (assert.eq.instance.exports.foo):
     17        * wasm/function-tests/nameSection.js:
     18        (const.compile):
     19        * wasm/function-tests/stack-overflow.js:
     20        (import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
     21        (assertOverflows.makeInstance):
     22        * wasm/function-tests/table-basic-2.js:
     23        (import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
     24        * wasm/function-tests/table-basic.js:
     25        (import.Builder.from.string_appeared_here.import.as.assert.from.string_appeared_here.makeInstance):
     26        * wasm/function-tests/trap-from-start-async.js:
     27        * wasm/function-tests/trap-from-start.js:
     28        * wasm/js-api/Module.exports.js:
     29        (assert.truthy):
     30        * wasm/js-api/Module.imports.js:
     31        (assert.truthy):
     32        * wasm/js-api/call-indirect.js:
     33        (const.oneTable):
     34        (const.multiTable):
     35        (multiTable.const.makeTable):
     36        (multiTable):
     37        (multiTable.Polyphic2Import):
     38        (multiTable.VirtualImport):
     39        * wasm/js-api/element-data.js:
     40        * wasm/js-api/element.js:
     41        (assert.throws.new.WebAssembly.Module.builder.WebAssembly):
     42        (assert.throws):
     43        (badInstantiation.makeModule):
     44        (badInstantiation.test):
     45        (badInstantiation):
     46        * wasm/js-api/extension-MemoryMode.js:
     47        * wasm/js-api/table.js:
     48        (new.WebAssembly.Module):
     49        (assert.throws):
     50        (assertBadTableImport):
     51        (assert.throws.WebAssembly.Table.prototype.grow):
     52        (new.WebAssembly.Table):
     53        (assertBadTable):
     54        (assert.truthy):
     55        * wasm/js-api/test_basic_api.js:
     56        (const.c.in.constructorProperties.switch):
     57        * wasm/js-api/unique-signature.js:
     58        (CallIndirectWithDuplicateSignatures):
     59        * wasm/js-api/wrapper-function.js:
     60        * wasm/modules/table.wat:
     61        * wasm/modules/wasm-imports-js-re-exports-wasm-exports/imports.wat:
     62        * wasm/modules/wasm-imports-js-re-exports-wasm-exports/sum.wat:
     63        * wasm/modules/wasm-imports-wasm-exports/imports.wat:
     64        * wasm/modules/wasm-imports-wasm-exports/sum.wat:
     65        * wasm/references/anyref_table.js:
     66        * wasm/references/anyref_table_import.js:
     67        (doSet):
     68        (assert.throws):
     69        * wasm/references/func_ref.js:
     70        (makeFuncrefIdent):
     71        (assert.eq.instance.exports.fix):
     72        (GetLocal.0.I32Const.0.TableSet.0.End.End.WebAssembly.assert.throws):
     73        (GetLocal.0.I32Const.0.TableSet.0.End.End.WebAssembly):
     74        (let.importedFun.of):
     75        (makeAnyfuncIdent): Deleted.
     76        (makeAnyfuncIdent.fun): Deleted.
     77        * wasm/references/multitable.js:
     78        (assert.eq):
     79        (assert.throws):
     80        * wasm/references/table_misc.js:
     81        (GetLocal.0.TableFill.0.End.End.WebAssembly):
     82        * wasm/references/validation.js:
     83        (assert.throws.new.WebAssembly.Module.bin):
     84        (assert.throws):
     85        * wasm/spec-harness/index.js:
     86        * wasm/spec-harness/wasm-constants.js:
     87        * wasm/spec-harness/wasm-module-builder.js:
     88        (WasmModuleBuilder.prototype.toArray):
     89        * wasm/spec-harness/wast.js:
     90        (elem_type):
     91        (string_of_elem_type):
     92        (string_of_table_type):
     93        * wasm/spec-tests/jsapi.js:
     94        * wasm/stress/wasm-table-grow-initialize.js:
     95        * wasm/wasm.json:
     96
    1972019-06-18  Justin Michaud  <justin_michaud@apple.com>
    298
  • trunk/JSTests/wasm/function-tests/basic-element.js

    r209785 r246589  
    33
    44
    5 const tableDescription = {initial: 1, element: "anyfunc"};
     5const tableDescription = {initial: 1, element: "funcref"};
    66const builder = new Builder()
    77    .Type().End()
  • trunk/JSTests/wasm/function-tests/context-switch.js

    r217017 r246589  
    44{
    55    function makeInstance() {
    6         const tableDescription = {initial: 1, element: "anyfunc"};
     6        const tableDescription = {initial: 1, element: "funcref"};
    77        const builder = new Builder()
    88            .Type()
     
    8383{
    8484    function makeInstance() {
    85         const tableDescription = {initial: 1, element: "anyfunc"};
     85        const tableDescription = {initial: 1, element: "funcref"};
    8686        const builder = new Builder()
    8787            .Type()
     
    172172{
    173173    function makeInstance() {
    174         const tableDescription = {initial: 1, element: "anyfunc"};
     174        const tableDescription = {initial: 1, element: "funcref"};
    175175        const builder = new Builder()
    176176            .Type()
  • trunk/JSTests/wasm/function-tests/exceptions.js

    r210229 r246589  
    33
    44function makeInstance() {
    5     const tableDescription = {initial: 1, element: "anyfunc"};
     5    const tableDescription = {initial: 1, element: "funcref"};
    66    const builder = new Builder()
    77        .Type()
  • trunk/JSTests/wasm/function-tests/grow-memory-2.js

    r210201 r246589  
    3838{
    3939    const memoryDescription = {initial: 0, maximum: 2};
    40     const tableDescription = {initial: 1, maximum: 1, element: "anyfunc"};
     40    const tableDescription = {initial: 1, maximum: 1, element: "funcref"};
    4141    const builder = (new Builder())
    4242        .Type()
  • trunk/JSTests/wasm/function-tests/nameSection.js

    r225550 r246589  
    3939            switch (imp.kind) {
    4040            case "function": importObject[imp.module][imp.name] = () => {}; break;
    41             case "table": importObject[imp.module][imp.name] = new WebAssembly.Table({ initial: 6, maximum: 6, element: "anyfunc" }); break;
     41            case "table": importObject[imp.module][imp.name] = new WebAssembly.Table({ initial: 6, maximum: 6, element: "funcref" }); break;
    4242            case "memory": importObject[imp.module][imp.name] = new WebAssembly.Memory({ initial: 16777216 / (64 * 1024), maximum: 16777216 / (64 * 1024) }); break;
    4343            case "global": importObject[imp.module][imp.name] = 0; break;
  • trunk/JSTests/wasm/function-tests/stack-overflow.js

    r225550 r246589  
    44{
    55    function makeInstance() {
    6         const tableDescription = {initial: 1, element: "anyfunc"};
     6        const tableDescription = {initial: 1, element: "funcref"};
    77        const builder = new Builder()
    88            .Type()
     
    5858{
    5959    function makeInstance() {
    60         const tableDescription = {initial: 1, element: "anyfunc"};
     60        const tableDescription = {initial: 1, element: "funcref"};
    6161        const builder = new Builder()
    6262            .Type()
  • trunk/JSTests/wasm/function-tests/table-basic-2.js

    r209771 r246589  
    99        .End()
    1010        .Import()
    11             .Table("imp", "table", {initial: 20, element: "anyfunc"})
     11            .Table("imp", "table", {initial: 20, element: "funcref"})
    1212            .Function("imp", "func", { params: ["i32"], ret: "i32" })
    1313        .End()
     
    3434    const bin = builder.WebAssembly().get();
    3535    const module = new WebAssembly.Module(bin);
    36     const table = new WebAssembly.Table({initial: 20, element: "anyfunc"});
     36    const table = new WebAssembly.Table({initial: 20, element: "funcref"});
    3737    return {instance: new WebAssembly.Instance(module, {imp: {table, func}}), table};
    3838}
  • trunk/JSTests/wasm/function-tests/table-basic.js

    r210026 r246589  
    99        .End()
    1010        .Import()
    11             .Table("imp", "table", {initial: 20, element: "anyfunc"})
     11            .Table("imp", "table", {initial: 20, element: "funcref"})
    1212        .End()
    1313        .Function().End()
     
    3434    const bin = builder.WebAssembly().get();
    3535    const module = new WebAssembly.Module(bin);
    36     const table = new WebAssembly.Table({initial: 20, element: "anyfunc"});
     36    const table = new WebAssembly.Table({initial: 20, element: "funcref"});
    3737    return {instance: new WebAssembly.Instance(module, {imp: {table}}), table};
    3838}
  • trunk/JSTests/wasm/function-tests/trap-from-start-async.js

    r223274 r246589  
    33
    44const memoryInfo = { initial: 2 };
    5 const tableInfo = { element: "anyfunc", initial: 8 };
     5const tableInfo = { element: "funcref", initial: 8 };
    66
    77async function StartTrapsAsync() {
  • trunk/JSTests/wasm/function-tests/trap-from-start.js

    r223274 r246589  
    33
    44const memoryInfo = { initial: 2 };
    5 const tableInfo = { element: "anyfunc", initial: 8 };
     5const tableInfo = { element: "funcref", initial: 8 };
    66
    77(function StartTraps() {
  • trunk/JSTests/wasm/js-api/Module.exports.js

    r215664 r246589  
    1818            .Function().End()
    1919            .Table()
    20                 .Table({initial: 20, maximum: 30, element: "anyfunc"})
     20                .Table({initial: 20, maximum: 30, element: "funcref"})
    2121            .End()
    2222            .Memory().InitialMaxPages(1, 1).End()
  • trunk/JSTests/wasm/js-api/Module.imports.js

    r215664 r246589  
    1818            .Import()
    1919                .Function("fooFunction", "barFunction", { params: [] })
    20                 .Table("fooTable", "barTable", {initial: 20, element: "anyfunc"})
     20                .Table("fooTable", "barTable", {initial: 20, element: "funcref"})
    2121                .Memory("fooMemory", "barMemory", {initial: 20})
    2222                .Global().I32("fooGlobal", "barGlobal", "immutable").End()
  • trunk/JSTests/wasm/js-api/call-indirect.js

    r246571 r246589  
    77        .Import()
    88            .Function("imp", "func", { params: ["i32"] })
    9             .Table("imp", "table", { initial: 1, maximum: 1, element: "anyfunc"})
     9            .Table("imp", "table", { initial: 1, maximum: 1, element: "funcref"})
    1010        .End()
    1111        .Function().End()
     
    3737        .Import()
    3838            .Function("imp", "func", { params: ["i32"] })
    39             .Table("imp", "table0", { initial: 0, maximum: 0, element: "anyfunc"})
    40             .Table("imp", "table", { initial: 1, maximum: 1, element: "anyfunc"})
     39            .Table("imp", "table0", { initial: 0, maximum: 0, element: "funcref"})
     40            .Table("imp", "table", { initial: 1, maximum: 1, element: "funcref"})
    4141        .End()
    4242        .Function().End()
     
    6666
    6767const makeTable = () => {
    68     return new WebAssembly.Table({initial: 1, maximum: 1, element: "anyfunc"});
     68    return new WebAssembly.Table({initial: 1, maximum: 1, element: "funcref"});
    6969};
    7070
     
    7474    const table = makeTable();
    7575    const module = wasmModuleWhichImportJS();
    76     const instance = new WebAssembly.Instance(module, { imp: { func: counterSetter, table, table0: new WebAssembly.Table({initial: 0, maximum: 0, element: "anyfunc"}) } });
     76    const instance = new WebAssembly.Instance(module, { imp: { func: counterSetter, table, table0: new WebAssembly.Table({initial: 0, maximum: 0, element: "funcref"}) } });
    7777    table.set(0, instance.exports.callFunc);
    7878    for (let i = 0; i < 4096; ++i) {
     
    9191
    9292    const tableA = makeTable();
    93     const instanceA = new WebAssembly.Instance(module, { imp: { func: counterASetter, table: tableA, table0: new WebAssembly.Table({initial: 0, maximum: 0, element: "anyfunc"}) } });
     93    const instanceA = new WebAssembly.Instance(module, { imp: { func: counterASetter, table: tableA, table0: new WebAssembly.Table({initial: 0, maximum: 0, element: "funcref"}) } });
    9494    tableA.set(0, instanceA.exports.callFunc);
    9595
    9696    const tableB = makeTable();
    97     const instanceB = new WebAssembly.Instance(module, { imp: { func: counterBSetter, table: tableB, table0: new WebAssembly.Table({initial: 0, maximum: 0, element: "anyfunc"}) } });
     97    const instanceB = new WebAssembly.Instance(module, { imp: { func: counterBSetter, table: tableB, table0: new WebAssembly.Table({initial: 0, maximum: 0, element: "funcref"}) } });
    9898    tableB.set(0, instanceB.exports.callFunc);
    9999    for (let i = 0; i < 2048; ++i) {
     
    127127    for (let i = 0; i < num; ++i) {
    128128        let table = makeTable();
    129         instances[i] = new WebAssembly.Instance(module, { imp: { func: counterSetters[i], table, table0: new WebAssembly.Table({initial: 0, maximum: 0, element: "anyfunc"}) } });
     129        instances[i] = new WebAssembly.Instance(module, { imp: { func: counterSetters[i], table, table0: new WebAssembly.Table({initial: 0, maximum: 0, element: "funcref"}) } });
    130130        table.set(0, instances[i].exports.callFunc);
    131131    }
  • trunk/JSTests/wasm/js-api/element-data.js

    r210028 r246589  
    1111        .Import()
    1212            .Memory("imp", "memory", memoryDescription)
    13             .Table("imp", "table", {element: "anyfunc", initial: 19}) // unspecified maximum.
     13            .Table("imp", "table", {element: "funcref", initial: 19}) // unspecified maximum.
    1414        .End()
    1515        .Function().End()
     
    3131    const module = new WebAssembly.Module(bin);
    3232    const memory = new WebAssembly.Memory(memoryDescription);
    33     const table = new WebAssembly.Table({element: "anyfunc", initial: 19});
     33    const table = new WebAssembly.Table({element: "funcref", initial: 19});
    3434    const imports = {
    3535        imp: {
  • trunk/JSTests/wasm/js-api/element.js

    r235420 r246589  
    2828        .Function().End()
    2929        .Table()
    30             .Table({element: "anyfunc", initial: 20})
     30            .Table({element: "funcref", initial: 20})
    3131        .End()
    3232        .Element()
     
    5151        .Function().End()
    5252        .Table()
    53             .Table({element: "anyfunc", initial: 20, maximum: 20})
     53            .Table({element: "funcref", initial: 20, maximum: 20})
    5454        .End()
    5555        .Element()
     
    7575        .Function().End()
    7676        .Table()
    77             .Table({element: "anyfunc", initial: 20, maximum: 20})
     77            .Table({element: "funcref", initial: 20, maximum: 20})
    7878        .End()
    7979        .Element()
     
    9999        .Function().End()
    100100        .Table()
    101             .Table({element: "anyfunc", initial: 20, maximum: 20})
     101            .Table({element: "funcref", initial: 20, maximum: 20})
    102102        .End()
    103103        .Element()
     
    122122            .Type().End()
    123123            .Import()
    124                 .Table("imp", "table", {element: "anyfunc", initial: 19}) // unspecified maximum.
     124                .Table("imp", "table", {element: "funcref", initial: 19}) // unspecified maximum.
    125125            .End()
    126126            .Function().End()
     
    143143
    144144    for (let i = 19; i < 19 + 5; i++) {
    145         const table = new WebAssembly.Table({element: "anyfunc", initial: i});
     145        const table = new WebAssembly.Table({element: "funcref", initial: i});
    146146        badInstantiation(table, WebAssembly.LinkError, "Element is trying to set an out of bounds table index (evaluating 'new WebAssembly.Instance(module, {imp: {table: actualTable}})')");
    147147    }
     
    153153            .Type().End()
    154154            .Import()
    155                 .Table("imp", "table", {element: "anyfunc", initial: 19}) // unspecified maximum.
     155                .Table("imp", "table", {element: "funcref", initial: 19}) // unspecified maximum.
    156156                .Global().I32("imp", "global", "immutable").End()
    157157            .End()
     
    174174
    175175    function test(i) {
    176         const table = new WebAssembly.Table({element: "anyfunc", initial: 19});
     176        const table = new WebAssembly.Table({element: "funcref", initial: 19});
    177177        const global = i;
    178178        const module = makeModule();
     
    196196            .Type().End()
    197197            .Import()
    198                 .Table("imp", "table", {element: "anyfunc", initial: 19}) // unspecified maximum.
     198                .Table("imp", "table", {element: "funcref", initial: 19}) // unspecified maximum.
    199199                .Global().F32("imp", "global", "immutable").End()
    200200            .End()
  • trunk/JSTests/wasm/js-api/extension-MemoryMode.js

    r215340 r246589  
    1919assert.throws(() => WebAssemblyMemoryMode({}), TypeError, message);
    2020assert.throws(() => WebAssemblyMemoryMode(new WebAssembly.Module(emptyModuleArray)), TypeError, message);
    21 assert.throws(() => WebAssemblyMemoryMode(new WebAssembly.Table({initial: 1, element: "anyfunc"})), TypeError, message);
     21assert.throws(() => WebAssemblyMemoryMode(new WebAssembly.Table({initial: 1, element: "funcref"})), TypeError, message);
    2222
    2323const validateMode = what => {
  • trunk/JSTests/wasm/js-api/table.js

    r246571 r246589  
    66        .Type().End()
    77        .Import()
    8             .Table("imp", "table", {initial: 20, element: "anyfunc"})
    9         .End()
    10         .Function().End()
    11         .Table()
    12             .Table({initial: 20, maximum: 30, element: "anyfunc"})
     8            .Table("imp", "table", {initial: 20, element: "funcref"})
     9        .End()
     10        .Function().End()
     11        .Table()
     12            .Table({initial: 20, maximum: 30, element: "funcref"})
    1313        .End()
    1414        .Code()
     
    3434        .Function().End()
    3535        .Table()
    36             .Table({initial: 20, maximum: 30, element: "anyfunc"})
    37             .Table({initial: 20, maximum: 30, element: "anyfunc"})
     36            .Table({initial: 20, maximum: 30, element: "funcref"})
     37            .Table({initial: 20, maximum: 30, element: "funcref"})
    3838        .End()
    3939        .Code()
     
    6363        .Function().End()
    6464        .Table()
    65             .Table({initial:20, element:"anyfunc"})
     65            .Table({initial:20, element:"funcref"})
    6666        .End()
    6767        .Export()
     
    8282        .Function().End()
    8383        .Table()
    84             .Table({initial:20, element:"anyfunc"})
    85             .Table({initial:20, element:"anyfunc"})
     84            .Table({initial:20, element:"funcref"})
     85            .Table({initial:20, element:"funcref"})
    8686        .End()
    8787        .Export()
     
    117117        .Function().End()
    118118        .Table()
    119             .Table({initial: 20, maximum: 30, element: "anyfunc"})
     119            .Table({initial: 20, maximum: 30, element: "funcref"})
    120120        .End()
    121121        .Export()
     
    154154    let badDescriptions = [
    155155        [{initial: 10, element: "i32"},
    156          "WebAssembly.Module doesn't parse at byte 18: Table type should be anyfunc or anyref, got -1 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    157          "WebAssembly.Module doesn't parse at byte 26: Table type should be anyfunc or anyref, got -1 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     156         "WebAssembly.Module doesn't parse at byte 18: Table type should be funcref or anyref, got -1 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
     157         "WebAssembly.Module doesn't parse at byte 26: Table type should be funcref or anyref, got -1 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    158158        [{initial: 10, element: "f32"},
    159          "WebAssembly.Module doesn't parse at byte 18: Table type should be anyfunc or anyref, got -3 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    160          "WebAssembly.Module doesn't parse at byte 26: Table type should be anyfunc or anyref, got -3 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     159         "WebAssembly.Module doesn't parse at byte 18: Table type should be funcref or anyref, got -3 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
     160         "WebAssembly.Module doesn't parse at byte 26: Table type should be funcref or anyref, got -3 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    161161        [{initial: 10, element: "f64"},
    162          "WebAssembly.Module doesn't parse at byte 18: Table type should be anyfunc or anyref, got -4 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    163          "WebAssembly.Module doesn't parse at byte 26: Table type should be anyfunc or anyref, got -4 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     162         "WebAssembly.Module doesn't parse at byte 18: Table type should be funcref or anyref, got -4 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
     163         "WebAssembly.Module doesn't parse at byte 26: Table type should be funcref or anyref, got -4 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    164164        [{initial: 10, element: "i64"},
    165          "WebAssembly.Module doesn't parse at byte 18: Table type should be anyfunc or anyref, got -2 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    166          "WebAssembly.Module doesn't parse at byte 26: Table type should be anyfunc or anyref, got -2 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     165         "WebAssembly.Module doesn't parse at byte 18: Table type should be funcref or anyref, got -2 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
     166         "WebAssembly.Module doesn't parse at byte 26: Table type should be funcref or anyref, got -2 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    167167        [{initial: 10, maximum: 20, element: "i32"},
    168          "WebAssembly.Module doesn't parse at byte 18: Table type should be anyfunc or anyref, got -1 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    169          "WebAssembly.Module doesn't parse at byte 26: Table type should be anyfunc or anyref, got -1 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     168         "WebAssembly.Module doesn't parse at byte 18: Table type should be funcref or anyref, got -1 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
     169         "WebAssembly.Module doesn't parse at byte 26: Table type should be funcref or anyref, got -1 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    170170        [{initial: 10, maximum: 20, element: "f32"},
    171          "WebAssembly.Module doesn't parse at byte 18: Table type should be anyfunc or anyref, got -3 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    172          "WebAssembly.Module doesn't parse at byte 26: Table type should be anyfunc or anyref, got -3 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     171         "WebAssembly.Module doesn't parse at byte 18: Table type should be funcref or anyref, got -3 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
     172         "WebAssembly.Module doesn't parse at byte 26: Table type should be funcref or anyref, got -3 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    173173        [{initial: 10, maximum: 20, element: "f64"},
    174          "WebAssembly.Module doesn't parse at byte 18: Table type should be anyfunc or anyref, got -4 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    175          "WebAssembly.Module doesn't parse at byte 26: Table type should be anyfunc or anyref, got -4 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     174         "WebAssembly.Module doesn't parse at byte 18: Table type should be funcref or anyref, got -4 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
     175         "WebAssembly.Module doesn't parse at byte 26: Table type should be funcref or anyref, got -4 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    176176        [{initial: 10, maximum: 20, element: "i64"},
    177          "WebAssembly.Module doesn't parse at byte 18: Table type should be anyfunc or anyref, got -2 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    178          "WebAssembly.Module doesn't parse at byte 26: Table type should be anyfunc or anyref, got -2 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    179 
    180         [{initial: 10, maximum: 9, element: "anyfunc"},
     177         "WebAssembly.Module doesn't parse at byte 18: Table type should be funcref or anyref, got -2 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
     178         "WebAssembly.Module doesn't parse at byte 26: Table type should be funcref or anyref, got -2 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     179
     180        [{initial: 10, maximum: 9, element: "funcref"},
    181181         "WebAssembly.Module doesn't parse at byte 21: resizable limits has a initial page count of 10 which is greater than its maximum 9 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    182182         "WebAssembly.Module doesn't parse at byte 29: resizable limits has a initial page count of 10 which is greater than its maximum 9 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    183         [{initial: 1, maximum: 0, element: "anyfunc"},
     183        [{initial: 1, maximum: 0, element: "funcref"},
    184184         "WebAssembly.Module doesn't parse at byte 21: resizable limits has a initial page count of 1 which is greater than its maximum 0 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    185185         "WebAssembly.Module doesn't parse at byte 29: resizable limits has a initial page count of 1 which is greater than its maximum 0 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    186         [{initial: 2**32 - 1, maximum: 2**32 - 2, element: "anyfunc"},
     186        [{initial: 2**32 - 1, maximum: 2**32 - 2, element: "funcref"},
    187187         "WebAssembly.Module doesn't parse at byte 29: resizable limits has a initial page count of 4294967295 which is greater than its maximum 4294967294 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    188188         "WebAssembly.Module doesn't parse at byte 37: resizable limits has a initial page count of 4294967295 which is greater than its maximum 4294967294 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
    189         [{initial: 2**31, element: "anyfunc"},
     189        [{initial: 2**31, element: "funcref"},
    190190         "WebAssembly.Module doesn't parse at byte 24: Table's initial page count of 2147483648 is too big, maximum 10000000 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')",
    191191         "WebAssembly.Module doesn't parse at byte 32: Table's initial page count of 2147483648 is too big, maximum 10000000 (evaluating 'new WebAssembly.Module(builder.WebAssembly().get())')"],
     
    202202        .Type().End()
    203203        .Import()
    204             .Table("imp", "table", {initial: 20, element: "anyfunc"})
    205             .Table("imp", "table", {initial: 20, element: "anyfunc"})
     204            .Table("imp", "table", {initial: 20, element: "funcref"})
     205            .Table("imp", "table", {initial: 20, element: "funcref"})
    206206        .End()
    207207        .Function().End()
     
    227227
    228228    const badTables = [
    229         [{initial: 100, maximum:100, element:"anyfunc"}, new WebAssembly.Table({initial:100, element: "anyfunc"}), "Table import imp:table does not have a 'maximum' but the module requires that it does (evaluating 'new WebAssembly.Instance(module, {imp: {table}})')"],
    230         [{initial: 100, maximum:100, element:"anyfunc"}, new WebAssembly.Table({initial:100, maximum:101, element: "anyfunc"}), "Imported Table imp:table 'maximum' is larger than the module's expected 'maximum' (evaluating 'new WebAssembly.Instance(module, {imp: {table}})')"],
    231         [{initial: 100, element:"anyfunc"}, new WebAssembly.Table({initial:10, element: "anyfunc"}), "Table import imp:table provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, {imp: {table}})')"],
    232         [{initial: 10, element:"anyfunc"}, new WebAssembly.Table({initial:9, element: "anyfunc"}), "Table import imp:table provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, {imp: {table}})')"],
     229        [{initial: 100, maximum:100, element:"funcref"}, new WebAssembly.Table({initial:100, element: "funcref"}), "Table import imp:table does not have a 'maximum' but the module requires that it does (evaluating 'new WebAssembly.Instance(module, {imp: {table}})')"],
     230        [{initial: 100, maximum:100, element:"funcref"}, new WebAssembly.Table({initial:100, maximum:101, element: "funcref"}), "Imported Table imp:table 'maximum' is larger than the module's expected 'maximum' (evaluating 'new WebAssembly.Instance(module, {imp: {table}})')"],
     231        [{initial: 100, element:"funcref"}, new WebAssembly.Table({initial:10, element: "funcref"}), "Table import imp:table provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, {imp: {table}})')"],
     232        [{initial: 10, element:"funcref"}, new WebAssembly.Table({initial:9, element: "funcref"}), "Table import imp:table provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, {imp: {table}})')"],
    233233    ];
    234234    for (const [d, t, m] of badTables) {
     
    241241{
    242242    {
    243         const table = new WebAssembly.Table({element: "anyfunc", initial: 20, maximum: 30});
     243        const table = new WebAssembly.Table({element: "funcref", initial: 20, maximum: 30});
    244244        assert.eq(20, table.grow(0));
    245245        assert.eq(20, table.length);
     
    249249
    250250    {
    251         const table = new WebAssembly.Table({element: "anyfunc", initial: 20, maximum: 30});
     251        const table = new WebAssembly.Table({element: "funcref", initial: 20, maximum: 30});
    252252        assert.eq(20, table.grow(10));
    253253        assert.eq(30, table.grow(0));
     
    256256
    257257    {
    258         const table = new WebAssembly.Table({element: "anyfunc", initial: 20});
     258        const table = new WebAssembly.Table({element: "funcref", initial: 20});
    259259        let called = false;
    260260        table.grow({valueOf() { called = true; return 42; }});
     
    264264
    265265    {
    266         const table = new WebAssembly.Table({element: "anyfunc", initial: 20});
     266        const table = new WebAssembly.Table({element: "funcref", initial: 20});
    267267        assert.throws(() => table.get(20), RangeError, "WebAssembly.Table.prototype.get expects an integer less than the length of the table");
    268268        for (let i = 0; i < 20; i++)
     
    271271
    272272    {
    273         const table = new WebAssembly.Table({element: "anyfunc", initial: 20});
     273        const table = new WebAssembly.Table({element: "funcref", initial: 20});
    274274        assert.throws(() => table.set(20, null), RangeError, "WebAssembly.Table.prototype.set expects an integer less than the length of the table");
    275275        for (let i = 0; i < 20; i++)
     
    279279    {
    280280        // This should not throw
    281         new WebAssembly.Table({initial: 2**20, maximum: 2**32 - 1, element: "anyfunc"});
     281        new WebAssembly.Table({initial: 2**20, maximum: 2**32 - 1, element: "funcref"});
    282282    }
    283283}
     
    289289            .Type().End()
    290290            .Import()
    291                 .Table("imp", "table", {initial: 25, element: "anyfunc"})
     291                .Table("imp", "table", {initial: 25, element: "funcref"})
    292292            .End()
    293293            .Function().End()
     
    307307        .Type().End()
    308308        .Import()
    309             .Table("imp", "table", {initial: 25, element: "anyfunc"})
     309            .Table("imp", "table", {initial: 25, element: "funcref"})
    310310        .End()
    311311        .Function().End()
     
    317317
    318318    const module = new WebAssembly.Module(builder.WebAssembly().get());
    319     const table = new WebAssembly.Table({element: "anyfunc", initial: 25});
     319    const table = new WebAssembly.Table({element: "funcref", initial: 25});
    320320    const instance = new WebAssembly.Instance(module, {imp: {table}});
    321321    assert.truthy(table === instance.exports.table);
     
    328328        .Function().End()
    329329        .Table()
    330             .Table({initial: 20, maximum: 30, element: "anyfunc"})
     330            .Table({initial: 20, maximum: 30, element: "funcref"})
    331331        .End()
    332332        .Export()
     
    348348        .Function().End()
    349349        .Table()
    350             .Table({initial: 0, maximum: 1, element: "anyfunc"})
    351             .Table({initial: 20, maximum: 30, element: "anyfunc"})
     350            .Table({initial: 0, maximum: 1, element: "funcref"})
     351            .Table({initial: 20, maximum: 30, element: "funcref"})
    352352        .End()
    353353        .Export()
  • trunk/JSTests/wasm/js-api/test_basic_api.js

    r235420 r246589  
    9494        break;
    9595    case "Table":
    96         new WebAssembly.Table({initial: 20, element: "anyfunc"});
    97         new WebAssembly.Table({initial: 20, maximum: 20, element: "anyfunc"});
    98         new WebAssembly.Table({initial: 20, maximum: 25, element: "anyfunc"});
     96        new WebAssembly.Table({initial: 20, element: "funcref"});
     97        new WebAssembly.Table({initial: 20, maximum: 20, element: "funcref"});
     98        new WebAssembly.Table({initial: 20, maximum: 25, element: "funcref"});
    9999        break;
    100100    case "CompileError":
  • trunk/JSTests/wasm/js-api/unique-signature.js

    r210026 r246589  
    1717        .Function().End()
    1818        .Table()
    19             .Table({initial: 4, maximum: 4, element: "anyfunc"})
     19            .Table({initial: 4, maximum: 4, element: "funcref"})
    2020        .End()
    2121        .Export()
  • trunk/JSTests/wasm/js-api/wrapper-function.js

    r223274 r246589  
    5757
    5858{
    59     const tableDescription = {element: "anyfunc", initial: 2};
     59    const tableDescription = {element: "funcref", initial: 2};
    6060    function makeInstance(type, imp) {
    6161        const builder = new Builder()
  • trunk/JSTests/wasm/modules/table.wat

    r230759 r246589  
    11(module
    2     (table $table (export "table") 3 anyfunc)
     2    (table $table (export "table") 3 funcref)
    33    (func $f0 (result i32) i32.const 42)
    44    (func $f1 (result i32) i32.const 83)
  • trunk/JSTests/wasm/modules/wasm-imports-js-re-exports-wasm-exports/imports.wat

    r230768 r246589  
    22    (import "./re-export.js" "sum" (func $sum (param i32 i32) (result i32)))
    33    (import "./re-export.js" "answer" (global i32))
    4     (import "./re-export.js" "table" (table $table 4 anyfunc))
     4    (import "./re-export.js" "table" (table $table 4 funcref))
    55    (export "table" (table $table))
    66    (type $t0 (func (param i32) (result i32)))
  • trunk/JSTests/wasm/modules/wasm-imports-js-re-exports-wasm-exports/sum.wat

    r230768 r246589  
    66        i32.add)
    77    (global (export "answer") i32 i32.const 42)
    8     (table $table (export "table") 4 anyfunc)
     8    (table $table (export "table") 4 funcref)
    99    (elem (i32.const 0) $sum))
  • trunk/JSTests/wasm/modules/wasm-imports-wasm-exports/imports.wat

    r230768 r246589  
    66    (import "./sum.wasm" "answer3" (global f32))
    77    (import "./sum.wasm" "answer4" (global f64))
    8     (import "./sum.wasm" "table" (table $table 4 anyfunc))
     8    (import "./sum.wasm" "table" (table $table 4 funcref))
    99    (type $t0 (func (param i32) (result i32)))
    1010    (func $addOne (export "addOne") (type $t0) (param $p0 i32) (result i32)
  • trunk/JSTests/wasm/modules/wasm-imports-wasm-exports/sum.wat

    r230768 r246589  
    11(module
    2     (table $table (export "table") 4 anyfunc)
     2    (table $table (export "table") 4 funcref)
    33    (type $t0 (func (param i32 i32) (result i32)))
    44    (func $sum (export "sum") (type $t0) (param $p0 i32) (param $p1 i32) (result i32)
  • trunk/JSTests/wasm/references/anyref_table.js

    r246571 r246589  
    7474      .I32Const(42)
    7575    .End()
    76     .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't parse at byte 30: Table 0 must have type 'anyfunc' to have an element section (evaluating 'new WebAssembly.Module')")
     76    .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't parse at byte 30: Table 0 must have type 'funcref' to have an element section (evaluating 'new WebAssembly.Module')")
    7777
    7878function doGCSet() {
  • trunk/JSTests/wasm/references/anyref_table_import.js

    r246571 r246589  
    211211
    212212{
    213     const tbl = new WebAssembly.Table({initial:2, element:"anyfunc"});
     213    const tbl = new WebAssembly.Table({initial:2, element:"funcref"});
    214214
    215215    const mod = new WebAssembly.Module((new Builder())
     
    226226    assert.throws(() => new WebAssembly.Instance(mod, { imp: { tbl }}), Error, "Table import imp:tbl provided a 'type' that is wrong (evaluating 'new WebAssembly.Instance(mod, { imp: { tbl }})')");
    227227}
     228
     229{
     230    const tbl = new WebAssembly.Table({initial:2, element:"funcref"});
     231
     232    const mod = new WebAssembly.Module((new Builder())
     233      .Type().End()
     234      .Import()
     235            .Table("imp", "tbl", {initial: 2, element: "anyref"})
     236      .End()
     237      .Function().End()
     238      .Export()
     239      .End()
     240      .Code()
     241      .End().WebAssembly().get())
     242
     243    assert.throws(() => new WebAssembly.Instance(mod, { imp: { tbl }}), Error, "Table import imp:tbl provided a 'type' that is wrong (evaluating 'new WebAssembly.Instance(mod, { imp: { tbl }})')");
     244}
  • trunk/JSTests/wasm/references/func_ref.js

    r246571 r246589  
    4545}
    4646
    47 function makeAnyfuncIdent() {
     47function makeFuncrefIdent() {
    4848    const builder = (new Builder())
    4949          .Type().End()
     
    5353          .End()
    5454          .Code()
    55             .Function("h", { params: ["anyfunc"], ret: "anyfunc" }, [])
     55            .Function("h", { params: ["funcref"], ret: "funcref" }, [])
    5656              .GetLocal(0)
    5757            .End()
     
    8383          .End()
    8484          .Code()
    85             .Function("h", { params: ["anyfunc"], ret: "anyref" }, ["anyref"])
     85            .Function("h", { params: ["funcref"], ret: "anyref" }, ["anyref"])
    8686              .GetLocal(0)
    8787              .SetLocal(1)
     
    8989            .End()
    9090
    91             .Function("i", { params: ["anyfunc"], ret: "anyfunc" }, ["anyfunc"])
     91            .Function("i", { params: ["funcref"], ret: "funcref" }, ["funcref"])
    9292              .GetLocal(0)
    9393              .SetLocal(1)
     
    9595            .End()
    9696
    97             .Function("get_h", { params: [], ret: "anyfunc" }, ["anyfunc"])
     97            .Function("get_h", { params: [], ret: "funcref" }, ["funcref"])
    9898              .I32Const(0)
    9999              .RefFunc(0)
    100100              .SetLocal(0)
    101               .If("anyfunc")
    102               .Block("anyfunc", (b) =>
     101              .If("funcref")
     102              .Block("funcref", (b) =>
    103103                b.GetLocal(0)
    104104              )
    105105              .Else()
    106               .Block("anyfunc", (b) =>
     106              .Block("funcref", (b) =>
    107107                b.GetLocal(0)
    108108              )
     
    110110            .End()
    111111
    112             .Function("fix", { params: [], ret: "anyfunc" }, [])
     112            .Function("fix", { params: [], ret: "funcref" }, [])
    113113              .RefFunc(3)
    114114            .End()
    115115
    116             .Function("get_not_exported", { params: [], ret: "anyfunc" }, [])
     116            .Function("get_not_exported", { params: [], ret: "funcref" }, [])
    117117              .RefFunc(5)
    118118            .End()
     
    122122            .End()
    123123
    124             .Function("local_read", { params: [], ret: "i32" }, ["anyfunc"])
     124            .Function("local_read", { params: [], ret: "i32" }, ["funcref"])
    125125              .GetLocal(0)
    126126              .RefIsNull()
     
    136136    assert.eq(instance.exports.h(null), null)
    137137
    138     assert.throws(() => instance.exports.h(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     138    assert.throws(() => instance.exports.h(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    139139    assert.eq(instance.exports.h(myfun), myfun)
    140     assert.throws(() => instance.exports.h(5), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
    141     assert.throws(() => instance.exports.h(undefined), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     140    assert.throws(() => instance.exports.h(5), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
     141    assert.throws(() => instance.exports.h(undefined), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    142142
    143143    assert.eq(instance.exports.i(null), null)
    144144    assert.eq(instance.exports.i(myfun), myfun)
    145     assert.throws(() => instance.exports.i(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
    146     assert.throws(() => instance.exports.i(5), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
    147 
    148     assert.throws(() => instance.exports.get_h()(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     145    assert.throws(() => instance.exports.i(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
     146    assert.throws(() => instance.exports.i(5), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
     147
     148    assert.throws(() => instance.exports.get_h()(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    149149    assert.eq(instance.exports.get_h()(null), null)
    150150    assert.eq(instance.exports.get_h()(myfun), myfun)
    151     assert.throws(() => instance.exports.get_h()(5), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     151    assert.throws(() => instance.exports.get_h()(5), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    152152
    153153    assert.eq(instance.exports.get_not_exported()(), 42)
     
    168168      .Type().End()
    169169      .Import()
    170            .Global().Anyfunc("imp", "ref", "immutable").End()
     170           .Global().Funcref("imp", "ref", "immutable").End()
    171171      .End()
    172172      .Function().End()
    173173      .Global()
    174           .RefNull("anyfunc", "mutable")
    175           .RefNull("anyfunc", "immutable")
    176           .GetGlobal("anyfunc", 0, "mutable")
    177           .RefFunc("anyfunc", 2, "immutable")
     174          .RefNull("funcref", "mutable")
     175          .RefNull("funcref", "immutable")
     176          .GetGlobal("funcref", 0, "mutable")
     177          .RefFunc("funcref", 2, "immutable")
    178178      .End()
    179179      .Export()
     
    188188      .End()
    189189      .Code()
    190         .Function("set_glob", { params: ["anyfunc"], ret: "void" })
     190        .Function("set_glob", { params: ["funcref"], ret: "void" })
    191191          .GetLocal(0)
    192192          .SetGlobal(1)
    193193        .End()
    194194
    195         .Function("get_glob", { params: [], ret: "anyfunc" })
     195        .Function("get_glob", { params: [], ret: "funcref" })
    196196            .GetGlobal(1)
    197197        .End()
     
    207207        .End()
    208208
    209         .Function("get_import", { params: [], ret: "anyfunc" })
     209        .Function("get_import", { params: [], ret: "funcref" })
    210210            .GetGlobal(0)
    211211        .End()
     
    224224    $1.exports.set_glob(myfun); assert.eq($1.exports.get_glob()(), 42);
    225225
    226     assert.throws(() => $1.exports.set_glob(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     226    assert.throws(() => $1.exports.set_glob(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    227227
    228228    assert.eq($1.exports.glob_is_null(), 0)
     
    234234  .Type().End()
    235235  .Import()
    236        .Global().Anyfunc("imp", "ref", "immutable").End()
     236       .Global().Funcref("imp", "ref", "immutable").End()
    237237  .End()
    238238  .Function().End()
     
    243243  .Function().End()
    244244  .Code()
    245     .Function("h", { params: ["anyfunc"], ret: "anyref" })
     245    .Function("h", { params: ["funcref"], ret: "anyref" })
    246246      .GetLocal(0)
    247247    .End()
     
    252252  .Function().End()
    253253  .Table()
    254     .Table({initial: 1, element: "anyfunc"})
     254    .Table({initial: 1, element: "funcref"})
    255255  .End()
    256256  .Code()
     
    260260      .TableSet(0)
    261261    .End()
    262   .End().WebAssembly().get()), Error, "WebAssembly.Module doesn't validate: table.set value to type I32 expected Anyfunc, in function at index 0 (evaluating 'new WebAssembly.Module')");
     262  .End().WebAssembly().get()), Error, "WebAssembly.Module doesn't validate: table.set value to type I32 expected Funcref, in function at index 0 (evaluating 'new WebAssembly.Module')");
    263263
    264264// Tables
     
    269269      .Table()
    270270            .Table({initial: 0, element: "anyref"})
    271             .Table({initial: 1, element: "anyfunc"})
     271            .Table({initial: 1, element: "funcref"})
    272272      .End()
    273273      .Global()
    274           .RefNull("anyfunc", "mutable")
     274          .RefNull("funcref", "mutable")
    275275      .End()
    276276      .Export()
     
    281281      .End()
    282282      .Code()
    283         .Function("set_glob", { params: ["anyfunc"], ret: "void" })
     283        .Function("set_glob", { params: ["funcref"], ret: "void" })
    284284          .GetLocal(0)
    285285          .SetGlobal(0)
    286286        .End()
    287287
    288         .Function("get_glob", { params: [], ret: "anyfunc" })
     288        .Function("get_glob", { params: [], ret: "funcref" })
    289289            .GetGlobal(0)
    290290        .End()
     
    315315    $1.exports.set_glob(ident); assert.eq($1.exports.get_glob(), ident); assert.eq($1.exports.call_glob(42), 42)
    316316
    317     assert.throws(() => $1.exports.set_glob(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     317    assert.throws(() => $1.exports.set_glob(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    318318    $1.exports.set_glob(myfun); assert.eq($1.exports.get_glob(), myfun); assert.throws(() => $1.exports.call_glob(42), Error, "call_indirect to a signature that does not match (evaluating 'func(...args)')")
    319319
    320320    for (let i=0; i<1000; ++i) {
    321         assert.throws(() => $1.exports.set_glob(function() {}), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')");
     321        assert.throws(() => $1.exports.set_glob(function() {}), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')");
    322322    }
    323323}
     
    331331      .Table()
    332332            .Table({initial: 0, element: "anyref"})
    333             .Table({initial: 1, element: "anyfunc"})
     333            .Table({initial: 1, element: "funcref"})
    334334      .End()
    335335      .Export()
     
    338338      .End()
    339339      .Code()
    340         .Function("set", { params: ["anyfunc"], ret: "void" })
     340        .Function("set", { params: ["funcref"], ret: "void" })
    341341          .I32Const(0)
    342342          .GetLocal(0)
     
    344344        .End()
    345345
    346         .Function("get", { params: [], ret: "anyfunc" })
     346        .Function("get", { params: [], ret: "funcref" })
    347347            .I32Const(0)
    348348            .TableGet(1)
     
    377377// Wasm->JS Calls
    378378
    379 for (let importedFun of [function(i) { return i; }, makeAnyfuncIdent()]) {
     379for (let importedFun of [function(i) { return i; }, makeFuncrefIdent()]) {
    380380    const $1 = new WebAssembly.Instance(new WebAssembly.Module((new Builder())
    381381      .Type().End()
    382382      .Import()
    383            .Function("imp", "h", { params: ["anyfunc"], ret: "anyfunc" })
     383           .Function("imp", "h", { params: ["funcref"], ret: "funcref" })
    384384      .End()
    385385      .Function().End()
    386386      .Table()
    387             .Table({initial: 1, element: "anyfunc"})
     387            .Table({initial: 1, element: "funcref"})
    388388      .End()
    389389      .Export()
     
    394394      .End()
    395395      .Code()
    396         .Function("test1", { params: ["anyfunc"], ret: "anyfunc" })
     396        .Function("test1", { params: ["funcref"], ret: "funcref" })
    397397          .GetLocal(0)
    398398          .Call(0)
    399399        .End()
    400400
    401         .Function("test2", { params: [], ret: "anyfunc" })
     401        .Function("test2", { params: [], ret: "funcref" })
    402402          .RefFunc(1)
    403403          .Call(0)
    404404        .End()
    405405
    406         .Function("test3", { params: ["anyfunc"], ret: "anyfunc" })
     406        .Function("test3", { params: ["funcref"], ret: "funcref" })
    407407          .GetLocal(0)
    408408          .I32Const(0)
     
    413413        .End()
    414414
    415         .Function("test4", { params: [], ret: "anyfunc" })
     415        .Function("test4", { params: [], ret: "funcref" })
    416416          .RefFunc(1)
    417417          .I32Const(0)
     
    431431        assert.eq(test(myfun), myfun)
    432432        assert.eq(test(myfun)(), 1337)
    433         assert.throws(() => test(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     433        assert.throws(() => test(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    434434
    435435        for (let i=0; i<1000; ++i) {
    436             assert.throws(() => test(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     436            assert.throws(() => test(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    437437        }
    438438    }
     
    441441        assert.eq(test(), $1.exports.test1)
    442442        assert.eq(test()(myfun), myfun)
    443         assert.throws(() => test()(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     443        assert.throws(() => test()(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    444444
    445445        for (let i=0; i<1000; ++i) {
    446             assert.throws(() => test()(fun), Error, "Anyfunc must be an exported wasm function (evaluating 'func(...args)')")
     446            assert.throws(() => test()(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    447447        }
    448448    }
  • trunk/JSTests/wasm/references/multitable.js

    r246571 r246589  
    172172          .Function().End()
    173173          .Table()
    174                 .Table({initial: 3, maximum: 30, element: "anyfunc"})
    175                 .Table({initial: 2, maximum: 30, element: "anyfunc"})
     174                .Table({initial: 3, maximum: 30, element: "funcref"})
     175                .Table({initial: 2, maximum: 30, element: "funcref"})
    176176          .End()
    177177          .Export()
     
    221221          .Function().End()
    222222          .Table()
    223                 .Table({initial: 3, maximum: 30, element: "anyfunc"})
    224                 .Table({initial: 2, maximum: 30, element: "anyfunc"})
     223                .Table({initial: 3, maximum: 30, element: "funcref"})
     224                .Table({initial: 2, maximum: 30, element: "funcref"})
    225225          .End()
    226226          .Export()
     
    273273          .Function().End()
    274274          .Table()
    275                 .Table({initial: 3, maximum: 3, element: "anyfunc"})
    276                 .Table({initial: 2, maximum: 2, element: "anyfunc"})
     275                .Table({initial: 3, maximum: 3, element: "funcref"})
     276                .Table({initial: 2, maximum: 2, element: "funcref"})
    277277          .End()
    278278          .Element()
     
    292292          .Table()
    293293                .Table({initial: 3, maximum: 3, element: "anyref"})
    294                 .Table({initial: 2, maximum: 3, element: "anyfunc"})
     294                .Table({initial: 2, maximum: 3, element: "funcref"})
    295295          .End()
    296296          .Element()
     
    303303              .I32Const(42)
    304304            .End()
    305           .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't parse at byte 40: Table 0 must have type 'anyfunc' to have an element section (evaluating 'new WebAssembly.Module')")
    306 
    307 assert.throws(() => new WebAssembly.Instance(new WebAssembly.Module((new Builder())
    308           .Type().End()
    309           .Function().End()
    310           .Table()
    311                 .Table({initial: 3, maximum: 3, element: "anyref"})
    312                 .Table({initial: 2, maximum: 3, element: "anyfunc"})
     305          .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't parse at byte 40: Table 0 must have type 'funcref' to have an element section (evaluating 'new WebAssembly.Module')")
     306
     307assert.throws(() => new WebAssembly.Instance(new WebAssembly.Module((new Builder())
     308          .Type().End()
     309          .Function().End()
     310          .Table()
     311                .Table({initial: 3, maximum: 3, element: "anyref"})
     312                .Table({initial: 2, maximum: 3, element: "funcref"})
    313313          .End()
    314314          .Code()
     
    324324          .Table()
    325325                .Table({initial: 3, maximum: 3, element: "anyref"})
    326                 .Table({initial: 2, maximum: 3, element: "anyfunc"})
     326                .Table({initial: 2, maximum: 3, element: "funcref"})
    327327          .End()
    328328          .Code()
     
    339339          .Table()
    340340                .Table({initial: 3, maximum: 3, element: "anyref"})
    341                 .Table({initial: 2, maximum: 3, element: "anyfunc"})
     341                .Table({initial: 2, maximum: 3, element: "funcref"})
    342342          .End()
    343343          .Code()
     
    352352          .Table()
    353353                .Table({initial: 3, maximum: 3, element: "anyref"})
    354                 .Table({initial: 2, maximum: 3, element: "anyfunc"})
     354                .Table({initial: 2, maximum: 3, element: "funcref"})
    355355          .End()
    356356          .Code()
     
    358358              .CallIndirect(0,0)
    359359            .End()
    360           .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't parse at byte 4: call_indirect is only valid when a table has type anyfunc, in function at index 0 (evaluating 'new WebAssembly.Module')")
    361 
    362 assert.throws(() => new WebAssembly.Instance(new WebAssembly.Module((new Builder())
    363           .Type().End()
    364           .Function().End()
    365           .Table()
    366                 .Table({initial: 3, maximum: 3, element: "anyref"})
    367                 .Table({initial: 2, maximum: 3, element: "anyfunc"})
     360          .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't parse at byte 4: call_indirect is only valid when a table has type funcref, in function at index 0 (evaluating 'new WebAssembly.Module')")
     361
     362assert.throws(() => new WebAssembly.Instance(new WebAssembly.Module((new Builder())
     363          .Type().End()
     364          .Function().End()
     365          .Table()
     366                .Table({initial: 3, maximum: 3, element: "anyref"})
     367                .Table({initial: 2, maximum: 3, element: "funcref"})
    368368          .End()
    369369          .Code()
     
    372372              .TableGet(0)
    373373            .End()
    374           .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't validate: table.get index to type Anyfunc expected I32, in function at index 0 (evaluating 'new WebAssembly.Module')")
    375 
    376 
    377 assert.throws(() => new WebAssembly.Instance(new WebAssembly.Module((new Builder())
    378           .Type().End()
    379           .Function().End()
    380           .Table()
    381                 .Table({initial: 3, maximum: 3, element: "anyref"})
    382                 .Table({initial: 2, maximum: 3, element: "anyfunc"})
     374          .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't validate: table.get index to type Funcref expected I32, in function at index 0 (evaluating 'new WebAssembly.Module')")
     375
     376
     377assert.throws(() => new WebAssembly.Instance(new WebAssembly.Module((new Builder())
     378          .Type().End()
     379          .Function().End()
     380          .Table()
     381                .Table({initial: 3, maximum: 3, element: "anyref"})
     382                .Table({initial: 2, maximum: 3, element: "funcref"})
    383383          .End()
    384384          .Code()
     
    388388              .TableSet(0)
    389389            .End()
    390           .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't validate: table.set index to type Anyfunc expected I32, in function at index 0 (evaluating 'new WebAssembly.Module')")
    391 
    392 assert.throws(() => new WebAssembly.Instance(new WebAssembly.Module((new Builder())
    393           .Type().End()
    394           .Function().End()
    395           .Table()
    396                 .Table({initial: 3, maximum: 3, element: "anyref"})
    397                 .Table({initial: 2, maximum: 3, element: "anyfunc"})
     390          .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't validate: table.set index to type Funcref expected I32, in function at index 0 (evaluating 'new WebAssembly.Module')")
     391
     392assert.throws(() => new WebAssembly.Instance(new WebAssembly.Module((new Builder())
     393          .Type().End()
     394          .Function().End()
     395          .Table()
     396                .Table({initial: 3, maximum: 3, element: "anyref"})
     397                .Table({initial: 2, maximum: 3, element: "funcref"})
    398398          .End()
    399399          .Code()
     
    403403              .TableSet(1)
    404404            .End()
    405           .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't validate: table.set value to type Anyref expected Anyfunc, in function at index 0 (evaluating 'new WebAssembly.Module')")
     405          .End().WebAssembly().get())), Error, "WebAssembly.Module doesn't validate: table.set value to type Anyref expected Funcref, in function at index 0 (evaluating 'new WebAssembly.Module')")
    406406
    407407function tableInsanity(num, b) {
     
    429429    const $1 = new WebAssembly.Instance(new WebAssembly.Module(tableInsanity(1000000-2, (new Builder())
    430430          .Type().End())
    431                 .Table({initial: 3, maximum: 3, element: "anyfunc"})
     431                .Table({initial: 3, maximum: 3, element: "funcref"})
    432432                .Table({initial: 3, maximum: 3, element: "anyref"})
    433433          .End()
  • trunk/JSTests/wasm/references/table_misc.js

    r246577 r246589  
    195195          .Function().End()
    196196          .Table()
    197                 .Table({initial: 0, maximum: 0, element: "anyfunc"})
    198                 .Table({initial: 20, maximum: 30, element: "anyfunc"})
     197                .Table({initial: 0, maximum: 0, element: "funcref"})
     198                .Table({initial: 20, maximum: 30, element: "funcref"})
    199199          .End()
    200200          .Export()
  • trunk/JSTests/wasm/references/validation.js

    r246571 r246589  
    2626      .Type().End()
    2727      .Import()
    28             .Table("imp", "tbl", {initial: 2, element: "anyfunc"})
     28            .Table("imp", "tbl", {initial: 2, element: "funcref"})
    2929      .End()
    3030      .Function().End()
     
    4343    bin.trim();
    4444
    45     assert.throws(() => new WebAssembly.Module(bin.get()), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: table.set value to type I32 expected Anyfunc, in function at index 0 (evaluating 'new WebAssembly.Module(bin.get())')");
     45    assert.throws(() => new WebAssembly.Module(bin.get()), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: table.set value to type I32 expected Funcref, in function at index 0 (evaluating 'new WebAssembly.Module(bin.get())')");
    4646}
    4747
     
    5050      .Type().End()
    5151      .Import()
    52             .Table("imp", "tbl", {initial: 2, element: "anyfunc"})
     52            .Table("imp", "tbl", {initial: 2, element: "funcref"})
    5353      .End()
    5454      .Function().End()
     
    6767    bin.trim();
    6868
    69     assert.throws(() => new WebAssembly.Module(bin.get()), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: table.set value to type Anyref expected Anyfunc, in function at index 0 (evaluating 'new WebAssembly.Module(bin.get())')");
     69    assert.throws(() => new WebAssembly.Module(bin.get()), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: table.set value to type Anyref expected Funcref, in function at index 0 (evaluating 'new WebAssembly.Module(bin.get())')");
    7070}
    7171
     
    7474      .Type().End()
    7575      .Import()
    76             .Table("imp", "tbl", {initial: 2, element: "anyfunc"})
     76            .Table("imp", "tbl", {initial: 2, element: "funcref"})
    7777      .End()
    7878      .Function().End()
     
    9494
    9595{
    96     assert.throws(() => new WebAssembly.Table({initial:2, element:"i32"}), TypeError, "WebAssembly.Table expects its 'element' field to be the string 'anyfunc' or 'anyref'");
     96    assert.throws(() => new WebAssembly.Table({initial:2, element:"i32"}), TypeError, "WebAssembly.Table expects its 'element' field to be the string 'funcref' or 'anyref'");
    9797}
  • trunk/JSTests/wasm/spec-harness/index.js

    r245496 r246589  
    8383            print: print,
    8484            global: 666,
    85             table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'anyfunc'}),
     85            table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'funcref'}),
    8686            memory: new WebAssembly.Memory({initial: 1, maximum: 2})
    8787        }
  • trunk/JSTests/wasm/spec-harness/wasm-constants.js

    r218216 r246589  
    7272
    7373let kWasmFunctionTypeForm = 0x60;
    74 let kWasmAnyFunctionTypeForm = 0x70;
     74let kWasmFuncReftionTypeForm = 0x70;
    7575
    7676let kResizableMaximumFlag = 1;
  • trunk/JSTests/wasm/spec-harness/wasm-module-builder.js

    r218216 r246589  
    322322            if (has_max) section.emit_u32v(imp.maximum); // maximum
    323323          } else if (imp.kind == kExternalTable) {
    324             section.emit_u8(kWasmAnyFunctionTypeForm);
     324            section.emit_u8(kWasmFuncReftionTypeForm);
    325325            var has_max = (typeof imp.maximum) != "undefined";
    326326            section.emit_u8(has_max ? 1 : 0); // flags
     
    355355      binary.emit_section(kTableSectionCode, section => {
    356356        section.emit_u8(1);  // one table entry
    357         section.emit_u8(kWasmAnyFunctionTypeForm);
     357        section.emit_u8(kWasmFuncReftionTypeForm);
    358358        section.emit_u8(1);
    359359        section.emit_u32v(wasm.function_table_length);
  • trunk/JSTests/wasm/spec-harness/wast.js

    r214824 r246589  
    1483214832  }
    1483314833  else {
    14834     return /* AnyFuncType */0;
     14834    return /* FuncRefType */0;
    1483514835  }
    1483614836}
     
    2070720707                          })]);
    2070820708        case 11 :
    20709             return /* ANYFUNC */0;
     20709            return /* FUNCREF */0;
    2071020710        case 12 :
    2071120711            return /* MUT */1;
     
    2599425994  },
    2599525995  function () {
    25996     return /* AnyFuncType */0;
     25996    return /* FuncRefType */0;
    2599725997  },
    2599825998  function (__caml_parser_env) {
     
    2767927679  /* check */"Y\0\0\0\\\0\xb5\0^\0\xbf\0\xb4\0\x8f\0\xbc\0\xbd\0\xd7\0\x89\0Z\0[\0\xbc\0]\0\xce\0\xca\0\xc4\0^\0X\0\b\x01\xc5\0\xc6\0\\\0\x97\0^\0\x9b\0\xce\0\x9d\0\xd6\0\xd7\0\t\x01\xd1\0\xd2\0\xdf\0\xe0\0\xe1\0i\x01j\x01k\x01+\x01\x01\x01\n\0b\x01c\x012\x011\x01\x8a\x003\x01\t\x015\x01\x8e\0\x04\x01F\0\t\x01<\x01=\x01\xea\0\n\x01\xe6\0\xe7\0N\0\x8a\0\0\0\x9a\0\x9b\0\x8e\0\x9d\x008\x019\x01&\0<\x01=\x01\b\x01\xcb\0\xcc\0\xcd\0\xfc\0\x85\x01\xd8\0\x87\0\x88\0\x04\x012\x01\x11\x01\b\x01\x8d\0\t\x01\n\x01\x9e\0\x9f\0\xa0\0\xa1\0\xa2\0\x04\x01\xa4\0\xa5\0\xa6\0\xa7\0\xa8\0\n\x01\x10\x01\xaa\x01\x12\x01\x01\x01\x87\0\x88\0\0\0)\x01\x05\x01\x07\x01\x8d\0\t\x01\xcb\0\xcc\0\xcd\0\xcf\0\x01\x01\x03\0\xf6\0\t\x01\xf8\0\x04\x01\x07\x01\xfb\0\n\x011\x01<\x01=\x01\x0e\x01\x04\x01\x01\x01\x11\x01\xdf\0\t\x01\xe1\0\n\x01\x07\x01\x17\0\x18\0\x19\0\x1a\0+\x01\x01\x01\x1d\0\x1a\x012\x01\x05\x011\x01\x04\x013\x01\t\x015\x01\xde\0:\x01;\x01<\x01=\x01>\x01?\x01@\x01A\x01B\x01C\x01D\x01E\x01F\x01G\x01\x13\0\t\x01\x15\0\x16\0\x04\x01{\x01\x04\x01\x04\x01\x04\x01`\x01\n\x01\t\x01\x1f\0 \0\n\x01\x01\x01\n\x01\x14\x01\n\x01\x05\x01'\0x\x01\x04\x01\n\x01z\x01r\x01{\x01x\x01\n\x01\x04\x01.\x01/\x01Q\x01y\x01\x05\x01\n\x01\x04\x016\x01\t\x018\x019\x01\x8c\x01\x81\x01\x8e\x01\x01\0\x02\0\x03\0\x8a\x01\x1b\0\x1c\0\x1d\0\x1e\0\x04\x01\x90\x01#\x01$\x01%\x01&\x01<\x01\x9e\x019\0:\0;\0<\0=\0>\0?\0@\0A\0B\0\x06\x01\xa2\x01K\x01\t\x01\x06\x01\x0e\x01s\x01\t\x01\x11\x01\x06\x01\x06\x01\x04\x01\t\x01\t\x01\x04\x01\x07\x01\x04\x01\xb2\x01\n\x01\x04\x01\xb5\x01\x82\x018\x019\x01U\x01V\x01W\x01X\x01\n\x01\x01\x01\x02\x01\x03\x01h\x01i\x01j\x01k\x01\x91\x01-\x01.\x01/\x01\x05\x01\x06\x01\x04\x01t\x01\n\x01\x06\x01\t\x01\n\x01\t\x01\x04\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\t\x01\x11\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01\x92\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01+\x01,\x01-\x01\t\x01\n\x01\n\x011\x01\n\x013\x014\x015\x016\x01\n\x018\x019\x01\xaa\x01#\x01\x06\x01\n\x01\n\x01\t\x01\x05\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\n\x01H\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01\n\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\x06\x01\x04\x01\x04\x01\t\x01\n\x01\x0b\x01\f\x01\r\x01+\x01\x0f\x01\n\x01\n\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\t\x01\x04\x01\t\x01\t\x01\t\x01\t\x01\n\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\t\x01\x11\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01H\x01\"\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01!\x01\n\x01\t\x01\t\x01\n\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\t\x01\x11\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\x01\x01\t\x01\x06\x01\n\x01\t\x01\n\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\n\x01\x11\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\t\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\t\x01\x04\x01\n\x01\x04\x01\t\x01\n\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\"\x01\x11\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\n\x01\n\x01\n\x01\t\x01\n\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\x06\x01\x11\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\b\x01\n\x01\x01\x01\t\x01\t\x01\x07\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\x06\x01\x11\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\n\x01\n\x016\x01\t\x01\n\x01\x0b\x01\f\x01\r\x01\n\x01\x0f\x01\n\x01\n\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\n\x01\n\x01\x06\x01\t\x01\x04\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x014\x01\n\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\x0e\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\x0e\x01\n\x01\n\x01\n\x01\t\x01\n\x01\x0b\x01\f\x01\r\x01\t\x01\x0f\x01\n\x01\n\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\n\x01\n\x01\n\x01\t\x01\x06\x01\x0b\x01\f\x01\r\x01\x0e\x01\x0f\x01\n\x01\n\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\t\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\n\x01\n\x01\n\x01\t\x01\t\x01\x0b\x01\f\x01\r\x01\n\x01\x0f\x01\n\x01\n\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\x0e\x01\n\x01\n\x01\t\x01\x11\x01\x0b\x01\f\x01\r\x01\n\x01\x0f\x01\t\x01\0\0\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\x11\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\n\x01\n\x01\n\x01\t\x01\x01\x01\x0b\x01\f\x01\r\x01\n\x01\x0f\x01\n\x01\n\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\n\x01\n\x01\x01\x01\n\x01\t\x01\t\x01\x0b\x01\f\x01\r\x01\x01\x01\x0f\x01\x0e\x01\n\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\n\x01H\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\x0e\x01\x86\0\xab\0\xaa\0\t\x01\xf4\0\x0b\x01\f\x01\r\x01\x14\x01\x0f\x01\x02\0\x8d\0\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xffH\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x01\f\x01\r\x01\xff\xff\x0f\x01\xff\xff\xff\xff\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xffH\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff-\x01.\x01/\x010\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff8\x019\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x01\f\x01\r\x01\xff\xff\x0f\x01\xff\xffH\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xff\xff\xff#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff-\x01.\x01/\x010\x01\x0b\x01\f\x01\r\x01\xff\xff\x0f\x01\xff\xff\xff\xff\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xffH\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff\xff\xff.\x01/\x010\x01\x0b\x01\f\x01\r\x01\xff\xff\x0f\x01\xff\xff\xff\xff\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xffH\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x01\f\x01\r\x01\xff\xff\x0f\x01\x10\x017\x01\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xffH\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x01\f\x01\r\x01\xff\xff\x0f\x01\xff\xff\xff\xff\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xffH\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff0\x01\x0b\x01\f\x01\r\x01\xff\xff\x0f\x01\x10\x01\xff\xff\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xffH\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x0b\x01\f\x01\r\x01\xff\xff\x0f\x01\xff\xff\xff\xff\x12\x01\x13\x01\x14\x01\x15\x01\x16\x01\x17\x01\x18\x01\x19\x01\x1a\x01\x1b\x01\x1c\x01\x1d\x01\x1e\x01\x1f\x01 \x01\xff\xffH\x01#\x01$\x01%\x01&\x01'\x01(\x01)\x01*\x01\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xffH\x01",
    2768027680  /* error_function */parse_error,
    27681   /* names_const */"ANYFUNC\0MUT\0LPAR\0RPAR\0NOP\0DROP\0BLOCK\0END\0IF\0THEN\0ELSE\0SELECT\0LOOP\0BR\0BR_IF\0BR_TABLE\0CALL\0CALL_INDIRECT\0RETURN\0GET_LOCAL\0SET_LOCAL\0TEE_LOCAL\0GET_GLOBAL\0SET_GLOBAL\0UNREACHABLE\0CURRENT_MEMORY\0GROW_MEMORY\0FUNC\0START\0TYPE\0PARAM\0RESULT\0LOCAL\0GLOBAL\0MODULE\0TABLE\0ELEM\0MEMORY\0DATA\0OFFSET\0IMPORT\0EXPORT\0SCRIPT\0REGISTER\0INVOKE\0GET\0ASSERT_MALFORMED\0ASSERT_INVALID\0ASSERT_SOFT_INVALID\0ASSERT_UNLINKABLE\0ASSERT_RETURN\0ASSERT_RETURN_NAN\0ASSERT_TRAP\0ASSERT_EXHAUSTION\0INPUT\0OUTPUT\0EOF\0",
     27681  /* names_const */"FUNCREF\0MUT\0LPAR\0RPAR\0NOP\0DROP\0BLOCK\0END\0IF\0THEN\0ELSE\0SELECT\0LOOP\0BR\0BR_IF\0BR_TABLE\0CALL\0CALL_INDIRECT\0RETURN\0GET_LOCAL\0SET_LOCAL\0TEE_LOCAL\0GET_GLOBAL\0SET_GLOBAL\0UNREACHABLE\0CURRENT_MEMORY\0GROW_MEMORY\0FUNC\0START\0TYPE\0PARAM\0RESULT\0LOCAL\0GLOBAL\0MODULE\0TABLE\0ELEM\0MEMORY\0DATA\0OFFSET\0IMPORT\0EXPORT\0SCRIPT\0REGISTER\0INVOKE\0GET\0ASSERT_MALFORMED\0ASSERT_INVALID\0ASSERT_SOFT_INVALID\0ASSERT_UNLINKABLE\0ASSERT_RETURN\0ASSERT_RETURN_NAN\0ASSERT_TRAP\0ASSERT_EXHAUSTION\0INPUT\0OUTPUT\0EOF\0",
    2768227682  /* names_block */"NAT\0INT\0FLOAT\0TEXT\0VAR\0VALUE_TYPE\0LOAD\0STORE\0OFFSET_EQ_NAT\0ALIGN_EQ_NAT\0CONST\0UNARY\0BINARY\0COMPARE\0CONVERT\0TEST\0"
    2768327683];
     
    2946829468
    2946929469function string_of_elem_type() {
    29470   return "anyfunc";
     29470  return "funcref";
    2947129471}
    2947229472
     
    2948329483
    2948429484function string_of_table_type(param) {
    29485   return string_of_limits(param[0]) + " anyfunc";
     29485  return string_of_limits(param[0]) + " funcref";
    2948629486}
    2948729487
  • trunk/JSTests/wasm/spec-tests/jsapi.js

    r218216 r246589  
    515515    assertThrows(() => new Table({initial:1, element:1}), TypeError);
    516516    assertThrows(() => new Table({initial:1, element:"any"}), TypeError);
    517     assertThrows(() => new Table({initial:1, element:{valueOf() { return "anyfunc" }}}), TypeError);
    518     assertThrows(() => new Table({initial:{valueOf() { throw new Error("here")}}, element:"anyfunc"}), Error);
    519     assertThrows(() => new Table({initial:-1, element:"anyfunc"}), RangeError);
    520     assertThrows(() => new Table({initial:Math.pow(2,32), element:"anyfunc"}), RangeError);
    521     assertThrows(() => new Table({initial:2, maximum:1, element:"anyfunc"}), RangeError);
    522     assertThrows(() => new Table({initial:2, maximum:Math.pow(2,32), element:"anyfunc"}), RangeError);
    523     assert_equals(new Table({initial:1, element:"anyfunc"}) instanceof Table, true);
    524     assert_equals(new Table({initial:1.5, element:"anyfunc"}) instanceof Table, true);
    525     assert_equals(new Table({initial:1, maximum:1.5, element:"anyfunc"}) instanceof Table, true);
    526     assert_equals(new Table({initial:1, maximum:Math.pow(2,32)-1, element:"anyfunc"}) instanceof Table, true);
     517    assertThrows(() => new Table({initial:1, element:{valueOf() { return "funcref" }}}), TypeError);
     518    assertThrows(() => new Table({initial:{valueOf() { throw new Error("here")}}, element:"funcref"}), Error);
     519    assertThrows(() => new Table({initial:-1, element:"funcref"}), RangeError);
     520    assertThrows(() => new Table({initial:Math.pow(2,32), element:"funcref"}), RangeError);
     521    assertThrows(() => new Table({initial:2, maximum:1, element:"funcref"}), RangeError);
     522    assertThrows(() => new Table({initial:2, maximum:Math.pow(2,32), element:"funcref"}), RangeError);
     523    assert_equals(new Table({initial:1, element:"funcref"}) instanceof Table, true);
     524    assert_equals(new Table({initial:1.5, element:"funcref"}) instanceof Table, true);
     525    assert_equals(new Table({initial:1, maximum:1.5, element:"funcref"}) instanceof Table, true);
     526    assert_equals(new Table({initial:1, maximum:Math.pow(2,32)-1, element:"funcref"}) instanceof Table, true);
    527527}, "'WebAssembly.Table' constructor function");
    528528
     
    544544
    545545test(() => {
    546     tbl1 = new Table({initial:2, element:"anyfunc"});
     546    tbl1 = new Table({initial:2, element:"funcref"});
    547547    assert_equals(typeof tbl1, "object");
    548548    assert_equals(String(tbl1), "[object WebAssembly.Table]");
     
    632632    assertThrows(() => tblGrow.call(tbl1, -1), RangeError);
    633633    assertThrows(() => tblGrow.call(tbl1, Math.pow(2,32)), RangeError);
    634     var tbl = new Table({element:"anyfunc", initial:1, maximum:2});
     634    var tbl = new Table({element:"funcref", initial:1, maximum:2});
    635635    assert_equals(tbl.length, 1);
    636636    assert_equals(tbl.grow(0), 1);
     
    733733    }
    734734    var scratch_memory = new WebAssembly.Memory({initial:1});
    735     var scratch_table = new WebAssembly.Table({element:"anyfunc", initial:1, maximum:1});
     735    var scratch_table = new WebAssembly.Table({element:"funcref", initial:1, maximum:1});
    736736    assertInstantiateError([], TypeError);
    737737    assertInstantiateError([undefined], TypeError);
  • trunk/JSTests/wasm/stress/wasm-table-grow-initialize.js

    r246487 r246589  
    55
    66var table = new WebAssembly.Table({
    7     element: "anyfunc",
     7    element: "funcref",
    88    initial: 20
    99});
  • trunk/JSTests/wasm/wasm.json

    r246577 r246589  
    1212        "f32":     { "type": "varint7", "value":  -3, "b3type": "B3::Float" },
    1313        "f64":     { "type": "varint7", "value":  -4, "b3type": "B3::Double" },
    14         "anyfunc": { "type": "varint7", "value": -16, "b3type": "B3::Int64" },
     14        "funcref": { "type": "varint7", "value": -16, "b3type": "B3::Int64" },
    1515        "anyref":  { "type": "varint7", "value": -17, "b3type": "B3::Int64" },
    1616        "func":    { "type": "varint7", "value": -32, "b3type": "B3::Void" },
    1717        "void":    { "type": "varint7", "value": -64, "b3type": "B3::Void" }
    1818    },
    19     "value_type": ["i32", "i64", "f32", "f64", "anyref", "anyfunc"],
    20     "block_type": ["i32", "i64", "f32", "f64", "void", "anyref", "anyfunc"],
    21     "elem_type": ["anyfunc","anyref"],
     19    "value_type": ["i32", "i64", "f32", "f64", "anyref", "funcref"],
     20    "block_type": ["i32", "i64", "f32", "f64", "void", "anyref", "funcref"],
     21    "elem_type": ["funcref","anyref"],
    2222    "external_kind": {
    2323        "Function": { "type": "uint8", "value": 0 },
     
    6060        "f64.const":           { "category": "special",    "value":  68, "return": ["f64"],      "parameter": [],                       "immediate": [{"name": "value",          "type": "double"}],                                               "description": "a constant value interpreted as f64" },
    6161        "f32.const":           { "category": "special",    "value":  67, "return": ["f32"],      "parameter": [],                       "immediate": [{"name": "value",          "type": "float"}],                                                "description": "a constant value interpreted as f32" },
    62         "ref.null":            { "category": "special",    "value": 208, "return": ["anyfunc"],  "parameter": [],                       "immediate": [],                                                                                           "description": "a constant null reference" },
     62        "ref.null":            { "category": "special",    "value": 208, "return": ["funcref"],  "parameter": [],                       "immediate": [],                                                                                           "description": "a constant null reference" },
    6363        "ref.is_null":         { "category": "special",    "value": 209, "return": ["i32"],      "parameter": ["anyref"],               "immediate": [],                                                                                           "description": "determine if a reference is null" },
    64         "ref.func":            { "category": "special",    "value": 210, "return": ["anyfunc"],  "parameter": [],                       "immediate": [{"name": "function_index",  "type": "varuint32"}],                                           "description": "return a reference to the function at the given index" },
     64        "ref.func":            { "category": "special",    "value": 210, "return": ["funcref"],  "parameter": [],                       "immediate": [{"name": "function_index",  "type": "varuint32"}],                                           "description": "return a reference to the function at the given index" },
    6565        "get_local":           { "category": "special",    "value":  32, "return": ["any"],      "parameter": [],                       "immediate": [{"name": "local_index",    "type": "varuint32"}],                                            "description": "read a local variable or parameter" },
    6666        "set_local":           { "category": "special",    "value":  33, "return": [],           "parameter": ["any"],                  "immediate": [{"name": "local_index",    "type": "varuint32"}],                                            "description": "write a local variable or parameter" },
  • trunk/Source/JavaScriptCore/ChangeLog

    r246587 r246589  
     12019-06-19  Justin Michaud  <justin_michaud@apple.com>
     2
     3        [WASM-References] Rename anyfunc to funcref
     4        https://bugs.webkit.org/show_bug.cgi?id=198983
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Anyfunc should become funcref since it was renamed in the spec. We should also support the string 'anyfunc' in the table constructor since this is
     9        the only non-binary-format place where it is exposed to users.
     10
     11        * wasm/WasmAirIRGenerator.cpp:
     12        (JSC::Wasm::AirIRGenerator::gFuncref):
     13        (JSC::Wasm::AirIRGenerator::tmpForType):
     14        (JSC::Wasm::AirIRGenerator::emitCCall):
     15        (JSC::Wasm::AirIRGenerator::moveOpForValueType):
     16        (JSC::Wasm::AirIRGenerator::AirIRGenerator):
     17        (JSC::Wasm::AirIRGenerator::addLocal):
     18        (JSC::Wasm::AirIRGenerator::addConstant):
     19        (JSC::Wasm::AirIRGenerator::addRefFunc):
     20        (JSC::Wasm::AirIRGenerator::addReturn):
     21        (JSC::Wasm::AirIRGenerator::gAnyfunc): Deleted.
     22        * wasm/WasmCallingConvention.h:
     23        (JSC::Wasm::CallingConventionAir::marshallArgument const):
     24        (JSC::Wasm::CallingConventionAir::setupCall const):
     25        * wasm/WasmExceptionType.h:
     26        * wasm/WasmFormat.h:
     27        (JSC::Wasm::isValueType):
     28        (JSC::Wasm::isSubtype):
     29        (JSC::Wasm::TableInformation::wasmType const):
     30        * wasm/WasmFunctionParser.h:
     31        (JSC::Wasm::FunctionParser<Context>::parseExpression):
     32        * wasm/WasmSectionParser.cpp:
     33        (JSC::Wasm::SectionParser::parseTableHelper):
     34        (JSC::Wasm::SectionParser::parseElement):
     35        (JSC::Wasm::SectionParser::parseInitExpr):
     36        * wasm/WasmValidate.cpp:
     37        (JSC::Wasm::Validate::addRefFunc):
     38        * wasm/js/JSToWasm.cpp:
     39        (JSC::Wasm::createJSToWasmWrapper):
     40        * wasm/js/WasmToJS.cpp:
     41        (JSC::Wasm::wasmToJS):
     42        * wasm/js/WebAssemblyFunction.cpp:
     43        (JSC::callWebAssemblyFunction):
     44        (JSC::WebAssemblyFunction::jsCallEntrypointSlow):
     45        * wasm/js/WebAssemblyModuleRecord.cpp:
     46        (JSC::WebAssemblyModuleRecord::link):
     47        * wasm/js/WebAssemblyTableConstructor.cpp:
     48        (JSC::constructJSWebAssemblyTable):
     49        * wasm/wasm.json:
     50
    1512019-06-19  Fujii Hironori  <Hironori.Fujii@sony.com>
    252
  • trunk/Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp

    r246577 r246589  
    366366    TypedTmp g64() { return { newTmp(B3::GP), Type::I64 }; }
    367367    TypedTmp gAnyref() { return { newTmp(B3::GP), Type::Anyref }; }
    368     TypedTmp gAnyfunc() { return { newTmp(B3::GP), Type::Anyfunc }; }
     368    TypedTmp gFuncref() { return { newTmp(B3::GP), Type::Funcref }; }
    369369    TypedTmp f32() { return { newTmp(B3::FP), Type::F32 }; }
    370370    TypedTmp f64() { return { newTmp(B3::FP), Type::F64 }; }
     
    377377        case Type::I64:
    378378            return g64();
    379         case Type::Anyfunc:
    380             return gAnyfunc();
     379        case Type::Funcref:
     380            return gFuncref();
    381381        case Type::Anyref:
    382382            return gAnyref();
     
    517517            case Type::I64:
    518518            case Type::Anyref:
    519             case Type::Anyfunc:
     519            case Type::Funcref:
    520520                resultType = B3::Int64;
    521521                break;
     
    566566        case Type::I64:
    567567        case Type::Anyref:
    568         case Type::Anyfunc:
     568        case Type::Funcref:
    569569            return Move;
    570570        case Type::F32:
     
    814814        case Type::I64:
    815815        case Type::Anyref:
    816         case Type::Anyfunc:
     816        case Type::Funcref:
    817817            append(Move, arg, m_locals[i]);
    818818            break;
     
    900900        switch (type) {
    901901        case Type::Anyref:
    902         case Type::Anyfunc:
     902        case Type::Funcref:
    903903            append(Move, Arg::imm(JSValue::encode(jsNull())), local);
    904904            break;
     
    935935    case Type::I64:
    936936    case Type::Anyref:
    937     case Type::Anyfunc:
     937    case Type::Funcref:
    938938        append(block, Move, Arg::bigImm(value), result);
    939939        break;
     
    974974{
    975975    // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>.
    976     result = tmpForType(Type::Anyfunc);
     976    result = tmpForType(Type::Funcref);
    977977    emitCCall(&doWasmRefFunc, result, instanceValue(), addConstant(Type::I32, index));
    978978
     
    17001700        case Type::I64:
    17011701        case Type::Anyref:
    1702         case Type::Anyfunc:
     1702        case Type::Funcref:
    17031703            append(Move, returnValues[0], returnValueGPR);
    17041704            append(Ret64, returnValueGPR);
  • trunk/Source/JavaScriptCore/wasm/WasmCallingConvention.h

    r246504 r246589  
    237237        case Type::I64:
    238238        case Type::Anyref:
    239         case Wasm::Anyfunc:
     239        case Wasm::Funcref:
    240240            marshallArgumentImpl(m_gprArgs, gpArgumentCount, stackOffset, regFunc, stackFunc);
    241241            break;
     
    303303        case Type::I64:
    304304        case Type::Anyref:
    305         case Wasm::Anyfunc:
     305        case Wasm::Funcref:
    306306            patchpoint->resultConstraint = B3::ValueRep::reg(GPRInfo::returnValueGPR);
    307307            break;
  • trunk/Source/JavaScriptCore/wasm/WasmExceptionType.h

    r246577 r246589  
    4545    macro(I64ArgumentType, "WebAssembly function with an i64 argument can't be called from JavaScript") \
    4646    macro(I64ReturnType, "WebAssembly function that returns i64 can't be called from JavaScript") \
    47     macro(FuncrefNotWasm, "Anyfunc must be an exported wasm function")
     47    macro(FuncrefNotWasm, "Funcref must be an exported wasm function")
    4848
    4949enum class ExceptionType : uint32_t {
  • trunk/Source/JavaScriptCore/wasm/WasmFormat.h

    r246571 r246589  
    6969        return true;
    7070    case Anyref:
    71     case Anyfunc:
     71    case Funcref:
    7272        return Options::useWebAssemblyReferences();
    7373    default:
     
    8181    if (sub == parent)
    8282        return true;
    83     return sub == Anyfunc && parent == Anyref;
     83    return sub == Funcref && parent == Anyref;
    8484}
    8585   
     
    246246    Optional<uint32_t> maximum() const { return m_maximum; }
    247247    TableElementType type() const { return m_type; }
    248     Wasm::Type wasmType() const { return m_type == TableElementType::Funcref ? Type::Anyfunc : Type::Anyref; }
     248    Wasm::Type wasmType() const { return m_type == TableElementType::Funcref ? Type::Funcref : Type::Anyref; }
    249249
    250250private:
  • trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h

    r246577 r246589  
    343343    case RefNull: {
    344344        WASM_PARSER_FAIL_IF(!Options::useWebAssemblyReferences(), "references are not enabled");
    345         m_expressionStack.append(m_context.addConstant(Anyfunc, JSValue::encode(jsNull())));
     345        m_expressionStack.append(m_context.addConstant(Funcref, JSValue::encode(jsNull())));
    346346        return { };
    347347    }
     
    444444        WASM_PARSER_FAIL_IF(tableIndex >= m_info.tableCount(), "call_indirect's table index ", tableIndex, " invalid, limit is ", m_info.tableCount());
    445445        WASM_PARSER_FAIL_IF(m_info.usedSignatures.size() <= signatureIndex, "call_indirect's signature index ", signatureIndex, " exceeds known signatures ", m_info.usedSignatures.size());
    446         WASM_PARSER_FAIL_IF(m_info.tables[tableIndex].type() != TableElementType::Funcref, "call_indirect is only valid when a table has type anyfunc");
     446        WASM_PARSER_FAIL_IF(m_info.tables[tableIndex].type() != TableElementType::Funcref, "call_indirect is only valid when a table has type funcref");
    447447
    448448        const Signature& calleeSignature = m_info.usedSignatures[signatureIndex].get();
  • trunk/Source/JavaScriptCore/wasm/WasmSectionParser.cpp

    r246571 r246589  
    199199    int8_t type;
    200200    WASM_PARSER_FAIL_IF(!parseInt7(type), "can't parse Table type");
    201     WASM_PARSER_FAIL_IF(type != Wasm::Anyfunc && type != Wasm::Anyref, "Table type should be anyfunc or anyref, got ", type);
     201    WASM_PARSER_FAIL_IF(type != Wasm::Funcref && type != Wasm::Anyref, "Table type should be funcref or anyref, got ", type);
    202202
    203203    uint32_t initial;
     
    210210    ASSERT(!maximum || *maximum >= initial);
    211211
    212     TableElementType tableType = type == Wasm::Anyfunc ? TableElementType::Funcref : TableElementType::Anyref;
     212    TableElementType tableType = type == Wasm::Funcref ? TableElementType::Funcref : TableElementType::Anyref;
    213213    m_info->tables.append(TableInformation(initial, maximum, isImport, tableType));
    214214
     
    379379        WASM_PARSER_FAIL_IF(!parseVarUInt32(tableIndex), "can't get ", elementNum, "th Element table index");
    380380        WASM_PARSER_FAIL_IF(tableIndex >= m_info->tableCount(), "Element section for Table ", tableIndex, " exceeds available Table ", m_info->tableCount());
    381         WASM_PARSER_FAIL_IF(m_info->tables[tableIndex].type() != TableElementType::Funcref, "Table ", tableIndex, " must have type 'anyfunc' to have an element section");
     381        WASM_PARSER_FAIL_IF(m_info->tables[tableIndex].type() != TableElementType::Funcref, "Table ", tableIndex, " must have type 'funcref' to have an element section");
    382382        Type initExprType;
    383383        WASM_FAIL_IF_HELPER_FAILS(parseInitExpr(initOpcode, initExprBits, initExprType));
     
    482482
    483483    case RefNull: {
    484         resultType = Anyfunc;
     484        resultType = Funcref;
    485485        bitsOrImportNumber = JSValue::encode(jsNull());
    486486        break;
     
    492492        WASM_PARSER_FAIL_IF(index >= m_info->functions.size(), "ref.func index", index, " exceeds the number of functions ", m_info->functions.size());
    493493
    494         resultType = Anyfunc;
     494        resultType = Funcref;
    495495        bitsOrImportNumber = index;
    496496        break;
  • trunk/Source/JavaScriptCore/wasm/WasmValidate.cpp

    r246577 r246589  
    239239auto Validate::addRefFunc(uint32_t index, ExpressionType& result) -> Result
    240240{
    241     result = Type::Anyfunc;
     241    result = Type::Funcref;
    242242    WASM_VALIDATOR_FAIL_IF(index >= m_module.functionIndexSpaceSize(), "ref.func index ", index, " is too large, max is ", m_module.functionIndexSpaceSize());
    243243    m_module.addReferencedFunction(index);
  • trunk/Source/JavaScriptCore/wasm/js/JSToWasm.cpp

    r246504 r246589  
    8585        case Wasm::I32:
    8686        case Wasm::Anyref:
    87         case Wasm::Anyfunc:
     87        case Wasm::Funcref:
    8888            if (numGPRs >= wasmCallingConvention().m_gprArgs.size())
    8989                totalFrameSize += sizeof(void*);
     
    155155            case Wasm::I32:
    156156            case Wasm::I64:
    157             case Wasm::Anyfunc:
     157            case Wasm::Funcref:
    158158            case Wasm::Anyref:
    159159                if (numGPRs >= wasmCallingConvention().m_gprArgs.size()) {
     
    241241        break;
    242242    case Wasm::Anyref:
    243     case Wasm::Anyfunc:
     243    case Wasm::Funcref:
    244244        break;
    245245    case Wasm::I32:
  • trunk/Source/JavaScriptCore/wasm/js/WasmToJS.cpp

    r246504 r246589  
    166166                RELEASE_ASSERT_NOT_REACHED();
    167167            case Anyref:
    168             case Anyfunc:
     168            case Funcref:
    169169            case I32: {
    170170                GPRReg gprReg;
     
    243243                        arg = jsNumber(static_cast<int32_t>(buffer[argNum]));
    244244                        break;
    245                     case Anyfunc: {
     245                    case Funcref: {
    246246                        arg = JSValue::decode(buffer[argNum]);
    247247                        ASSERT(isWebAssemblyHostFunction(*vm, arg) || arg.isNull());
     
    281281                    break;
    282282                }
    283                 case Anyfunc: {
     283                case Funcref: {
    284284                    realResult = JSValue::encode(result);
    285285                    ASSERT(result.isFunction(*vm) || result.isNull());
     
    382382                RELEASE_ASSERT_NOT_REACHED(); // Handled above.
    383383            case Anyref:
    384             case Anyfunc:
     384            case Funcref:
    385385            case I32: {
    386386                GPRReg gprReg;
     
    451451                RELEASE_ASSERT_NOT_REACHED(); // Handled above.
    452452            case Anyref:
    453             case Anyfunc:
     453            case Funcref:
    454454            case I32:
    455455                // Skipped: handled above.
     
    559559        break;
    560560    }
    561     case Anyfunc:
     561    case Funcref:
    562562    case Anyref:
    563563        break;
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp

    r246504 r246589  
    8585            arg = JSValue::decode(arg.toInt32(exec));
    8686            break;
    87         case Wasm::Anyfunc: {
     87        case Wasm::Funcref: {
    8888            if (!isWebAssemblyHostFunction(vm, arg) && !arg.isNull())
    89                 return JSValue::encode(throwException(exec, scope, createJSWebAssemblyRuntimeError(exec, vm, "Anyfunc must be an exported wasm function")));
     89                return JSValue::encode(throwException(exec, scope, createJSWebAssemblyRuntimeError(exec, vm, "Funcref must be an exported wasm function")));
    9090            break;
    9191        }
     
    233233            break;
    234234        case Wasm::Anyref:
    235         case Wasm::Anyfunc:
     235        case Wasm::Funcref:
    236236        case Wasm::I32:
    237237            if (numGPRs >= Wasm::wasmCallingConvention().m_gprArgs.size())
     
    309309                }
    310310                break;
    311             case Wasm::Anyfunc: {
     311            case Wasm::Funcref: {
    312312                // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>.
    313313                bool (*shouldThrow)(Wasm::Instance*, JSValue) = [] (Wasm::Instance* wasmInstance, JSValue arg) -> bool {
     
    493493        break;
    494494    }
    495     case Wasm::Anyfunc:
     495    case Wasm::Funcref:
    496496    case Wasm::Anyref:
    497497        break;
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp

    r246571 r246589  
    238238            // iii. Append ToWebAssemblyValue(v) to imports.
    239239            switch (moduleInformation.globals[import.kindIndex].type) {
    240             case Wasm::Anyfunc:
     240            case Wasm::Funcref:
    241241                if (!isWebAssemblyHostFunction(vm, value) && !value.isNull())
    242242                    return exception(createJSWebAssemblyLinkError(exec, vm, importFailMessage(import, "imported global", "must be a wasm exported function or null")));
     
    411411            switch (global.type) {
    412412            case Wasm::Anyref:
    413             case Wasm::Anyfunc:
     413            case Wasm::Funcref:
    414414                exportedValue = JSValue::decode(m_instance->instance().loadI64Global(exp.kindIndex));
    415415                break;
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp

    r246139 r246589  
    6666        String elementString = elementValue.toWTFString(exec);
    6767        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    68         if (elementString == "anyfunc")
     68        if (elementString == "funcref" || elementString == "anyfunc")
    6969            type = Wasm::TableElementType::Funcref;
    7070        else if (elementString == "anyref")
    7171            type = Wasm::TableElementType::Anyref;
    7272        else
    73             return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, "WebAssembly.Table expects its 'element' field to be the string 'anyfunc' or 'anyref'"_s)));
     73            return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, "WebAssembly.Table expects its 'element' field to be the string 'funcref' or 'anyref'"_s)));
    7474    }
    7575
  • trunk/Source/JavaScriptCore/wasm/wasm.json

    r246577 r246589  
    1212        "f32":     { "type": "varint7", "value":  -3, "b3type": "B3::Float" },
    1313        "f64":     { "type": "varint7", "value":  -4, "b3type": "B3::Double" },
    14         "anyfunc": { "type": "varint7", "value": -16, "b3type": "B3::Int64" },
     14        "funcref": { "type": "varint7", "value": -16, "b3type": "B3::Int64" },
    1515        "anyref":  { "type": "varint7", "value": -17, "b3type": "B3::Int64" },
    1616        "func":    { "type": "varint7", "value": -32, "b3type": "B3::Void" },
    1717        "void":    { "type": "varint7", "value": -64, "b3type": "B3::Void" }
    1818    },
    19     "value_type": ["i32", "i64", "f32", "f64", "anyref", "anyfunc"],
    20     "block_type": ["i32", "i64", "f32", "f64", "void", "anyref", "anyfunc"],
    21     "elem_type": ["anyfunc","anyref"],
     19    "value_type": ["i32", "i64", "f32", "f64", "anyref", "funcref"],
     20    "block_type": ["i32", "i64", "f32", "f64", "void", "anyref", "funcref"],
     21    "elem_type": ["funcref","anyref"],
    2222    "external_kind": {
    2323        "Function": { "type": "uint8", "value": 0 },
     
    6060        "f64.const":           { "category": "special",    "value":  68, "return": ["f64"],      "parameter": [],                       "immediate": [{"name": "value",          "type": "double"}],                                               "description": "a constant value interpreted as f64" },
    6161        "f32.const":           { "category": "special",    "value":  67, "return": ["f32"],      "parameter": [],                       "immediate": [{"name": "value",          "type": "float"}],                                                "description": "a constant value interpreted as f32" },
    62         "ref.null":            { "category": "special",    "value": 208, "return": ["anyfunc"],  "parameter": [],                       "immediate": [],                                                                                           "description": "a constant null reference" },
     62        "ref.null":            { "category": "special",    "value": 208, "return": ["funcref"],  "parameter": [],                       "immediate": [],                                                                                           "description": "a constant null reference" },
    6363        "ref.is_null":         { "category": "special",    "value": 209, "return": ["i32"],      "parameter": ["anyref"],               "immediate": [],                                                                                           "description": "determine if a reference is null" },
    64         "ref.func":            { "category": "special",    "value": 210, "return": ["anyfunc"],  "parameter": [],                       "immediate": [{"name": "function_index", "type": "varuint32"}],                                            "description": "return a reference to the function at the given index" },
     64        "ref.func":            { "category": "special",    "value": 210, "return": ["funcref"],  "parameter": [],                       "immediate": [{"name": "function_index", "type": "varuint32"}],                                            "description": "return a reference to the function at the given index" },
    6565        "get_local":           { "category": "special",    "value":  32, "return": ["any"],      "parameter": [],                       "immediate": [{"name": "local_index",    "type": "varuint32"}],                                            "description": "read a local variable or parameter" },
    6666        "set_local":           { "category": "special",    "value":  33, "return": [],           "parameter": ["any"],                  "immediate": [{"name": "local_index",    "type": "varuint32"}],                                            "description": "write a local variable or parameter" },
Note: See TracChangeset for help on using the changeset viewer.