Changeset 273813 in webkit
- Timestamp:
- Mar 3, 2021 4:20:00 AM (17 months ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 24 edited
-
ChangeLog (modified) (1 diff)
-
bytecode/BytecodeDumper.cpp (modified) (3 diffs)
-
bytecode/BytecodeDumper.h (modified) (2 diffs)
-
wasm/WasmAirIRGenerator.cpp (modified) (82 diffs)
-
wasm/WasmB3IRGenerator.cpp (modified) (19 diffs)
-
wasm/WasmCallingConvention.h (modified) (4 diffs)
-
wasm/WasmFormat.h (modified) (3 diffs)
-
wasm/WasmFunctionCodeBlock.h (modified) (2 diffs)
-
wasm/WasmFunctionParser.h (modified) (50 diffs)
-
wasm/WasmGlobal.cpp (modified) (7 diffs)
-
wasm/WasmLLIntGenerator.cpp (modified) (16 diffs)
-
wasm/WasmOperations.cpp (modified) (2 diffs)
-
wasm/WasmParser.h (modified) (2 diffs)
-
wasm/WasmSectionParser.cpp (modified) (14 diffs)
-
wasm/WasmSignature.cpp (modified) (5 diffs)
-
wasm/WasmSignature.h (modified) (1 diff)
-
wasm/WasmTable.cpp (modified) (1 diff)
-
wasm/generateWasmOpsHeader.py (modified) (7 diffs)
-
wasm/js/JSToWasm.cpp (modified) (8 diffs)
-
wasm/js/JSWebAssemblyHelpers.h (modified) (1 diff)
-
wasm/js/WasmToJS.cpp (modified) (11 diffs)
-
wasm/js/WebAssemblyFunction.cpp (modified) (7 diffs)
-
wasm/js/WebAssemblyGlobalConstructor.cpp (modified) (7 diffs)
-
wasm/js/WebAssemblyModuleRecord.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r273779 r273813 1 2021-03-03 Dmitry Bezhetskov <dbezhetskov@igalia.com> 2 3 [WASM-Function-References] Extend wasm type with type index 4 https://bugs.webkit.org/show_bug.cgi?id=222351 5 6 Reviewed by Keith Miller. 7 8 Extend wasm type with type index to represent 9 new reference types from typed function references 10 proposal: https://github.com/WebAssembly/function-references/blob/master/proposals/function-references/Overview.md. 11 12 * bytecode/BytecodeDumper.cpp: 13 (JSC::Wasm::BytecodeDumper::dumpConstants): 14 (JSC::Wasm::BytecodeDumper::formatConstant const): 15 * bytecode/BytecodeDumper.h: 16 * wasm/WasmAirIRGenerator.cpp: 17 (JSC::Wasm::TypedTmp::TypedTmp): 18 (JSC::Wasm::TypedTmp::dump const): 19 (JSC::Wasm::AirIRGenerator::g32): 20 (JSC::Wasm::AirIRGenerator::g64): 21 (JSC::Wasm::AirIRGenerator::gExternref): 22 (JSC::Wasm::AirIRGenerator::gFuncref): 23 (JSC::Wasm::AirIRGenerator::f32): 24 (JSC::Wasm::AirIRGenerator::f64): 25 (JSC::Wasm::AirIRGenerator::tmpForType): 26 (JSC::Wasm::AirIRGenerator::emitCCall): 27 (JSC::Wasm::AirIRGenerator::moveOpForValueType): 28 (JSC::Wasm::AirIRGenerator::AirIRGenerator): 29 (JSC::Wasm::AirIRGenerator::addLocal): 30 (JSC::Wasm::AirIRGenerator::addConstant): 31 (JSC::Wasm::AirIRGenerator::addRefIsNull): 32 (JSC::Wasm::AirIRGenerator::addRefFunc): 33 (JSC::Wasm::AirIRGenerator::addTableGet): 34 (JSC::Wasm::AirIRGenerator::addTableSet): 35 (JSC::Wasm::AirIRGenerator::addTableInit): 36 (JSC::Wasm::AirIRGenerator::addElemDrop): 37 (JSC::Wasm::AirIRGenerator::addTableSize): 38 (JSC::Wasm::AirIRGenerator::addTableGrow): 39 (JSC::Wasm::AirIRGenerator::addTableFill): 40 (JSC::Wasm::AirIRGenerator::addTableCopy): 41 (JSC::Wasm::AirIRGenerator::addGrowMemory): 42 (JSC::Wasm::AirIRGenerator::addCurrentMemory): 43 (JSC::Wasm::AirIRGenerator::addMemoryFill): 44 (JSC::Wasm::AirIRGenerator::addMemoryCopy): 45 (JSC::Wasm::AirIRGenerator::addMemoryInit): 46 (JSC::Wasm::AirIRGenerator::addDataDrop): 47 (JSC::Wasm::AirIRGenerator::emitCheckAndPreparePointer): 48 (JSC::Wasm::AirIRGenerator::sanitizeAtomicResult): 49 (JSC::Wasm::AirIRGenerator::appendGeneralAtomic): 50 (JSC::Wasm::AirIRGenerator::appendStrongCAS): 51 (JSC::Wasm::AirIRGenerator::emitAtomicLoadOp): 52 (JSC::Wasm::AirIRGenerator::atomicLoad): 53 (JSC::Wasm::AirIRGenerator::emitAtomicStoreOp): 54 (JSC::Wasm::AirIRGenerator::emitAtomicBinaryRMWOp): 55 (JSC::Wasm::AirIRGenerator::atomicBinaryRMW): 56 (JSC::Wasm::AirIRGenerator::emitAtomicCompareExchange): 57 (JSC::Wasm::AirIRGenerator::atomicCompareExchange): 58 (JSC::Wasm::AirIRGenerator::atomicWait): 59 (JSC::Wasm::AirIRGenerator::atomicNotify): 60 (JSC::Wasm::AirIRGenerator::truncSaturated): 61 (JSC::Wasm::AirIRGenerator::addReturn): 62 (JSC::Wasm::AirIRGenerator::addSwitch): 63 (JSC::Wasm::AirIRGenerator::emitModOrDiv): 64 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncSF64>): 65 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncSF32>): 66 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncUF64>): 67 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncUF32>): 68 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncSF64>): 69 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>): 70 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncSF32>): 71 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>): 72 (JSC::Wasm::AirIRGenerator::addShift): 73 (JSC::Wasm::AirIRGenerator::addFloatingPointBinOp): 74 (JSC::Wasm::AirIRGenerator::addOp<OpType::F32Min>): 75 (JSC::Wasm::AirIRGenerator::addFloatingPointMinOrMax): 76 (JSC::Wasm::AirIRGenerator::addOp<OpType::F32Max>): 77 (JSC::Wasm::AirIRGenerator::addOp<OpType::F64Mul>): 78 (JSC::Wasm::AirIRGenerator::addOp<OpType::F32Div>): 79 (JSC::Wasm::AirIRGenerator::addOp<OpType::F64Div>): 80 (JSC::Wasm::AirIRGenerator::addOp<OpType::F32Neg>): 81 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64Rotr>): 82 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64Rotl>): 83 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32ShrU>): 84 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32ShrS>): 85 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32Shl>): 86 (JSC::Wasm::AirIRGenerator::addOp<OpType::F64Min>): 87 (JSC::Wasm::AirIRGenerator::addOp<OpType::F64Sub>): 88 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64ShrS>): 89 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64ShrU>): 90 (JSC::Wasm::AirIRGenerator::addOp<OpType::I64Shl>): 91 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32Rotl>): 92 (JSC::Wasm::AirIRGenerator::addOp<OpType::I32Rotr>): 93 (JSC::Wasm::AirIRGenerator::addOp<OpType::F64Neg>): 94 (JSC::Wasm::AirIRGenerator::addOp<OpType::F64Max>): 95 * wasm/WasmB3IRGenerator.cpp: 96 (JSC::Wasm::B3IRGenerator::addTableGet): 97 (JSC::Wasm::B3IRGenerator::addRefFunc): 98 (JSC::Wasm::B3IRGenerator::addTableInit): 99 (JSC::Wasm::B3IRGenerator::addTableSize): 100 (JSC::Wasm::B3IRGenerator::addTableGrow): 101 (JSC::Wasm::B3IRGenerator::addTableFill): 102 (JSC::Wasm::B3IRGenerator::addTableCopy): 103 (JSC::Wasm::B3IRGenerator::addMemoryFill): 104 (JSC::Wasm::B3IRGenerator::addMemoryInit): 105 (JSC::Wasm::B3IRGenerator::addMemoryCopy): 106 (JSC::Wasm::B3IRGenerator::sanitizeAtomicResult): 107 (JSC::Wasm::B3IRGenerator::atomicLoad): 108 (JSC::Wasm::B3IRGenerator::emitAtomicStoreOp): 109 (JSC::Wasm::B3IRGenerator::emitAtomicBinaryRMWOp): 110 (JSC::Wasm::B3IRGenerator::atomicBinaryRMW): 111 (JSC::Wasm::B3IRGenerator::emitAtomicCompareExchange): 112 (JSC::Wasm::B3IRGenerator::atomicCompareExchange): 113 * wasm/WasmCallingConvention.h: 114 (JSC::Wasm::WasmCallingConvention::marshallLocation const): 115 (JSC::Wasm::WasmCallingConvention::callInformationFor const): 116 (JSC::Wasm::JSCallingConvention::marshallLocation const): 117 * wasm/WasmFormat.h: 118 (JSC::Wasm::isValueType): 119 (JSC::Wasm::isRefType): 120 (JSC::Wasm::TableInformation::wasmType const): 121 * wasm/WasmFunctionCodeBlock.h: 122 * wasm/WasmFunctionParser.h: 123 (JSC::Wasm::FunctionParser::TypedExpression::TypedExpression): 124 (JSC::Wasm::FunctionParser<Context>::load): 125 (JSC::Wasm::FunctionParser<Context>::store): 126 (JSC::Wasm::FunctionParser<Context>::atomicLoad): 127 (JSC::Wasm::FunctionParser<Context>::atomicStore): 128 (JSC::Wasm::FunctionParser<Context>::atomicBinaryRMW): 129 (JSC::Wasm::FunctionParser<Context>::atomicCompareExchange): 130 (JSC::Wasm::FunctionParser<Context>::atomicWait): 131 (JSC::Wasm::FunctionParser<Context>::atomicNotify): 132 (JSC::Wasm::FunctionParser<Context>::checkBranchTarget): 133 (JSC::Wasm::FunctionParser<Context>::unify): 134 (JSC::Wasm::FunctionParser<Context>::parseExpression): 135 * wasm/WasmGlobal.cpp: 136 (JSC::Wasm::Global::get const): 137 (JSC::Wasm::Global::set): 138 (JSC::Wasm::Global::visitAggregateImpl): 139 * wasm/WasmLLIntGenerator.cpp: 140 (JSC::Wasm::LLIntGenerator::jsNullConstant): 141 (JSC::Wasm::LLIntGenerator::zeroConstant): 142 (JSC::Wasm::LLIntGenerator::callInformationForCaller): 143 (JSC::Wasm::LLIntGenerator::callInformationForCallee): 144 (JSC::Wasm::LLIntGenerator::addArguments): 145 (JSC::Wasm::LLIntGenerator::addLocal): 146 * wasm/WasmOperations.cpp: 147 (JSC::Wasm::JSC_DEFINE_JIT_OPERATION): 148 * wasm/WasmParser.h: 149 (JSC::Wasm::Parser<SuccessType>::parseBlockSignature): 150 (JSC::Wasm::Parser<SuccessType>::parseValueType): 151 * wasm/WasmSectionParser.cpp: 152 (JSC::Wasm::SectionParser::parseType): 153 (JSC::Wasm::SectionParser::parseTableHelper): 154 (JSC::Wasm::SectionParser::parseGlobal): 155 (JSC::Wasm::SectionParser::parseElement): 156 (JSC::Wasm::SectionParser::parseInitExpr): 157 (JSC::Wasm::SectionParser::parseI32InitExpr): 158 (JSC::Wasm::SectionParser::parseElementSegmentVectorOfExpressions): 159 * wasm/WasmSignature.cpp: 160 (JSC::Wasm::Signature::dump const): 161 (JSC::Wasm::computeHash): 162 (JSC::Wasm::SignatureInformation::SignatureInformation): 163 * wasm/WasmSignature.h: 164 (JSC::Wasm::SignatureInformation::thunkFor const): 165 * wasm/WasmTable.cpp: 166 (JSC::Wasm::Table::wasmType const): 167 * wasm/generateWasmOpsHeader.py: 168 (TypeKind): 169 * wasm/js/JSToWasm.cpp: 170 (JSC::Wasm::marshallJSResult): 171 (JSC::Wasm::createJSToWasmWrapper): 172 * wasm/js/JSWebAssemblyHelpers.h: 173 (JSC::defaultValueForReferenceType): 174 * wasm/js/WasmToJS.cpp: 175 (JSC::Wasm::wasmToJS): 176 * wasm/js/WebAssemblyFunction.cpp: 177 (JSC::JSC_DEFINE_HOST_FUNCTION): 178 (JSC::WebAssemblyFunction::jsCallEntrypointSlow): 179 * wasm/js/WebAssemblyGlobalConstructor.cpp: 180 (JSC::JSC_DEFINE_HOST_FUNCTION): 181 * wasm/js/WebAssemblyModuleRecord.cpp: 182 (JSC::WebAssemblyModuleRecord::linkImpl): 183 1 184 2021-03-02 Yusuke Suzuki <ysuzuki@apple.com> 2 185 -
trunk/Source/JavaScriptCore/bytecode/BytecodeDumper.cpp
r269552 r273813 38 38 #include "WasmGeneratorTraits.h" 39 39 #include "WasmModuleInformation.h" 40 #include "WasmOps.h"41 40 #include "WasmSignatureInlines.h" 42 41 … … 363 362 for (const auto& constant : block->constants()) { 364 363 Type type = block->constantTypes()[i]; 365 this->m_out.print(" const", i, " : ", type , " = ", formatConstant(type, constant), "\n");364 this->m_out.print(" const", i, " : ", type.kind, " = ", formatConstant(type, constant), "\n"); 366 365 ++i; 367 366 } … … 378 377 CString BytecodeDumper::formatConstant(Type type, uint64_t constant) const 379 378 { 380 switch (type ) {381 case Type ::I32:379 switch (type.kind) { 380 case TypeKind::I32: 382 381 return toCString(static_cast<int32_t>(constant)); 383 case Type ::I64:382 case TypeKind::I64: 384 383 return toCString(constant); 385 case Type ::F32:384 case TypeKind::F32: 386 385 return toCString(bitwise_cast<float>(static_cast<int32_t>(constant))); 387 386 break; 388 case Type ::F64:387 case TypeKind::F64: 389 388 return toCString(bitwise_cast<double>(constant)); 390 389 break; 391 case Type ::Externref:392 case Type ::Funcref:390 case TypeKind::Externref: 391 case TypeKind::Funcref: 393 392 if (JSValue::decode(constant) == jsNull()) 394 393 return "null"; -
trunk/Source/JavaScriptCore/bytecode/BytecodeDumper.h
r268871 r273813 32 32 #include "InstructionStream.h" 33 33 #include "StructureStubInfo.h" 34 #include "WasmOps.h" 34 35 35 36 namespace JSC { … … 131 132 class FunctionCodeBlock; 132 133 struct ModuleInformation; 133 enum Type : int8_t;134 134 135 135 class BytecodeDumper final : public JSC::BytecodeDumper<FunctionCodeBlock> { -
trunk/Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp
r272933 r273813 86 86 constexpr TypedTmp() 87 87 : m_tmp() 88 , m_type(Type::Void) 89 { } 88 , m_type(Types::Void) 89 { 90 } 90 91 91 92 TypedTmp(Tmp tmp, Type type) … … 117 118 void dump(PrintStream& out) const 118 119 { 119 out.print("(", m_tmp, ", ", m_type , ")");120 out.print("(", m_tmp, ", ", m_type.kind, ", ", m_type.index, ")"); 120 121 } 121 122 … … 407 408 } 408 409 409 TypedTmp g32() { return { newTmp(B3::GP), Type ::I32 }; }410 TypedTmp g64() { return { newTmp(B3::GP), Type ::I64 }; }411 TypedTmp gExternref() { return { newTmp(B3::GP), Type ::Externref }; }412 TypedTmp gFuncref() { return { newTmp(B3::GP), Type ::Funcref }; }413 TypedTmp f32() { return { newTmp(B3::FP), Type ::F32 }; }414 TypedTmp f64() { return { newTmp(B3::FP), Type ::F64 }; }410 TypedTmp g32() { return { newTmp(B3::GP), Types::I32 }; } 411 TypedTmp g64() { return { newTmp(B3::GP), Types::I64 }; } 412 TypedTmp gExternref() { return { newTmp(B3::GP), Types::Externref }; } 413 TypedTmp gFuncref() { return { newTmp(B3::GP), Types::Funcref }; } 414 TypedTmp f32() { return { newTmp(B3::FP), Types::F32 }; } 415 TypedTmp f64() { return { newTmp(B3::FP), Types::F64 }; } 415 416 416 417 TypedTmp tmpForType(Type type) 417 418 { 418 switch (type ) {419 case Type ::I32:419 switch (type.kind) { 420 case TypeKind::I32: 420 421 return g32(); 421 case Type ::I64:422 case TypeKind::I64: 422 423 return g64(); 423 case Type ::Funcref:424 case TypeKind::Funcref: 424 425 return gFuncref(); 425 case Type ::Externref:426 case TypeKind::Externref: 426 427 return gExternref(); 427 case Type ::F32:428 case TypeKind::F32: 428 429 return f32(); 429 case Type ::F64:430 case TypeKind::F64: 430 431 return f64(); 431 case Type ::Void:432 case TypeKind::Void: 432 433 return { }; 433 434 default: … … 592 593 B3::Type resultType = B3::Void; 593 594 if (result) { 594 switch (result.type() ) {595 case Type ::I32:595 switch (result.type().kind) { 596 case TypeKind::I32: 596 597 resultType = B3::Int32; 597 598 break; 598 case Type ::I64:599 case Type ::Externref:600 case Type ::Funcref:599 case TypeKind::I64: 600 case TypeKind::Externref: 601 case TypeKind::Funcref: 601 602 resultType = B3::Int64; 602 603 break; 603 case Type ::F32:604 case TypeKind::F32: 604 605 resultType = B3::Float; 605 606 break; 606 case Type ::F64:607 case TypeKind::F64: 607 608 resultType = B3::Double; 608 609 break; … … 642 643 static B3::Air::Opcode moveOpForValueType(Type type) 643 644 { 644 switch (type ) {645 case Type ::I32:645 switch (type.kind) { 646 case TypeKind::I32: 646 647 return Move32; 647 case Type ::I64:648 case Type ::Externref:649 case Type ::Funcref:648 case TypeKind::I64: 649 case TypeKind::Externref: 650 case TypeKind::Funcref: 650 651 return Move; 651 case Type ::F32:652 case TypeKind::F32: 652 653 return MoveFloat; 653 case Type ::F64:654 case TypeKind::F64: 654 655 return MoveDouble; 655 656 default: … … 884 885 append(Move, Tmp(contextInstance), m_instanceValue); 885 886 } else 886 m_instanceValue = { Tmp(contextInstance), Type ::I64 };887 m_instanceValue = { Tmp(contextInstance), Types::I64 }; 887 888 888 889 ASSERT(!m_locals.size()); … … 898 899 B3::ValueRep location = wasmCallInfo.params[i]; 899 900 Arg arg = location.isReg() ? Arg(Tmp(location.reg())) : Arg::addr(Tmp(GPRInfo::callFrameRegister), location.offsetFromFP()); 900 switch (signature.argument(i) ) {901 case Type ::I32:901 switch (signature.argument(i).kind) { 902 case TypeKind::I32: 902 903 append(Move32, arg, m_locals[i]); 903 904 break; 904 case Type ::I64:905 case Type ::Externref:906 case Type ::Funcref:905 case TypeKind::I64: 906 case TypeKind::Externref: 907 case TypeKind::Funcref: 907 908 append(Move, arg, m_locals[i]); 908 909 break; 909 case Type ::F32:910 case TypeKind::F32: 910 911 append(MoveFloat, arg, m_locals[i]); 911 912 break; 912 case Type ::F64:913 case TypeKind::F64: 913 914 append(MoveDouble, arg, m_locals[i]); 914 915 break; … … 1005 1006 auto local = tmpForType(type); 1006 1007 m_locals.uncheckedAppend(local); 1007 switch (type ) {1008 case Type ::Externref:1009 case Type ::Funcref:1008 switch (type.kind) { 1009 case TypeKind::Externref: 1010 case TypeKind::Funcref: 1010 1011 append(Move, Arg::imm(JSValue::encode(jsNull())), local); 1011 1012 break; 1012 case Type ::I32:1013 case Type ::I64: {1013 case TypeKind::I32: 1014 case TypeKind::I64: { 1014 1015 append(Xor64, local, local); 1015 1016 break; 1016 1017 } 1017 case Type ::F32:1018 case Type ::F64: {1018 case TypeKind::F32: 1019 case TypeKind::F64: { 1019 1020 auto temp = g64(); 1020 1021 // IEEE 754 "0" is just int32/64 zero. 1021 1022 append(Xor64, temp, temp); 1022 append(type == Type::F32? Move32ToFloat : Move64ToDouble, temp, local);1023 append(type.isF32() ? Move32ToFloat : Move64ToDouble, temp, local); 1023 1024 break; 1024 1025 } … … 1038 1039 { 1039 1040 auto result = tmpForType(type); 1040 switch (type ) {1041 case Type ::I32:1042 case Type ::I64:1043 case Type ::Externref:1044 case Type ::Funcref:1041 switch (type.kind) { 1042 case TypeKind::I32: 1043 case TypeKind::I64: 1044 case TypeKind::Externref: 1045 case TypeKind::Funcref: 1045 1046 append(block, Move, Arg::bigImm(value), result); 1046 1047 break; 1047 case Type ::F32:1048 case Type ::F64: {1048 case TypeKind::F32: 1049 case TypeKind::F64: { 1049 1050 auto tmp = g64(); 1050 1051 append(block, Move, Arg::bigImm(value), tmp); 1051 append(block, type == Type::F32? Move32ToFloat : Move64ToDouble, tmp, result);1052 append(block, type.isF32() ? Move32ToFloat : Move64ToDouble, tmp, result); 1052 1053 break; 1053 1054 } … … 1075 1076 { 1076 1077 ASSERT(value.tmp()); 1077 result = tmpForType(Type ::I32);1078 result = tmpForType(Types::I32); 1078 1079 auto tmp = g64(); 1079 1080 … … 1087 1088 { 1088 1089 // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>. 1089 result = tmpForType(Type ::Funcref);1090 emitCCall(&operationWasmRefFunc, result, instanceValue(), addConstant(Type ::I32, index));1090 result = tmpForType(Types::Funcref); 1091 emitCCall(&operationWasmRefFunc, result, instanceValue(), addConstant(Types::I32, index)); 1091 1092 1092 1093 return { }; … … 1097 1098 // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>. 1098 1099 ASSERT(index.tmp()); 1099 ASSERT(index.type() == Type::I32); 1100 1101 ASSERT(index.type().isI32()); 1100 1102 result = tmpForType(m_info.tables[tableIndex].wasmType()); 1101 1103 1102 emitCCall(&operationGetWasmTableElement, result, instanceValue(), addConstant(Type ::I32, tableIndex), index);1104 emitCCall(&operationGetWasmTableElement, result, instanceValue(), addConstant(Types::I32, tableIndex), index); 1103 1105 emitCheck([&] { 1104 1106 return Inst(BranchTest32, nullptr, Arg::resCond(MacroAssembler::Zero), result, result); … … 1114 1116 // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>. 1115 1117 ASSERT(index.tmp()); 1116 ASSERT(index.type() == Type::I32);1118 ASSERT(index.type().isI32()); 1117 1119 ASSERT(value.tmp()); 1118 1120 1119 1121 auto shouldThrow = g32(); 1120 emitCCall(&operationSetWasmTableElement, shouldThrow, instanceValue(), addConstant(Type ::I32, tableIndex), index, value);1122 emitCCall(&operationSetWasmTableElement, shouldThrow, instanceValue(), addConstant(Types::I32, tableIndex), index, value); 1121 1123 1122 1124 emitCheck([&] { … … 1132 1134 { 1133 1135 ASSERT(dstOffset.tmp()); 1134 ASSERT(dstOffset.type() == Type::I32);1136 ASSERT(dstOffset.type().isI32()); 1135 1137 1136 1138 ASSERT(srcOffset.tmp()); 1137 ASSERT(srcOffset.type() == Type::I32);1139 ASSERT(srcOffset.type().isI32()); 1138 1140 1139 1141 ASSERT(length.tmp()); 1140 ASSERT(length.type() == Type::I32);1141 1142 auto result = tmpForType(Type ::I32);1142 ASSERT(length.type().isI32()); 1143 1144 auto result = tmpForType(Types::I32); 1143 1145 emitCCall( 1144 1146 &operationWasmTableInit, result, instanceValue(), 1145 addConstant(Type ::I32, elementIndex),1146 addConstant(Type ::I32, tableIndex),1147 addConstant(Types::I32, elementIndex), 1148 addConstant(Types::I32, tableIndex), 1147 1149 dstOffset, srcOffset, length); 1148 1150 … … 1158 1160 auto AirIRGenerator::addElemDrop(unsigned elementIndex) -> PartialResult 1159 1161 { 1160 emitCCall(&operationWasmElemDrop, TypedTmp(), instanceValue(), addConstant(Type ::I32, elementIndex));1162 emitCCall(&operationWasmElemDrop, TypedTmp(), instanceValue(), addConstant(Types::I32, elementIndex)); 1161 1163 return { }; 1162 1164 } … … 1165 1167 { 1166 1168 // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>. 1167 result = tmpForType(Type ::I32);1168 1169 emitCCall(&operationGetWasmTableSize, result, instanceValue(), addConstant(Type ::I32, tableIndex));1169 result = tmpForType(Types::I32); 1170 1171 emitCCall(&operationGetWasmTableSize, result, instanceValue(), addConstant(Types::I32, tableIndex)); 1170 1172 1171 1173 return { }; … … 1177 1179 ASSERT(fill.type() == m_info.tables[tableIndex].wasmType()); 1178 1180 ASSERT(delta.tmp()); 1179 ASSERT(delta.type() == Type::I32);1180 result = tmpForType(Type ::I32);1181 1182 emitCCall(&operationWasmTableGrow, result, instanceValue(), addConstant(Type ::I32, tableIndex), fill, delta);1181 ASSERT(delta.type().isI32()); 1182 result = tmpForType(Types::I32); 1183 1184 emitCCall(&operationWasmTableGrow, result, instanceValue(), addConstant(Types::I32, tableIndex), fill, delta); 1183 1185 1184 1186 return { }; … … 1190 1192 ASSERT(fill.type() == m_info.tables[tableIndex].wasmType()); 1191 1193 ASSERT(offset.tmp()); 1192 ASSERT(offset.type() == Type::I32);1194 ASSERT(offset.type().isI32()); 1193 1195 ASSERT(count.tmp()); 1194 ASSERT(count.type() == Type::I32);1195 1196 auto result = tmpForType(Type ::I32);1197 emitCCall(&operationWasmTableFill, result, instanceValue(), addConstant(Type ::I32, tableIndex), offset, fill, count);1196 ASSERT(count.type().isI32()); 1197 1198 auto result = tmpForType(Types::I32); 1199 emitCCall(&operationWasmTableFill, result, instanceValue(), addConstant(Types::I32, tableIndex), offset, fill, count); 1198 1200 1199 1201 emitCheck([&] { … … 1209 1211 { 1210 1212 ASSERT(dstOffset.tmp()); 1211 ASSERT(dstOffset.type() == Type::I32);1213 ASSERT(dstOffset.type().isI32()); 1212 1214 1213 1215 ASSERT(srcOffset.tmp()); 1214 ASSERT(srcOffset.type() == Type::I32);1216 ASSERT(srcOffset.type().isI32()); 1215 1217 1216 1218 ASSERT(length.tmp()); 1217 ASSERT(length.type() == Type::I32);1218 1219 auto result = tmpForType(Type ::I32);1219 ASSERT(length.type().isI32()); 1220 1221 auto result = tmpForType(Types::I32); 1220 1222 emitCCall( 1221 1223 &operationWasmTableCopy, result, instanceValue(), 1222 addConstant(Type ::I32, dstTableIndex),1223 addConstant(Type ::I32, srcTableIndex),1224 addConstant(Types::I32, dstTableIndex), 1225 addConstant(Types::I32, srcTableIndex), 1224 1226 dstOffset, srcOffset, length); 1225 1227 … … 1255 1257 { 1256 1258 result = g32(); 1257 emitCCall(&operationGrowMemory, result, TypedTmp { Tmp(GPRInfo::callFrameRegister), Type ::I64 }, instanceValue(), delta);1259 emitCCall(&operationGrowMemory, result, TypedTmp { Tmp(GPRInfo::callFrameRegister), Types::I64 }, instanceValue(), delta); 1258 1260 restoreWebAssemblyGlobalState(RestoreCachedStackLimit::No, m_info.memory, instanceValue(), m_currentBlock); 1259 1261 … … 1277 1279 static_assert(PageCount::pageSize == 1ull << shiftValue, "This must hold for the code below to be correct."); 1278 1280 append(Move, Arg::imm(16), temp2); 1279 addShift(Type ::I32, Urshift64, temp1, temp2, result);1281 addShift(Types::I32, Urshift64, temp1, temp2, result); 1280 1282 append(Move32, result, result); 1281 1283 … … 1286 1288 { 1287 1289 ASSERT(dstAddress.tmp()); 1288 ASSERT(dstAddress.type() == Type::I32);1290 ASSERT(dstAddress.type().isI32()); 1289 1291 1290 1292 ASSERT(targetValue.tmp()); 1291 ASSERT(targetValue.type() == Type::I32);1293 ASSERT(targetValue.type().isI32()); 1292 1294 1293 1295 ASSERT(count.tmp()); 1294 ASSERT(count.type() == Type::I32);1295 1296 auto result = tmpForType(Type ::I32);1296 ASSERT(count.type().isI32()); 1297 1298 auto result = tmpForType(Types::I32); 1297 1299 emitCCall( 1298 1300 &operationWasmMemoryFill, result, instanceValue(), … … 1311 1313 { 1312 1314 ASSERT(dstAddress.tmp()); 1313 ASSERT(dstAddress.type() == Type::I32);1315 ASSERT(dstAddress.type().isI32()); 1314 1316 1315 1317 ASSERT(srcAddress.tmp()); 1316 ASSERT(srcAddress.type() == Type::I32);1318 ASSERT(srcAddress.type().isI32()); 1317 1319 1318 1320 ASSERT(count.tmp()); 1319 ASSERT(count.type() == Type::I32);1320 1321 auto result = tmpForType(Type ::I32);1321 ASSERT(count.type().isI32()); 1322 1323 auto result = tmpForType(Types::I32); 1322 1324 emitCCall( 1323 1325 &operationWasmMemoryCopy, result, instanceValue(), … … 1336 1338 { 1337 1339 ASSERT(dstAddress.tmp()); 1338 ASSERT(dstAddress.type() == Type::I32);1340 ASSERT(dstAddress.type().isI32()); 1339 1341 1340 1342 ASSERT(srcAddress.tmp()); 1341 ASSERT(srcAddress.type() == Type::I32);1343 ASSERT(srcAddress.type().isI32()); 1342 1344 1343 1345 ASSERT(length.tmp()); 1344 ASSERT(length.type() == Type::I32);1345 1346 auto result = tmpForType(Type ::I32);1346 ASSERT(length.type().isI32()); 1347 1348 auto result = tmpForType(Types::I32); 1347 1349 emitCCall( 1348 1350 &operationWasmMemoryInit, result, instanceValue(), 1349 addConstant(Type ::I32, dataSegmentIndex),1351 addConstant(Types::I32, dataSegmentIndex), 1350 1352 dstAddress, srcAddress, length); 1351 1353 … … 1361 1363 auto AirIRGenerator::addDataDrop(unsigned dataSegmentIndex) -> PartialResult 1362 1364 { 1363 emitCCall(&operationWasmDataDrop, TypedTmp(), instanceValue(), addConstant(Type ::I32, dataSegmentIndex));1365 emitCCall(&operationWasmDataDrop, TypedTmp(), instanceValue(), addConstant(Types::I32, dataSegmentIndex)); 1364 1366 return { }; 1365 1367 } … … 1581 1583 append(Move, Arg::bigImm(static_cast<uint64_t>(sizeOfOperation) + offset - 1), temp); 1582 1584 append(Add64, result, temp); 1583 auto sizeMax = addConstant(Type ::I64, maximum);1585 auto sizeMax = addConstant(Types::I64, maximum); 1584 1586 1585 1587 emitCheck([&] { … … 1901 1903 void AirIRGenerator::sanitizeAtomicResult(ExtAtomicOpType op, Type valueType, Tmp source, Tmp dest) 1902 1904 { 1903 switch (valueType ) {1904 case Type ::I64: {1905 switch (valueType.kind) { 1906 case TypeKind::I64: { 1905 1907 switch (accessWidth(op)) { 1906 1908 case B3::Width8: … … 1921 1923 return; 1922 1924 } 1923 case Type ::I32:1925 case TypeKind::I32: 1924 1926 switch (accessWidth(op)) { 1925 1927 case B3::Width8: … … 1960 1962 auto tmp = [&](Arg arg) -> TypedTmp { 1961 1963 if (arg.isTmp()) 1962 return TypedTmp(arg.tmp(), accessWidth == B3::Width64 ? Type ::I64 : Type::I32);1964 return TypedTmp(arg.tmp(), accessWidth == B3::Width64 ? Types::I64 : Types::I32); 1963 1965 TypedTmp result = newTmp(); 1964 1966 append(Move, arg, result); … … 2071 2073 auto tmp = [&](Arg arg) -> TypedTmp { 2072 2074 if (arg.isTmp()) 2073 return TypedTmp(arg.tmp(), accessWidth == B3::Width64 ? Type ::I64 : Type::I32);2075 return TypedTmp(arg.tmp(), accessWidth == B3::Width64 ? Types::I64 : Types::I32); 2074 2076 TypedTmp result = newTmp(); 2075 2077 append(Move, arg, result); … … 2166 2168 B3::Air::Opcode nonAtomicOpcode = OPCODE_FOR_CANONICAL_WIDTH(Add, accessWidth(op)); 2167 2169 2168 TypedTmp result = valueType == Type::I64? g64() : g32();2170 TypedTmp result = valueType.isI64() ? g64() : g32(); 2169 2171 2170 2172 if (opcode) { … … 2203 2205 2204 2206 // We won't reach here, so we just pick a random reg. 2205 switch (valueType ) {2206 case Type ::I32:2207 switch (valueType.kind) { 2208 case TypeKind::I32: 2207 2209 result = g32(); 2208 2210 break; 2209 case Type ::I64:2211 case TypeKind::I64: 2210 2212 result = g64(); 2211 2213 break; … … 2240 2242 if (opcode) { 2241 2243 if (isValidForm(opcode.value(), Arg::Tmp, addrArg.kind(), Arg::Tmp)) { 2242 TypedTmp result = valueType == Type::I64? g64() : g32();2244 TypedTmp result = valueType.isI64() ? g64() : g32(); 2243 2245 appendEffectful(opcode.value(), value, addrArg, result); 2244 2246 return; … … 2246 2248 2247 2249 if (isValidForm(opcode.value(), Arg::Tmp, addrArg.kind())) { 2248 TypedTmp result = valueType == Type::I64? g64() : g32();2250 TypedTmp result = valueType.isI64() ? g64() : g32(); 2249 2251 append(Move, value, result); 2250 2252 appendEffectful(opcode.value(), result, addrArg); … … 2253 2255 } 2254 2256 2255 appendGeneralAtomic(op, nonAtomicOpcode, B3::Commutative, value, addrArg, valueType == Type::I64? g64() : g32());2257 appendGeneralAtomic(op, nonAtomicOpcode, B3::Commutative, value, addrArg, valueType.isI64() ? g64() : g32()); 2256 2258 } 2257 2259 … … 2312 2314 if (isX86() || isARM64E()) { 2313 2315 TypedTmp newValue; 2314 if (valueType == Type::I64) {2316 if (valueType.isI64()) { 2315 2317 newValue = g64(); 2316 2318 append(Move, value, newValue); … … 2339 2341 if (isARM64E()) { 2340 2342 TypedTmp newValue; 2341 if (valueType == Type::I64) {2343 if (valueType.isI64()) { 2342 2344 newValue = g64(); 2343 2345 append(Not64, value, newValue); … … 2392 2394 } 2393 2395 2394 TypedTmp result = valueType == Type::I64? g64() : g32();2396 TypedTmp result = valueType.isI64() ? g64() : g32(); 2395 2397 2396 2398 if (opcode) { … … 2427 2429 emitPatchpoint(patch, Tmp()); 2428 2430 2429 switch (valueType ) {2430 case Type ::I32:2431 switch (valueType.kind) { 2432 case TypeKind::I32: 2431 2433 result = g32(); 2432 2434 break; 2433 case Type ::I64:2435 case TypeKind::I64: 2434 2436 result = g64(); 2435 2437 break; … … 2459 2461 } 2460 2462 2461 TypedTmp result = valueType == Type::I64? g64() : g32();2463 TypedTmp result = valueType.isI64() ? g64() : g32(); 2462 2464 2463 2465 if (valueWidth == accessWidth) { … … 2471 2473 BasicBlock* continuation = m_code.addBlock(); 2472 2474 2473 TypedTmp truncatedExpected = valueType == Type::I64? g64() : g32();2475 TypedTmp truncatedExpected = valueType.isI64() ? g64() : g32(); 2474 2476 sanitizeAtomicResult(op, valueType, expected, truncatedExpected); 2475 2477 … … 2526 2528 2527 2529 // We won't reach here, so we just pick a random reg. 2528 switch (valueType ) {2529 case Type ::I32:2530 switch (valueType.kind) { 2531 case TypeKind::I32: 2530 2532 result = g32(); 2531 2533 break; 2532 case Type ::I64:2534 case TypeKind::I64: 2533 2535 result = g64(); 2534 2536 break; … … 2547 2549 2548 2550 if (op == ExtAtomicOpType::MemoryAtomicWait32) 2549 emitCCall(&operationMemoryAtomicWait32, result, instanceValue(), pointer, addConstant(Type ::I32, offset), value, timeout);2551 emitCCall(&operationMemoryAtomicWait32, result, instanceValue(), pointer, addConstant(Types::I32, offset), value, timeout); 2550 2552 else 2551 emitCCall(&operationMemoryAtomicWait64, result, instanceValue(), pointer, addConstant(Type ::I32, offset), value, timeout);2553 emitCCall(&operationMemoryAtomicWait64, result, instanceValue(), pointer, addConstant(Types::I32, offset), value, timeout); 2552 2554 emitCheck([&] { 2553 2555 return Inst(Branch32, nullptr, Arg::relCond(MacroAssembler::LessThan), result, Arg::imm(0)); … … 2563 2565 result = g32(); 2564 2566 2565 emitCCall(&operationMemoryAtomicNotify, result, instanceValue(), pointer, addConstant(Type ::I32, offset), count);2567 emitCCall(&operationMemoryAtomicNotify, result, instanceValue(), pointer, addConstant(Types::I32, offset), count); 2566 2568 emitCheck([&] { 2567 2569 return Inst(Branch32, nullptr, Arg::relCond(MacroAssembler::LessThan), result, Arg::imm(0)); … … 2587 2589 switch (op) { 2588 2590 case Ext1OpType::I32TruncSatF32S: 2589 maxFloat = addConstant(Type ::F32, bitwise_cast<uint32_t>(-static_cast<float>(std::numeric_limits<int32_t>::min())));2590 minFloat = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int32_t>::min())));2591 maxFloat = addConstant(Types::F32, bitwise_cast<uint32_t>(-static_cast<float>(std::numeric_limits<int32_t>::min()))); 2592 minFloat = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int32_t>::min()))); 2591 2593 break; 2592 2594 case Ext1OpType::I32TruncSatF32U: 2593 maxFloat = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int32_t>::min()) * static_cast<float>(-2.0)));2594 minFloat = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(-1.0)));2595 maxFloat = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int32_t>::min()) * static_cast<float>(-2.0))); 2596 minFloat = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(-1.0))); 2595 2597 break; 2596 2598 case Ext1OpType::I32TruncSatF64S: 2597 maxFloat = addConstant(Type ::F64, bitwise_cast<uint64_t>(-static_cast<double>(std::numeric_limits<int32_t>::min())));2598 minFloat = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int32_t>::min()) - 1.0));2599 maxFloat = addConstant(Types::F64, bitwise_cast<uint64_t>(-static_cast<double>(std::numeric_limits<int32_t>::min()))); 2600 minFloat = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int32_t>::min()) - 1.0)); 2599 2601 break; 2600 2602 case Ext1OpType::I32TruncSatF64U: 2601 maxFloat = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int32_t>::min()) * -2.0));2602 minFloat = addConstant(Type ::F64, bitwise_cast<uint64_t>(-1.0));2603 maxFloat = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int32_t>::min()) * -2.0)); 2604 minFloat = addConstant(Types::F64, bitwise_cast<uint64_t>(-1.0)); 2603 2605 break; 2604 2606 case Ext1OpType::I64TruncSatF32S: 2605 maxFloat = addConstant(Type ::F32, bitwise_cast<uint32_t>(-static_cast<float>(std::numeric_limits<int64_t>::min())));2606 minFloat = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int64_t>::min())));2607 maxFloat = addConstant(Types::F32, bitwise_cast<uint32_t>(-static_cast<float>(std::numeric_limits<int64_t>::min()))); 2608 minFloat = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int64_t>::min()))); 2607 2609 break; 2608 2610 case Ext1OpType::I64TruncSatF32U: 2609 maxFloat = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int64_t>::min()) * static_cast<float>(-2.0)));2610 minFloat = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(-1.0)));2611 maxFloat = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int64_t>::min()) * static_cast<float>(-2.0))); 2612 minFloat = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(-1.0))); 2611 2613 if (isX86()) 2612 signBitConstant = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<uint64_t>::max() - std::numeric_limits<int64_t>::max())));2614 signBitConstant = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<uint64_t>::max() - std::numeric_limits<int64_t>::max()))); 2613 2615 requiresMacroScratchRegisters = true; 2614 2616 break; 2615 2617 case Ext1OpType::I64TruncSatF64S: 2616 maxFloat = addConstant(Type ::F64, bitwise_cast<uint64_t>(-static_cast<double>(std::numeric_limits<int64_t>::min())));2617 minFloat = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int64_t>::min())));2618 maxFloat = addConstant(Types::F64, bitwise_cast<uint64_t>(-static_cast<double>(std::numeric_limits<int64_t>::min()))); 2619 minFloat = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int64_t>::min()))); 2618 2620 break; 2619 2621 case Ext1OpType::I64TruncSatF64U: 2620 maxFloat = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int64_t>::min()) * -2.0));2621 minFloat = addConstant(Type ::F64, bitwise_cast<uint64_t>(-1.0));2622 maxFloat = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int64_t>::min()) * -2.0)); 2623 minFloat = addConstant(Types::F64, bitwise_cast<uint64_t>(-1.0)); 2622 2624 if (isX86()) 2623 signBitConstant = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<uint64_t>::max() - std::numeric_limits<int64_t>::max())));2625 signBitConstant = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<uint64_t>::max() - std::numeric_limits<int64_t>::max()))); 2624 2626 requiresMacroScratchRegisters = true; 2625 2627 break; … … 2665 2667 BasicBlock* continuation = m_code.addBlock(); 2666 2668 2667 auto branchOp = operandType == Type ::F32 ? BranchFloat : BranchDouble;2669 auto branchOp = operandType == Types::F32 ? BranchFloat : BranchDouble; 2668 2670 append(m_currentBlock, branchOp, Arg::doubleCond(MacroAssembler::DoubleLessThanOrEqualOrUnordered), arg, minFloat); 2669 2671 m_currentBlock->setSuccessors(minCase, maxCheckCase); … … 3001 3003 3002 3004 ASSERT(rep.isReg()); 3003 if (data.signature()->returnType(i) == I32)3005 if (data.signature()->returnType(i).isI32()) 3004 3006 append(Move32, tmp, tmp); 3005 3007 returnConstraints.append(ConstrainedTmp(tmp, wasmCallInfo.results[i])); … … 3041 3043 successors.append(defaultTarget.targetBlockForBranch()); 3042 3044 3043 ASSERT(condition.type() == Type::I32);3045 ASSERT(condition.type().isI32()); 3044 3046 3045 3047 // FIXME: We should consider dynamically switching between a jump table … … 3615 3617 3616 3618 auto temp = sizeof(IntType) == 4 ? g32() : g64(); 3617 auto one = addConstant(sizeof(IntType) == 4 ? Type ::I32 : Type::I64, 1);3619 auto one = addConstant(sizeof(IntType) == 4 ? Types::I32 : Types::I64, 1); 3618 3620 3619 3621 append(sizeof(IntType) == 4 ? Add32 : Add64, rhs, one, temp); … … 3625 3627 denMayBeBad->setSuccessors(continuation, denNotZero); 3626 3628 3627 auto min = addConstant(denNotZero, sizeof(IntType) == 4 ? Type ::I32 : Type::I64, std::numeric_limits<IntType>::min());3629 auto min = addConstant(denNotZero, sizeof(IntType) == 4 ? Types::I32 : Types::I64, std::numeric_limits<IntType>::min()); 3628 3630 if (isDiv) 3629 3631 append(denNotZero, sizeof(IntType) == 4 ? Move32 : Move, min, result); … … 3888 3890 auto AirIRGenerator::addOp<OpType::I32TruncSF64>(ExpressionType arg, ExpressionType& result) -> PartialResult 3889 3891 { 3890 auto max = addConstant(Type ::F64, bitwise_cast<uint64_t>(-static_cast<double>(std::numeric_limits<int32_t>::min())));3891 auto min = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int32_t>::min()) - 1.0));3892 auto max = addConstant(Types::F64, bitwise_cast<uint64_t>(-static_cast<double>(std::numeric_limits<int32_t>::min()))); 3893 auto min = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int32_t>::min()) - 1.0)); 3892 3894 3893 3895 auto temp1 = g32(); … … 3917 3919 auto AirIRGenerator::addOp<OpType::I32TruncSF32>(ExpressionType arg, ExpressionType& result) -> PartialResult 3918 3920 { 3919 auto max = addConstant(Type ::F32, bitwise_cast<uint32_t>(-static_cast<float>(std::numeric_limits<int32_t>::min())));3920 auto min = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int32_t>::min())));3921 auto max = addConstant(Types::F32, bitwise_cast<uint32_t>(-static_cast<float>(std::numeric_limits<int32_t>::min()))); 3922 auto min = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int32_t>::min()))); 3921 3923 3922 3924 auto temp1 = g32(); … … 3946 3948 auto AirIRGenerator::addOp<OpType::I32TruncUF64>(ExpressionType arg, ExpressionType& result) -> PartialResult 3947 3949 { 3948 auto max = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int32_t>::min()) * -2.0));3949 auto min = addConstant(Type ::F64, bitwise_cast<uint64_t>(-1.0));3950 auto max = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int32_t>::min()) * -2.0)); 3951 auto min = addConstant(Types::F64, bitwise_cast<uint64_t>(-1.0)); 3950 3952 3951 3953 auto temp1 = g32(); … … 3974 3976 auto AirIRGenerator::addOp<OpType::I32TruncUF32>(ExpressionType arg, ExpressionType& result) -> PartialResult 3975 3977 { 3976 auto max = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int32_t>::min()) * static_cast<float>(-2.0)));3977 auto min = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(-1.0)));3978 auto max = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int32_t>::min()) * static_cast<float>(-2.0))); 3979 auto min = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(-1.0))); 3978 3980 3979 3981 auto temp1 = g32(); … … 4002 4004 auto AirIRGenerator::addOp<OpType::I64TruncSF64>(ExpressionType arg, ExpressionType& result) -> PartialResult 4003 4005 { 4004 auto max = addConstant(Type ::F64, bitwise_cast<uint64_t>(-static_cast<double>(std::numeric_limits<int64_t>::min())));4005 auto min = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int64_t>::min())));4006 auto max = addConstant(Types::F64, bitwise_cast<uint64_t>(-static_cast<double>(std::numeric_limits<int64_t>::min()))); 4007 auto min = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int64_t>::min()))); 4006 4008 4007 4009 auto temp1 = g32(); … … 4031 4033 auto AirIRGenerator::addOp<OpType::I64TruncUF64>(ExpressionType arg, ExpressionType& result) -> PartialResult 4032 4034 { 4033 auto max = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int64_t>::min()) * -2.0));4034 auto min = addConstant(Type ::F64, bitwise_cast<uint64_t>(-1.0));4035 auto max = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<int64_t>::min()) * -2.0)); 4036 auto min = addConstant(Types::F64, bitwise_cast<uint64_t>(-1.0)); 4035 4037 4036 4038 auto temp1 = g32(); … … 4048 4050 TypedTmp signBitConstant; 4049 4051 if (isX86()) 4050 signBitConstant = addConstant(Type ::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<uint64_t>::max() - std::numeric_limits<int64_t>::max())));4052 signBitConstant = addConstant(Types::F64, bitwise_cast<uint64_t>(static_cast<double>(std::numeric_limits<uint64_t>::max() - std::numeric_limits<int64_t>::max()))); 4051 4053 4052 4054 Vector<ConstrainedTmp> args; … … 4078 4080 auto AirIRGenerator::addOp<OpType::I64TruncSF32>(ExpressionType arg, ExpressionType& result) -> PartialResult 4079 4081 { 4080 auto max = addConstant(Type ::F32, bitwise_cast<uint32_t>(-static_cast<float>(std::numeric_limits<int64_t>::min())));4081 auto min = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int64_t>::min())));4082 auto max = addConstant(Types::F32, bitwise_cast<uint32_t>(-static_cast<float>(std::numeric_limits<int64_t>::min()))); 4083 auto min = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int64_t>::min()))); 4082 4084 4083 4085 auto temp1 = g32(); … … 4106 4108 auto AirIRGenerator::addOp<OpType::I64TruncUF32>(ExpressionType arg, ExpressionType& result) -> PartialResult 4107 4109 { 4108 auto max = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int64_t>::min()) * static_cast<float>(-2.0)));4109 auto min = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(-1.0)));4110 auto max = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<int64_t>::min()) * static_cast<float>(-2.0))); 4111 auto min = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(-1.0))); 4110 4112 4111 4113 auto temp1 = g32(); … … 4123 4125 TypedTmp signBitConstant; 4124 4126 if (isX86()) 4125 signBitConstant = addConstant(Type ::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<uint64_t>::max() - std::numeric_limits<int64_t>::max())));4127 signBitConstant = addConstant(Types::F32, bitwise_cast<uint32_t>(static_cast<float>(std::numeric_limits<uint64_t>::max() - std::numeric_limits<int64_t>::max()))); 4126 4128 4127 4129 auto* patchpoint = addPatchpoint(B3::Int64); … … 4153 4155 auto AirIRGenerator::addShift(Type type, B3::Air::Opcode op, ExpressionType value, ExpressionType shift, ExpressionType& result) -> PartialResult 4154 4156 { 4155 ASSERT(type == Type::I64 || type == Type::I32);4157 ASSERT(type.isI64() || type.isI32()); 4156 4158 result = tmpForType(type); 4157 4159 … … 4221 4223 auto AirIRGenerator::addFloatingPointBinOp(Type type, B3::Air::Opcode op, ExpressionType lhs, ExpressionType rhs, ExpressionType& result) -> PartialResult 4222 4224 { 4223 ASSERT(type == Type::F32 || type == Type::F64);4225 ASSERT(type.isF32() || type.isF64()); 4224 4226 result = tmpForType(type); 4225 4227 … … 4274 4276 template<> auto AirIRGenerator::addOp<OpType::F32Min>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4275 4277 { 4276 return addFloatingPointMinOrMax( F32, MinOrMax::Min, arg0, arg1, result);4278 return addFloatingPointMinOrMax(Types::F32, MinOrMax::Min, arg0, arg1, result); 4277 4279 } 4278 4280 … … 4293 4295 auto AirIRGenerator::addFloatingPointMinOrMax(Type floatType, MinOrMax minOrMax, ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4294 4296 { 4295 ASSERT(floatType == F32 || floatType == F64);4297 ASSERT(floatType.isF32() || floatType.isF64()); 4296 4298 result = tmpForType(floatType); 4297 4299 … … 4304 4306 BasicBlock* continuation = m_code.addBlock(); 4305 4307 4306 auto branchOp = floatType == F32? BranchFloat : BranchDouble;4308 auto branchOp = floatType.isF32() ? BranchFloat : BranchDouble; 4307 4309 append(m_currentBlock, branchOp, Arg::doubleCond(MacroAssembler::DoubleEqualAndOrdered), arg0, arg1); 4308 4310 m_currentBlock->setSuccessors(isEqual, notEqual); … … 4314 4316 notLessThan->setSuccessors(isGreaterThan, isNaN); 4315 4317 4316 auto andOp = floatType == F32? AndFloat : AndDouble;4317 auto orOp = floatType == F32? OrFloat : OrDouble;4318 auto andOp = floatType.isF32() ? AndFloat : AndDouble; 4319 auto orOp = floatType.isF32() ? OrFloat : OrDouble; 4318 4320 append(isEqual, minOrMax == MinOrMax::Max ? andOp : orOp, arg0, arg1, result); 4319 4321 append(isEqual, Jump); … … 4330 4332 isGreaterThan->setSuccessors(continuation); 4331 4333 4332 auto addOp = floatType == F32? AddFloat : AddDouble;4334 auto addOp = floatType.isF32() ? AddFloat : AddDouble; 4333 4335 append(isNaN, addOp, arg0, arg1, result); 4334 4336 append(isNaN, Jump); … … 4342 4344 template<> auto AirIRGenerator::addOp<OpType::F32Max>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4343 4345 { 4344 return addFloatingPointMinOrMax( F32, MinOrMax::Max, arg0, arg1, result);4346 return addFloatingPointMinOrMax(Types::F32, MinOrMax::Max, arg0, arg1, result); 4345 4347 } 4346 4348 4347 4349 template<> auto AirIRGenerator::addOp<OpType::F64Mul>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4348 4350 { 4349 return addFloatingPointBinOp(Type ::F64, MulDouble, arg0, arg1, result);4351 return addFloatingPointBinOp(Types::F64, MulDouble, arg0, arg1, result); 4350 4352 } 4351 4353 4352 4354 template<> auto AirIRGenerator::addOp<OpType::F32Div>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4353 4355 { 4354 return addFloatingPointBinOp(Type ::F32, DivFloat, arg0, arg1, result);4356 return addFloatingPointBinOp(Types::F32, DivFloat, arg0, arg1, result); 4355 4357 } 4356 4358 … … 4461 4463 template<> auto AirIRGenerator::addOp<OpType::F64Div>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4462 4464 { 4463 return addFloatingPointBinOp(Type ::F64, DivDouble, arg0, arg1, result);4465 return addFloatingPointBinOp(Types::F64, DivDouble, arg0, arg1, result); 4464 4466 } 4465 4467 … … 4512 4514 append(NegateFloat, arg0, result); 4513 4515 else { 4514 auto constant = addConstant(Type ::I32, bitwise_cast<uint32_t>(static_cast<float>(-0.0)));4516 auto constant = addConstant(Types::I32, bitwise_cast<uint32_t>(static_cast<float>(-0.0))); 4515 4517 auto temp = g32(); 4516 4518 append(MoveFloatTo32, arg0, temp); … … 4537 4539 template<> auto AirIRGenerator::addOp<OpType::I64Rotr>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4538 4540 { 4539 return addShift(Type ::I64, RotateRight64, arg0, arg1, result);4541 return addShift(Types::I64, RotateRight64, arg0, arg1, result); 4540 4542 } 4541 4543 … … 4596 4598 append(Move, arg1, newShift); 4597 4599 append(Neg64, newShift); 4598 return addShift(Type ::I64, RotateRight64, arg0, newShift, result);4600 return addShift(Types::I64, RotateRight64, arg0, newShift, result); 4599 4601 } else 4600 return addShift(Type ::I64, RotateLeft64, arg0, arg1, result);4602 return addShift(Types::I64, RotateLeft64, arg0, arg1, result); 4601 4603 } 4602 4604 … … 4638 4640 template<> auto AirIRGenerator::addOp<OpType::I32ShrU>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4639 4641 { 4640 return addShift(Type ::I32, Urshift32, arg0, arg1, result);4642 return addShift(Types::I32, Urshift32, arg0, arg1, result); 4641 4643 } 4642 4644 … … 4652 4654 template<> auto AirIRGenerator::addOp<OpType::I32ShrS>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4653 4655 { 4654 return addShift(Type ::I32, Rshift32, arg0, arg1, result);4656 return addShift(Types::I32, Rshift32, arg0, arg1, result); 4655 4657 } 4656 4658 … … 4678 4680 template<> auto AirIRGenerator::addOp<OpType::I32Shl>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4679 4681 { 4680 return addShift(Type ::I32, Lshift32, arg0, arg1, result);4682 return addShift(Types::I32, Lshift32, arg0, arg1, result); 4681 4683 } 4682 4684 … … 4702 4704 template<> auto AirIRGenerator::addOp<OpType::F64Min>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4703 4705 { 4704 return addFloatingPointMinOrMax( F64, MinOrMax::Min, arg0, arg1, result);4706 return addFloatingPointMinOrMax(Types::F64, MinOrMax::Min, arg0, arg1, result); 4705 4707 } 4706 4708 … … 4733 4735 template<> auto AirIRGenerator::addOp<OpType::F64Sub>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4734 4736 { 4735 return addFloatingPointBinOp(Type ::F64, SubDouble, arg0, arg1, result);4737 return addFloatingPointBinOp(Types::F64, SubDouble, arg0, arg1, result); 4736 4738 } 4737 4739 … … 4885 4887 template<> auto AirIRGenerator::addOp<OpType::I64ShrS>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4886 4888 { 4887 return addShift(Type ::I64, Rshift64, arg0, arg1, result);4889 return addShift(Types::I64, Rshift64, arg0, arg1, result); 4888 4890 } 4889 4891 4890 4892 template<> auto AirIRGenerator::addOp<OpType::I64ShrU>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4891 4893 { 4892 return addShift(Type ::I64, Urshift64, arg0, arg1, result);4894 return addShift(Types::I64, Urshift64, arg0, arg1, result); 4893 4895 } 4894 4896 … … 4902 4904 template<> auto AirIRGenerator::addOp<OpType::I64Shl>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4903 4905 { 4904 return addShift(Type ::I64, Lshift64, arg0, arg1, result);4906 return addShift(Types::I64, Lshift64, arg0, arg1, result); 4905 4907 } 4906 4908 … … 4926 4928 append(Move, arg1, newShift); 4927 4929 append(Neg64, newShift); 4928 return addShift(Type ::I32, RotateRight32, arg0, newShift, result);4930 return addShift(Types::I32, RotateRight32, arg0, newShift, result); 4929 4931 } else 4930 return addShift(Type ::I32, RotateLeft32, arg0, arg1, result);4932 return addShift(Types::I32, RotateLeft32, arg0, arg1, result); 4931 4933 } 4932 4934 4933 4935 template<> auto AirIRGenerator::addOp<OpType::I32Rotr>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 4934 4936 { 4935 return addShift(Type ::I32, RotateRight32, arg0, arg1, result);4937 return addShift(Types::I32, RotateRight32, arg0, arg1, result); 4936 4938 } 4937 4939 … … 5006 5008 append(NegateDouble, arg0, result); 5007 5009 else { 5008 auto constant = addConstant(Type ::I64, bitwise_cast<uint64_t>(static_cast<double>(-0.0)));5010 auto constant = addConstant(Types::I64, bitwise_cast<uint64_t>(static_cast<double>(-0.0))); 5009 5011 auto temp = g64(); 5010 5012 append(MoveDoubleTo64, arg0, temp); … … 5017 5019 template<> auto AirIRGenerator::addOp<OpType::F64Max>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult 5018 5020 { 5019 return addFloatingPointMinOrMax( F64, MinOrMax::Max, arg0, arg1, result);5021 return addFloatingPointMinOrMax(Types::F64, MinOrMax::Max, arg0, arg1, result); 5020 5022 } 5021 5023 -
trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp
r272933 r273813 713 713 { 714 714 // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>. 715 result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type( Externref), origin(),715 result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type(Types::Externref), origin(), 716 716 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationGetWasmTableElement)), 717 717 instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), tableIndex), index); … … 754 754 result = m_currentBlock->appendNew<CCallValue>(m_proc, B3::Int64, origin(), 755 755 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmRefFunc)), 756 instanceValue(), addConstant(Type ::I32, index));756 instanceValue(), addConstant(Types::I32, index)); 757 757 758 758 return { }; … … 762 762 { 763 763 auto result = m_currentBlock->appendNew<CCallValue>( 764 m_proc, toB3Type( I32), origin(),764 m_proc, toB3Type(Types::I32), origin(), 765 765 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmTableInit)), 766 766 instanceValue(), … … 795 795 { 796 796 // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>. 797 result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type( I32), origin(),797 result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type(Types::I32), origin(), 798 798 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationGetWasmTableSize)), 799 799 instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), tableIndex)); … … 804 804 auto B3IRGenerator::addTableGrow(unsigned tableIndex, ExpressionType fill, ExpressionType delta, ExpressionType& result) -> PartialResult 805 805 { 806 result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type( I32), origin(),806 result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type(Types::I32), origin(), 807 807 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmTableGrow)), 808 808 instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), tableIndex), fill, delta); … … 813 813 auto B3IRGenerator::addTableFill(unsigned tableIndex, ExpressionType offset, ExpressionType fill, ExpressionType count) -> PartialResult 814 814 { 815 auto result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type( I32), origin(),815 auto result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type(Types::I32), origin(), 816 816 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmTableFill)), 817 817 instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), tableIndex), offset, fill, count); … … 832 832 { 833 833 auto result = m_currentBlock->appendNew<CCallValue>( 834 m_proc, toB3Type( I32), origin(),834 m_proc, toB3Type(Types::I32), origin(), 835 835 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmTableCopy)), 836 836 instanceValue(), … … 899 899 { 900 900 auto result = m_currentBlock->appendNew<CCallValue>( 901 m_proc, toB3Type( I32), origin(),901 m_proc, toB3Type(Types::I32), origin(), 902 902 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmMemoryFill)), 903 903 instanceValue(), … … 919 919 { 920 920 auto result = m_currentBlock->appendNew<CCallValue>( 921 m_proc, toB3Type( I32), origin(),921 m_proc, toB3Type(Types::I32), origin(), 922 922 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmMemoryInit)), 923 923 instanceValue(), … … 940 940 { 941 941 auto result = m_currentBlock->appendNew<CCallValue>( 942 m_proc, toB3Type( I32), origin(),942 m_proc, toB3Type(Types::I32), origin(), 943 943 m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmMemoryCopy)), 944 944 instanceValue(), … … 1388 1388 }; 1389 1389 1390 switch (valueType ) {1391 case Type ::I64: {1390 switch (valueType.kind) { 1391 case TypeKind::I64: { 1392 1392 if (accessWidth(op) == B3::Width64) 1393 1393 return result; 1394 1394 return m_currentBlock->appendNew<Value>(m_proc, ZExt32, origin(), sanitize32(result)); 1395 1395 } 1396 case Type ::I32:1396 case TypeKind::I32: 1397 1397 return sanitize32(result); 1398 1398 default: … … 1446 1446 }); 1447 1447 1448 switch (valueType ) {1449 case Type ::I32:1448 switch (valueType.kind) { 1449 case TypeKind::I32: 1450 1450 result = constant(Int32, 0); 1451 1451 break; 1452 case Type ::I64:1452 case TypeKind::I64: 1453 1453 result = constant(Int64, 0); 1454 1454 break; … … 1467 1467 pointer = fixupPointerPlusOffsetForAtomicOps(op, pointer, uoffset); 1468 1468 1469 if (valueType == Type::I64&& accessWidth(op) != B3::Width64)1469 if (valueType.isI64() && accessWidth(op) != B3::Width64) 1470 1470 value = m_currentBlock->appendNew<B3::Value>(m_proc, B3::Trunc, Origin(), value); 1471 1471 m_currentBlock->appendNew<AtomicValue>(m_proc, memoryKind(AtomicXchg), origin(), accessWidth(op), value, pointer); … … 1554 1554 } 1555 1555 1556 if (valueType == Type::I64&& accessWidth(op) != B3::Width64)1556 if (valueType.isI64() && accessWidth(op) != B3::Width64) 1557 1557 value = m_currentBlock->appendNew<B3::Value>(m_proc, B3::Trunc, Origin(), value); 1558 1558 … … 1572 1572 }); 1573 1573 1574 switch (valueType ) {1575 case Type ::I32:1574 switch (valueType.kind) { 1575 case TypeKind::I32: 1576 1576 result = constant(Int32, 0); 1577 1577 break; 1578 case Type ::I64:1578 case TypeKind::I64: 1579 1579 result = constant(Int64, 0); 1580 1580 break; … … 1599 1599 1600 1600 Value* maximum = nullptr; 1601 switch (valueType ) {1602 case Type ::I64: {1601 switch (valueType.kind) { 1602 case TypeKind::I64: { 1603 1603 switch (accessWidth) { 1604 1604 case B3::Width8: … … 1616 1616 break; 1617 1617 } 1618 case Type ::I32:1618 case TypeKind::I32: 1619 1619 switch (accessWidth) { 1620 1620 case B3::Width8: … … 1647 1647 auto truncatedExpected = expected; 1648 1648 auto truncatedValue = value; 1649 if (valueType == Type::I64) {1649 if (valueType.isI64()) { 1650 1650 truncatedExpected = m_currentBlock->appendNew<B3::Value>(m_proc, B3::Trunc, Origin(), expected); 1651 1651 truncatedValue = m_currentBlock->appendNew<B3::Value>(m_proc, B3::Trunc, Origin(), value); … … 1697 1697 }); 1698 1698 1699 switch (valueType ) {1700 case Type ::I32:1699 switch (valueType.kind) { 1700 case TypeKind::I32: 1701 1701 result = constant(Int32, 0); 1702 1702 break; 1703 case Type ::I64:1703 case TypeKind::I64: 1704 1704 result = constant(Int64, 0); 1705 1705 break; -
trunk/Source/JavaScriptCore/wasm/WasmCallingConvention.h
r271500 r273813 103 103 { 104 104 ASSERT(isValueType(valueType)); 105 switch (valueType ) {106 case I32:107 case I64:108 case Funcref:109 case Externref:105 switch (valueType.kind) { 106 case TypeKind::I32: 107 case TypeKind::I64: 108 case TypeKind::Funcref: 109 case TypeKind::Externref: 110 110 return marshallLocationImpl(role, gprArgs, gpArgumentCount, stackOffset); 111 case F32:112 case F64:111 case TypeKind::F32: 112 case TypeKind::F64: 113 113 return marshallLocationImpl(role, fprArgs, fpArgumentCount, stackOffset); 114 114 default: … … 131 131 Vector<ArgumentLocation> params(signature.argumentCount()); 132 132 for (size_t i = 0; i < signature.argumentCount(); ++i) { 133 argumentsIncludeI64 |= signature.argument(i) == I64;133 argumentsIncludeI64 |= signature.argument(i).isI64(); 134 134 params[i] = marshallLocation(role, signature.argument(i), gpArgumentCount, fpArgumentCount, argStackOffset); 135 135 } … … 142 142 Vector<ArgumentLocation, 1> results(signature.returnCount()); 143 143 for (size_t i = 0; i < signature.returnCount(); ++i) { 144 resultsIncludeI64 |= signature.returnType(i) == I64;144 resultsIncludeI64 |= signature.returnType(i).isI64(); 145 145 results[i] = marshallLocation(role, signature.returnType(i), gpArgumentCount, fpArgumentCount, resultStackOffset); 146 146 } … … 191 191 { 192 192 ASSERT(isValueType(valueType)); 193 switch (valueType ) {194 case I32:195 case I64:196 case Funcref:197 case Externref:193 switch (valueType.kind) { 194 case TypeKind::I32: 195 case TypeKind::I64: 196 case TypeKind::Funcref: 197 case TypeKind::Externref: 198 198 return marshallLocationImpl(role, gprArgs, gpArgumentCount, stackOffset); 199 case F32:200 case F64:199 case TypeKind::F32: 200 case TypeKind::F64: 201 201 return marshallLocationImpl(role, fprArgs, fpArgumentCount, stackOffset); 202 202 default: -
trunk/Source/JavaScriptCore/wasm/WasmFormat.h
r271775 r273813 62 62 inline bool isValueType(Type type) 63 63 { 64 switch (type ) {65 case I32:66 case I64:67 case F32:68 case F64:64 switch (type.kind) { 65 case TypeKind::I32: 66 case TypeKind::I64: 67 case TypeKind::F32: 68 case TypeKind::F64: 69 69 return true; 70 case Externref:71 case Funcref:70 case TypeKind::Externref: 71 case TypeKind::Funcref: 72 72 return Options::useWebAssemblyReferences(); 73 73 default: … … 79 79 inline bool isRefType(Type type) 80 80 { 81 return type == Externref || type == Funcref;81 return type.isFuncref() || type.isExternref(); 82 82 } 83 83 … … 296 296 Optional<uint32_t> maximum() const { return m_maximum; } 297 297 TableElementType type() const { return m_type; } 298 Wasm::Type wasmType() const { return m_type == TableElementType::Funcref ? Type::Funcref : Type::Externref; }298 Type wasmType() const { return m_type == TableElementType::Funcref ? Types::Funcref : Types::Externref; } 299 299 300 300 private: -
trunk/Source/JavaScriptCore/wasm/WasmFunctionCodeBlock.h
r255687 r273813 32 32 #include "MacroAssemblerCodeRef.h" 33 33 #include "WasmLLIntTierUpCounter.h" 34 #include "WasmOps.h" 34 35 #include <wtf/HashMap.h> 35 36 #include <wtf/Vector.h> … … 47 48 class Signature; 48 49 struct GeneratorTraits; 49 enum Type : int8_t;50 50 51 51 // FIXME: Consider merging this with LLIntCallee -
trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h
r272933 r273813 62 62 class TypedExpression { 63 63 public: 64 TypedExpression() = default; 64 TypedExpression() 65 : m_type(Types::Void) 66 { 67 } 65 68 66 69 TypedExpression(Type type, ExpressionType value) … … 333 336 WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "load pointer"); 334 337 335 WASM_VALIDATOR_FAIL_IF( pointer.type() != I32, m_currentOpcode, " pointer type mismatch");338 WASM_VALIDATOR_FAIL_IF(!pointer.type().isI32(), m_currentOpcode, " pointer type mismatch"); 336 339 337 340 ExpressionType result; … … 356 359 WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "store pointer"); 357 360 358 WASM_VALIDATOR_FAIL_IF( pointer.type() != I32, m_currentOpcode, " pointer type mismatch");361 WASM_VALIDATOR_FAIL_IF(!pointer.type().isI32(), m_currentOpcode, " pointer type mismatch"); 359 362 WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, m_currentOpcode, " value type mismatch"); 360 363 … … 390 393 WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "load pointer"); 391 394 392 WASM_VALIDATOR_FAIL_IF( pointer.type() != I32, static_cast<unsigned>(op), " pointer type mismatch");395 WASM_VALIDATOR_FAIL_IF(!pointer.type().isI32(), static_cast<unsigned>(op), " pointer type mismatch"); 393 396 394 397 ExpressionType result; … … 413 416 WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "store pointer"); 414 417 415 WASM_VALIDATOR_FAIL_IF( pointer.type() != I32, m_currentOpcode, " pointer type mismatch");418 WASM_VALIDATOR_FAIL_IF(!pointer.type().isI32(), m_currentOpcode, " pointer type mismatch"); 416 419 WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, m_currentOpcode, " value type mismatch"); 417 420 … … 435 438 WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "pointer"); 436 439 437 WASM_VALIDATOR_FAIL_IF( pointer.type() != I32, static_cast<unsigned>(op), " pointer type mismatch");440 WASM_VALIDATOR_FAIL_IF(!pointer.type().isI32(), static_cast<unsigned>(op), " pointer type mismatch"); 438 441 WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, static_cast<unsigned>(op), " value type mismatch"); 439 442 … … 461 464 WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "pointer"); 462 465 463 WASM_VALIDATOR_FAIL_IF( pointer.type() != I32, static_cast<unsigned>(op), " pointer type mismatch");466 WASM_VALIDATOR_FAIL_IF(!pointer.type().isI32(), static_cast<unsigned>(op), " pointer type mismatch"); 464 467 WASM_VALIDATOR_FAIL_IF(expected.type() != memoryType, static_cast<unsigned>(op), " expected type mismatch"); 465 468 WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, static_cast<unsigned>(op), " value type mismatch"); … … 488 491 WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "pointer"); 489 492 490 WASM_VALIDATOR_FAIL_IF( pointer.type() != I32, static_cast<unsigned>(op), " pointer type mismatch");493 WASM_VALIDATOR_FAIL_IF(!pointer.type().isI32(), static_cast<unsigned>(op), " pointer type mismatch"); 491 494 WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, static_cast<unsigned>(op), " value type mismatch"); 492 WASM_VALIDATOR_FAIL_IF( timeout.type() != I64, static_cast<unsigned>(op), " timeout type mismatch");495 WASM_VALIDATOR_FAIL_IF(!timeout.type().isI64(), static_cast<unsigned>(op), " timeout type mismatch"); 493 496 494 497 ExpressionType result; 495 498 WASM_TRY_ADD_TO_CONTEXT(atomicWait(op, pointer, value, timeout, result, offset)); 496 m_expressionStack.constructAndAppend( I32, result);499 m_expressionStack.constructAndAppend(Types::I32, result); 497 500 return { }; 498 501 } … … 513 516 WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "pointer"); 514 517 515 WASM_VALIDATOR_FAIL_IF( pointer.type() != I32, static_cast<unsigned>(op), " pointer type mismatch");516 WASM_VALIDATOR_FAIL_IF( count.type() != I32, static_cast<unsigned>(op), " count type mismatch"); // The spec's definition is saying i64, but all implementations (including tests) are using i32. So looks like the spec is wrong.518 WASM_VALIDATOR_FAIL_IF(!pointer.type().isI32(), static_cast<unsigned>(op), " pointer type mismatch"); 519 WASM_VALIDATOR_FAIL_IF(!count.type().isI32(), static_cast<unsigned>(op), " count type mismatch"); // The spec's definition is saying i64, but all implementations (including tests) are using i32. So looks like the spec is wrong. 517 520 518 521 ExpressionType result; 519 522 WASM_TRY_ADD_TO_CONTEXT(atomicNotify(op, pointer, count, result, offset)); 520 m_expressionStack.constructAndAppend( I32, result);523 m_expressionStack.constructAndAppend(Types::I32, result); 521 524 return { }; 522 525 } … … 697 700 unsigned offset = m_expressionStack.size() - target.branchTargetArity(); 698 701 for (unsigned i = 0; i < target.branchTargetArity(); ++i) 699 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);702 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().kind, " but branch target expects a value of ", target.branchTargetType(i).kind, " at index ", i); 700 703 701 704 return { }; … … 707 710 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"); 708 711 for (unsigned i = 0; i < controlData.signature()->returnCount(); ++i) 709 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));712 WASM_VALIDATOR_FAIL_IF(m_expressionStack[i].type() != controlData.signature()->returnType(i), "control flow returns with unexpected type. ", m_expressionStack[i].type().kind, " is not a ", controlData.signature()->returnType(i).kind); 710 713 711 714 return { }; … … 716 719 { 717 720 switch (m_currentOpcode) { 718 #define CREATE_CASE(name, id, b3op, inc, lhsType, rhsType, returnType) case OpType::name: return binaryCase<OpType::name>( returnType, lhsType,rhsType);721 #define CREATE_CASE(name, id, b3op, inc, lhsType, rhsType, returnType) case OpType::name: return binaryCase<OpType::name>(Types::returnType, Types::lhsType, Types::rhsType); 719 722 FOR_EACH_WASM_BINARY_OP(CREATE_CASE) 720 723 #undef CREATE_CASE 721 724 722 #define CREATE_CASE(name, id, b3op, inc, operandType, returnType) case OpType::name: return unaryCase<OpType::name>( returnType,operandType);725 #define CREATE_CASE(name, id, b3op, inc, operandType, returnType) case OpType::name: return unaryCase<OpType::name>(Types::returnType, Types::operandType); 723 726 FOR_EACH_WASM_UNARY_OP(CREATE_CASE) 724 727 #undef CREATE_CASE … … 736 739 WASM_PARSER_FAIL_IF(isRefType(nonZero.type()) || isRefType(nonZero.type()), "can't use ref-types with unannotated select"); 737 740 738 WASM_VALIDATOR_FAIL_IF( condition.type() != I32, "select condition must be i32, got ", condition.type());739 WASM_VALIDATOR_FAIL_IF(nonZero.type() != zero.type(), "select result types must match, got ", nonZero.type() , " and ", zero.type());741 WASM_VALIDATOR_FAIL_IF(!condition.type().isI32(), "select condition must be i32, got ", condition.type().kind); 742 WASM_VALIDATOR_FAIL_IF(nonZero.type() != zero.type(), "select result types must match, got ", nonZero.type().kind, " and ", zero.type().kind); 740 743 741 744 ExpressionType result; … … 760 763 WASM_TRY_POP_EXPRESSION_STACK_INTO(nonZero, "select non-zero"); 761 764 762 WASM_VALIDATOR_FAIL_IF( condition.type() != I32, "select condition must be i32, got ", condition.type());763 WASM_VALIDATOR_FAIL_IF(nonZero.type() != immediates.targetType, "select result types must match, got ", nonZero.type() , " and ", immediates.targetType);764 WASM_VALIDATOR_FAIL_IF(zero.type() != immediates.targetType, "select result types must match, got ", zero.type() , " and ", immediates.targetType);765 WASM_VALIDATOR_FAIL_IF(!condition.type().isI32(), "select condition must be i32, got ", condition.type().kind); 766 WASM_VALIDATOR_FAIL_IF(nonZero.type() != immediates.targetType, "select result types must match, got ", nonZero.type().kind, " and ", immediates.targetType.kind); 767 WASM_VALIDATOR_FAIL_IF(zero.type() != immediates.targetType, "select result types must match, got ", zero.type().kind, " and ", immediates.targetType.kind); 765 768 766 769 ExpressionType result; … … 771 774 } 772 775 773 #define CREATE_CASE(name, id, b3op, inc, memoryType) case OpType::name: return load( memoryType);776 #define CREATE_CASE(name, id, b3op, inc, memoryType) case OpType::name: return load(Types::memoryType); 774 777 FOR_EACH_WASM_MEMORY_LOAD_OP(CREATE_CASE) 775 778 #undef CREATE_CASE 776 779 777 #define CREATE_CASE(name, id, b3op, inc, memoryType) case OpType::name: return store( memoryType);780 #define CREATE_CASE(name, id, b3op, inc, memoryType) case OpType::name: return store(Types::memoryType); 778 781 FOR_EACH_WASM_MEMORY_STORE_OP(CREATE_CASE) 779 782 #undef CREATE_CASE … … 782 785 uint32_t constant; 783 786 WASM_PARSER_FAIL_IF(!parseUInt32(constant), "can't parse 32-bit floating-point constant"); 784 m_expressionStack.constructAndAppend( F32, m_context.addConstant(F32, constant));787 m_expressionStack.constructAndAppend(Types::F32, m_context.addConstant(Types::F32, constant)); 785 788 return { }; 786 789 } … … 789 792 int32_t constant; 790 793 WASM_PARSER_FAIL_IF(!parseVarInt32(constant), "can't parse 32-bit constant"); 791 m_expressionStack.constructAndAppend( I32, m_context.addConstant(I32, constant));794 m_expressionStack.constructAndAppend(Types::I32, m_context.addConstant(Types::I32, constant)); 792 795 return { }; 793 796 } … … 796 799 uint64_t constant; 797 800 WASM_PARSER_FAIL_IF(!parseUInt64(constant), "can't parse 64-bit floating-point constant"); 798 m_expressionStack.constructAndAppend( F64, m_context.addConstant(F64, constant));801 m_expressionStack.constructAndAppend(Types::F64, m_context.addConstant(Types::F64, constant)); 799 802 return { }; 800 803 } … … 803 806 int64_t constant; 804 807 WASM_PARSER_FAIL_IF(!parseVarInt64(constant), "can't parse 64-bit constant"); 805 m_expressionStack.constructAndAppend( I64, m_context.addConstant(I64, constant));808 m_expressionStack.constructAndAppend(Types::I64, m_context.addConstant(Types::I64, constant)); 806 809 return { }; 807 810 } … … 815 818 TypedExpression index; 816 819 WASM_TRY_POP_EXPRESSION_STACK_INTO(index, "table.get"); 817 WASM_VALIDATOR_FAIL_IF( I32 != index.type(), "table.get index to type ", index.type(), " expected ",I32);820 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != index.type().kind, "table.get index to type ", index.type().kind, " expected ", TypeKind::I32); 818 821 819 822 ExpressionType result; … … 832 835 WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "table.set"); 833 836 WASM_TRY_POP_EXPRESSION_STACK_INTO(index, "table.set"); 834 WASM_VALIDATOR_FAIL_IF( I32 != index.type(), "table.set index to type ", index.type(), " expected ",I32);837 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != index.type().kind, "table.set index to type ", index.type().kind, " expected ", TypeKind::I32); 835 838 Type type = m_info.tables[tableIndex].wasmType(); 836 WASM_VALIDATOR_FAIL_IF(value.type() != type, "table.set value to type ", value.type() , " expected ", type);839 WASM_VALIDATOR_FAIL_IF(value.type() != type, "table.set value to type ", value.type().kind, " expected ", type.kind); 837 840 RELEASE_ASSERT(m_info.tables[tableIndex].type() == TableElementType::Externref || m_info.tables[tableIndex].type() == TableElementType::Funcref); 838 841 WASM_TRY_ADD_TO_CONTEXT(addTableSet(tableIndex, index, value)); … … 859 862 WASM_TRY_POP_EXPRESSION_STACK_INTO(dstOffset, "table.init"); 860 863 861 WASM_VALIDATOR_FAIL_IF( I32 != dstOffset.type(), "table.init dst_offset to type ", dstOffset.type(), " expected ",I32);862 WASM_VALIDATOR_FAIL_IF( I32 != srcOffset.type(), "table.init src_offset to type ", srcOffset.type(), " expected ",I32);863 WASM_VALIDATOR_FAIL_IF( I32 != lenght.type(), "table.init length to type ", lenght.type(), " expected ",I32);864 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != dstOffset.type().kind, "table.init dst_offset to type ", dstOffset.type().kind, " expected ", TypeKind::I32); 865 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != srcOffset.type().kind, "table.init src_offset to type ", srcOffset.type().kind, " expected ", TypeKind::I32); 866 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != lenght.type().kind, "table.init length to type ", lenght.type().kind, " expected ", TypeKind::I32); 864 867 865 868 WASM_TRY_ADD_TO_CONTEXT(addTableInit(immediates.elementIndex, immediates.tableIndex, dstOffset, srcOffset, lenght)); … … 883 886 ExpressionType result; 884 887 WASM_TRY_ADD_TO_CONTEXT(addTableSize(tableIndex, result)); 885 m_expressionStack.constructAndAppend( I32, result);888 m_expressionStack.constructAndAppend(Types::I32, result); 886 889 break; 887 890 } … … 897 900 WASM_TRY_POP_EXPRESSION_STACK_INTO(fill, "table.grow"); 898 901 899 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());900 WASM_VALIDATOR_FAIL_IF( I32 != delta.type(), "table.grow expects an i32 delta value, got ", delta.type());902 WASM_VALIDATOR_FAIL_IF(fill.type() != m_info.tables[tableIndex].wasmType(), "table.grow expects fill value of type ", m_info.tables[tableIndex].wasmType().kind, " got ", fill.type().kind); 903 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != delta.type().kind, "table.grow expects an i32 delta value, got ", delta.type().kind); 901 904 902 905 ExpressionType result; 903 906 WASM_TRY_ADD_TO_CONTEXT(addTableGrow(tableIndex, fill, delta, result)); 904 m_expressionStack.constructAndAppend( I32, result);907 m_expressionStack.constructAndAppend(Types::I32, result); 905 908 break; 906 909 } … … 916 919 WASM_TRY_POP_EXPRESSION_STACK_INTO(offset, "table.fill"); 917 920 918 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());919 WASM_VALIDATOR_FAIL_IF( I32 != offset.type(), "table.fill expects an i32 offset value, got ", offset.type());920 WASM_VALIDATOR_FAIL_IF( I32 != count.type(), "table.fill expects an i32 count value, got ", count.type());921 WASM_VALIDATOR_FAIL_IF(fill.type() != m_info.tables[tableIndex].wasmType(), "table.fill expects fill value of type ", m_info.tables[tableIndex].wasmType().kind, " got ", fill.type().kind); 922 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != offset.type().kind, "table.fill expects an i32 offset value, got ", offset.type().kind); 923 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != count.type().kind, "table.fill expects an i32 count value, got ", count.type().kind); 921 924 922 925 WASM_TRY_ADD_TO_CONTEXT(addTableFill(tableIndex, offset, fill, count)); … … 931 934 const auto srcType = m_info.table(immediates.srcTableIndex).wasmType(); 932 935 const auto dstType = m_info.table(immediates.dstTableIndex).wasmType(); 933 WASM_VALIDATOR_FAIL_IF(srcType != dstType, "type mismatch at table.copy. got ", srcType , " and ", dstType);936 WASM_VALIDATOR_FAIL_IF(srcType != dstType, "type mismatch at table.copy. got ", srcType.kind, " and ", dstType.kind); 934 937 935 938 TypedExpression dstOffset; … … 940 943 WASM_TRY_POP_EXPRESSION_STACK_INTO(dstOffset, "table.copy"); 941 944 942 WASM_VALIDATOR_FAIL_IF( I32 != dstOffset.type(), "table.copy dst_offset to type ", dstOffset.type(), " expected ",I32);943 WASM_VALIDATOR_FAIL_IF( I32 != srcOffset.type(), "table.copy src_offset to type ", srcOffset.type(), " expected ",I32);944 WASM_VALIDATOR_FAIL_IF( I32 != length.type(), "table.copy length to type ", length.type(), " expected ",I32);945 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != dstOffset.type().kind, "table.copy dst_offset to type ", dstOffset.type().kind, " expected ", TypeKind::I32); 946 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != srcOffset.type().kind, "table.copy src_offset to type ", srcOffset.type().kind, " expected ", TypeKind::I32); 947 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != length.type().kind, "table.copy length to type ", length.type().kind, " expected ", TypeKind::I32); 945 948 946 949 WASM_TRY_ADD_TO_CONTEXT(addTableCopy(immediates.dstTableIndex, immediates.srcTableIndex, dstOffset, srcOffset, length)); … … 962 965 WASM_TRY_POP_EXPRESSION_STACK_INTO(dstAddress, "memory.fill"); 963 966 964 WASM_VALIDATOR_FAIL_IF( I32 != dstAddress.type(), "memory.fill dstAddress to type ", dstAddress.type(), " expected ",I32);965 WASM_VALIDATOR_FAIL_IF( I32 != targetValue.type(), "memory.fill targetValue to type ", targetValue.type(), " expected ",I32);966 WASM_VALIDATOR_FAIL_IF( I32 != count.type(), "memory.fill size to type ", count.type(), " expected ",I32);967 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != dstAddress.type().kind, "memory.fill dstAddress to type ", dstAddress.type().kind, " expected ", TypeKind::I32); 968 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != targetValue.type().kind, "memory.fill targetValue to type ", targetValue.type().kind, " expected ", TypeKind::I32); 969 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != count.type().kind, "memory.fill size to type ", count.type().kind, " expected ", TypeKind::I32); 967 970 968 971 WASM_TRY_ADD_TO_CONTEXT(addMemoryFill(dstAddress, targetValue, count)); … … 984 987 WASM_TRY_POP_EXPRESSION_STACK_INTO(dstAddress, "memory.copy"); 985 988 986 WASM_VALIDATOR_FAIL_IF( I32 != dstAddress.type(), "memory.copy dstAddress to type ", dstAddress.type(), " expected ",I32);987 WASM_VALIDATOR_FAIL_IF( I32 != srcAddress.type(), "memory.copy targetValue to type ", srcAddress.type(), " expected ",I32);988 WASM_VALIDATOR_FAIL_IF( I32 != count.type(), "memory.copy size to type ", count.type(), " expected ",I32);989 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != dstAddress.type().kind, "memory.copy dstAddress to type ", dstAddress.type().kind, " expected ", TypeKind::I32); 990 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != srcAddress.type().kind, "memory.copy targetValue to type ", srcAddress.type().kind, " expected ", TypeKind::I32); 991 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != count.type().kind, "memory.copy size to type ", count.type().kind, " expected ", TypeKind::I32); 989 992 990 993 WASM_TRY_ADD_TO_CONTEXT(addMemoryCopy(dstAddress, srcAddress, count)); … … 1004 1007 WASM_TRY_POP_EXPRESSION_STACK_INTO(dstAddress, "memory.init"); 1005 1008 1006 WASM_VALIDATOR_FAIL_IF( I32 != dstAddress.type(), "memory.init dst address to type ", dstAddress.type(), " expected ",I32);1007 WASM_VALIDATOR_FAIL_IF( I32 != srcAddress.type(), "memory.init src address to type ", srcAddress.type(), " expected ",I32);1008 WASM_VALIDATOR_FAIL_IF( I32 != length.type(), "memory.init length to type ", length.type(), " expected ",I32);1009 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != dstAddress.type().kind, "memory.init dst address to type ", dstAddress.type().kind, " expected ", TypeKind::I32); 1010 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != srcAddress.type().kind, "memory.init src address to type ", srcAddress.type().kind, " expected ", TypeKind::I32); 1011 WASM_VALIDATOR_FAIL_IF(TypeKind::I32 != length.type().kind, "memory.init length to type ", length.type().kind, " expected ", TypeKind::I32); 1009 1012 1010 1013 WASM_TRY_ADD_TO_CONTEXT(addMemoryInit(immediates.dataSegmentIndex, dstAddress, srcAddress, length)); … … 1021 1024 } 1022 1025 1023 #define CREATE_CASE(name, id, b3op, inc, operandType, returnType) case Ext1OpType::name: return truncSaturated(op, returnType,operandType);1026 #define CREATE_CASE(name, id, b3op, inc, operandType, returnType) case Ext1OpType::name: return truncSaturated(op, Types::returnType, Types::operandType); 1024 1027 FOR_EACH_WASM_TRUNC_SATURATED_OP(CREATE_CASE) 1025 1028 #undef CREATE_CASE … … 1039 1042 ExtAtomicOpType op = static_cast<ExtAtomicOpType>(extOp); 1040 1043 switch (op) { 1041 #define CREATE_CASE(name, id, b3op, inc, memoryType) case ExtAtomicOpType::name: return atomicLoad(op, memoryType);1044 #define CREATE_CASE(name, id, b3op, inc, memoryType) case ExtAtomicOpType::name: return atomicLoad(op, Types::memoryType); 1042 1045 FOR_EACH_WASM_EXT_ATOMIC_LOAD_OP(CREATE_CASE) 1043 1046 #undef CREATE_CASE 1044 #define CREATE_CASE(name, id, b3op, inc, memoryType) case ExtAtomicOpType::name: return atomicStore(op, memoryType);1047 #define CREATE_CASE(name, id, b3op, inc, memoryType) case ExtAtomicOpType::name: return atomicStore(op, Types::memoryType); 1045 1048 FOR_EACH_WASM_EXT_ATOMIC_STORE_OP(CREATE_CASE) 1046 1049 #undef CREATE_CASE 1047 #define CREATE_CASE(name, id, b3op, inc, memoryType) case ExtAtomicOpType::name: return atomicBinaryRMW(op, memoryType);1050 #define CREATE_CASE(name, id, b3op, inc, memoryType) case ExtAtomicOpType::name: return atomicBinaryRMW(op, Types::memoryType); 1048 1051 FOR_EACH_WASM_EXT_ATOMIC_BINARY_RMW_OP(CREATE_CASE) 1049 1052 #undef CREATE_CASE 1050 1053 case ExtAtomicOpType::MemoryAtomicWait64: 1051 return atomicWait(op, I64);1054 return atomicWait(op, Types::I64); 1052 1055 case ExtAtomicOpType::MemoryAtomicWait32: 1053 return atomicWait(op, I32);1056 return atomicWait(op, Types::I32); 1054 1057 case ExtAtomicOpType::MemoryAtomicNotify: 1055 1058 return atomicNotify(op); … … 1059 1062 case ExtAtomicOpType::I32AtomicRmw16CmpxchgU: 1060 1063 case ExtAtomicOpType::I32AtomicRmwCmpxchg: 1061 return atomicCompareExchange(op, I32);1064 return atomicCompareExchange(op, Types::I32); 1062 1065 case ExtAtomicOpType::I64AtomicRmw8CmpxchgU: 1063 1066 case ExtAtomicOpType::I64AtomicRmw16CmpxchgU: 1064 1067 case ExtAtomicOpType::I64AtomicRmw32CmpxchgU: 1065 1068 case ExtAtomicOpType::I64AtomicRmwCmpxchg: 1066 return atomicCompareExchange(op, I64);1069 return atomicCompareExchange(op, Types::I64); 1067 1070 default: 1068 1071 WASM_PARSER_FAIL_IF(true, "invalid extended atomic op ", extOp); … … 1084 1087 TypedExpression value; 1085 1088 WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "ref.is_null"); 1086 WASM_VALIDATOR_FAIL_IF(!isRefType(value.type()), "ref.is_null to type ", value.type() , " expected a reference type");1089 WASM_VALIDATOR_FAIL_IF(!isRefType(value.type()), "ref.is_null to type ", value.type().kind, " expected a reference type"); 1087 1090 ExpressionType result; 1088 1091 WASM_TRY_ADD_TO_CONTEXT(addRefIsNull(value, result)); 1089 m_expressionStack.constructAndAppend( I32, result);1092 m_expressionStack.constructAndAppend(Types::I32, result); 1090 1093 return { }; 1091 1094 } … … 1102 1105 ExpressionType result; 1103 1106 WASM_TRY_ADD_TO_CONTEXT(addRefFunc(index, result)); 1104 m_expressionStack.constructAndAppend( Funcref, result);1107 m_expressionStack.constructAndAppend(Types::Funcref, result); 1105 1108 return { }; 1106 1109 } … … 1123 1126 WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "set_local"); 1124 1127 WASM_VALIDATOR_FAIL_IF(index >= m_locals.size(), "attempt to set unknown local ", index, " last one is ", m_locals.size()); 1125 WASM_VALIDATOR_FAIL_IF(value.type() != m_locals[index], "set_local to type ", value.type() , " expected ", m_locals[index]);1128 WASM_VALIDATOR_FAIL_IF(value.type() != m_locals[index], "set_local to type ", value.type().kind, " expected ", m_locals[index].kind); 1126 1129 WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value)); 1127 1130 return { }; … … 1135 1138 TypedExpression value = m_expressionStack.last(); 1136 1139 WASM_VALIDATOR_FAIL_IF(index >= m_locals.size(), "attempt to tee unknown local ", index, " last one is ", m_locals.size()); 1137 WASM_VALIDATOR_FAIL_IF(value.type() != m_locals[index], "set_local to type ", value.type() , " expected ", m_locals[index]);1140 WASM_VALIDATOR_FAIL_IF(value.type() != m_locals[index], "set_local to type ", value.type().kind, " expected ", m_locals[index].kind); 1138 1141 WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value)); 1139 1142 return { }; … … 1163 1166 Type globalType = m_info.globals[index].type; 1164 1167 ASSERT(isValueType(globalType)); 1165 WASM_VALIDATOR_FAIL_IF(globalType != value.type(), "set_global ", index, " with type ", globalType , " with a variable of type ", value.type());1168 WASM_VALIDATOR_FAIL_IF(globalType != value.type(), "set_global ", index, " with type ", globalType.kind, " with a variable of type ", value.type().kind); 1166 1169 1167 1170 WASM_TRY_ADD_TO_CONTEXT(setGlobal(index, value)); … … 1182 1185 for (size_t i = firstArgumentIndex; i < m_expressionStack.size(); ++i) { 1183 1186 TypedExpression arg = m_expressionStack.at(i); 1184 WASM_VALIDATOR_FAIL_IF(arg.type() != calleeSignature.argument(i - firstArgumentIndex), "argument type mismatch in call, got ", arg.type() , ", expected ", calleeSignature.argument(i - firstArgumentIndex));1187 WASM_VALIDATOR_FAIL_IF(arg.type() != calleeSignature.argument(i - firstArgumentIndex), "argument type mismatch in call, got ", arg.type().kind, ", expected ", calleeSignature.argument(i - firstArgumentIndex).kind); 1185 1188 args.uncheckedAppend(arg); 1186 1189 m_context.didPopValueFromStack(); … … 1215 1218 WASM_PARSER_FAIL_IF(argumentCount > m_expressionStack.size(), "call_indirect expects ", argumentCount, " arguments, but the expression stack currently holds ", m_expressionStack.size(), " values"); 1216 1219 1217 WASM_VALIDATOR_FAIL_IF( m_expressionStack.last().type() != I32, "non-i32 call_indirect index ", m_expressionStack.last().type());1220 WASM_VALIDATOR_FAIL_IF(!m_expressionStack.last().type().isI32(), "non-i32 call_indirect index ", m_expressionStack.last().type().kind); 1218 1221 1219 1222 Vector<ExpressionType> args; … … 1223 1226 TypedExpression arg = m_expressionStack.at(i); 1224 1227 if (i < m_expressionStack.size() - 1) 1225 WASM_VALIDATOR_FAIL_IF(arg.type() != calleeSignature.argument(i - firstArgumentIndex), "argument type mismatch in call_indirect, got ", arg.type() , ", expected ", calleeSignature.argument(i - firstArgumentIndex));1228 WASM_VALIDATOR_FAIL_IF(arg.type() != calleeSignature.argument(i - firstArgumentIndex), "argument type mismatch in call_indirect, got ", arg.type().kind, ", expected ", calleeSignature.argument(i - firstArgumentIndex).kind); 1226 1229 args.uncheckedAppend(arg); 1227 1230 m_context.didPopValueFromStack(); … … 1237 1240 return { }; 1238 1241 } 1239 1240 1242 case Block: { 1241 1243 BlockSignature inlineSignature; … … 1246 1248 for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) { 1247 1249 Type type = m_expressionStack.at(offset + i).type(); 1248 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);1250 WASM_VALIDATOR_FAIL_IF(type != inlineSignature->argument(i), "Block expects the argument at index", i, " to be ", inlineSignature->argument(i).kind, " but argument has type ", type.kind); 1249 1251 } 1250 1252 … … 1269 1271 for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) { 1270 1272 Type type = m_expressionStack.at(offset + i).type(); 1271 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);1273 WASM_VALIDATOR_FAIL_IF(type != inlineSignature->argument(i), "Loop expects the argument at index", i, " to be ", inlineSignature->argument(i).kind, " but argument has type ", type.kind); 1272 1274 } 1273 1275 … … 1290 1292 WASM_TRY_POP_EXPRESSION_STACK_INTO(condition, "if condition"); 1291 1293 1292 WASM_VALIDATOR_FAIL_IF( condition.type() != I32, "if condition must be i32, got ", condition.type());1294 WASM_VALIDATOR_FAIL_IF(!condition.type().isI32(), "if condition must be i32, got ", condition.type().kind); 1293 1295 WASM_VALIDATOR_FAIL_IF(m_expressionStack.size() < inlineSignature->argumentCount(), "Too few arguments on stack for if block. If expects ", inlineSignature->argumentCount(), ", but only ", m_expressionStack.size(), " were present. If block has signature: ", inlineSignature->toString()); 1294 1296 unsigned offset = m_expressionStack.size() - inlineSignature->argumentCount(); 1295 1297 for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) 1296 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());1298 WASM_VALIDATOR_FAIL_IF(m_expressionStack[offset + i].type() != inlineSignature->argument(i), "Loop expects the argument at index", i, " to be ", inlineSignature->argument(i).kind, " but argument has type ", m_expressionStack[i].type().kind); 1297 1299 1298 1300 int64_t oldSize = m_expressionStack.size(); … … 1328 1330 if (m_currentOpcode == BrIf) { 1329 1331 WASM_TRY_POP_EXPRESSION_STACK_INTO(condition, "br / br_if condition"); 1330 WASM_VALIDATOR_FAIL_IF( condition.type() != I32, "conditional branch with non-i32 condition ", condition.type());1332 WASM_VALIDATOR_FAIL_IF(!condition.type().isI32(), "conditional branch with non-i32 condition ", condition.type().kind); 1331 1333 } else { 1332 1334 m_unreachableBlocks = 1; 1333 condition = TypedExpression { Void, Context::emptyExpression() };1335 condition = TypedExpression { Types::Void, Context::emptyExpression() }; 1334 1336 } 1335 1337 … … 1362 1364 1363 1365 WASM_TRY_POP_EXPRESSION_STACK_INTO(condition, "br_table condition"); 1364 WASM_VALIDATOR_FAIL_IF( condition.type() != I32, "br_table with non-i32 condition ", condition.type());1366 WASM_VALIDATOR_FAIL_IF(!condition.type().isI32(), "br_table with non-i32 condition ", condition.type().kind); 1365 1367 1366 1368 for (unsigned i = 0; i < targets.size(); ++i) { … … 1368 1370 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()); 1369 1371 for (unsigned type = 0; type < defaultTarget.branchTargetArity(); ++type) 1370 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());1372 WASM_VALIDATOR_FAIL_IF(defaultTarget.branchTargetType(type) != target->branchTargetType(type), "br_table target type mismatch at offset ", type, " expected: ", defaultTarget.branchTargetType(type).kind, " but saw: ", target->branchTargetType(type).kind, " when targeting block: ", target->signature()->toString()); 1371 1373 } 1372 1374 … … 1427 1429 TypedExpression delta; 1428 1430 WASM_TRY_POP_EXPRESSION_STACK_INTO(delta, "expect an i32 argument to grow_memory on the stack"); 1429 WASM_VALIDATOR_FAIL_IF( delta.type() != I32, "grow_memory with non-i32 delta argument has type: ", delta.type());1431 WASM_VALIDATOR_FAIL_IF(!delta.type().isI32(), "grow_memory with non-i32 delta argument has type: ", delta.type().kind); 1430 1432 1431 1433 ExpressionType result; 1432 1434 WASM_TRY_ADD_TO_CONTEXT(addGrowMemory(delta, result)); 1433 m_expressionStack.constructAndAppend( I32, result);1435 m_expressionStack.constructAndAppend(Types::I32, result); 1434 1436 1435 1437 return { }; … … 1445 1447 ExpressionType result; 1446 1448 WASM_TRY_ADD_TO_CONTEXT(addCurrentMemory(result)); 1447 m_expressionStack.constructAndAppend( I32, result);1449 m_expressionStack.constructAndAppend(Types::I32, result); 1448 1450 1449 1451 return { }; -
trunk/Source/JavaScriptCore/wasm/WasmGlobal.cpp
r273138 r273813 38 38 JSValue Global::get(JSGlobalObject* globalObject) const 39 39 { 40 switch (m_type ) {41 case Wasm::Type::I32:40 switch (m_type.kind) { 41 case TypeKind::I32: 42 42 return jsNumber(bitwise_cast<int32_t>(static_cast<uint32_t>(m_value.m_primitive))); 43 case Wasm::Type::I64:43 case TypeKind::I64: 44 44 return JSBigInt::makeHeapBigIntOrBigInt32(globalObject, static_cast<int64_t>(m_value.m_primitive)); 45 case Wasm::Type::F32:45 case TypeKind::F32: 46 46 return jsNumber(purifyNaN(static_cast<double>(bitwise_cast<float>(static_cast<uint32_t>(m_value.m_primitive))))); 47 case Wasm::Type::F64:47 case TypeKind::F64: 48 48 return jsNumber(purifyNaN(bitwise_cast<double>(m_value.m_primitive))); 49 case Wasm::Externref:50 case Wasm::Funcref:49 case TypeKind::Externref: 50 case TypeKind::Funcref: 51 51 return m_value.m_externref.get(); 52 52 default: … … 60 60 auto throwScope = DECLARE_THROW_SCOPE(vm); 61 61 ASSERT(m_mutability != Wasm::GlobalInformation::Immutable); 62 switch (m_type ) {63 case Wasm::Type::I32: {62 switch (m_type.kind) { 63 case TypeKind::I32: { 64 64 int32_t value = argument.toInt32(globalObject); 65 65 RETURN_IF_EXCEPTION(throwScope, void()); … … 67 67 break; 68 68 } 69 case Wasm::Type::I64: {69 case TypeKind::I64: { 70 70 int64_t value = argument.toBigInt64(globalObject); 71 71 RETURN_IF_EXCEPTION(throwScope, void()); … … 73 73 break; 74 74 } 75 case Wasm::Type::F32: {75 case TypeKind::F32: { 76 76 float value = argument.toFloat(globalObject); 77 77 RETURN_IF_EXCEPTION(throwScope, void()); … … 79 79 break; 80 80 } 81 case Wasm::Type::F64: {81 case TypeKind::F64: { 82 82 double value = argument.toNumber(globalObject); 83 83 RETURN_IF_EXCEPTION(throwScope, void()); … … 85 85 break; 86 86 } 87 case Wasm::Externref: {87 case TypeKind::Externref: { 88 88 RELEASE_ASSERT(m_owner); 89 89 m_value.m_externref.set(m_owner->vm(), m_owner, argument); 90 90 break; 91 91 } 92 case Wasm::Funcref: {92 case TypeKind::Funcref: { 93 93 RELEASE_ASSERT(m_owner); 94 94 if (!isWebAssemblyHostFunction(vm, argument) && !argument.isNull()) { … … 107 107 void Global::visitAggregateImpl(Visitor& visitor) 108 108 { 109 switch (m_type ) {110 case Wasm::Type::Externref:111 case Wasm::Type::Funcref: {109 switch (m_type.kind) { 110 case TypeKind::Externref: 111 case TypeKind::Funcref: { 112 112 RELEASE_ASSERT(m_owner); 113 113 visitor.append(m_value.m_externref); -
trunk/Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp
r272933 r273813 296 296 m_codeBlock->m_constants.append(JSValue::encode(jsNull())); 297 297 if (UNLIKELY(Options::dumpGeneratedWasmBytecodes())) 298 m_codeBlock->m_constantTypes.append(Type ::Externref);298 m_codeBlock->m_constantTypes.append(Types::Externref); 299 299 } 300 300 return m_jsNullConstant; … … 307 307 m_codeBlock->m_constants.append(0); 308 308 if (UNLIKELY(Options::dumpGeneratedWasmBytecodes())) 309 m_codeBlock->m_constantTypes.append(Type ::I32);309 m_codeBlock->m_constantTypes.append(Types::I32); 310 310 } 311 311 return m_zeroConstant; … … 535 535 536 536 auto allocateStackRegister = [&](Type type) { 537 switch (type ) {538 case Type ::I32:539 case Type ::I64:540 case Type ::Externref:541 case Type ::Funcref:537 switch (type.kind) { 538 case TypeKind::I32: 539 case TypeKind::I64: 540 case TypeKind::Externref: 541 case TypeKind::Funcref: 542 542 if (gprIndex < gprCount) 543 543 ++gprIndex; … … 545 545 ++stackCount; 546 546 break; 547 case Type ::F32:548 case Type ::F64:547 case TypeKind::F32: 548 case TypeKind::F64: 549 549 if (fprIndex < fprCount) 550 550 ++fprIndex; … … 552 552 ++stackCount; 553 553 break; 554 case Void:555 case Func:554 case TypeKind::Void: 555 case TypeKind::Func: 556 556 RELEASE_ASSERT_NOT_REACHED(); 557 557 } … … 590 590 fprIndex = gprIndex - gprCount; 591 591 for (uint32_t i = 0; i < signature.argumentCount(); i++) { 592 switch (signature.argument(i) ) {593 case Type ::I32:594 case Type ::I64:595 case Type ::Externref:596 case Type ::Funcref:592 switch (signature.argument(i).kind) { 593 case TypeKind::I32: 594 case TypeKind::I64: 595 case TypeKind::Externref: 596 case TypeKind::Funcref: 597 597 if (gprIndex > gprLimit) 598 598 arguments[i] = virtualRegisterForLocal(--gprIndex); … … 600 600 arguments[i] = virtualRegisterForLocal(--stackIndex); 601 601 break; 602 case Type ::F32:603 case Type ::F64:602 case TypeKind::F32: 603 case TypeKind::F64: 604 604 if (fprIndex > fprLimit) 605 605 arguments[i] = virtualRegisterForLocal(--fprIndex); … … 607 607 arguments[i] = virtualRegisterForLocal(--stackIndex); 608 608 break; 609 case Void:610 case Func:609 case TypeKind::Void: 610 case TypeKind::Func: 611 611 RELEASE_ASSERT_NOT_REACHED(); 612 612 } … … 617 617 fprIndex = gprIndex - gprCount; 618 618 for (uint32_t i = 0; i < signature.returnCount(); i++) { 619 switch (signature.returnType(i) ) {620 case Type ::I32:621 case Type ::I64:622 case Type ::Externref:623 case Type ::Funcref:619 switch (signature.returnType(i).kind) { 620 case TypeKind::I32: 621 case TypeKind::I64: 622 case TypeKind::Externref: 623 case TypeKind::Funcref: 624 624 if (gprIndex > gprLimit) 625 625 temporaryResults[i] = virtualRegisterForLocal(--gprIndex); … … 627 627 temporaryResults[i] = virtualRegisterForLocal(--stackIndex); 628 628 break; 629 case Type ::F32:630 case Type ::F64:629 case TypeKind::F32: 630 case TypeKind::F64: 631 631 if (fprIndex > fprLimit) 632 632 temporaryResults[i] = virtualRegisterForLocal(--fprIndex); … … 634 634 temporaryResults[i] = virtualRegisterForLocal(--stackIndex); 635 635 break; 636 case Void:637 case Func:636 case TypeKind::Void: 637 case TypeKind::Func: 638 638 RELEASE_ASSERT_NOT_REACHED(); 639 639 } … … 672 672 673 673 for (uint32_t i = 0; i < signature.returnCount(); i++) { 674 switch (signature.returnType(i) ) {675 case Type ::I32:676 case Type ::I64:677 case Type ::Externref:678 case Type ::Funcref:674 switch (signature.returnType(i).kind) { 675 case TypeKind::I32: 676 case TypeKind::I64: 677 case TypeKind::Externref: 678 case TypeKind::Funcref: 679 679 if (gprIndex < maxGPRIndex) 680 680 m_results.append(virtualRegisterForLocal(numberOfLLIntCalleeSaveRegisters + gprIndex++)); … … 682 682 m_results.append(virtualRegisterForArgumentIncludingThis(stackIndex++)); 683 683 break; 684 case Type ::F32:685 case Type ::F64:684 case TypeKind::F32: 685 case TypeKind::F64: 686 686 if (fprIndex < maxFPRIndex) 687 687 m_results.append(virtualRegisterForLocal(numberOfLLIntCalleeSaveRegisters + fprIndex++)); … … 689 689 m_results.append(virtualRegisterForArgumentIncludingThis(stackIndex++)); 690 690 break; 691 case Void:692 case Func:691 case TypeKind::Void: 692 case TypeKind::Func: 693 693 RELEASE_ASSERT_NOT_REACHED(); 694 694 } … … 726 726 727 727 for (uint32_t i = 0; i < signature.argumentCount(); i++) { 728 switch (signature.argument(i) ) {729 case Type ::I32:730 case Type ::I64:731 case Type ::Externref:732 case Type ::Funcref:728 switch (signature.argument(i).kind) { 729 case TypeKind::I32: 730 case TypeKind::I64: 731 case TypeKind::Externref: 732 case TypeKind::Funcref: 733 733 addArgument(i, gprIndex, maxGPRIndex); 734 734 break; 735 case Type ::F32:736 case Type ::F64:735 case TypeKind::F32: 736 case TypeKind::F64: 737 737 addArgument(i, fprIndex, maxFPRIndex); 738 738 break; 739 case Void:740 case Func:739 case TypeKind::Void: 740 case TypeKind::Func: 741 741 RELEASE_ASSERT_NOT_REACHED(); 742 742 } … … 753 753 754 754 m_codeBlock->m_numVars += count; 755 switch (type ) {756 case Type ::Externref:757 case Type ::Funcref:755 switch (type.kind) { 756 case TypeKind::Externref: 757 case TypeKind::Funcref: 758 758 while (count--) 759 759 m_unitializedLocals.append(push(NoConsistencyCheck)); -
trunk/Source/JavaScriptCore/wasm/WasmOperations.cpp
r271775 r273813 549 549 550 550 uint64_t unboxedValue = 0; 551 switch (signature->returnType(index) ) {552 case I32:551 switch (signature->returnType(index).kind) { 552 case TypeKind::I32: 553 553 unboxedValue = value.toInt32(globalObject); 554 554 break; 555 case I64:555 case TypeKind::I64: 556 556 unboxedValue = value.toBigInt64(globalObject); 557 557 break; 558 case F32:558 case TypeKind::F32: 559 559 unboxedValue = bitwise_cast<uint32_t>(value.toFloat(globalObject)); 560 560 break; 561 case F64:561 case TypeKind::F64: 562 562 unboxedValue = bitwise_cast<uint64_t>(value.toNumber(globalObject)); 563 563 break; 564 case Funcref:564 case TypeKind::Funcref: 565 565 if (!value.isCallable(vm)) { 566 566 throwTypeError(globalObject, scope, "Funcref value is not a function"_s); … … 568 568 } 569 569 FALLTHROUGH; 570 case Externref:570 case TypeKind::Externref: 571 571 unboxedValue = bitwise_cast<uint64_t>(value); 572 572 RELEASE_ASSERT(Options::useWebAssemblyReferences()); -
trunk/Source/JavaScriptCore/wasm/WasmParser.h
r271594 r273813 276 276 ALWAYS_INLINE typename Parser<SuccessType>::PartialResult Parser<SuccessType>::parseBlockSignature(const ModuleInformation& info, BlockSignature& result) 277 277 { 278 int8_t value;279 if (peekInt7( value) && isValidType(value)) {280 Type type = static_cast<Type>(value);281 WASM_PARSER_FAIL_IF(!(isValueType(type) || type == Void), "result type of block: ", makeString(type), " is not a value type or Void");278 int8_t typeKind; 279 if (peekInt7(typeKind) && isValidTypeKind(typeKind)) { 280 Type type = {static_cast<TypeKind>(typeKind), 0}; 281 WASM_PARSER_FAIL_IF(!(isValueType(type) || type.isVoid()), "result type of block: ", makeString(type.kind), " is not a value type or Void"); 282 282 result = m_signatureInformation.thunkFor(type); 283 283 m_offset++; … … 299 299 ALWAYS_INLINE bool Parser<SuccessType>::parseValueType(Type& result) 300 300 { 301 int8_t value; 302 if (!parseInt7(value)) 303 return false; 304 if (!isValidType(value) || !isValueType(static_cast<Type>(value))) 305 return false; 306 result = static_cast<Type>(value); 301 int8_t kind; 302 if (!parseInt7(kind)) 303 return false; 304 Type type = {static_cast<TypeKind>(kind), 0}; 305 if (!isValidTypeKind(kind) || !isValueType(type)) 306 return false; 307 result = type; 307 308 return true; 308 309 } -
trunk/Source/JavaScriptCore/wasm/WasmSectionParser.cpp
r271141 r273813 54 54 55 55 WASM_PARSER_FAIL_IF(!parseInt7(type), "can't get ", i, "th Type's type"); 56 WASM_PARSER_FAIL_IF(type != Func, i, "th Type is non-Func ", type);56 WASM_PARSER_FAIL_IF(type != static_cast<int8_t>(TypeKind::Func), i, "th Type is non-Func ", type); 57 57 WASM_PARSER_FAIL_IF(!parseVarUInt32(argumentCount), "can't get ", i, "th Type's argument count"); 58 58 WASM_PARSER_FAIL_IF(argumentCount > maxFunctionParams, i, "th argument count is too big ", argumentCount, " maximum ", maxFunctionParams); … … 207 207 int8_t type; 208 208 WASM_PARSER_FAIL_IF(!parseInt7(type), "can't parse Table type"); 209 WASM_PARSER_FAIL_IF(type != Wasm::Funcref && type != Wasm::Externref, "Table type should be funcref or anyref, got ", type);209 WASM_PARSER_FAIL_IF(type != static_cast<int8_t>(TypeKind::Funcref) && type != static_cast<int8_t>(TypeKind::Externref), "Table type should be funcref or anyref, got ", type); 210 210 211 211 uint32_t initial; … … 219 219 ASSERT(!maximum || *maximum >= initial); 220 220 221 TableElementType tableType = type == Wasm::Funcref? TableElementType::Funcref : TableElementType::Externref;221 TableElementType tableType = type == static_cast<int8_t>(TypeKind::Funcref) ? TableElementType::Funcref : TableElementType::Externref; 222 222 m_info->tables.append(TableInformation(initial, maximum, isImport, tableType)); 223 223 … … 305 305 else 306 306 global.initializationType = GlobalInformation::FromExpression; 307 WASM_PARSER_FAIL_IF(typeForInitOpcode != global.type, "Global init_expr opcode of type ", typeForInitOpcode , " doesn't match global's type ", global.type);307 WASM_PARSER_FAIL_IF(typeForInitOpcode != global.type, "Global init_expr opcode of type ", typeForInitOpcode.kind, " doesn't match global's type ", global.type.kind); 308 308 309 309 if (initOpcode == RefFunc) … … 486 486 Type refType; 487 487 WASM_PARSER_FAIL_IF(!parseRefType(refType), "can't parse reftype in elem section"); 488 WASM_PARSER_FAIL_IF( refType != Funcref, "reftype in element section should be funcref");488 WASM_PARSER_FAIL_IF(!refType.isFuncref(), "reftype in element section should be funcref"); 489 489 490 490 uint32_t indexCount; … … 510 510 Type refType; 511 511 WASM_PARSER_FAIL_IF(!parseRefType(refType), "can't parse reftype in elem section"); 512 WASM_PARSER_FAIL_IF( refType != Funcref, "reftype in element section should be funcref");512 WASM_PARSER_FAIL_IF(!refType.isFuncref(), "reftype in element section should be funcref"); 513 513 514 514 uint32_t indexCount; … … 528 528 Type refType; 529 529 WASM_PARSER_FAIL_IF(!parseRefType(refType), "can't parse reftype in elem section"); 530 WASM_PARSER_FAIL_IF( refType != Funcref, "reftype in element section should be funcref");530 WASM_PARSER_FAIL_IF(!refType.isFuncref(), "reftype in element section should be funcref"); 531 531 532 532 uint32_t indexCount; … … 564 564 WASM_PARSER_FAIL_IF(!parseVarInt32(constant), "can't get constant value for init_expr's i32.const"); 565 565 bitsOrImportNumber = static_cast<uint64_t>(constant); 566 resultType = I32;566 resultType = Types::I32; 567 567 break; 568 568 } … … 572 572 WASM_PARSER_FAIL_IF(!parseVarInt64(constant), "can't get constant value for init_expr's i64.const"); 573 573 bitsOrImportNumber = constant; 574 resultType = I64;574 resultType = Types::I64; 575 575 break; 576 576 } … … 580 580 WASM_PARSER_FAIL_IF(!parseUInt32(constant), "can't get constant value for init_expr's f32.const"); 581 581 bitsOrImportNumber = constant; 582 resultType = F32;582 resultType = Types::F32; 583 583 break; 584 584 } … … 588 588 WASM_PARSER_FAIL_IF(!parseUInt64(constant), "can't get constant value for init_expr's f64.const"); 589 589 bitsOrImportNumber = constant; 590 resultType = F64;590 resultType = Types::F64; 591 591 break; 592 592 } … … 618 618 WASM_PARSER_FAIL_IF(index >= m_info->functions.size(), "ref.func index", index, " exceeds the number of functions ", m_info->functions.size()); 619 619 620 resultType = Funcref;620 resultType = Types::Funcref; 621 621 bitsOrImportNumber = index; 622 622 break; … … 648 648 Type initExprType; 649 649 WASM_FAIL_IF_HELPER_FAILS(parseInitExpr(initOpcode, initExprBits, initExprType)); 650 WASM_PARSER_FAIL_IF( initExprType != I32, failMessage);650 WASM_PARSER_FAIL_IF(!initExprType.isI32(), failMessage); 651 651 initExpr = makeI32InitExpr(initOpcode, initExprBits); 652 652 … … 694 694 Type typeOfNull; 695 695 WASM_PARSER_FAIL_IF(!parseRefType(typeOfNull), "ref.null type must be a func type in elem section"); 696 WASM_PARSER_FAIL_IF( typeOfNull != Funcref, "ref.null extern is forbidden in element section's, ", elementNum, "th element's ", index, "th index");696 WASM_PARSER_FAIL_IF(!typeOfNull.isFuncref(), "ref.null extern is forbidden in element section's, ", elementNum, "th element's ", index, "th index"); 697 697 functionIndex = Element::nullFuncIndex; 698 698 } -
trunk/Source/JavaScriptCore/wasm/WasmSignature.cpp
r261441 r273813 53 53 CommaPrinter comma; 54 54 for (SignatureArgCount arg = 0; arg < argumentCount(); ++arg) 55 out.print(comma, makeString(argument(arg) ));55 out.print(comma, makeString(argument(arg).kind)); 56 56 out.print(")"); 57 57 } … … 61 61 out.print(" -> ["); 62 62 for (SignatureArgCount ret = 0; ret < returnCount(); ++ret) 63 out.print(comma, makeString(returnType(ret) ));63 out.print(comma, makeString(returnType(ret).kind)); 64 64 out.print("]"); 65 65 } … … 69 69 { 70 70 unsigned accumulator = 0xa1bcedd8u; 71 for (uint32_t i = 0; i < argumentCount; ++i) 72 accumulator = WTF::pairIntHash(accumulator, WTF::IntHash<uint8_t>::hash(static_cast<uint8_t>(argumentTypes[i]))); 73 for (uint32_t i = 0; i < returnCount; ++i) 74 accumulator = WTF::pairIntHash(accumulator, WTF::IntHash<uint8_t>::hash(static_cast<uint8_t>(returnTypes[i]))); 71 for (uint32_t i = 0; i < argumentCount; ++i) { 72 accumulator = WTF::pairIntHash(accumulator, WTF::IntHash<uint8_t>::hash(static_cast<uint8_t>(argumentTypes[i].kind))); 73 accumulator = WTF::pairIntHash(accumulator, WTF::IntHash<unsigned>::hash(argumentTypes[i].index)); 74 } 75 for (uint32_t i = 0; i < returnCount; ++i) { 76 accumulator = WTF::pairIntHash(accumulator, WTF::IntHash<uint8_t>::hash(static_cast<uint8_t>(returnTypes[i].kind))); 77 accumulator = WTF::pairIntHash(accumulator, WTF::IntHash<unsigned>::hash(returnTypes[i].index)); 78 } 75 79 return accumulator; 76 80 } … … 96 100 #define MAKE_THUNK_SIGNATURE(type, enc, str, val) \ 97 101 do { \ 98 if ( type != Void) {\102 if (TypeKind::type != TypeKind::Void) { \ 99 103 RefPtr<Signature> sig = Signature::tryCreate(1, 0); \ 100 104 sig->ref(); \ 101 sig->getReturnType(0) = type;\102 thunkSignatures[linearizeType( type)] = sig.get();\105 sig->getReturnType(0) = Types::type; \ 106 thunkSignatures[linearizeType(TypeKind::type)] = sig.get(); \ 103 107 m_signatureSet.add(SignatureHash { sig.releaseNonNull() }); \ 104 108 } \ … … 111 115 RefPtr<Signature> sig = Signature::tryCreate(0, 0); 112 116 sig->ref(); 113 thunkSignatures[linearizeType( Void)] = sig.get();117 thunkSignatures[linearizeType(TypeKind::Void)] = sig.get(); 114 118 m_signatureSet.add(SignatureHash { sig.releaseNonNull() }); 115 119 } -
trunk/Source/JavaScriptCore/wasm/WasmSignature.h
r273662 r273813 143 143 144 144 static RefPtr<Signature> signatureFor(const Vector<Type, 1>& returnTypes, const Vector<Type>& argumentTypes); 145 ALWAYS_INLINE const Signature* thunkFor(Type type) const { return thunkSignatures[linearizeType(type )]; }145 ALWAYS_INLINE const Signature* thunkFor(Type type) const { return thunkSignatures[linearizeType(type.kind)]; } 146 146 147 147 static const Signature& get(SignatureIndex); -
trunk/Source/JavaScriptCore/wasm/WasmTable.cpp
r273138 r273813 181 181 { 182 182 if (isExternrefTable()) 183 return Type ::Externref;183 return Types::Externref; 184 184 ASSERT(isFuncrefTable()); 185 return Type ::Funcref;185 return Types::Funcref; 186 186 } 187 187 -
trunk/Source/JavaScriptCore/wasm/generateWasmOpsHeader.py
r272933 r273813 208 208 """ + type_definitions + """ 209 209 #define CREATE_ENUM_VALUE(name, id, ...) name = id, 210 enum Type: int8_t {210 enum class TypeKind : int8_t { 211 211 FOR_EACH_WASM_TYPE(CREATE_ENUM_VALUE) 212 212 }; 213 213 #undef CREATE_ENUM_VALUE 214 215 struct Type { 216 TypeKind kind; 217 unsigned index; 218 219 bool operator==(const Type& other) const 220 { 221 return other.kind == kind && other.index == index; 222 } 223 224 bool operator!=(const Type& other) const 225 { 226 return !(other == *this); 227 } 228 229 #define CREATE_PREDICATE(name, ...) bool is ## name() const { return kind == TypeKind::name; } 230 FOR_EACH_WASM_TYPE(CREATE_PREDICATE) 231 #undef CREATE_PREDICATE 232 }; 233 234 namespace Types 235 { 236 #define CREATE_CONSTANT(name, id, ...) constexpr Type name = Type{TypeKind::name, 0u}; 237 FOR_EACH_WASM_TYPE(CREATE_CONSTANT) 238 #undef CREATE_CONSTANT 239 } // namespace Types 214 240 215 241 #define CREATE_CASE(name, id, ...) case id: return true; 216 242 template <typename Int> 217 inline bool isValidType (Int i)243 inline bool isValidTypeKind(Int i) 218 244 { 219 245 switch (i) { … … 227 253 228 254 #if ENABLE(WEBASSEMBLY_B3JIT) 229 #define CREATE_CASE(name, id, b3type, ...) case name: return b3type;255 #define CREATE_CASE(name, id, b3type, ...) case TypeKind::name: return b3type; 230 256 inline B3::Type toB3Type(Type type) 231 257 { 232 switch (type ) {258 switch (type.kind) { 233 259 FOR_EACH_WASM_TYPE(CREATE_CASE) 234 260 } … … 239 265 #endif 240 266 241 #define CREATE_CASE(name, ...) case name: return #name;242 inline const char* makeString(Type type)243 { 244 switch ( type) {267 #define CREATE_CASE(name, ...) case TypeKind::name: return #name; 268 inline const char* makeString(TypeKind kind) 269 { 270 switch (kind) { 245 271 FOR_EACH_WASM_TYPE(CREATE_CASE) 246 272 } … … 250 276 #undef CREATE_CASE 251 277 252 #define CREATE_CASE(name, id, b3type, inc, ...) case id: return inc;253 inline int linearizeType(Type type)254 { 255 switch ( type) {278 #define CREATE_CASE(name, id, b3type, inc, ...) case TypeKind::name: return inc; 279 inline int linearizeType(TypeKind kind) 280 { 281 switch (kind) { 256 282 FOR_EACH_WASM_TYPE(CREATE_CASE) 257 283 } … … 261 287 #undef CREATE_CASE 262 288 263 #define CREATE_CASE(name, id, b3type, inc, ...) case inc: return name;264 inline Type linearizedToType(int i)289 #define CREATE_CASE(name, id, b3type, inc, ...) case inc: return TypeKind::name; 290 inline TypeKind linearizedToType(int i) 265 291 { 266 292 switch (i) { … … 268 294 } 269 295 RELEASE_ASSERT_NOT_REACHED(); 270 return Void;296 return TypeKind::Void; 271 297 } 272 298 #undef CREATE_CASE … … 405 431 namespace WTF { 406 432 407 inline void printInternal(PrintStream& out, JSC::Wasm::Type type)408 { 409 out.print(JSC::Wasm::makeString( type));433 inline void printInternal(PrintStream& out, JSC::Wasm::TypeKind kind) 434 { 435 out.print(JSC::Wasm::makeString(kind)); 410 436 } 411 437 -
trunk/Source/JavaScriptCore/wasm/js/JSToWasm.cpp
r271500 r273813 41 41 void marshallJSResult(CCallHelpers& jit, const Signature& signature, const CallInformation& wasmFrameConvention, const RegisterAtOffsetList& savedResultRegisters) 42 42 { 43 auto boxWasmResult = [](CCallHelpers& jit, Wasm::Type type, Reg src, JSValueRegs dst) {44 switch (type ) {45 case Wasm::Void:43 auto boxWasmResult = [](CCallHelpers& jit, Type type, Reg src, JSValueRegs dst) { 44 switch (type.kind) { 45 case TypeKind::Void: 46 46 jit.moveTrustedValue(jsUndefined(), dst); 47 47 break; 48 case Wasm::Externref:49 case Wasm::Funcref:48 case TypeKind::Externref: 49 case TypeKind::Funcref: 50 50 jit.move(src.gpr(), dst.payloadGPR()); 51 51 break; 52 case Wasm::I32:52 case TypeKind::I32: 53 53 jit.zeroExtend32ToWord(src.gpr(), dst.payloadGPR()); 54 54 jit.boxInt32(dst.payloadGPR(), dst, DoNotHaveTagRegisters); 55 55 break; 56 case Wasm::F32:56 case TypeKind::F32: 57 57 jit.convertFloatToDouble(src.fpr(), src.fpr()); 58 58 FALLTHROUGH; 59 case Wasm::F64: {59 case TypeKind::F64: { 60 60 jit.moveTrustedValue(jsNumber(pureNaN()), dst); 61 61 auto isNaN = jit.branchIfNaN(src.fpr()); … … 73 73 jit.moveTrustedValue(jsUndefined(), JSValueRegs { GPRInfo::returnValueGPR }); 74 74 else if (signature.returnCount() == 1) { 75 if (signature.returnType(0) == Wasm::I64) {75 if (signature.returnType(0).isI64()) { 76 76 GPRReg inputGPR = wasmFrameConvention.results[0].reg().gpr(); 77 77 GPRReg wasmContextInstanceGPR = PinnedRegisterInfo::get().wasmContextInstancePointer; … … 95 95 Type type = signature.returnType(i); 96 96 97 hasI64 |= type == Wasm::I64;97 hasI64 |= type.isI64(); 98 98 if (loc.isReg()) { 99 if ( type != Wasm::I64) {99 if (!type.isI64()) { 100 100 boxWasmResult(jit, signature.returnType(i), loc.reg(), scratch); 101 101 jit.storeValue(scratch, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(loc.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes)); … … 103 103 jit.storeValue(JSValueRegs { loc.reg().gpr() }, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(loc.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes)); 104 104 } else { 105 if ( type != Wasm::I64) {105 if (!type.isI64()) { 106 106 auto location = CCallHelpers::Address(CCallHelpers::stackPointerRegister, loc.offsetFromSP()); 107 Reg tmp = type == F32 || type == F64? Reg(fprScratch) : Reg(scratch.gpr());107 Reg tmp = (type.isF32() || type.isF64()) ? Reg(fprScratch) : Reg(scratch.gpr()); 108 108 jit.load64ToReg(location, tmp); 109 109 boxWasmResult(jit, signature.returnType(i), tmp, scratch); … … 112 112 } 113 113 114 switch (type ) {115 case Wasm::I32:114 switch (type.kind) { 115 case TypeKind::I32: 116 116 indexingType = leastUpperBoundOfIndexingTypes(indexingType, ArrayWithInt32); 117 117 break; 118 case Wasm::F32:119 case Wasm::F64:118 case TypeKind::F32: 119 case TypeKind::F64: 120 120 indexingType = leastUpperBoundOfIndexingTypes(indexingType, ArrayWithDouble); 121 121 break; … … 132 132 ValueLocation loc = wasmFrameConvention.results[i]; 133 133 Type type = signature.returnType(i); 134 if ( type != Wasm::I64)134 if (!type.isI64()) 135 135 continue; 136 136 … … 239 239 CCallHelpers::Address jsParam(GPRInfo::callFrameRegister, jsFrameConvention.params[i].offsetFromFP()); 240 240 if (wasmFrameConvention.params[i].isStackArgument()) { 241 if (type == Wasm::I32 || type == Wasm::F32) {241 if (type.isI32() || type.isF32()) { 242 242 jit.load32(jsParam, scratchReg); 243 243 jit.store32(scratchReg, calleeFrame.withOffset(wasmFrameConvention.params[i].offsetFromSP())); … … 247 247 } 248 248 } else { 249 if (type == Wasm::I32 || type == Wasm::F32)249 if (type.isI32() || type.isF32()) 250 250 jit.load32ToReg(jsParam, wasmFrameConvention.params[i].reg()); 251 251 else -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h
r272071 r273813 139 139 { 140 140 ASSERT(Wasm::isRefType(type)); 141 if (type == Wasm::Type::Externref)141 if (type.isExternref()) 142 142 return jsUndefined(); 143 ASSERT(type == Wasm::Type::Funcref);143 ASSERT(type.isFuncref()); 144 144 return jsNull(); 145 145 } -
trunk/Source/JavaScriptCore/wasm/js/WasmToJS.cpp
r271168 r273813 102 102 for (unsigned argNum = 0; argNum < argCount; ++argNum) { 103 103 Type argType = signature.argument(argNum); 104 switch (argType ) {105 case Void:106 case Func:104 switch (argType.kind) { 105 case TypeKind::Void: 106 case TypeKind::Func: 107 107 RELEASE_ASSERT_NOT_REACHED(); // Handled above. 108 case Externref:109 case Funcref:110 case I32:111 case I64: {108 case TypeKind::Externref: 109 case TypeKind::Funcref: 110 case TypeKind::I32: 111 case TypeKind::I64: { 112 112 GPRReg gprReg; 113 113 if (marshalledGPRs < wasmCC.gprArgs.size()) … … 120 120 } 121 121 ++marshalledGPRs; 122 if (argType == I32) {122 if (argType.isI32()) { 123 123 jit.zeroExtend32ToWord(gprReg, gprReg); // Clear non-int32 and non-tag bits. 124 124 jit.boxInt32(gprReg, JSValueRegs(gprReg), DoNotHaveTagRegisters); … … 128 128 break; 129 129 } 130 case F32:131 case F64:130 case TypeKind::F32: 131 case TypeKind::F64: 132 132 // Skipped: handled below. 133 133 if (marshalledFPRs >= wasmCC.fprArgs.size()) … … 174 174 for (unsigned argNum = 0; argNum < argCount; ++argNum) { 175 175 Type argType = signature.argument(argNum); 176 switch (argType ) {177 case Void:178 case Func:176 switch (argType.kind) { 177 case TypeKind::Void: 178 case TypeKind::Func: 179 179 RELEASE_ASSERT_NOT_REACHED(); // Handled above. 180 case Externref:181 case Funcref:182 case I32:183 case I64: {180 case TypeKind::Externref: 181 case TypeKind::Funcref: 182 case TypeKind::I32: 183 case TypeKind::I64: { 184 184 // Skipped: handled above. 185 185 if (marshalledGPRs >= wasmCC.gprArgs.size()) … … 189 189 break; 190 190 } 191 case F32: {191 case TypeKind::F32: { 192 192 FPRReg fprReg; 193 193 if (marshalledFPRs < wasmCC.fprArgs.size()) … … 203 203 break; 204 204 } 205 case F64: {205 case TypeKind::F64: { 206 206 FPRReg fprReg; 207 207 if (marshalledFPRs < wasmCC.fprArgs.size()) … … 227 227 unsigned calleeFrameOffset = CallFrameSlot::firstArgument * static_cast<int>(sizeof(Register)); 228 228 for (unsigned argNum = 0; argNum < argCount; ++argNum) { 229 if (signature.argument(argNum) == I64) {229 if (signature.argument(argNum).isI64()) { 230 230 jit.loadWasmContextInstance(GPRInfo::argumentGPR0); 231 231 jit.load64(calleeFrame.withOffset(calleeFrameOffset), GPRInfo::argumentGPR1); … … 275 275 276 276 if (signature.returnCount() == 1) { 277 switch (signature.returnType(0) ) {278 case Void:279 case Func:277 switch (signature.returnType(0).kind) { 278 case TypeKind::Void: 279 case TypeKind::Func: 280 280 // For the JavaScript embedding, imports with these types in their signature return are a WebAssembly.Module validation error. 281 281 RELEASE_ASSERT_NOT_REACHED(); 282 282 break; 283 case I64: {283 case TypeKind::I64: { 284 284 // FIXME: Optimize I64 extraction from BigInt. 285 285 // https://bugs.webkit.org/show_bug.cgi?id=220053 … … 295 295 break; 296 296 } 297 case I32: {297 case TypeKind::I32: { 298 298 CCallHelpers::JumpList done; 299 299 CCallHelpers::JumpList slowPath; … … 318 318 break; 319 319 } 320 case Funcref:321 case Externref:320 case TypeKind::Funcref: 321 case TypeKind::Externref: 322 322 jit.move(GPRInfo::returnValueGPR, wasmCallInfo.results[0].gpr()); 323 323 break; 324 case F32: {324 case TypeKind::F32: { 325 325 CCallHelpers::JumpList done; 326 326 FPRReg dest = wasmCallInfo.results[0].fpr(); … … 353 353 break; 354 354 } 355 case F64: {355 case TypeKind::F64: { 356 356 CCallHelpers::JumpList done; 357 357 FPRReg dest = wasmCallInfo.results[0].fpr(); -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp
r273138 r273813 80 80 for (unsigned argIndex = 0; argIndex < signature.argumentCount(); ++argIndex) { 81 81 JSValue arg = callFrame->argument(argIndex); 82 switch (signature.argument(argIndex) ) {83 case Wasm:: I32:82 switch (signature.argument(argIndex).kind) { 83 case Wasm::TypeKind::I32: 84 84 arg = JSValue::decode(arg.toInt32(globalObject)); 85 85 break; 86 case Wasm:: Funcref: {86 case Wasm::TypeKind::Funcref: { 87 87 if (!isWebAssemblyHostFunction(vm, arg) && !arg.isNull()) 88 88 return JSValue::encode(throwException(globalObject, scope, createJSWebAssemblyRuntimeError(globalObject, vm, "Funcref must be an exported wasm function"))); 89 89 break; 90 90 } 91 case Wasm:: Externref:92 break; 93 case Wasm:: I64:91 case Wasm::TypeKind::Externref: 92 break; 93 case Wasm::TypeKind::I64: 94 94 arg = JSValue::decode(bitwise_cast<uint64_t>(arg.toBigInt64(globalObject))); 95 95 break; 96 case Wasm:: F32:96 case Wasm::TypeKind::F32: 97 97 arg = JSValue::decode(bitwise_cast<uint32_t>(arg.toFloat(globalObject))); 98 98 break; 99 case Wasm:: F64:99 case Wasm::TypeKind::F64: 100 100 arg = JSValue::decode(bitwise_cast<uint64_t>(arg.toNumber(globalObject))); 101 101 break; 102 case Wasm:: Void:103 case Wasm:: Func:102 case Wasm::TypeKind::Void: 103 case Wasm::TypeKind::Func: 104 104 RELEASE_ASSERT_NOT_REACHED(); 105 105 } … … 261 261 262 262 auto type = signature.argument(i); 263 switch (type ) {264 case Wasm:: I32: {263 switch (type.kind) { 264 case Wasm::TypeKind::I32: { 265 265 jit.load64(jsParam, scratchGPR); 266 266 slowPath.append(jit.branchIfNotInt32(scratchGPR)); … … 271 271 break; 272 272 } 273 case Wasm:: Funcref: {273 case Wasm::TypeKind::Funcref: { 274 274 // Ensure we have a WASM exported function. 275 275 jit.load64(jsParam, scratchGPR); … … 291 291 FALLTHROUGH; 292 292 } 293 case Wasm:: Externref: {293 case Wasm::TypeKind::Externref: { 294 294 if (isStack) { 295 295 jit.load64(jsParam, scratchGPR); … … 299 299 break; 300 300 } 301 case Wasm:: F32:302 case Wasm:: F64: {301 case Wasm::TypeKind::F32: 302 case Wasm::TypeKind::F64: { 303 303 if (!isStack) 304 304 scratchFPR = wasmCallInfo.params[i].fpr(); 305 305 auto moveToDestination = [&] () { 306 306 if (isStack) { 307 if (signature.argument(i) == Wasm::F32)307 if (signature.argument(i).isF32()) 308 308 jit.storeFloat(scratchFPR, calleeFrame.withOffset(wasmCallInfo.params[i].offsetFromSP())); 309 309 else … … 317 317 318 318 jit.unboxDouble(scratchGPR, scratchGPR, scratchFPR); 319 if (signature.argument(i) == Wasm::F32)319 if (signature.argument(i).isF32()) 320 320 jit.convertDoubleToFloat(scratchFPR, scratchFPR); 321 321 moveToDestination(); … … 323 323 324 324 isInt32.link(&jit); 325 if (signature.argument(i) == Wasm::F32) {325 if (signature.argument(i).isF32()) { 326 326 jit.convertInt32ToFloat(scratchGPR, scratchFPR); 327 327 moveToDestination(); -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp
r273661 r273813 88 88 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 89 89 if (valueString == "i32"_s) 90 type = Wasm::Type ::I32;90 type = Wasm::Types::I32; 91 91 else if (valueString == "i64"_s) 92 type = Wasm::Type ::I64;92 type = Wasm::Types::I64; 93 93 else if (valueString == "f32"_s) 94 type = Wasm::Type ::F32;94 type = Wasm::Types::F32; 95 95 else if (valueString == "f64"_s) 96 type = Wasm::Type ::F64;96 type = Wasm::Types::F64; 97 97 else if (Options::useWebAssemblyReferences() && (valueString == "anyfunc"_s || valueString == "funcref"_s)) 98 type = Wasm::Type ::Funcref;98 type = Wasm::Types::Funcref; 99 99 else if (Options::useWebAssemblyReferences() && valueString == "externref"_s) 100 type = Wasm::Type ::Externref;100 type = Wasm::Types::Externref; 101 101 else 102 102 return JSValue::encode(throwException(globalObject, throwScope, createTypeError(globalObject, "WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', 'f64', 'anyfunc', 'funcref', or 'externref'"_s))); … … 105 105 uint64_t initialValue = 0; 106 106 JSValue argument = callFrame->argument(1); 107 switch (type ) {108 case Wasm::Type ::I32: {107 switch (type.kind) { 108 case Wasm::TypeKind::I32: { 109 109 if (!argument.isUndefined()) { 110 110 int32_t value = argument.toInt32(globalObject); … … 114 114 break; 115 115 } 116 case Wasm::Type ::I64: {116 case Wasm::TypeKind::I64: { 117 117 if (!argument.isUndefined()) { 118 118 int64_t value = argument.toBigInt64(globalObject); … … 122 122 break; 123 123 } 124 case Wasm::Type ::F32: {124 case Wasm::TypeKind::F32: { 125 125 if (!argument.isUndefined()) { 126 126 float value = argument.toFloat(globalObject); … … 130 130 break; 131 131 } 132 case Wasm::Type ::F64: {132 case Wasm::TypeKind::F64: { 133 133 if (!argument.isUndefined()) { 134 134 double value = argument.toNumber(globalObject); … … 138 138 break; 139 139 } 140 case Wasm::Type ::Funcref: {140 case Wasm::TypeKind::Funcref: { 141 141 ASSERT(Options::useWebAssemblyReferences()); 142 142 if (argument.isUndefined()) … … 149 149 break; 150 150 } 151 case Wasm::Type ::Externref: {151 case Wasm::TypeKind::Externref: { 152 152 ASSERT(Options::useWebAssemblyReferences()); 153 153 if (argument.isUndefined()) -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp
r273225 r273813 247 247 if (globalValue->global()->mutability() != Wasm::GlobalInformation::Immutable) 248 248 return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "must be a same mutability"))); 249 switch (moduleInformation.globals[import.kindIndex].type ) {250 case Wasm:: Funcref:249 switch (moduleInformation.globals[import.kindIndex].type.kind) { 250 case Wasm::TypeKind::Funcref: 251 251 value = globalValue->global()->get(globalObject); 252 252 RETURN_IF_EXCEPTION(scope, void()); … … 255 255 m_instance->instance().setGlobal(import.kindIndex, value); 256 256 break; 257 case Wasm:: Externref:257 case Wasm::TypeKind::Externref: 258 258 value = globalValue->global()->get(globalObject); 259 259 RETURN_IF_EXCEPTION(scope, void()); 260 260 m_instance->instance().setGlobal(import.kindIndex, value); 261 261 break; 262 case Wasm:: I32:263 case Wasm:: I64:264 case Wasm:: F32:265 case Wasm:: F64:262 case Wasm::TypeKind::I32: 263 case Wasm::TypeKind::I64: 264 case Wasm::TypeKind::F32: 265 case Wasm::TypeKind::F64: 266 266 m_instance->instance().setGlobal(import.kindIndex, globalValue->global()->getPrimitive()); 267 267 break; … … 273 273 if (!isRefType(globalType)) { 274 274 // ii. If the global_type of i is i64 or Type(v) is Number, throw a WebAssembly.LinkError. 275 if (globalType == Wasm::I64) {275 if (globalType.isI64()) { 276 276 if (!value.isBigInt()) 277 277 return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "must be a BigInt"))); … … 283 283 284 284 // iii. Append ToWebAssemblyValue(v) to imports. 285 switch (globalType ) {286 case Wasm:: Funcref:285 switch (globalType.kind) { 286 case Wasm::TypeKind::Funcref: 287 287 if (!isWebAssemblyHostFunction(vm, value) && !value.isNull()) 288 288 return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "must be a wasm exported function or null"))); 289 289 m_instance->instance().setGlobal(import.kindIndex, value); 290 290 break; 291 case Wasm:: Externref:291 case Wasm::TypeKind::Externref: 292 292 m_instance->instance().setGlobal(import.kindIndex, value); 293 293 break; 294 case Wasm:: I32:294 case Wasm::TypeKind::I32: 295 295 m_instance->instance().setGlobal(import.kindIndex, value.toInt32(globalObject)); 296 296 break; 297 case Wasm:: I64: {297 case Wasm::TypeKind::I64: { 298 298 int64_t bits = value.toBigInt64(globalObject); 299 299 RETURN_IF_EXCEPTION(scope, void()); … … 301 301 break; 302 302 } 303 case Wasm:: F32:303 case Wasm::TypeKind::F32: 304 304 m_instance->instance().setGlobal(import.kindIndex, bitwise_cast<uint32_t>(value.toFloat(globalObject))); 305 305 break; 306 case Wasm:: F64:306 case Wasm::TypeKind::F64: 307 307 m_instance->instance().setGlobal(import.kindIndex, bitwise_cast<uint64_t>(value.asNumber())); 308 308 break; … … 488 488 case Wasm::ExternalKind::Global: { 489 489 const Wasm::GlobalInformation& global = moduleInformation.globals[exp.kindIndex]; 490 switch (global.type ) {491 case Wasm:: Externref:492 case Wasm:: Funcref:493 case Wasm:: I32:494 case Wasm:: I64:495 case Wasm:: F32:496 case Wasm:: F64: {490 switch (global.type.kind) { 491 case Wasm::TypeKind::Externref: 492 case Wasm::TypeKind::Funcref: 493 case Wasm::TypeKind::I32: 494 case Wasm::TypeKind::I64: 495 case Wasm::TypeKind::F32: 496 case Wasm::TypeKind::F64: { 497 497 // If global is immutable, we are not creating a binding internally. 498 498 // But we need to create a binding just to export it. This binding is not actually connected. But this is OK since it is immutable.
Note: See TracChangeset
for help on using the changeset viewer.