Changeset 270015 in webkit


Ignore:
Timestamp:
Nov 18, 2020 8:11:18 PM (3 years ago)
Author:
commit-queue@webkit.org
Message:

[WASM-References] Remove subtyping rule for externref and funcref
https://bugs.webkit.org/show_bug.cgi?id=218885

Patch by Dmitry Bezhetskov <dbezhetskov> on 2020-11-18
Reviewed by Yusuke Suzuki.

Make funcref is not a subtype of externref.
The spec: https://webassembly.github.io/reference-types/core/
The PR for removing subtype from the spec:
https://github.com/WebAssembly/reference-types/pull/87.

JSTests:

  • wasm/references/func_ref.js:

(assert.eq.instance.exports.fix.fun):
(assert.eq.instance.exports.fix):

  • wasm/references/validation.js:

Source/JavaScriptCore:

  • wasm/WasmFormat.h:

(JSC::Wasm::isSubtype):

  • wasm/WasmFunctionParser.h:

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

  • wasm/js/WebAssemblyModuleRecord.cpp:

(JSC::WebAssemblyModuleRecord::link):

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r270005 r270015  
     12020-11-18  Dmitry Bezhetskov  <dbezhetskov@igalia.com>
     2
     3        [WASM-References] Remove subtyping rule for externref and funcref
     4        https://bugs.webkit.org/show_bug.cgi?id=218885
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Make funcref is not a subtype of externref.
     9        The spec: https://webassembly.github.io/reference-types/core/
     10        The PR for removing subtype from the spec:
     11        https://github.com/WebAssembly/reference-types/pull/87.
     12
     13        * wasm/references/func_ref.js:
     14        (assert.eq.instance.exports.fix.fun):
     15        (assert.eq.instance.exports.fix):
     16        * wasm/references/validation.js:
     17
    1182020-11-18  Ross Kirsling  <ross.kirsling@sony.com>
    219
  • trunk/JSTests/wasm/js-api/web-assembly-instantiate.js

    r250559 r270015  
    7777        } catch(e) {
    7878            assert.truthy(e instanceof WebAssembly.CompileError);
    79             assert.eq(e.message, "WebAssembly.Module doesn't validate: control flow returns with unexpected type. F32 is not a subtype of I32, in function at index 0");
     79            assert.eq(e.message, "WebAssembly.Module doesn't validate: control flow returns with unexpected type. F32 is not a I32, in function at index 0");
    8080        }
    8181    }
  • trunk/JSTests/wasm/references/func_ref.js

    r269729 r270015  
    7676          .Function().End()
    7777          .Export()
    78               .Function("h")
    7978              .Function("i")
    80               .Function("get_h")
     79              .Function("get_i")
    8180              .Function("fix")
    8281              .Function("get_not_exported")
     
    8483          .End()
    8584          .Code()
    86             .Function("h", { params: ["funcref"], ret: "externref" }, ["externref"])
    87               .GetLocal(0)
    88               .SetLocal(1)
    89               .GetLocal(1)
    90             .End()
    91 
    9285            .Function("i", { params: ["funcref"], ret: "funcref" }, ["funcref"])
    9386              .GetLocal(0)
     
    9689            .End()
    9790
    98             .Function("get_h", { params: [], ret: "funcref" }, ["funcref"])
     91            .Function("get_i", { params: [], ret: "funcref" }, ["funcref"])
    9992              .I32Const(0)
    10093              .RefFunc(0)
     
    112105
    113106            .Function("fix", { params: [], ret: "funcref" }, [])
    114               .RefFunc(3)
     107              .RefFunc(2)
    115108            .End()
    116109
    117110            .Function("get_not_exported", { params: [], ret: "funcref" }, [])
    118               .RefFunc(5)
     111              .RefFunc(4)
    119112            .End()
    120113
     
    135128
    136129    assert.eq(instance.exports.local_read(), 1)
    137     assert.eq(instance.exports.h(null), null)
    138 
    139     assert.throws(() => instance.exports.h(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    140     assert.eq(instance.exports.h(myfun), myfun)
    141     assert.throws(() => instance.exports.h(5), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    142     assert.throws(() => instance.exports.h(undefined), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    143130
    144131    assert.eq(instance.exports.i(null), null)
     
    147134    assert.throws(() => instance.exports.i(5), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    148135
    149     assert.throws(() => instance.exports.get_h()(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    150     assert.eq(instance.exports.get_h()(null), null)
    151     assert.eq(instance.exports.get_h()(myfun), myfun)
    152     assert.throws(() => instance.exports.get_h()(5), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
     136    assert.throws(() => instance.exports.get_i()(fun), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
     137    assert.eq(instance.exports.get_i()(null), null)
     138    assert.eq(instance.exports.get_i()(myfun), myfun)
     139    assert.throws(() => instance.exports.get_i()(5), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')")
    153140
    154141    assert.eq(instance.exports.get_not_exported()(), 42)
     
    156143    assert.eq(instance.exports.fix()(), instance.exports.fix());
    157144    assert.eq(instance.exports.fix(), instance.exports.fix);
     145}
     146
     147// Casting the Funcref to Externref is forbidden.
     148
     149{
     150    function fun() { return 41; }
     151
     152    const builder = (new Builder())
     153          .Type().End()
     154          .Function().End()
     155          .Export()
     156              .Function("h")
     157          .End()
     158          .Code()
     159            .Function("h", { params: ["funcref"], ret: "externref" }, ["externref"])
     160              .GetLocal(0)
     161              .SetLocal(1)
     162              .GetLocal(1)
     163            .End()
     164          .End();
     165
     166    const bin = builder.WebAssembly().get();
     167    assert.throws(() => new WebAssembly.Module(bin), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: set_local to type Funcref expected Externref, in function at index 0 (evaluating 'new WebAssembly.Module(bin)')");
    158168}
    159169
     
    247257      .GetLocal(0)
    248258    .End()
    249   .End().WebAssembly().get()), Error, "WebAssembly.Module doesn't validate: control flow returns with unexpected type. Externref is not a subtype of Funcref, in function at index 0 (evaluating 'new WebAssembly.Module')");
     259  .End().WebAssembly().get()), Error, "WebAssembly.Module doesn't validate: control flow returns with unexpected type. Externref is not a Funcref, in function at index 0 (evaluating 'new WebAssembly.Module')");
    250260
    251261assert.throws(() => new WebAssembly.Module((new Builder())
  • trunk/JSTests/wasm/references/validation.js

    r269552 r270015  
    2020    bin.trim();
    2121
    22     assert.throws(() => new WebAssembly.Module(bin.get()), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: ref.is_null to type I32 expected Externref, in function at index 0 (evaluating 'new WebAssembly.Module(bin.get())')");
     22    assert.throws(() => new WebAssembly.Module(bin.get()), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: ref.is_null to type I32 expected a reference type, in function at index 0 (evaluating 'new WebAssembly.Module(bin.get())')");
    2323}
    2424
     
    9191    bin.trim();
    9292
    93     assert.throws(() => new WebAssembly.Module(bin.get()), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: control flow returns with unexpected type. Externref is not a subtype of Funcref, in function at index 0 (evaluating 'new WebAssembly.Module(bin.get())')");
     93    assert.throws(() => new WebAssembly.Module(bin.get()), WebAssembly.CompileError, "WebAssembly.Module doesn't validate: control flow returns with unexpected type. Externref is not a Funcref, in function at index 0 (evaluating 'new WebAssembly.Module(bin.get())')");
    9494}
    9595
  • trunk/LayoutTests/workers/wasm-references/test.js

    r269929 r270015  
    18611861              .TableSize(1)
    18621862            .End()
    1863             .Function("tbl_grow", { params: ["i32"], ret: "i32" })
    1864                 .RefFunc(0)
     1863            .Function("tbl_grow", { params: ["externref", "i32"], ret: "i32" })
    18651864                .GetLocal(0)
     1865                .GetLocal(1)
    18661866                .TableGrow(1)
    18671867            .End()
  • trunk/LayoutTests/workers/wasm-references/worker.js

    r246645 r270015  
    174174        try {
    175175            assert.eq($1.exports.tbl_size(), 20)
    176             assert.eq($1.exports.tbl_grow(5), 20)
     176            assert.eq($1.exports.tbl_grow("hi", 5), 20)
    177177            assert.eq($1.exports.tbl_size(), 25)
    178178            assert.eq($1.exports.tbl.get(0), null)
    179             assert.eq($1.exports.tbl.get(24), $1.exports.tbl_size)
     179            assert.eq($1.exports.tbl.get(24), "hi")
    180180
    181181            for (let i=0; i<1000; ++i) {
  • trunk/Source/JavaScriptCore/ChangeLog

    r270005 r270015  
     12020-11-18  Dmitry Bezhetskov  <dbezhetskov@igalia.com>
     2
     3        [WASM-References] Remove subtyping rule for externref and funcref
     4        https://bugs.webkit.org/show_bug.cgi?id=218885
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Make funcref is not a subtype of externref.
     9        The spec: https://webassembly.github.io/reference-types/core/
     10        The PR for removing subtype from the spec:
     11        https://github.com/WebAssembly/reference-types/pull/87.
     12
     13        * wasm/WasmFormat.h:
     14        (JSC::Wasm::isSubtype):
     15        * wasm/WasmFunctionParser.h:
     16        (JSC::Wasm::FunctionParser<Context>::parseExpression):
     17        * wasm/js/WebAssemblyModuleRecord.cpp:
     18        (JSC::WebAssemblyModuleRecord::link):
     19
    1202020-11-18  Ross Kirsling  <ross.kirsling@sony.com>
    221
  • trunk/Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp

    r269974 r270015  
    11031103{
    11041104    ASSERT(fill.tmp());
    1105     ASSERT(isSubtype(fill.type(), m_info.tables[tableIndex].wasmType()));
     1105    ASSERT(fill.type() == m_info.tables[tableIndex].wasmType());
    11061106    ASSERT(delta.tmp());
    11071107    ASSERT(delta.type() == Type::I32);
     
    11161116{
    11171117    ASSERT(fill.tmp());
    1118     ASSERT(isSubtype(fill.type(), m_info.tables[tableIndex].wasmType()));
     1118    ASSERT(fill.type() == m_info.tables[tableIndex].wasmType());
    11191119    ASSERT(offset.tmp());
    11201120    ASSERT(offset.type() == Type::I32);
     
    12521252            append(moveOpForValueType(type), value, Arg::addr(temp));
    12531253        }
    1254         if (isSubtype(type, Externref))
     1254        if (isRefType(type))
    12551255            emitWriteBarrierForJSWrapper();
    12561256        break;
     
    12671267        append(moveOpForValueType(type), value, Arg::addr(temp));
    12681268        // We emit a write-barrier onto JSWebAssemblyGlobal, not JSWebAssemblyInstance.
    1269         if (isSubtype(type, Externref)) {
     1269        if (isRefType(type)) {
    12701270            auto cell = g64();
    12711271            auto vm = g64();
     
    23312331void AirIRGenerator::unify(const ExpressionType dst, const ExpressionType source)
    23322332{
    2333     ASSERT(isSubtype(source.type(), dst.type()));
     2333    ASSERT(source.type() == dst.type());
    23342334    append(moveOpForValueType(dst.type()), source, dst);
    23352335}
  • trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp

    r269974 r270015  
    634634        Variable* local = m_proc.addVariable(toB3Type(type));
    635635        m_locals.uncheckedAppend(local);
    636         auto val = isSubtype(type, Externref) ? JSValue::encode(jsNull()) : 0;
     636        auto val = isRefType(type) ? JSValue::encode(jsNull()) : 0;
    637637        m_currentBlock->appendNew<VariableValue>(m_proc, Set, Origin(), local, constant(toB3Type(type), val, Origin()));
    638638    }
     
    841841    case Wasm::GlobalInformation::BindingMode::EmbeddedInInstance:
    842842        m_currentBlock->appendNew<MemoryValue>(m_proc, Store, origin(), value, globalsArray, safeCast<int32_t>(index * sizeof(Register)));
    843         if (isSubtype(global.type, Externref))
     843        if (isRefType(global.type))
    844844            emitWriteBarrierForJSWrapper();
    845845        break;
     
    849849        m_currentBlock->appendNew<MemoryValue>(m_proc, Store, origin(), value, pointer);
    850850        // We emit a write-barrier onto JSWebAssemblyGlobal, not JSWebAssemblyInstance.
    851         if (isSubtype(global.type, Externref)) {
     851        if (isRefType(global.type)) {
    852852            Value* instance = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(), instanceValue(), safeCast<int32_t>(Instance::offsetOfOwner()));
    853853            Value* cell = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(), pointer, Wasm::Global::offsetOfOwner() - Wasm::Global::offsetOfValue());
  • trunk/Source/JavaScriptCore/wasm/WasmFormat.h

    r269729 r270015  
    7979}
    8080
    81 inline bool isSubtype(Type sub, Type parent)
    82 {
    83     if (sub == parent)
    84         return true;
    85     return sub == Funcref && parent == Externref;
    86 }
    87 
    8881inline bool isRefType(Type type)
    8982{
  • trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h

    r269998 r270015  
    328328    unsigned offset = m_expressionStack.size() - target.branchTargetArity();
    329329    for (unsigned i = 0; i < target.branchTargetArity(); ++i)
    330         WASM_VALIDATOR_FAIL_IF(!isSubtype(target.branchTargetType(i), m_expressionStack[offset + i].type()), "branch's stack type is not a subtype of block's type branch target type. Stack value has type", m_expressionStack[offset + i].type(), " but branch target expects a value with subtype of ", target.branchTargetType(i), " at index ", i);
     330        WASM_VALIDATOR_FAIL_IF(target.branchTargetType(i) != m_expressionStack[offset + i].type(), "branch's stack type is not a block's type branch target type. Stack value has type", m_expressionStack[offset + i].type(), " but branch target expects a value of ", target.branchTargetType(i), " at index ", i);
    331331
    332332    return { };
     
    338338    WASM_VALIDATOR_FAIL_IF(controlData.signature()->returnCount() != m_expressionStack.size(), " block with type: ", controlData.signature()->toString(), " returns: ", controlData.signature()->returnCount(), " but stack has: ", m_expressionStack.size(), " values");
    339339    for (unsigned i = 0; i < controlData.signature()->returnCount(); ++i)
    340         WASM_VALIDATOR_FAIL_IF(!isSubtype(m_expressionStack[i].type(), controlData.signature()->returnType(i)), "control flow returns with unexpected type. ", m_expressionStack[i].type(), " is not a subtype of ", controlData.signature()->returnType(i));
     340        WASM_VALIDATOR_FAIL_IF(m_expressionStack[i].type() != controlData.signature()->returnType(i), "control flow returns with unexpected type. ", m_expressionStack[i].type(), " is not a ", controlData.signature()->returnType(i));
    341341
    342342    return { };
     
    437437        WASM_VALIDATOR_FAIL_IF(I32 != index.type(), "table.set index to type ", index.type(), " expected ", I32);
    438438        Type type = m_info.tables[tableIndex].wasmType();
    439         WASM_VALIDATOR_FAIL_IF(!isSubtype(value.type(), type), "table.set value to type ", value.type(), " expected ", type);
     439        WASM_VALIDATOR_FAIL_IF(value.type() != type, "table.set value to type ", value.type(), " expected ", type);
    440440        RELEASE_ASSERT(m_info.tables[tableIndex].type() == TableElementType::Externref || m_info.tables[tableIndex].type() == TableElementType::Funcref);
    441441        WASM_TRY_ADD_TO_CONTEXT(addTableSet(tableIndex, index, value));
     
    464464            WASM_TRY_POP_EXPRESSION_STACK_INTO(fill, "table.grow");
    465465
    466             WASM_VALIDATOR_FAIL_IF(!isSubtype(fill.type(), m_info.tables[tableIndex].wasmType()), "table.grow expects fill value of type ", m_info.tables[tableIndex].wasmType(), " got ", fill.type());
     466            WASM_VALIDATOR_FAIL_IF(fill.type() != m_info.tables[tableIndex].wasmType(), "table.grow expects fill value of type ", m_info.tables[tableIndex].wasmType(), " got ", fill.type());
    467467            WASM_VALIDATOR_FAIL_IF(I32 != delta.type(), "table.grow expects an i32 delta value, got ", delta.type());
    468468
     
    478478            WASM_TRY_POP_EXPRESSION_STACK_INTO(offset, "table.fill");
    479479
    480             WASM_VALIDATOR_FAIL_IF(!isSubtype(fill.type(), m_info.tables[tableIndex].wasmType()), "table.fill expects fill value of type ", m_info.tables[tableIndex].wasmType(), " got ", fill.type());
     480            WASM_VALIDATOR_FAIL_IF(fill.type() != m_info.tables[tableIndex].wasmType(), "table.fill expects fill value of type ", m_info.tables[tableIndex].wasmType(), " got ", fill.type());
    481481            WASM_VALIDATOR_FAIL_IF(I32 != offset.type(), "table.fill expects an i32 offset value, got ", offset.type());
    482482            WASM_VALIDATOR_FAIL_IF(I32 != count.type(), "table.fill expects an i32 count value, got ", count.type());
     
    504504        TypedExpression value;
    505505        WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "ref.is_null");
    506         WASM_VALIDATOR_FAIL_IF(!isSubtype(value.type(), Externref), "ref.is_null to type ", value.type(), " expected ", Externref);
     506        WASM_VALIDATOR_FAIL_IF(!isRefType(value.type()), "ref.is_null to type ", value.type(), " expected a reference type");
    507507        ExpressionType result;
    508508        WASM_TRY_ADD_TO_CONTEXT(addRefIsNull(value, result));
     
    540540        WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "set_local");
    541541        WASM_VALIDATOR_FAIL_IF(index >= m_locals.size(), "attempt to set unknown local ", index, " last one is ", m_locals.size());
    542         WASM_VALIDATOR_FAIL_IF(!isSubtype(value.type(), m_locals[index]), "set_local to type ", value.type(), " expected ", m_locals[index]);
     542        WASM_VALIDATOR_FAIL_IF(value.type() != m_locals[index], "set_local to type ", value.type(), " expected ", m_locals[index]);
    543543        WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value));
    544544        return { };
     
    551551        TypedExpression value = m_expressionStack.last();
    552552        WASM_VALIDATOR_FAIL_IF(index >= m_locals.size(), "attempt to tee unknown local ", index, " last one is ", m_locals.size());
    553         WASM_VALIDATOR_FAIL_IF(!isSubtype(value.type(), m_locals[index]), "set_local to type ", value.type(), " expected ", m_locals[index]);
     553        WASM_VALIDATOR_FAIL_IF(value.type() != m_locals[index], "set_local to type ", value.type(), " expected ", m_locals[index]);
    554554        WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value));
    555555        return { };
     
    599599        for (size_t i = firstArgumentIndex; i < m_expressionStack.size(); ++i) {
    600600            TypedExpression arg = m_expressionStack.at(i);
    601             WASM_VALIDATOR_FAIL_IF(!isSubtype(arg.type(), calleeSignature.argument(i - firstArgumentIndex)), "argument type mismatch in call, got ", arg.type(), ", expected ", calleeSignature.argument(i - firstArgumentIndex));
     601            WASM_VALIDATOR_FAIL_IF(arg.type() != calleeSignature.argument(i - firstArgumentIndex), "argument type mismatch in call, got ", arg.type(), ", expected ", calleeSignature.argument(i - firstArgumentIndex));
    602602            args.uncheckedAppend(arg);
    603603            m_context.didPopValueFromStack();
     
    640640            TypedExpression arg = m_expressionStack.at(i);
    641641            if (i < m_expressionStack.size() - 1)
    642                 WASM_VALIDATOR_FAIL_IF(!isSubtype(arg.type(), calleeSignature.argument(i - firstArgumentIndex)), "argument type mismatch in call_indirect, got ", arg.type(), ", expected ", calleeSignature.argument(i - firstArgumentIndex));
     642                WASM_VALIDATOR_FAIL_IF(arg.type() != calleeSignature.argument(i - firstArgumentIndex), "argument type mismatch in call_indirect, got ", arg.type(), ", expected ", calleeSignature.argument(i - firstArgumentIndex));
    643643            args.uncheckedAppend(arg);
    644644            m_context.didPopValueFromStack();
     
    663663        for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) {
    664664            Type type = m_expressionStack.at(offset + i).type();
    665             WASM_VALIDATOR_FAIL_IF(!isSubtype(type, inlineSignature->argument(i)), "Block expects the argument at index", i, " to be a subtype of ", inlineSignature->argument(i), " but argument has type ", type);
     665            WASM_VALIDATOR_FAIL_IF(type != inlineSignature->argument(i), "Block expects the argument at index", i, " to be ", inlineSignature->argument(i), " but argument has type ", type);
    666666        }
    667667
     
    686686        for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) {
    687687            Type type = m_expressionStack.at(offset + i).type();
    688             WASM_VALIDATOR_FAIL_IF(!isSubtype(type, inlineSignature->argument(i)), "Loop expects the argument at index", i, " to be a subtype of ", inlineSignature->argument(i), " but argument has type ", type);
     688            WASM_VALIDATOR_FAIL_IF(type != inlineSignature->argument(i), "Loop expects the argument at index", i, " to be ", inlineSignature->argument(i), " but argument has type ", type);
    689689        }
    690690
     
    711711        unsigned offset = m_expressionStack.size() - inlineSignature->argumentCount();
    712712        for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i)
    713             WASM_VALIDATOR_FAIL_IF(!isSubtype(m_expressionStack[offset + i].type(), inlineSignature->argument(i)), "Loop expects the argument at index", i, " to be a subtype of ", inlineSignature->argument(i), " but argument has type ", m_expressionStack[i].type());
     713            WASM_VALIDATOR_FAIL_IF(m_expressionStack[offset + i].type() != inlineSignature->argument(i), "Loop expects the argument at index", i, " to be ", inlineSignature->argument(i), " but argument has type ", m_expressionStack[i].type());
    714714
    715715        int64_t oldSize = m_expressionStack.size();
     
    785785            WASM_VALIDATOR_FAIL_IF(defaultTarget.branchTargetArity() != target->branchTargetArity(), "br_table target type size mismatch. Default has size: ", defaultTarget.branchTargetArity(), "but target: ", i, " has size: ", target->branchTargetArity());
    786786            for (unsigned type = 0; type < defaultTarget.branchTargetArity(); ++type)
    787                 WASM_VALIDATOR_FAIL_IF(!isSubtype(defaultTarget.branchTargetType(type), target->branchTargetType(type)), "br_table target type mismatch at offset ", type, " expected: ", defaultTarget.branchTargetType(type), " but saw: ", target->branchTargetType(type), " when targeting block: ", target->signature()->toString());
     787                WASM_VALIDATOR_FAIL_IF(defaultTarget.branchTargetType(type) != target->branchTargetType(type), "br_table target type mismatch at offset ", type, " expected: ", defaultTarget.branchTargetType(type), " but saw: ", target->branchTargetType(type), " when targeting block: ", target->signature()->toString());
    788788        }
    789789
  • trunk/Source/JavaScriptCore/wasm/WasmInstance.cpp

    r269552 r270015  
    6363            // This is kept alive by JSWebAssemblyInstance -> JSWebAssemblyGlobal -> binding.
    6464            m_globalsToBinding.set(i);
    65         } else if (isSubtype(global.type, Externref)) {
     65        } else if (isRefType(global.type)) {
    6666            // This is kept alive by JSWebAssemblyInstance -> binding.
    6767            m_globalsToMark.set(i);
  • trunk/Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp

    r269552 r270015  
    827827    switch (global.bindingMode) {
    828828    case Wasm::GlobalInformation::BindingMode::EmbeddedInInstance:
    829         if (isSubtype(type, Externref))
     829        if (isRefType(type))
    830830            WasmSetGlobalRef::emit(this, index, value);
    831831        else
     
    833833        break;
    834834    case Wasm::GlobalInformation::BindingMode::Portable:
    835         if (isSubtype(type, Externref))
     835        if (isRefType(type))
    836836            WasmSetGlobalRefPortableBinding::emit(this, index, value);
    837837        else
  • trunk/Source/JavaScriptCore/wasm/WasmSectionParser.cpp

    r269998 r270015  
    299299        else
    300300            global.initializationType = GlobalInformation::FromExpression;
    301         WASM_PARSER_FAIL_IF(!isSubtype(typeForInitOpcode, global.type), "Global init_expr opcode of type ", typeForInitOpcode, " doesn't match global's type ", global.type);
     301        WASM_PARSER_FAIL_IF(typeForInitOpcode != global.type, "Global init_expr opcode of type ", typeForInitOpcode, " doesn't match global's type ", global.type);
    302302
    303303        m_info->globals.uncheckedAppend(WTFMove(global));
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp

    r269974 r270015  
    257257                    }
    258258                } else {
     259                    const auto globalType = moduleInformation.globals[import.kindIndex].type;
    259260                    // ii. If the global_type of i is i64 or Type(v) is not Number, throw a WebAssembly.LinkError.
    260                     if (moduleInformation.globals[import.kindIndex].type == Wasm::I64)
     261                    if (globalType == Wasm::I64)
    261262                        return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "cannot be an i64")));
    262                     if (!isSubtype(moduleInformation.globals[import.kindIndex].type, Wasm::Externref) && !value.isNumber())
     263                    if (!isRefType(globalType) && !value.isNumber())
    263264                        return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "must be a number")));
    264265
Note: See TracChangeset for help on using the changeset viewer.