Changeset 270015 in webkit
- Timestamp:
- Nov 18, 2020 8:11:18 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r270005 r270015 1 2020-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 1 18 2020-11-18 Ross Kirsling <ross.kirsling@sony.com> 2 19 -
trunk/JSTests/wasm/js-api/web-assembly-instantiate.js
r250559 r270015 77 77 } catch(e) { 78 78 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 ofI32, 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"); 80 80 } 81 81 } -
trunk/JSTests/wasm/references/func_ref.js
r269729 r270015 76 76 .Function().End() 77 77 .Export() 78 .Function("h")79 78 .Function("i") 80 .Function("get_ h")79 .Function("get_i") 81 80 .Function("fix") 82 81 .Function("get_not_exported") … … 84 83 .End() 85 84 .Code() 86 .Function("h", { params: ["funcref"], ret: "externref" }, ["externref"])87 .GetLocal(0)88 .SetLocal(1)89 .GetLocal(1)90 .End()91 92 85 .Function("i", { params: ["funcref"], ret: "funcref" }, ["funcref"]) 93 86 .GetLocal(0) … … 96 89 .End() 97 90 98 .Function("get_ h", { params: [], ret: "funcref" }, ["funcref"])91 .Function("get_i", { params: [], ret: "funcref" }, ["funcref"]) 99 92 .I32Const(0) 100 93 .RefFunc(0) … … 112 105 113 106 .Function("fix", { params: [], ret: "funcref" }, []) 114 .RefFunc( 3)107 .RefFunc(2) 115 108 .End() 116 109 117 110 .Function("get_not_exported", { params: [], ret: "funcref" }, []) 118 .RefFunc( 5)111 .RefFunc(4) 119 112 .End() 120 113 … … 135 128 136 129 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)')")143 130 144 131 assert.eq(instance.exports.i(null), null) … … 147 134 assert.throws(() => instance.exports.i(5), Error, "Funcref must be an exported wasm function (evaluating 'func(...args)')") 148 135 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)')") 153 140 154 141 assert.eq(instance.exports.get_not_exported()(), 42) … … 156 143 assert.eq(instance.exports.fix()(), instance.exports.fix()); 157 144 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)')"); 158 168 } 159 169 … … 247 257 .GetLocal(0) 248 258 .End() 249 .End().WebAssembly().get()), Error, "WebAssembly.Module doesn't validate: control flow returns with unexpected type. Externref is not a subtype ofFuncref, 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')"); 250 260 251 261 assert.throws(() => new WebAssembly.Module((new Builder()) -
trunk/JSTests/wasm/references/validation.js
r269552 r270015 20 20 bin.trim(); 21 21 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())')"); 23 23 } 24 24 … … 91 91 bin.trim(); 92 92 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 ofFuncref, 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())')"); 94 94 } 95 95 -
trunk/LayoutTests/workers/wasm-references/test.js
r269929 r270015 1861 1861 .TableSize(1) 1862 1862 .End() 1863 .Function("tbl_grow", { params: ["i32"], ret: "i32" }) 1864 .RefFunc(0) 1863 .Function("tbl_grow", { params: ["externref", "i32"], ret: "i32" }) 1865 1864 .GetLocal(0) 1865 .GetLocal(1) 1866 1866 .TableGrow(1) 1867 1867 .End() -
trunk/LayoutTests/workers/wasm-references/worker.js
r246645 r270015 174 174 try { 175 175 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) 177 177 assert.eq($1.exports.tbl_size(), 25) 178 178 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") 180 180 181 181 for (let i=0; i<1000; ++i) { -
trunk/Source/JavaScriptCore/ChangeLog
r270005 r270015 1 2020-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 1 20 2020-11-18 Ross Kirsling <ross.kirsling@sony.com> 2 21 -
trunk/Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp
r269974 r270015 1103 1103 { 1104 1104 ASSERT(fill.tmp()); 1105 ASSERT( isSubtype(fill.type(), m_info.tables[tableIndex].wasmType()));1105 ASSERT(fill.type() == m_info.tables[tableIndex].wasmType()); 1106 1106 ASSERT(delta.tmp()); 1107 1107 ASSERT(delta.type() == Type::I32); … … 1116 1116 { 1117 1117 ASSERT(fill.tmp()); 1118 ASSERT( isSubtype(fill.type(), m_info.tables[tableIndex].wasmType()));1118 ASSERT(fill.type() == m_info.tables[tableIndex].wasmType()); 1119 1119 ASSERT(offset.tmp()); 1120 1120 ASSERT(offset.type() == Type::I32); … … 1252 1252 append(moveOpForValueType(type), value, Arg::addr(temp)); 1253 1253 } 1254 if (is Subtype(type, Externref))1254 if (isRefType(type)) 1255 1255 emitWriteBarrierForJSWrapper(); 1256 1256 break; … … 1267 1267 append(moveOpForValueType(type), value, Arg::addr(temp)); 1268 1268 // We emit a write-barrier onto JSWebAssemblyGlobal, not JSWebAssemblyInstance. 1269 if (is Subtype(type, Externref)) {1269 if (isRefType(type)) { 1270 1270 auto cell = g64(); 1271 1271 auto vm = g64(); … … 2331 2331 void AirIRGenerator::unify(const ExpressionType dst, const ExpressionType source) 2332 2332 { 2333 ASSERT( isSubtype(source.type(), dst.type()));2333 ASSERT(source.type() == dst.type()); 2334 2334 append(moveOpForValueType(dst.type()), source, dst); 2335 2335 } -
trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
r269974 r270015 634 634 Variable* local = m_proc.addVariable(toB3Type(type)); 635 635 m_locals.uncheckedAppend(local); 636 auto val = is Subtype(type, Externref) ? JSValue::encode(jsNull()) : 0;636 auto val = isRefType(type) ? JSValue::encode(jsNull()) : 0; 637 637 m_currentBlock->appendNew<VariableValue>(m_proc, Set, Origin(), local, constant(toB3Type(type), val, Origin())); 638 638 } … … 841 841 case Wasm::GlobalInformation::BindingMode::EmbeddedInInstance: 842 842 m_currentBlock->appendNew<MemoryValue>(m_proc, Store, origin(), value, globalsArray, safeCast<int32_t>(index * sizeof(Register))); 843 if (is Subtype(global.type, Externref))843 if (isRefType(global.type)) 844 844 emitWriteBarrierForJSWrapper(); 845 845 break; … … 849 849 m_currentBlock->appendNew<MemoryValue>(m_proc, Store, origin(), value, pointer); 850 850 // We emit a write-barrier onto JSWebAssemblyGlobal, not JSWebAssemblyInstance. 851 if (is Subtype(global.type, Externref)) {851 if (isRefType(global.type)) { 852 852 Value* instance = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(), instanceValue(), safeCast<int32_t>(Instance::offsetOfOwner())); 853 853 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 79 79 } 80 80 81 inline bool isSubtype(Type sub, Type parent)82 {83 if (sub == parent)84 return true;85 return sub == Funcref && parent == Externref;86 }87 88 81 inline bool isRefType(Type type) 89 82 { -
trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h
r269998 r270015 328 328 unsigned offset = m_expressionStack.size() - target.branchTargetArity(); 329 329 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); 331 331 332 332 return { }; … … 338 338 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"); 339 339 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)); 341 341 342 342 return { }; … … 437 437 WASM_VALIDATOR_FAIL_IF(I32 != index.type(), "table.set index to type ", index.type(), " expected ", I32); 438 438 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); 440 440 RELEASE_ASSERT(m_info.tables[tableIndex].type() == TableElementType::Externref || m_info.tables[tableIndex].type() == TableElementType::Funcref); 441 441 WASM_TRY_ADD_TO_CONTEXT(addTableSet(tableIndex, index, value)); … … 464 464 WASM_TRY_POP_EXPRESSION_STACK_INTO(fill, "table.grow"); 465 465 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()); 467 467 WASM_VALIDATOR_FAIL_IF(I32 != delta.type(), "table.grow expects an i32 delta value, got ", delta.type()); 468 468 … … 478 478 WASM_TRY_POP_EXPRESSION_STACK_INTO(offset, "table.fill"); 479 479 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()); 481 481 WASM_VALIDATOR_FAIL_IF(I32 != offset.type(), "table.fill expects an i32 offset value, got ", offset.type()); 482 482 WASM_VALIDATOR_FAIL_IF(I32 != count.type(), "table.fill expects an i32 count value, got ", count.type()); … … 504 504 TypedExpression value; 505 505 WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "ref.is_null"); 506 WASM_VALIDATOR_FAIL_IF(!is Subtype(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"); 507 507 ExpressionType result; 508 508 WASM_TRY_ADD_TO_CONTEXT(addRefIsNull(value, result)); … … 540 540 WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "set_local"); 541 541 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]); 543 543 WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value)); 544 544 return { }; … … 551 551 TypedExpression value = m_expressionStack.last(); 552 552 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]); 554 554 WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value)); 555 555 return { }; … … 599 599 for (size_t i = firstArgumentIndex; i < m_expressionStack.size(); ++i) { 600 600 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)); 602 602 args.uncheckedAppend(arg); 603 603 m_context.didPopValueFromStack(); … … 640 640 TypedExpression arg = m_expressionStack.at(i); 641 641 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)); 643 643 args.uncheckedAppend(arg); 644 644 m_context.didPopValueFromStack(); … … 663 663 for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) { 664 664 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); 666 666 } 667 667 … … 686 686 for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) { 687 687 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); 689 689 } 690 690 … … 711 711 unsigned offset = m_expressionStack.size() - inlineSignature->argumentCount(); 712 712 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()); 714 714 715 715 int64_t oldSize = m_expressionStack.size(); … … 785 785 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()); 786 786 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()); 788 788 } 789 789 -
trunk/Source/JavaScriptCore/wasm/WasmInstance.cpp
r269552 r270015 63 63 // This is kept alive by JSWebAssemblyInstance -> JSWebAssemblyGlobal -> binding. 64 64 m_globalsToBinding.set(i); 65 } else if (is Subtype(global.type, Externref)) {65 } else if (isRefType(global.type)) { 66 66 // This is kept alive by JSWebAssemblyInstance -> binding. 67 67 m_globalsToMark.set(i); -
trunk/Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp
r269552 r270015 827 827 switch (global.bindingMode) { 828 828 case Wasm::GlobalInformation::BindingMode::EmbeddedInInstance: 829 if (is Subtype(type, Externref))829 if (isRefType(type)) 830 830 WasmSetGlobalRef::emit(this, index, value); 831 831 else … … 833 833 break; 834 834 case Wasm::GlobalInformation::BindingMode::Portable: 835 if (is Subtype(type, Externref))835 if (isRefType(type)) 836 836 WasmSetGlobalRefPortableBinding::emit(this, index, value); 837 837 else -
trunk/Source/JavaScriptCore/wasm/WasmSectionParser.cpp
r269998 r270015 299 299 else 300 300 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); 302 302 303 303 m_info->globals.uncheckedAppend(WTFMove(global)); -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp
r269974 r270015 257 257 } 258 258 } else { 259 const auto globalType = moduleInformation.globals[import.kindIndex].type; 259 260 // 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) 261 262 return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "cannot be an i64"))); 262 if (!is Subtype(moduleInformation.globals[import.kindIndex].type, Wasm::Externref) && !value.isNumber())263 if (!isRefType(globalType) && !value.isNumber()) 263 264 return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "must be a number"))); 264 265
Note: See TracChangeset
for help on using the changeset viewer.