Changeset 273813 in webkit


Ignore:
Timestamp:
Mar 3, 2021 4:20:00 AM (17 months ago)
Author:
commit-queue@webkit.org
Message:

[WASM-Function-References] Extend wasm type with type index
https://bugs.webkit.org/show_bug.cgi?id=222351

Patch by Dmitry Bezhetskov <dbezhetskov> on 2021-03-03
Reviewed by Keith Miller.

Extend wasm type with type index to represent
new reference types from typed function references
proposal: https://github.com/WebAssembly/function-references/blob/master/proposals/function-references/Overview.md.

  • bytecode/BytecodeDumper.cpp:

(JSC::Wasm::BytecodeDumper::dumpConstants):
(JSC::Wasm::BytecodeDumper::formatConstant const):

  • bytecode/BytecodeDumper.h:
  • wasm/WasmAirIRGenerator.cpp:

(JSC::Wasm::TypedTmp::TypedTmp):
(JSC::Wasm::TypedTmp::dump const):
(JSC::Wasm::AirIRGenerator::g32):
(JSC::Wasm::AirIRGenerator::g64):
(JSC::Wasm::AirIRGenerator::gExternref):
(JSC::Wasm::AirIRGenerator::gFuncref):
(JSC::Wasm::AirIRGenerator::f32):
(JSC::Wasm::AirIRGenerator::f64):
(JSC::Wasm::AirIRGenerator::tmpForType):
(JSC::Wasm::AirIRGenerator::emitCCall):
(JSC::Wasm::AirIRGenerator::moveOpForValueType):
(JSC::Wasm::AirIRGenerator::AirIRGenerator):
(JSC::Wasm::AirIRGenerator::addLocal):
(JSC::Wasm::AirIRGenerator::addConstant):
(JSC::Wasm::AirIRGenerator::addRefIsNull):
(JSC::Wasm::AirIRGenerator::addRefFunc):
(JSC::Wasm::AirIRGenerator::addTableGet):
(JSC::Wasm::AirIRGenerator::addTableSet):
(JSC::Wasm::AirIRGenerator::addTableInit):
(JSC::Wasm::AirIRGenerator::addElemDrop):
(JSC::Wasm::AirIRGenerator::addTableSize):
(JSC::Wasm::AirIRGenerator::addTableGrow):
(JSC::Wasm::AirIRGenerator::addTableFill):
(JSC::Wasm::AirIRGenerator::addTableCopy):
(JSC::Wasm::AirIRGenerator::addGrowMemory):
(JSC::Wasm::AirIRGenerator::addCurrentMemory):
(JSC::Wasm::AirIRGenerator::addMemoryFill):
(JSC::Wasm::AirIRGenerator::addMemoryCopy):
(JSC::Wasm::AirIRGenerator::addMemoryInit):
(JSC::Wasm::AirIRGenerator::addDataDrop):
(JSC::Wasm::AirIRGenerator::emitCheckAndPreparePointer):
(JSC::Wasm::AirIRGenerator::sanitizeAtomicResult):
(JSC::Wasm::AirIRGenerator::appendGeneralAtomic):
(JSC::Wasm::AirIRGenerator::appendStrongCAS):
(JSC::Wasm::AirIRGenerator::emitAtomicLoadOp):
(JSC::Wasm::AirIRGenerator::atomicLoad):
(JSC::Wasm::AirIRGenerator::emitAtomicStoreOp):
(JSC::Wasm::AirIRGenerator::emitAtomicBinaryRMWOp):
(JSC::Wasm::AirIRGenerator::atomicBinaryRMW):
(JSC::Wasm::AirIRGenerator::emitAtomicCompareExchange):
(JSC::Wasm::AirIRGenerator::atomicCompareExchange):
(JSC::Wasm::AirIRGenerator::atomicWait):
(JSC::Wasm::AirIRGenerator::atomicNotify):
(JSC::Wasm::AirIRGenerator::truncSaturated):
(JSC::Wasm::AirIRGenerator::addReturn):
(JSC::Wasm::AirIRGenerator::addSwitch):
(JSC::Wasm::AirIRGenerator::emitModOrDiv):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncSF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncSF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncUF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32TruncUF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncSF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF64>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncSF32>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64TruncUF32>):
(JSC::Wasm::AirIRGenerator::addShift):
(JSC::Wasm::AirIRGenerator::addFloatingPointBinOp):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F32Min>):
(JSC::Wasm::AirIRGenerator::addFloatingPointMinOrMax):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F32Max>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F64Mul>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F32Div>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F64Div>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F32Neg>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64Rotr>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64Rotl>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32ShrU>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32ShrS>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32Shl>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F64Min>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F64Sub>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64ShrS>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64ShrU>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I64Shl>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32Rotl>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::I32Rotr>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F64Neg>):
(JSC::Wasm::AirIRGenerator::addOp<OpType::F64Max>):

  • wasm/WasmB3IRGenerator.cpp:

(JSC::Wasm::B3IRGenerator::addTableGet):
(JSC::Wasm::B3IRGenerator::addRefFunc):
(JSC::Wasm::B3IRGenerator::addTableInit):
(JSC::Wasm::B3IRGenerator::addTableSize):
(JSC::Wasm::B3IRGenerator::addTableGrow):
(JSC::Wasm::B3IRGenerator::addTableFill):
(JSC::Wasm::B3IRGenerator::addTableCopy):
(JSC::Wasm::B3IRGenerator::addMemoryFill):
(JSC::Wasm::B3IRGenerator::addMemoryInit):
(JSC::Wasm::B3IRGenerator::addMemoryCopy):
(JSC::Wasm::B3IRGenerator::sanitizeAtomicResult):
(JSC::Wasm::B3IRGenerator::atomicLoad):
(JSC::Wasm::B3IRGenerator::emitAtomicStoreOp):
(JSC::Wasm::B3IRGenerator::emitAtomicBinaryRMWOp):
(JSC::Wasm::B3IRGenerator::atomicBinaryRMW):
(JSC::Wasm::B3IRGenerator::emitAtomicCompareExchange):
(JSC::Wasm::B3IRGenerator::atomicCompareExchange):

  • wasm/WasmCallingConvention.h:

(JSC::Wasm::WasmCallingConvention::marshallLocation const):
(JSC::Wasm::WasmCallingConvention::callInformationFor const):
(JSC::Wasm::JSCallingConvention::marshallLocation const):

  • wasm/WasmFormat.h:

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

  • wasm/WasmFunctionCodeBlock.h:
  • wasm/WasmFunctionParser.h:

(JSC::Wasm::FunctionParser::TypedExpression::TypedExpression):
(JSC::Wasm::FunctionParser<Context>::load):
(JSC::Wasm::FunctionParser<Context>::store):
(JSC::Wasm::FunctionParser<Context>::atomicLoad):
(JSC::Wasm::FunctionParser<Context>::atomicStore):
(JSC::Wasm::FunctionParser<Context>::atomicBinaryRMW):
(JSC::Wasm::FunctionParser<Context>::atomicCompareExchange):
(JSC::Wasm::FunctionParser<Context>::atomicWait):
(JSC::Wasm::FunctionParser<Context>::atomicNotify):
(JSC::Wasm::FunctionParser<Context>::checkBranchTarget):
(JSC::Wasm::FunctionParser<Context>::unify):
(JSC::Wasm::FunctionParser<Context>::parseExpression):

  • wasm/WasmGlobal.cpp:

(JSC::Wasm::Global::get const):
(JSC::Wasm::Global::set):
(JSC::Wasm::Global::visitAggregateImpl):

  • wasm/WasmLLIntGenerator.cpp:

(JSC::Wasm::LLIntGenerator::jsNullConstant):
(JSC::Wasm::LLIntGenerator::zeroConstant):
(JSC::Wasm::LLIntGenerator::callInformationForCaller):
(JSC::Wasm::LLIntGenerator::callInformationForCallee):
(JSC::Wasm::LLIntGenerator::addArguments):
(JSC::Wasm::LLIntGenerator::addLocal):

  • wasm/WasmOperations.cpp:

(JSC::Wasm::JSC_DEFINE_JIT_OPERATION):

  • wasm/WasmParser.h:

(JSC::Wasm::Parser<SuccessType>::parseBlockSignature):
(JSC::Wasm::Parser<SuccessType>::parseValueType):

  • wasm/WasmSectionParser.cpp:

(JSC::Wasm::SectionParser::parseType):
(JSC::Wasm::SectionParser::parseTableHelper):
(JSC::Wasm::SectionParser::parseGlobal):
(JSC::Wasm::SectionParser::parseElement):
(JSC::Wasm::SectionParser::parseInitExpr):
(JSC::Wasm::SectionParser::parseI32InitExpr):
(JSC::Wasm::SectionParser::parseElementSegmentVectorOfExpressions):

  • wasm/WasmSignature.cpp:

(JSC::Wasm::Signature::dump const):
(JSC::Wasm::computeHash):
(JSC::Wasm::SignatureInformation::SignatureInformation):

  • wasm/WasmSignature.h:

(JSC::Wasm::SignatureInformation::thunkFor const):

  • wasm/WasmTable.cpp:

(JSC::Wasm::Table::wasmType const):

  • wasm/generateWasmOpsHeader.py:

(TypeKind):

  • wasm/js/JSToWasm.cpp:

(JSC::Wasm::marshallJSResult):
(JSC::Wasm::createJSToWasmWrapper):

  • wasm/js/JSWebAssemblyHelpers.h:

(JSC::defaultValueForReferenceType):

  • wasm/js/WasmToJS.cpp:

(JSC::Wasm::wasmToJS):

  • wasm/js/WebAssemblyFunction.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::WebAssemblyFunction::jsCallEntrypointSlow):

  • wasm/js/WebAssemblyGlobalConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyModuleRecord.cpp:

(JSC::WebAssemblyModuleRecord::linkImpl):

Location:
trunk/Source/JavaScriptCore
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r273779 r273813  
     12021-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
    11842021-03-02  Yusuke Suzuki  <ysuzuki@apple.com>
    2185
  • trunk/Source/JavaScriptCore/bytecode/BytecodeDumper.cpp

    r269552 r273813  
    3838#include "WasmGeneratorTraits.h"
    3939#include "WasmModuleInformation.h"
    40 #include "WasmOps.h"
    4140#include "WasmSignatureInlines.h"
    4241
     
    363362        for (const auto& constant : block->constants()) {
    364363            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");
    366365            ++i;
    367366        }
     
    378377CString BytecodeDumper::formatConstant(Type type, uint64_t constant) const
    379378{
    380     switch (type) {
    381     case Type::I32:
     379    switch (type.kind) {
     380    case TypeKind::I32:
    382381        return toCString(static_cast<int32_t>(constant));
    383     case Type::I64:
     382    case TypeKind::I64:
    384383        return toCString(constant);
    385     case Type::F32:
     384    case TypeKind::F32:
    386385        return toCString(bitwise_cast<float>(static_cast<int32_t>(constant)));
    387386        break;
    388     case Type::F64:
     387    case TypeKind::F64:
    389388        return toCString(bitwise_cast<double>(constant));
    390389        break;
    391     case Type::Externref:
    392     case Type::Funcref:
     390    case TypeKind::Externref:
     391    case TypeKind::Funcref:
    393392        if (JSValue::decode(constant) == jsNull())
    394393            return "null";
  • trunk/Source/JavaScriptCore/bytecode/BytecodeDumper.h

    r268871 r273813  
    3232#include "InstructionStream.h"
    3333#include "StructureStubInfo.h"
     34#include "WasmOps.h"
    3435
    3536namespace JSC {
     
    131132class FunctionCodeBlock;
    132133struct ModuleInformation;
    133 enum Type : int8_t;
    134134
    135135class BytecodeDumper final : public JSC::BytecodeDumper<FunctionCodeBlock> {
  • trunk/Source/JavaScriptCore/wasm/WasmAirIRGenerator.cpp

    r272933 r273813  
    8686    constexpr TypedTmp()
    8787        : m_tmp()
    88         , m_type(Type::Void)
    89     { }
     88        , m_type(Types::Void)
     89    {
     90    }
    9091
    9192    TypedTmp(Tmp tmp, Type type)
     
    117118    void dump(PrintStream& out) const
    118119    {
    119         out.print("(", m_tmp, ", ", m_type, ")");
     120        out.print("(", m_tmp, ", ", m_type.kind, ", ", m_type.index, ")");
    120121    }
    121122
     
    407408    }
    408409
    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 }; }
    415416
    416417    TypedTmp tmpForType(Type type)
    417418    {
    418         switch (type) {
    419         case Type::I32:
     419        switch (type.kind) {
     420        case TypeKind::I32:
    420421            return g32();
    421         case Type::I64:
     422        case TypeKind::I64:
    422423            return g64();
    423         case Type::Funcref:
     424        case TypeKind::Funcref:
    424425            return gFuncref();
    425         case Type::Externref:
     426        case TypeKind::Externref:
    426427            return gExternref();
    427         case Type::F32:
     428        case TypeKind::F32:
    428429            return f32();
    429         case Type::F64:
     430        case TypeKind::F64:
    430431            return f64();
    431         case Type::Void:
     432        case TypeKind::Void:
    432433            return { };
    433434        default:
     
    592593        B3::Type resultType = B3::Void;
    593594        if (result) {
    594             switch (result.type()) {
    595             case Type::I32:
     595            switch (result.type().kind) {
     596            case TypeKind::I32:
    596597                resultType = B3::Int32;
    597598                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:
    601602                resultType = B3::Int64;
    602603                break;
    603             case Type::F32:
     604            case TypeKind::F32:
    604605                resultType = B3::Float;
    605606                break;
    606             case Type::F64:
     607            case TypeKind::F64:
    607608                resultType = B3::Double;
    608609                break;
     
    642643    static B3::Air::Opcode moveOpForValueType(Type type)
    643644    {
    644         switch (type) {
    645         case Type::I32:
     645        switch (type.kind) {
     646        case TypeKind::I32:
    646647            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:
    650651            return Move;
    651         case Type::F32:
     652        case TypeKind::F32:
    652653            return MoveFloat;
    653         case Type::F64:
     654        case TypeKind::F64:
    654655            return MoveDouble;
    655656        default:
     
    884885        append(Move, Tmp(contextInstance), m_instanceValue);
    885886    } else
    886         m_instanceValue = { Tmp(contextInstance), Type::I64 };
     887        m_instanceValue = { Tmp(contextInstance), Types::I64 };
    887888
    888889    ASSERT(!m_locals.size());
     
    898899        B3::ValueRep location = wasmCallInfo.params[i];
    899900        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:
    902903            append(Move32, arg, m_locals[i]);
    903904            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:
    907908            append(Move, arg, m_locals[i]);
    908909            break;
    909         case Type::F32:
     910        case TypeKind::F32:
    910911            append(MoveFloat, arg, m_locals[i]);
    911912            break;
    912         case Type::F64:
     913        case TypeKind::F64:
    913914            append(MoveDouble, arg, m_locals[i]);
    914915            break;
     
    10051006        auto local = tmpForType(type);
    10061007        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:
    10101011            append(Move, Arg::imm(JSValue::encode(jsNull())), local);
    10111012            break;
    1012         case Type::I32:
    1013         case Type::I64: {
     1013        case TypeKind::I32:
     1014        case TypeKind::I64: {
    10141015            append(Xor64, local, local);
    10151016            break;
    10161017        }
    1017         case Type::F32:
    1018         case Type::F64: {
     1018        case TypeKind::F32:
     1019        case TypeKind::F64: {
    10191020            auto temp = g64();
    10201021            // IEEE 754 "0" is just int32/64 zero.
    10211022            append(Xor64, temp, temp);
    1022             append(type == Type::F32 ? Move32ToFloat : Move64ToDouble, temp, local);
     1023            append(type.isF32() ? Move32ToFloat : Move64ToDouble, temp, local);
    10231024            break;
    10241025        }
     
    10381039{
    10391040    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:
    10451046        append(block, Move, Arg::bigImm(value), result);
    10461047        break;
    1047     case Type::F32:
    1048     case Type::F64: {
     1048    case TypeKind::F32:
     1049    case TypeKind::F64: {
    10491050        auto tmp = g64();
    10501051        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);
    10521053        break;
    10531054    }
     
    10751076{
    10761077    ASSERT(value.tmp());
    1077     result = tmpForType(Type::I32);
     1078    result = tmpForType(Types::I32);
    10781079    auto tmp = g64();
    10791080
     
    10871088{
    10881089    // 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));
    10911092
    10921093    return { };
     
    10971098    // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>.
    10981099    ASSERT(index.tmp());
    1099     ASSERT(index.type() == Type::I32);
     1100
     1101    ASSERT(index.type().isI32());
    11001102    result = tmpForType(m_info.tables[tableIndex].wasmType());
    11011103
    1102     emitCCall(&operationGetWasmTableElement, result, instanceValue(), addConstant(Type::I32, tableIndex), index);
     1104    emitCCall(&operationGetWasmTableElement, result, instanceValue(), addConstant(Types::I32, tableIndex), index);
    11031105    emitCheck([&] {
    11041106        return Inst(BranchTest32, nullptr, Arg::resCond(MacroAssembler::Zero), result, result);
     
    11141116    // FIXME: Emit this inline <https://bugs.webkit.org/show_bug.cgi?id=198506>.
    11151117    ASSERT(index.tmp());
    1116     ASSERT(index.type() == Type::I32);
     1118    ASSERT(index.type().isI32());
    11171119    ASSERT(value.tmp());
    11181120
    11191121    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);
    11211123
    11221124    emitCheck([&] {
     
    11321134{
    11331135    ASSERT(dstOffset.tmp());
    1134     ASSERT(dstOffset.type() == Type::I32);
     1136    ASSERT(dstOffset.type().isI32());
    11351137
    11361138    ASSERT(srcOffset.tmp());
    1137     ASSERT(srcOffset.type() == Type::I32);
     1139    ASSERT(srcOffset.type().isI32());
    11381140
    11391141    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);
    11431145    emitCCall(
    11441146        &operationWasmTableInit, result, instanceValue(),
    1145         addConstant(Type::I32, elementIndex),
    1146         addConstant(Type::I32, tableIndex),
     1147        addConstant(Types::I32, elementIndex),
     1148        addConstant(Types::I32, tableIndex),
    11471149        dstOffset, srcOffset, length);
    11481150
     
    11581160auto AirIRGenerator::addElemDrop(unsigned elementIndex) -> PartialResult
    11591161{
    1160     emitCCall(&operationWasmElemDrop, TypedTmp(), instanceValue(), addConstant(Type::I32, elementIndex));
     1162    emitCCall(&operationWasmElemDrop, TypedTmp(), instanceValue(), addConstant(Types::I32, elementIndex));
    11611163    return { };
    11621164}
     
    11651167{
    11661168    // 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));
    11701172
    11711173    return { };
     
    11771179    ASSERT(fill.type() == m_info.tables[tableIndex].wasmType());
    11781180    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);
    11831185
    11841186    return { };
     
    11901192    ASSERT(fill.type() == m_info.tables[tableIndex].wasmType());
    11911193    ASSERT(offset.tmp());
    1192     ASSERT(offset.type() == Type::I32);
     1194    ASSERT(offset.type().isI32());
    11931195    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);
    11981200
    11991201    emitCheck([&] {
     
    12091211{
    12101212    ASSERT(dstOffset.tmp());
    1211     ASSERT(dstOffset.type() == Type::I32);
     1213    ASSERT(dstOffset.type().isI32());
    12121214
    12131215    ASSERT(srcOffset.tmp());
    1214     ASSERT(srcOffset.type() == Type::I32);
     1216    ASSERT(srcOffset.type().isI32());
    12151217
    12161218    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);
    12201222    emitCCall(
    12211223        &operationWasmTableCopy, result, instanceValue(),
    1222         addConstant(Type::I32, dstTableIndex),
    1223         addConstant(Type::I32, srcTableIndex),
     1224        addConstant(Types::I32, dstTableIndex),
     1225        addConstant(Types::I32, srcTableIndex),
    12241226        dstOffset, srcOffset, length);
    12251227
     
    12551257{
    12561258    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);
    12581260    restoreWebAssemblyGlobalState(RestoreCachedStackLimit::No, m_info.memory, instanceValue(), m_currentBlock);
    12591261
     
    12771279    static_assert(PageCount::pageSize == 1ull << shiftValue, "This must hold for the code below to be correct.");
    12781280    append(Move, Arg::imm(16), temp2);
    1279     addShift(Type::I32, Urshift64, temp1, temp2, result);
     1281    addShift(Types::I32, Urshift64, temp1, temp2, result);
    12801282    append(Move32, result, result);
    12811283
     
    12861288{
    12871289    ASSERT(dstAddress.tmp());
    1288     ASSERT(dstAddress.type() == Type::I32);
     1290    ASSERT(dstAddress.type().isI32());
    12891291
    12901292    ASSERT(targetValue.tmp());
    1291     ASSERT(targetValue.type() == Type::I32);
     1293    ASSERT(targetValue.type().isI32());
    12921294
    12931295    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);
    12971299    emitCCall(
    12981300        &operationWasmMemoryFill, result, instanceValue(),
     
    13111313{
    13121314    ASSERT(dstAddress.tmp());
    1313     ASSERT(dstAddress.type() == Type::I32);
     1315    ASSERT(dstAddress.type().isI32());
    13141316
    13151317    ASSERT(srcAddress.tmp());
    1316     ASSERT(srcAddress.type() == Type::I32);
     1318    ASSERT(srcAddress.type().isI32());
    13171319
    13181320    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);
    13221324    emitCCall(
    13231325        &operationWasmMemoryCopy, result, instanceValue(),
     
    13361338{
    13371339    ASSERT(dstAddress.tmp());
    1338     ASSERT(dstAddress.type() == Type::I32);
     1340    ASSERT(dstAddress.type().isI32());
    13391341
    13401342    ASSERT(srcAddress.tmp());
    1341     ASSERT(srcAddress.type() == Type::I32);
     1343    ASSERT(srcAddress.type().isI32());
    13421344
    13431345    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);
    13471349    emitCCall(
    13481350        &operationWasmMemoryInit, result, instanceValue(),
    1349         addConstant(Type::I32, dataSegmentIndex),
     1351        addConstant(Types::I32, dataSegmentIndex),
    13501352        dstAddress, srcAddress, length);
    13511353
     
    13611363auto AirIRGenerator::addDataDrop(unsigned dataSegmentIndex) -> PartialResult
    13621364{
    1363     emitCCall(&operationWasmDataDrop, TypedTmp(), instanceValue(), addConstant(Type::I32, dataSegmentIndex));
     1365    emitCCall(&operationWasmDataDrop, TypedTmp(), instanceValue(), addConstant(Types::I32, dataSegmentIndex));
    13641366    return { };
    13651367}
     
    15811583            append(Move, Arg::bigImm(static_cast<uint64_t>(sizeOfOperation) + offset - 1), temp);
    15821584            append(Add64, result, temp);
    1583             auto sizeMax = addConstant(Type::I64, maximum);
     1585            auto sizeMax = addConstant(Types::I64, maximum);
    15841586
    15851587            emitCheck([&] {
     
    19011903void AirIRGenerator::sanitizeAtomicResult(ExtAtomicOpType op, Type valueType, Tmp source, Tmp dest)
    19021904{
    1903     switch (valueType) {
    1904     case Type::I64: {
     1905    switch (valueType.kind) {
     1906    case TypeKind::I64: {
    19051907        switch (accessWidth(op)) {
    19061908        case B3::Width8:
     
    19211923        return;
    19221924    }
    1923     case Type::I32:
     1925    case TypeKind::I32:
    19241926        switch (accessWidth(op)) {
    19251927        case B3::Width8:
     
    19601962    auto tmp = [&](Arg arg) -> TypedTmp {
    19611963        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);
    19631965        TypedTmp result = newTmp();
    19641966        append(Move, arg, result);
     
    20712073    auto tmp = [&](Arg arg) -> TypedTmp {
    20722074        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);
    20742076        TypedTmp result = newTmp();
    20752077        append(Move, arg, result);
     
    21662168    B3::Air::Opcode nonAtomicOpcode = OPCODE_FOR_CANONICAL_WIDTH(Add, accessWidth(op));
    21672169
    2168     TypedTmp result = valueType == Type::I64 ? g64() : g32();
     2170    TypedTmp result = valueType.isI64() ? g64() : g32();
    21692171
    21702172    if (opcode) {
     
    22032205
    22042206        // 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:
    22072209            result = g32();
    22082210            break;
    2209         case Type::I64:
     2211        case TypeKind::I64:
    22102212            result = g64();
    22112213            break;
     
    22402242    if (opcode) {
    22412243        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();
    22432245            appendEffectful(opcode.value(), value, addrArg, result);
    22442246            return;
     
    22462248
    22472249        if (isValidForm(opcode.value(), Arg::Tmp, addrArg.kind())) {
    2248             TypedTmp result = valueType == Type::I64 ? g64() : g32();
     2250            TypedTmp result = valueType.isI64() ? g64() : g32();
    22492251            append(Move, value, result);
    22502252            appendEffectful(opcode.value(), result, addrArg);
     
    22532255    }
    22542256
    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());
    22562258}
    22572259
     
    23122314        if (isX86() || isARM64E()) {
    23132315            TypedTmp newValue;
    2314             if (valueType == Type::I64) {
     2316            if (valueType.isI64()) {
    23152317                newValue = g64();
    23162318                append(Move, value, newValue);
     
    23392341        if (isARM64E()) {
    23402342            TypedTmp newValue;
    2341             if (valueType == Type::I64) {
     2343            if (valueType.isI64()) {
    23422344                newValue = g64();
    23432345                append(Not64, value, newValue);
     
    23922394    }
    23932395
    2394     TypedTmp result = valueType == Type::I64 ? g64() : g32();
     2396    TypedTmp result = valueType.isI64() ? g64() : g32();
    23952397
    23962398    if (opcode) {
     
    24272429        emitPatchpoint(patch, Tmp());
    24282430
    2429         switch (valueType) {
    2430         case Type::I32:
     2431        switch (valueType.kind) {
     2432        case TypeKind::I32:
    24312433            result = g32();
    24322434            break;
    2433         case Type::I64:
     2435        case TypeKind::I64:
    24342436            result = g64();
    24352437            break;
     
    24592461    }
    24602462
    2461     TypedTmp result = valueType == Type::I64 ? g64() : g32();
     2463    TypedTmp result = valueType.isI64() ? g64() : g32();
    24622464
    24632465    if (valueWidth == accessWidth) {
     
    24712473    BasicBlock* continuation = m_code.addBlock();
    24722474
    2473     TypedTmp truncatedExpected = valueType == Type::I64 ? g64() : g32();
     2475    TypedTmp truncatedExpected = valueType.isI64() ? g64() : g32();
    24742476    sanitizeAtomicResult(op, valueType, expected, truncatedExpected);
    24752477
     
    25262528
    25272529        // 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:
    25302532            result = g32();
    25312533            break;
    2532         case Type::I64:
     2534        case TypeKind::I64:
    25332535            result = g64();
    25342536            break;
     
    25472549
    25482550    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);
    25502552    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);
    25522554    emitCheck([&] {
    25532555        return Inst(Branch32, nullptr, Arg::relCond(MacroAssembler::LessThan), result, Arg::imm(0));
     
    25632565    result = g32();
    25642566
    2565     emitCCall(&operationMemoryAtomicNotify, result, instanceValue(), pointer, addConstant(Type::I32, offset), count);
     2567    emitCCall(&operationMemoryAtomicNotify, result, instanceValue(), pointer, addConstant(Types::I32, offset), count);
    25662568    emitCheck([&] {
    25672569        return Inst(Branch32, nullptr, Arg::relCond(MacroAssembler::LessThan), result, Arg::imm(0));
     
    25872589    switch (op) {
    25882590    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())));
    25912593        break;
    25922594    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)));
    25952597        break;
    25962598    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));
    25992601        break;
    26002602    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));
    26032605        break;
    26042606    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())));
    26072609        break;
    26082610    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)));
    26112613        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())));
    26132615        requiresMacroScratchRegisters = true;
    26142616        break;
    26152617    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())));
    26182620        break;
    26192621    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));
    26222624        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())));
    26242626        requiresMacroScratchRegisters = true;
    26252627        break;
     
    26652667    BasicBlock* continuation = m_code.addBlock();
    26662668
    2667     auto branchOp = operandType == Type::F32 ? BranchFloat : BranchDouble;
     2669    auto branchOp = operandType == Types::F32 ? BranchFloat : BranchDouble;
    26682670    append(m_currentBlock, branchOp, Arg::doubleCond(MacroAssembler::DoubleLessThanOrEqualOrUnordered), arg, minFloat);
    26692671    m_currentBlock->setSuccessors(minCase, maxCheckCase);
     
    30013003
    30023004        ASSERT(rep.isReg());
    3003         if (data.signature()->returnType(i) == I32)
     3005        if (data.signature()->returnType(i).isI32())
    30043006            append(Move32, tmp, tmp);
    30053007        returnConstraints.append(ConstrainedTmp(tmp, wasmCallInfo.results[i]));
     
    30413043    successors.append(defaultTarget.targetBlockForBranch());
    30423044
    3043     ASSERT(condition.type() == Type::I32);
     3045    ASSERT(condition.type().isI32());
    30443046
    30453047    // FIXME: We should consider dynamically switching between a jump table
     
    36153617
    36163618        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);
    36183620
    36193621        append(sizeof(IntType) == 4 ? Add32 : Add64, rhs, one, temp);
     
    36253627        denMayBeBad->setSuccessors(continuation, denNotZero);
    36263628
    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());
    36283630        if (isDiv)
    36293631            append(denNotZero, sizeof(IntType) == 4 ? Move32 : Move, min, result);
     
    38883890auto AirIRGenerator::addOp<OpType::I32TruncSF64>(ExpressionType arg, ExpressionType& result) -> PartialResult
    38893891{
    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));
    38923894
    38933895    auto temp1 = g32();
     
    39173919auto AirIRGenerator::addOp<OpType::I32TruncSF32>(ExpressionType arg, ExpressionType& result) -> PartialResult
    39183920{
    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())));
    39213923
    39223924    auto temp1 = g32();
     
    39463948auto AirIRGenerator::addOp<OpType::I32TruncUF64>(ExpressionType arg, ExpressionType& result) -> PartialResult
    39473949{
    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));
    39503952
    39513953    auto temp1 = g32();
     
    39743976auto AirIRGenerator::addOp<OpType::I32TruncUF32>(ExpressionType arg, ExpressionType& result) -> PartialResult
    39753977{
    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)));
    39783980
    39793981    auto temp1 = g32();
     
    40024004auto AirIRGenerator::addOp<OpType::I64TruncSF64>(ExpressionType arg, ExpressionType& result) -> PartialResult
    40034005{
    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())));
    40064008
    40074009    auto temp1 = g32();
     
    40314033auto AirIRGenerator::addOp<OpType::I64TruncUF64>(ExpressionType arg, ExpressionType& result) -> PartialResult
    40324034{
    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));
    40354037   
    40364038    auto temp1 = g32();
     
    40484050    TypedTmp signBitConstant;
    40494051    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())));
    40514053
    40524054    Vector<ConstrainedTmp> args;
     
    40784080auto AirIRGenerator::addOp<OpType::I64TruncSF32>(ExpressionType arg, ExpressionType& result) -> PartialResult
    40794081{
    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())));
    40824084
    40834085    auto temp1 = g32();
     
    41064108auto AirIRGenerator::addOp<OpType::I64TruncUF32>(ExpressionType arg, ExpressionType& result) -> PartialResult
    41074109{
    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)));
    41104112   
    41114113    auto temp1 = g32();
     
    41234125    TypedTmp signBitConstant;
    41244126    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())));
    41264128
    41274129    auto* patchpoint = addPatchpoint(B3::Int64);
     
    41534155auto AirIRGenerator::addShift(Type type, B3::Air::Opcode op, ExpressionType value, ExpressionType shift, ExpressionType& result) -> PartialResult
    41544156{
    4155     ASSERT(type == Type::I64 || type == Type::I32);
     4157    ASSERT(type.isI64() || type.isI32());
    41564158    result = tmpForType(type);
    41574159
     
    42214223auto AirIRGenerator::addFloatingPointBinOp(Type type, B3::Air::Opcode op, ExpressionType lhs, ExpressionType rhs, ExpressionType& result) -> PartialResult
    42224224{
    4223     ASSERT(type == Type::F32 || type == Type::F64);
     4225    ASSERT(type.isF32() || type.isF64());
    42244226    result = tmpForType(type);
    42254227
     
    42744276template<> auto AirIRGenerator::addOp<OpType::F32Min>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    42754277{
    4276     return addFloatingPointMinOrMax(F32, MinOrMax::Min, arg0, arg1, result);
     4278    return addFloatingPointMinOrMax(Types::F32, MinOrMax::Min, arg0, arg1, result);
    42774279}
    42784280
     
    42934295auto AirIRGenerator::addFloatingPointMinOrMax(Type floatType, MinOrMax minOrMax, ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    42944296{
    4295     ASSERT(floatType == F32 || floatType == F64);
     4297    ASSERT(floatType.isF32() || floatType.isF64());
    42964298    result = tmpForType(floatType);
    42974299
     
    43044306    BasicBlock* continuation = m_code.addBlock();
    43054307
    4306     auto branchOp = floatType == F32 ? BranchFloat : BranchDouble;
     4308    auto branchOp = floatType.isF32() ? BranchFloat : BranchDouble;
    43074309    append(m_currentBlock, branchOp, Arg::doubleCond(MacroAssembler::DoubleEqualAndOrdered), arg0, arg1);
    43084310    m_currentBlock->setSuccessors(isEqual, notEqual);
     
    43144316    notLessThan->setSuccessors(isGreaterThan, isNaN);
    43154317
    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;
    43184320    append(isEqual, minOrMax == MinOrMax::Max ? andOp : orOp, arg0, arg1, result);
    43194321    append(isEqual, Jump);
     
    43304332    isGreaterThan->setSuccessors(continuation);
    43314333
    4332     auto addOp = floatType == F32 ? AddFloat : AddDouble;
     4334    auto addOp = floatType.isF32() ? AddFloat : AddDouble;
    43334335    append(isNaN, addOp, arg0, arg1, result);
    43344336    append(isNaN, Jump);
     
    43424344template<> auto AirIRGenerator::addOp<OpType::F32Max>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    43434345{
    4344     return addFloatingPointMinOrMax(F32, MinOrMax::Max, arg0, arg1, result);
     4346    return addFloatingPointMinOrMax(Types::F32, MinOrMax::Max, arg0, arg1, result);
    43454347}
    43464348
    43474349template<> auto AirIRGenerator::addOp<OpType::F64Mul>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    43484350{
    4349     return addFloatingPointBinOp(Type::F64, MulDouble, arg0, arg1, result);
     4351    return addFloatingPointBinOp(Types::F64, MulDouble, arg0, arg1, result);
    43504352}
    43514353
    43524354template<> auto AirIRGenerator::addOp<OpType::F32Div>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    43534355{
    4354     return addFloatingPointBinOp(Type::F32, DivFloat, arg0, arg1, result);
     4356    return addFloatingPointBinOp(Types::F32, DivFloat, arg0, arg1, result);
    43554357}
    43564358
     
    44614463template<> auto AirIRGenerator::addOp<OpType::F64Div>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    44624464{
    4463     return addFloatingPointBinOp(Type::F64, DivDouble, arg0, arg1, result);
     4465    return addFloatingPointBinOp(Types::F64, DivDouble, arg0, arg1, result);
    44644466}
    44654467
     
    45124514        append(NegateFloat, arg0, result);
    45134515    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)));
    45154517        auto temp = g32();
    45164518        append(MoveFloatTo32, arg0, temp);
     
    45374539template<> auto AirIRGenerator::addOp<OpType::I64Rotr>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    45384540{
    4539     return addShift(Type::I64, RotateRight64, arg0, arg1, result);
     4541    return addShift(Types::I64, RotateRight64, arg0, arg1, result);
    45404542}
    45414543
     
    45964598        append(Move, arg1, newShift);
    45974599        append(Neg64, newShift);
    4598         return addShift(Type::I64, RotateRight64, arg0, newShift, result);
     4600        return addShift(Types::I64, RotateRight64, arg0, newShift, result);
    45994601    } else
    4600         return addShift(Type::I64, RotateLeft64, arg0, arg1, result);
     4602        return addShift(Types::I64, RotateLeft64, arg0, arg1, result);
    46014603}
    46024604
     
    46384640template<> auto AirIRGenerator::addOp<OpType::I32ShrU>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    46394641{
    4640     return addShift(Type::I32, Urshift32, arg0, arg1, result);
     4642    return addShift(Types::I32, Urshift32, arg0, arg1, result);
    46414643}
    46424644
     
    46524654template<> auto AirIRGenerator::addOp<OpType::I32ShrS>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    46534655{
    4654     return addShift(Type::I32, Rshift32, arg0, arg1, result);
     4656    return addShift(Types::I32, Rshift32, arg0, arg1, result);
    46554657}
    46564658
     
    46784680template<> auto AirIRGenerator::addOp<OpType::I32Shl>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    46794681{
    4680     return addShift(Type::I32, Lshift32, arg0, arg1, result);
     4682    return addShift(Types::I32, Lshift32, arg0, arg1, result);
    46814683}
    46824684
     
    47024704template<> auto AirIRGenerator::addOp<OpType::F64Min>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    47034705{
    4704     return addFloatingPointMinOrMax(F64, MinOrMax::Min, arg0, arg1, result);
     4706    return addFloatingPointMinOrMax(Types::F64, MinOrMax::Min, arg0, arg1, result);
    47054707}
    47064708
     
    47334735template<> auto AirIRGenerator::addOp<OpType::F64Sub>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    47344736{
    4735     return addFloatingPointBinOp(Type::F64, SubDouble, arg0, arg1, result);
     4737    return addFloatingPointBinOp(Types::F64, SubDouble, arg0, arg1, result);
    47364738}
    47374739
     
    48854887template<> auto AirIRGenerator::addOp<OpType::I64ShrS>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    48864888{
    4887     return addShift(Type::I64, Rshift64, arg0, arg1, result);
     4889    return addShift(Types::I64, Rshift64, arg0, arg1, result);
    48884890}
    48894891
    48904892template<> auto AirIRGenerator::addOp<OpType::I64ShrU>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    48914893{
    4892     return addShift(Type::I64, Urshift64, arg0, arg1, result);
     4894    return addShift(Types::I64, Urshift64, arg0, arg1, result);
    48934895}
    48944896
     
    49024904template<> auto AirIRGenerator::addOp<OpType::I64Shl>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    49034905{
    4904     return addShift(Type::I64, Lshift64, arg0, arg1, result);
     4906    return addShift(Types::I64, Lshift64, arg0, arg1, result);
    49054907}
    49064908
     
    49264928        append(Move, arg1, newShift);
    49274929        append(Neg64, newShift);
    4928         return addShift(Type::I32, RotateRight32, arg0, newShift, result);
     4930        return addShift(Types::I32, RotateRight32, arg0, newShift, result);
    49294931    } else
    4930         return addShift(Type::I32, RotateLeft32, arg0, arg1, result);
     4932        return addShift(Types::I32, RotateLeft32, arg0, arg1, result);
    49314933}
    49324934
    49334935template<> auto AirIRGenerator::addOp<OpType::I32Rotr>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    49344936{
    4935     return addShift(Type::I32, RotateRight32, arg0, arg1, result);
     4937    return addShift(Types::I32, RotateRight32, arg0, arg1, result);
    49364938}
    49374939
     
    50065008        append(NegateDouble, arg0, result);
    50075009    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)));
    50095011        auto temp = g64();
    50105012        append(MoveDoubleTo64, arg0, temp);
     
    50175019template<> auto AirIRGenerator::addOp<OpType::F64Max>(ExpressionType arg0, ExpressionType arg1, ExpressionType& result) -> PartialResult
    50185020{
    5019     return addFloatingPointMinOrMax(F64, MinOrMax::Max, arg0, arg1, result);
     5021    return addFloatingPointMinOrMax(Types::F64, MinOrMax::Max, arg0, arg1, result);
    50205022}
    50215023
  • trunk/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp

    r272933 r273813  
    713713{
    714714    // 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(),
    716716        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationGetWasmTableElement)),
    717717        instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), tableIndex), index);
     
    754754    result = m_currentBlock->appendNew<CCallValue>(m_proc, B3::Int64, origin(),
    755755        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmRefFunc)),
    756         instanceValue(), addConstant(Type::I32, index));
     756        instanceValue(), addConstant(Types::I32, index));
    757757
    758758    return { };
     
    762762{
    763763    auto result = m_currentBlock->appendNew<CCallValue>(
    764         m_proc, toB3Type(I32), origin(),
     764        m_proc, toB3Type(Types::I32), origin(),
    765765        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmTableInit)),
    766766        instanceValue(),
     
    795795{
    796796    // 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(),
    798798        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationGetWasmTableSize)),
    799799        instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), tableIndex));
     
    804804auto B3IRGenerator::addTableGrow(unsigned tableIndex, ExpressionType fill, ExpressionType delta, ExpressionType& result) -> PartialResult
    805805{
    806     result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type(I32), origin(),
     806    result = m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type(Types::I32), origin(),
    807807        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmTableGrow)),
    808808        instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), tableIndex), fill, delta);
     
    813813auto B3IRGenerator::addTableFill(unsigned tableIndex, ExpressionType offset, ExpressionType fill, ExpressionType count) -> PartialResult
    814814{
    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(),
    816816        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmTableFill)),
    817817        instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), tableIndex), offset, fill, count);
     
    832832{
    833833    auto result = m_currentBlock->appendNew<CCallValue>(
    834         m_proc, toB3Type(I32), origin(),
     834        m_proc, toB3Type(Types::I32), origin(),
    835835        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmTableCopy)),
    836836        instanceValue(),
     
    899899{
    900900    auto result = m_currentBlock->appendNew<CCallValue>(
    901         m_proc, toB3Type(I32), origin(),
     901        m_proc, toB3Type(Types::I32), origin(),
    902902        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmMemoryFill)),
    903903        instanceValue(),
     
    919919{
    920920    auto result = m_currentBlock->appendNew<CCallValue>(
    921         m_proc, toB3Type(I32), origin(),
     921        m_proc, toB3Type(Types::I32), origin(),
    922922        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmMemoryInit)),
    923923        instanceValue(),
     
    940940{
    941941    auto result = m_currentBlock->appendNew<CCallValue>(
    942         m_proc, toB3Type(I32), origin(),
     942        m_proc, toB3Type(Types::I32), origin(),
    943943        m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmMemoryCopy)),
    944944        instanceValue(),
     
    13881388    };
    13891389
    1390     switch (valueType) {
    1391     case Type::I64: {
     1390    switch (valueType.kind) {
     1391    case TypeKind::I64: {
    13921392        if (accessWidth(op) == B3::Width64)
    13931393            return result;
    13941394        return m_currentBlock->appendNew<Value>(m_proc, ZExt32, origin(), sanitize32(result));
    13951395    }
    1396     case Type::I32:
     1396    case TypeKind::I32:
    13971397        return sanitize32(result);
    13981398    default:
     
    14461446        });
    14471447
    1448         switch (valueType) {
    1449         case Type::I32:
     1448        switch (valueType.kind) {
     1449        case TypeKind::I32:
    14501450            result = constant(Int32, 0);
    14511451            break;
    1452         case Type::I64:
     1452        case TypeKind::I64:
    14531453            result = constant(Int64, 0);
    14541454            break;
     
    14671467    pointer = fixupPointerPlusOffsetForAtomicOps(op, pointer, uoffset);
    14681468
    1469     if (valueType == Type::I64 && accessWidth(op) != B3::Width64)
     1469    if (valueType.isI64() && accessWidth(op) != B3::Width64)
    14701470        value = m_currentBlock->appendNew<B3::Value>(m_proc, B3::Trunc, Origin(), value);
    14711471    m_currentBlock->appendNew<AtomicValue>(m_proc, memoryKind(AtomicXchg), origin(), accessWidth(op), value, pointer);
     
    15541554    }
    15551555
    1556     if (valueType == Type::I64 && accessWidth(op) != B3::Width64)
     1556    if (valueType.isI64() && accessWidth(op) != B3::Width64)
    15571557        value = m_currentBlock->appendNew<B3::Value>(m_proc, B3::Trunc, Origin(), value);
    15581558
     
    15721572        });
    15731573
    1574         switch (valueType) {
    1575         case Type::I32:
     1574        switch (valueType.kind) {
     1575        case TypeKind::I32:
    15761576            result = constant(Int32, 0);
    15771577            break;
    1578         case Type::I64:
     1578        case TypeKind::I64:
    15791579            result = constant(Int64, 0);
    15801580            break;
     
    15991599
    16001600    Value* maximum = nullptr;
    1601     switch (valueType) {
    1602     case Type::I64: {
     1601    switch (valueType.kind) {
     1602    case TypeKind::I64: {
    16031603        switch (accessWidth) {
    16041604        case B3::Width8:
     
    16161616        break;
    16171617    }
    1618     case Type::I32:
     1618    case TypeKind::I32:
    16191619        switch (accessWidth) {
    16201620        case B3::Width8:
     
    16471647        auto truncatedExpected = expected;
    16481648        auto truncatedValue = value;
    1649         if (valueType == Type::I64) {
     1649        if (valueType.isI64()) {
    16501650            truncatedExpected = m_currentBlock->appendNew<B3::Value>(m_proc, B3::Trunc, Origin(), expected);
    16511651            truncatedValue = m_currentBlock->appendNew<B3::Value>(m_proc, B3::Trunc, Origin(), value);
     
    16971697        });
    16981698
    1699         switch (valueType) {
    1700         case Type::I32:
     1699        switch (valueType.kind) {
     1700        case TypeKind::I32:
    17011701            result = constant(Int32, 0);
    17021702            break;
    1703         case Type::I64:
     1703        case TypeKind::I64:
    17041704            result = constant(Int64, 0);
    17051705            break;
  • trunk/Source/JavaScriptCore/wasm/WasmCallingConvention.h

    r271500 r273813  
    103103    {
    104104        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:
    110110            return marshallLocationImpl(role, gprArgs, gpArgumentCount, stackOffset);
    111         case F32:
    112         case F64:
     111        case TypeKind::F32:
     112        case TypeKind::F64:
    113113            return marshallLocationImpl(role, fprArgs, fpArgumentCount, stackOffset);
    114114        default:
     
    131131        Vector<ArgumentLocation> params(signature.argumentCount());
    132132        for (size_t i = 0; i < signature.argumentCount(); ++i) {
    133             argumentsIncludeI64 |= signature.argument(i) == I64;
     133            argumentsIncludeI64 |= signature.argument(i).isI64();
    134134            params[i] = marshallLocation(role, signature.argument(i), gpArgumentCount, fpArgumentCount, argStackOffset);
    135135        }
     
    142142        Vector<ArgumentLocation, 1> results(signature.returnCount());
    143143        for (size_t i = 0; i < signature.returnCount(); ++i) {
    144             resultsIncludeI64 |= signature.returnType(i) == I64;
     144            resultsIncludeI64 |= signature.returnType(i).isI64();
    145145            results[i] = marshallLocation(role, signature.returnType(i), gpArgumentCount, fpArgumentCount, resultStackOffset);
    146146        }
     
    191191    {
    192192        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:
    198198            return marshallLocationImpl(role, gprArgs, gpArgumentCount, stackOffset);
    199         case F32:
    200         case F64:
     199        case TypeKind::F32:
     200        case TypeKind::F64:
    201201            return marshallLocationImpl(role, fprArgs, fpArgumentCount, stackOffset);
    202202        default:
  • trunk/Source/JavaScriptCore/wasm/WasmFormat.h

    r271775 r273813  
    6262inline bool isValueType(Type type)
    6363{
    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:
    6969        return true;
    70     case Externref:
    71     case Funcref:
     70    case TypeKind::Externref:
     71    case TypeKind::Funcref:
    7272        return Options::useWebAssemblyReferences();
    7373    default:
     
    7979inline bool isRefType(Type type)
    8080{
    81     return type == Externref || type == Funcref;
     81    return type.isFuncref() || type.isExternref();
    8282}
    8383   
     
    296296    Optional<uint32_t> maximum() const { return m_maximum; }
    297297    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; }
    299299
    300300private:
  • trunk/Source/JavaScriptCore/wasm/WasmFunctionCodeBlock.h

    r255687 r273813  
    3232#include "MacroAssemblerCodeRef.h"
    3333#include "WasmLLIntTierUpCounter.h"
     34#include "WasmOps.h"
    3435#include <wtf/HashMap.h>
    3536#include <wtf/Vector.h>
     
    4748class Signature;
    4849struct GeneratorTraits;
    49 enum Type : int8_t;
    5050
    5151// FIXME: Consider merging this with LLIntCallee
  • trunk/Source/JavaScriptCore/wasm/WasmFunctionParser.h

    r272933 r273813  
    6262    class TypedExpression {
    6363    public:
    64         TypedExpression() = default;
     64        TypedExpression()
     65            : m_type(Types::Void)
     66        {
     67        }
    6568
    6669        TypedExpression(Type type, ExpressionType value)
     
    333336    WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "load pointer");
    334337
    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");
    336339
    337340    ExpressionType result;
     
    356359    WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "store pointer");
    357360
    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");
    359362    WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, m_currentOpcode, " value type mismatch");
    360363
     
    390393    WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "load pointer");
    391394
    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");
    393396
    394397    ExpressionType result;
     
    413416    WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "store pointer");
    414417
    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");
    416419    WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, m_currentOpcode, " value type mismatch");
    417420
     
    435438    WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "pointer");
    436439
    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");
    438441    WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, static_cast<unsigned>(op), " value type mismatch");
    439442
     
    461464    WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "pointer");
    462465
    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");
    464467    WASM_VALIDATOR_FAIL_IF(expected.type() != memoryType, static_cast<unsigned>(op), " expected type mismatch");
    465468    WASM_VALIDATOR_FAIL_IF(value.type() != memoryType, static_cast<unsigned>(op), " value type mismatch");
     
    488491    WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "pointer");
    489492
    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");
    491494    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");
    493496
    494497    ExpressionType result;
    495498    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);
    497500    return { };
    498501}
     
    513516    WASM_TRY_POP_EXPRESSION_STACK_INTO(pointer, "pointer");
    514517
    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.
    517520
    518521    ExpressionType result;
    519522    WASM_TRY_ADD_TO_CONTEXT(atomicNotify(op, pointer, count, result, offset));
    520     m_expressionStack.constructAndAppend(I32, result);
     523    m_expressionStack.constructAndAppend(Types::I32, result);
    521524    return { };
    522525}
     
    697700    unsigned offset = m_expressionStack.size() - target.branchTargetArity();
    698701    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);
    700703
    701704    return { };
     
    707710    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");
    708711    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);
    710713
    711714    return { };
     
    716719{
    717720    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);
    719722    FOR_EACH_WASM_BINARY_OP(CREATE_CASE)
    720723#undef CREATE_CASE
    721724
    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);
    723726    FOR_EACH_WASM_UNARY_OP(CREATE_CASE)
    724727#undef CREATE_CASE
     
    736739            WASM_PARSER_FAIL_IF(isRefType(nonZero.type()) || isRefType(nonZero.type()), "can't use ref-types with unannotated select");
    737740
    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);
    740743
    741744        ExpressionType result;
     
    760763        WASM_TRY_POP_EXPRESSION_STACK_INTO(nonZero, "select non-zero");
    761764
    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);
    765768
    766769        ExpressionType result;
     
    771774    }
    772775
    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);
    774777FOR_EACH_WASM_MEMORY_LOAD_OP(CREATE_CASE)
    775778#undef CREATE_CASE
    776779
    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);
    778781FOR_EACH_WASM_MEMORY_STORE_OP(CREATE_CASE)
    779782#undef CREATE_CASE
     
    782785        uint32_t constant;
    783786        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));
    785788        return { };
    786789    }
     
    789792        int32_t constant;
    790793        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));
    792795        return { };
    793796    }
     
    796799        uint64_t constant;
    797800        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));
    799802        return { };
    800803    }
     
    803806        int64_t constant;
    804807        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));
    806809        return { };
    807810    }
     
    815818        TypedExpression index;
    816819        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);
    818821
    819822        ExpressionType result;
     
    832835        WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "table.set");
    833836        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);
    835838        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);
    837840        RELEASE_ASSERT(m_info.tables[tableIndex].type() == TableElementType::Externref || m_info.tables[tableIndex].type() == TableElementType::Funcref);
    838841        WASM_TRY_ADD_TO_CONTEXT(addTableSet(tableIndex, index, value));
     
    859862            WASM_TRY_POP_EXPRESSION_STACK_INTO(dstOffset, "table.init");
    860863
    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);
    864867
    865868            WASM_TRY_ADD_TO_CONTEXT(addTableInit(immediates.elementIndex, immediates.tableIndex, dstOffset, srcOffset, lenght));
     
    883886            ExpressionType result;
    884887            WASM_TRY_ADD_TO_CONTEXT(addTableSize(tableIndex, result));
    885             m_expressionStack.constructAndAppend(I32, result);
     888            m_expressionStack.constructAndAppend(Types::I32, result);
    886889            break;
    887890        }
     
    897900            WASM_TRY_POP_EXPRESSION_STACK_INTO(fill, "table.grow");
    898901
    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);
    901904
    902905            ExpressionType result;
    903906            WASM_TRY_ADD_TO_CONTEXT(addTableGrow(tableIndex, fill, delta, result));
    904             m_expressionStack.constructAndAppend(I32, result);
     907            m_expressionStack.constructAndAppend(Types::I32, result);
    905908            break;
    906909        }
     
    916919            WASM_TRY_POP_EXPRESSION_STACK_INTO(offset, "table.fill");
    917920
    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);
    921924
    922925            WASM_TRY_ADD_TO_CONTEXT(addTableFill(tableIndex, offset, fill, count));
     
    931934            const auto srcType = m_info.table(immediates.srcTableIndex).wasmType();
    932935            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);
    934937
    935938            TypedExpression dstOffset;
     
    940943            WASM_TRY_POP_EXPRESSION_STACK_INTO(dstOffset, "table.copy");
    941944
    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);
    945948
    946949            WASM_TRY_ADD_TO_CONTEXT(addTableCopy(immediates.dstTableIndex, immediates.srcTableIndex, dstOffset, srcOffset, length));
     
    962965            WASM_TRY_POP_EXPRESSION_STACK_INTO(dstAddress, "memory.fill");
    963966
    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);
    967970
    968971            WASM_TRY_ADD_TO_CONTEXT(addMemoryFill(dstAddress, targetValue, count));
     
    984987            WASM_TRY_POP_EXPRESSION_STACK_INTO(dstAddress, "memory.copy");
    985988
    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);
    989992
    990993            WASM_TRY_ADD_TO_CONTEXT(addMemoryCopy(dstAddress, srcAddress, count));
     
    10041007            WASM_TRY_POP_EXPRESSION_STACK_INTO(dstAddress, "memory.init");
    10051008
    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);
    10091012
    10101013            WASM_TRY_ADD_TO_CONTEXT(addMemoryInit(immediates.dataSegmentIndex, dstAddress, srcAddress, length));
     
    10211024        }
    10221025
    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);
    10241027        FOR_EACH_WASM_TRUNC_SATURATED_OP(CREATE_CASE)
    10251028#undef CREATE_CASE
     
    10391042        ExtAtomicOpType op = static_cast<ExtAtomicOpType>(extOp);
    10401043        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);
    10421045        FOR_EACH_WASM_EXT_ATOMIC_LOAD_OP(CREATE_CASE)
    10431046#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);
    10451048        FOR_EACH_WASM_EXT_ATOMIC_STORE_OP(CREATE_CASE)
    10461049#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);
    10481051        FOR_EACH_WASM_EXT_ATOMIC_BINARY_RMW_OP(CREATE_CASE)
    10491052#undef CREATE_CASE
    10501053        case ExtAtomicOpType::MemoryAtomicWait64:
    1051             return atomicWait(op, I64);
     1054            return atomicWait(op, Types::I64);
    10521055        case ExtAtomicOpType::MemoryAtomicWait32:
    1053             return atomicWait(op, I32);
     1056            return atomicWait(op, Types::I32);
    10541057        case ExtAtomicOpType::MemoryAtomicNotify:
    10551058            return atomicNotify(op);
     
    10591062        case ExtAtomicOpType::I32AtomicRmw16CmpxchgU:
    10601063        case ExtAtomicOpType::I32AtomicRmwCmpxchg:
    1061             return atomicCompareExchange(op, I32);
     1064            return atomicCompareExchange(op, Types::I32);
    10621065        case ExtAtomicOpType::I64AtomicRmw8CmpxchgU:
    10631066        case ExtAtomicOpType::I64AtomicRmw16CmpxchgU:
    10641067        case ExtAtomicOpType::I64AtomicRmw32CmpxchgU:
    10651068        case ExtAtomicOpType::I64AtomicRmwCmpxchg:
    1066             return atomicCompareExchange(op, I64);
     1069            return atomicCompareExchange(op, Types::I64);
    10671070        default:
    10681071            WASM_PARSER_FAIL_IF(true, "invalid extended atomic op ", extOp);
     
    10841087        TypedExpression value;
    10851088        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");
    10871090        ExpressionType result;
    10881091        WASM_TRY_ADD_TO_CONTEXT(addRefIsNull(value, result));
    1089         m_expressionStack.constructAndAppend(I32, result);
     1092        m_expressionStack.constructAndAppend(Types::I32, result);
    10901093        return { };
    10911094    }
     
    11021105        ExpressionType result;
    11031106        WASM_TRY_ADD_TO_CONTEXT(addRefFunc(index, result));
    1104         m_expressionStack.constructAndAppend(Funcref, result);
     1107        m_expressionStack.constructAndAppend(Types::Funcref, result);
    11051108        return { };
    11061109    }
     
    11231126        WASM_TRY_POP_EXPRESSION_STACK_INTO(value, "set_local");
    11241127        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);
    11261129        WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value));
    11271130        return { };
     
    11351138        TypedExpression value = m_expressionStack.last();
    11361139        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);
    11381141        WASM_TRY_ADD_TO_CONTEXT(setLocal(index, value));
    11391142        return { };
     
    11631166        Type globalType = m_info.globals[index].type;
    11641167        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);
    11661169
    11671170        WASM_TRY_ADD_TO_CONTEXT(setGlobal(index, value));
     
    11821185        for (size_t i = firstArgumentIndex; i < m_expressionStack.size(); ++i) {
    11831186            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);
    11851188            args.uncheckedAppend(arg);
    11861189            m_context.didPopValueFromStack();
     
    12151218        WASM_PARSER_FAIL_IF(argumentCount > m_expressionStack.size(), "call_indirect expects ", argumentCount, " arguments, but the expression stack currently holds ", m_expressionStack.size(), " values");
    12161219
    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);
    12181221
    12191222        Vector<ExpressionType> args;
     
    12231226            TypedExpression arg = m_expressionStack.at(i);
    12241227            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);
    12261229            args.uncheckedAppend(arg);
    12271230            m_context.didPopValueFromStack();
     
    12371240        return { };
    12381241    }
    1239 
    12401242    case Block: {
    12411243        BlockSignature inlineSignature;
     
    12461248        for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) {
    12471249            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);
    12491251        }
    12501252
     
    12691271        for (unsigned i = 0; i < inlineSignature->argumentCount(); ++i) {
    12701272            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);
    12721274        }
    12731275
     
    12901292        WASM_TRY_POP_EXPRESSION_STACK_INTO(condition, "if condition");
    12911293
    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);
    12931295        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());
    12941296        unsigned offset = m_expressionStack.size() - inlineSignature->argumentCount();
    12951297        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);
    12971299
    12981300        int64_t oldSize = m_expressionStack.size();
     
    13281330        if (m_currentOpcode == BrIf) {
    13291331            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);
    13311333        } else {
    13321334            m_unreachableBlocks = 1;
    1333             condition = TypedExpression { Void, Context::emptyExpression() };
     1335            condition = TypedExpression { Types::Void, Context::emptyExpression() };
    13341336        }
    13351337
     
    13621364
    13631365        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);
    13651367
    13661368        for (unsigned i = 0; i < targets.size(); ++i) {
     
    13681370            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());
    13691371            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());
    13711373        }
    13721374
     
    14271429        TypedExpression delta;
    14281430        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);
    14301432
    14311433        ExpressionType result;
    14321434        WASM_TRY_ADD_TO_CONTEXT(addGrowMemory(delta, result));
    1433         m_expressionStack.constructAndAppend(I32, result);
     1435        m_expressionStack.constructAndAppend(Types::I32, result);
    14341436
    14351437        return { };
     
    14451447        ExpressionType result;
    14461448        WASM_TRY_ADD_TO_CONTEXT(addCurrentMemory(result));
    1447         m_expressionStack.constructAndAppend(I32, result);
     1449        m_expressionStack.constructAndAppend(Types::I32, result);
    14481450
    14491451        return { };
  • trunk/Source/JavaScriptCore/wasm/WasmGlobal.cpp

    r273138 r273813  
    3838JSValue Global::get(JSGlobalObject* globalObject) const
    3939{
    40     switch (m_type) {
    41     case Wasm::Type::I32:
     40    switch (m_type.kind) {
     41    case TypeKind::I32:
    4242        return jsNumber(bitwise_cast<int32_t>(static_cast<uint32_t>(m_value.m_primitive)));
    43     case Wasm::Type::I64:
     43    case TypeKind::I64:
    4444        return JSBigInt::makeHeapBigIntOrBigInt32(globalObject, static_cast<int64_t>(m_value.m_primitive));
    45     case Wasm::Type::F32:
     45    case TypeKind::F32:
    4646        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:
    4848        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:
    5151        return m_value.m_externref.get();
    5252    default:
     
    6060    auto throwScope = DECLARE_THROW_SCOPE(vm);
    6161    ASSERT(m_mutability != Wasm::GlobalInformation::Immutable);
    62     switch (m_type) {
    63     case Wasm::Type::I32: {
     62    switch (m_type.kind) {
     63    case TypeKind::I32: {
    6464        int32_t value = argument.toInt32(globalObject);
    6565        RETURN_IF_EXCEPTION(throwScope, void());
     
    6767        break;
    6868    }
    69     case Wasm::Type::I64: {
     69    case TypeKind::I64: {
    7070        int64_t value = argument.toBigInt64(globalObject);
    7171        RETURN_IF_EXCEPTION(throwScope, void());
     
    7373        break;
    7474    }
    75     case Wasm::Type::F32: {
     75    case TypeKind::F32: {
    7676        float value = argument.toFloat(globalObject);
    7777        RETURN_IF_EXCEPTION(throwScope, void());
     
    7979        break;
    8080    }
    81     case Wasm::Type::F64: {
     81    case TypeKind::F64: {
    8282        double value = argument.toNumber(globalObject);
    8383        RETURN_IF_EXCEPTION(throwScope, void());
     
    8585        break;
    8686    }
    87     case Wasm::Externref: {
     87    case TypeKind::Externref: {
    8888        RELEASE_ASSERT(m_owner);
    8989        m_value.m_externref.set(m_owner->vm(), m_owner, argument);
    9090        break;
    9191    }
    92     case Wasm::Funcref: {
     92    case TypeKind::Funcref: {
    9393        RELEASE_ASSERT(m_owner);
    9494        if (!isWebAssemblyHostFunction(vm, argument) && !argument.isNull()) {
     
    107107void Global::visitAggregateImpl(Visitor& visitor)
    108108{
    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: {
    112112        RELEASE_ASSERT(m_owner);
    113113        visitor.append(m_value.m_externref);
  • trunk/Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp

    r272933 r273813  
    296296            m_codeBlock->m_constants.append(JSValue::encode(jsNull()));
    297297            if (UNLIKELY(Options::dumpGeneratedWasmBytecodes()))
    298                 m_codeBlock->m_constantTypes.append(Type::Externref);
     298                m_codeBlock->m_constantTypes.append(Types::Externref);
    299299        }
    300300        return m_jsNullConstant;
     
    307307            m_codeBlock->m_constants.append(0);
    308308            if (UNLIKELY(Options::dumpGeneratedWasmBytecodes()))
    309                 m_codeBlock->m_constantTypes.append(Type::I32);
     309                m_codeBlock->m_constantTypes.append(Types::I32);
    310310        }
    311311        return m_zeroConstant;
     
    535535
    536536    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:
    542542            if (gprIndex < gprCount)
    543543                ++gprIndex;
     
    545545                ++stackCount;
    546546            break;
    547         case Type::F32:
    548         case Type::F64:
     547        case TypeKind::F32:
     548        case TypeKind::F64:
    549549            if (fprIndex < fprCount)
    550550                ++fprIndex;
     
    552552                ++stackCount;
    553553            break;
    554         case Void:
    555         case Func:
     554        case TypeKind::Void:
     555        case TypeKind::Func:
    556556            RELEASE_ASSERT_NOT_REACHED();
    557557        }
     
    590590    fprIndex = gprIndex - gprCount;
    591591    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:
    597597            if (gprIndex > gprLimit)
    598598                arguments[i] = virtualRegisterForLocal(--gprIndex);
     
    600600                arguments[i] = virtualRegisterForLocal(--stackIndex);
    601601            break;
    602         case Type::F32:
    603         case Type::F64:
     602        case TypeKind::F32:
     603        case TypeKind::F64:
    604604            if (fprIndex > fprLimit)
    605605                arguments[i] = virtualRegisterForLocal(--fprIndex);
     
    607607                arguments[i] = virtualRegisterForLocal(--stackIndex);
    608608            break;
    609         case Void:
    610         case Func:
     609        case TypeKind::Void:
     610        case TypeKind::Func:
    611611            RELEASE_ASSERT_NOT_REACHED();
    612612        }
     
    617617    fprIndex = gprIndex - gprCount;
    618618    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:
    624624            if (gprIndex > gprLimit)
    625625                temporaryResults[i] = virtualRegisterForLocal(--gprIndex);
     
    627627                temporaryResults[i] = virtualRegisterForLocal(--stackIndex);
    628628            break;
    629         case Type::F32:
    630         case Type::F64:
     629        case TypeKind::F32:
     630        case TypeKind::F64:
    631631            if (fprIndex > fprLimit)
    632632                temporaryResults[i] = virtualRegisterForLocal(--fprIndex);
     
    634634                temporaryResults[i] = virtualRegisterForLocal(--stackIndex);
    635635            break;
    636         case Void:
    637         case Func:
     636        case TypeKind::Void:
     637        case TypeKind::Func:
    638638            RELEASE_ASSERT_NOT_REACHED();
    639639        }
     
    672672
    673673    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:
    679679            if (gprIndex < maxGPRIndex)
    680680                m_results.append(virtualRegisterForLocal(numberOfLLIntCalleeSaveRegisters + gprIndex++));
     
    682682                m_results.append(virtualRegisterForArgumentIncludingThis(stackIndex++));
    683683            break;
    684         case Type::F32:
    685         case Type::F64:
     684        case TypeKind::F32:
     685        case TypeKind::F64:
    686686            if (fprIndex < maxFPRIndex)
    687687                m_results.append(virtualRegisterForLocal(numberOfLLIntCalleeSaveRegisters + fprIndex++));
     
    689689                m_results.append(virtualRegisterForArgumentIncludingThis(stackIndex++));
    690690            break;
    691         case Void:
    692         case Func:
     691        case TypeKind::Void:
     692        case TypeKind::Func:
    693693            RELEASE_ASSERT_NOT_REACHED();
    694694        }
     
    726726
    727727    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:
    733733            addArgument(i, gprIndex, maxGPRIndex);
    734734            break;
    735         case Type::F32:
    736         case Type::F64:
     735        case TypeKind::F32:
     736        case TypeKind::F64:
    737737            addArgument(i, fprIndex, maxFPRIndex);
    738738            break;
    739         case Void:
    740         case Func:
     739        case TypeKind::Void:
     740        case TypeKind::Func:
    741741            RELEASE_ASSERT_NOT_REACHED();
    742742        }
     
    753753
    754754    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:
    758758        while (count--)
    759759            m_unitializedLocals.append(push(NoConsistencyCheck));
  • trunk/Source/JavaScriptCore/wasm/WasmOperations.cpp

    r271775 r273813  
    549549
    550550        uint64_t unboxedValue = 0;
    551         switch (signature->returnType(index)) {
    552         case I32:
     551        switch (signature->returnType(index).kind) {
     552        case TypeKind::I32:
    553553            unboxedValue = value.toInt32(globalObject);
    554554            break;
    555         case I64:
     555        case TypeKind::I64:
    556556            unboxedValue = value.toBigInt64(globalObject);
    557557            break;
    558         case F32:
     558        case TypeKind::F32:
    559559            unboxedValue = bitwise_cast<uint32_t>(value.toFloat(globalObject));
    560560            break;
    561         case F64:
     561        case TypeKind::F64:
    562562            unboxedValue = bitwise_cast<uint64_t>(value.toNumber(globalObject));
    563563            break;
    564         case Funcref:
     564        case TypeKind::Funcref:
    565565            if (!value.isCallable(vm)) {
    566566                throwTypeError(globalObject, scope, "Funcref value is not a function"_s);
     
    568568            }
    569569            FALLTHROUGH;
    570         case Externref:
     570        case TypeKind::Externref:
    571571            unboxedValue = bitwise_cast<uint64_t>(value);
    572572            RELEASE_ASSERT(Options::useWebAssemblyReferences());
  • trunk/Source/JavaScriptCore/wasm/WasmParser.h

    r271594 r273813  
    276276ALWAYS_INLINE typename Parser<SuccessType>::PartialResult Parser<SuccessType>::parseBlockSignature(const ModuleInformation& info, BlockSignature& result)
    277277{
    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");
    282282        result = m_signatureInformation.thunkFor(type);
    283283        m_offset++;
     
    299299ALWAYS_INLINE bool Parser<SuccessType>::parseValueType(Type& result)
    300300{
    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;
    307308    return true;
    308309}
  • trunk/Source/JavaScriptCore/wasm/WasmSectionParser.cpp

    r271141 r273813  
    5454
    5555        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);
    5757        WASM_PARSER_FAIL_IF(!parseVarUInt32(argumentCount), "can't get ", i, "th Type's argument count");
    5858        WASM_PARSER_FAIL_IF(argumentCount > maxFunctionParams, i, "th argument count is too big ", argumentCount, " maximum ", maxFunctionParams);
     
    207207    int8_t type;
    208208    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);
    210210
    211211    uint32_t initial;
     
    219219    ASSERT(!maximum || *maximum >= initial);
    220220
    221     TableElementType tableType = type == Wasm::Funcref ? TableElementType::Funcref : TableElementType::Externref;
     221    TableElementType tableType = type == static_cast<int8_t>(TypeKind::Funcref) ? TableElementType::Funcref : TableElementType::Externref;
    222222    m_info->tables.append(TableInformation(initial, maximum, isImport, tableType));
    223223
     
    305305        else
    306306            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);
    308308
    309309        if (initOpcode == RefFunc)
     
    486486            Type refType;
    487487            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");
    489489
    490490            uint32_t indexCount;
     
    510510            Type refType;
    511511            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");
    513513
    514514            uint32_t indexCount;
     
    528528            Type refType;
    529529            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");
    531531
    532532            uint32_t indexCount;
     
    564564        WASM_PARSER_FAIL_IF(!parseVarInt32(constant), "can't get constant value for init_expr's i32.const");
    565565        bitsOrImportNumber = static_cast<uint64_t>(constant);
    566         resultType = I32;
     566        resultType = Types::I32;
    567567        break;
    568568    }
     
    572572        WASM_PARSER_FAIL_IF(!parseVarInt64(constant), "can't get constant value for init_expr's i64.const");
    573573        bitsOrImportNumber = constant;
    574         resultType = I64;
     574        resultType = Types::I64;
    575575        break;
    576576    }
     
    580580        WASM_PARSER_FAIL_IF(!parseUInt32(constant), "can't get constant value for init_expr's f32.const");
    581581        bitsOrImportNumber = constant;
    582         resultType = F32;
     582        resultType = Types::F32;
    583583        break;
    584584    }
     
    588588        WASM_PARSER_FAIL_IF(!parseUInt64(constant), "can't get constant value for init_expr's f64.const");
    589589        bitsOrImportNumber = constant;
    590         resultType = F64;
     590        resultType = Types::F64;
    591591        break;
    592592    }
     
    618618        WASM_PARSER_FAIL_IF(index >= m_info->functions.size(), "ref.func index", index, " exceeds the number of functions ", m_info->functions.size());
    619619
    620         resultType = Funcref;
     620        resultType = Types::Funcref;
    621621        bitsOrImportNumber = index;
    622622        break;
     
    648648    Type initExprType;
    649649    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);
    651651    initExpr = makeI32InitExpr(initOpcode, initExprBits);
    652652
     
    694694            Type typeOfNull;
    695695            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");
    697697            functionIndex = Element::nullFuncIndex;
    698698        }
  • trunk/Source/JavaScriptCore/wasm/WasmSignature.cpp

    r261441 r273813  
    5353        CommaPrinter comma;
    5454        for (SignatureArgCount arg = 0; arg < argumentCount(); ++arg)
    55             out.print(comma, makeString(argument(arg)));
     55            out.print(comma, makeString(argument(arg).kind));
    5656        out.print(")");
    5757    }
     
    6161        out.print(" -> [");
    6262        for (SignatureArgCount ret = 0; ret < returnCount(); ++ret)
    63             out.print(comma, makeString(returnType(ret)));
     63            out.print(comma, makeString(returnType(ret).kind));
    6464        out.print("]");
    6565    }
     
    6969{
    7070    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    }
    7579    return accumulator;
    7680}
     
    96100#define MAKE_THUNK_SIGNATURE(type, enc, str, val)                          \
    97101    do {                                                                   \
    98         if (type != Void) {                                                \
     102        if (TypeKind::type != TypeKind::Void) {                            \
    99103            RefPtr<Signature> sig = Signature::tryCreate(1, 0);            \
    100104            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();    \
    103107            m_signatureSet.add(SignatureHash { sig.releaseNonNull() });    \
    104108        }                                                                  \
     
    111115        RefPtr<Signature> sig = Signature::tryCreate(0, 0);
    112116        sig->ref();
    113         thunkSignatures[linearizeType(Void)] = sig.get();
     117        thunkSignatures[linearizeType(TypeKind::Void)] = sig.get();
    114118        m_signatureSet.add(SignatureHash { sig.releaseNonNull() });
    115119    }
  • trunk/Source/JavaScriptCore/wasm/WasmSignature.h

    r273662 r273813  
    143143
    144144    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)]; }
    146146
    147147    static const Signature& get(SignatureIndex);
  • trunk/Source/JavaScriptCore/wasm/WasmTable.cpp

    r273138 r273813  
    181181{
    182182    if (isExternrefTable())
    183         return Type::Externref;
     183        return Types::Externref;
    184184    ASSERT(isFuncrefTable());
    185     return Type::Funcref;
     185    return Types::Funcref;
    186186}
    187187
  • trunk/Source/JavaScriptCore/wasm/generateWasmOpsHeader.py

    r272933 r273813  
    208208""" + type_definitions + """
    209209#define CREATE_ENUM_VALUE(name, id, ...) name = id,
    210 enum Type : int8_t {
     210enum class TypeKind : int8_t {
    211211    FOR_EACH_WASM_TYPE(CREATE_ENUM_VALUE)
    212212};
    213213#undef CREATE_ENUM_VALUE
     214
     215struct 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
     234namespace Types
     235{
     236#define CREATE_CONSTANT(name, id, ...) constexpr Type name = Type{TypeKind::name, 0u};
     237FOR_EACH_WASM_TYPE(CREATE_CONSTANT)
     238#undef CREATE_CONSTANT
     239} // namespace Types
    214240
    215241#define CREATE_CASE(name, id, ...) case id: return true;
    216242template <typename Int>
    217 inline bool isValidType(Int i)
     243inline bool isValidTypeKind(Int i)
    218244{
    219245    switch (i) {
     
    227253
    228254#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;
    230256inline B3::Type toB3Type(Type type)
    231257{
    232     switch (type) {
     258    switch (type.kind) {
    233259    FOR_EACH_WASM_TYPE(CREATE_CASE)
    234260    }
     
    239265#endif
    240266
    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;
     268inline const char* makeString(TypeKind kind)
     269{
     270    switch (kind) {
    245271    FOR_EACH_WASM_TYPE(CREATE_CASE)
    246272    }
     
    250276#undef CREATE_CASE
    251277
    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;
     279inline int linearizeType(TypeKind kind)
     280{
     281    switch (kind) {
    256282    FOR_EACH_WASM_TYPE(CREATE_CASE)
    257283    }
     
    261287#undef CREATE_CASE
    262288
    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;
     290inline TypeKind linearizedToType(int i)
    265291{
    266292    switch (i) {
     
    268294    }
    269295    RELEASE_ASSERT_NOT_REACHED();
    270     return Void;
     296    return TypeKind::Void;
    271297}
    272298#undef CREATE_CASE
     
    405431namespace WTF {
    406432
    407 inline void printInternal(PrintStream& out, JSC::Wasm::Type type)
    408 {
    409     out.print(JSC::Wasm::makeString(type));
     433inline void printInternal(PrintStream& out, JSC::Wasm::TypeKind kind)
     434{
     435    out.print(JSC::Wasm::makeString(kind));
    410436}
    411437
  • trunk/Source/JavaScriptCore/wasm/js/JSToWasm.cpp

    r271500 r273813  
    4141void marshallJSResult(CCallHelpers& jit, const Signature& signature, const CallInformation& wasmFrameConvention, const RegisterAtOffsetList& savedResultRegisters)
    4242{
    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:
    4646            jit.moveTrustedValue(jsUndefined(), dst);
    4747            break;
    48         case Wasm::Externref:
    49         case Wasm::Funcref:
     48        case TypeKind::Externref:
     49        case TypeKind::Funcref:
    5050            jit.move(src.gpr(), dst.payloadGPR());
    5151            break;
    52         case Wasm::I32:
     52        case TypeKind::I32:
    5353            jit.zeroExtend32ToWord(src.gpr(), dst.payloadGPR());
    5454            jit.boxInt32(dst.payloadGPR(), dst, DoNotHaveTagRegisters);
    5555            break;
    56         case Wasm::F32:
     56        case TypeKind::F32:
    5757            jit.convertFloatToDouble(src.fpr(), src.fpr());
    5858            FALLTHROUGH;
    59         case Wasm::F64: {
     59        case TypeKind::F64: {
    6060            jit.moveTrustedValue(jsNumber(pureNaN()), dst);
    6161            auto isNaN = jit.branchIfNaN(src.fpr());
     
    7373        jit.moveTrustedValue(jsUndefined(), JSValueRegs { GPRInfo::returnValueGPR });
    7474    else if (signature.returnCount() == 1) {
    75         if (signature.returnType(0) == Wasm::I64) {
     75        if (signature.returnType(0).isI64()) {
    7676            GPRReg inputGPR = wasmFrameConvention.results[0].reg().gpr();
    7777            GPRReg wasmContextInstanceGPR = PinnedRegisterInfo::get().wasmContextInstancePointer;
     
    9595            Type type = signature.returnType(i);
    9696
    97             hasI64 |= type == Wasm::I64;
     97            hasI64 |= type.isI64();
    9898            if (loc.isReg()) {
    99                 if (type != Wasm::I64) {
     99                if (!type.isI64()) {
    100100                    boxWasmResult(jit, signature.returnType(i), loc.reg(), scratch);
    101101                    jit.storeValue(scratch, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(loc.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes));
     
    103103                    jit.storeValue(JSValueRegs { loc.reg().gpr() }, CCallHelpers::Address(CCallHelpers::stackPointerRegister, savedResultRegisters.find(loc.reg())->offset() + wasmFrameConvention.headerAndArgumentStackSizeInBytes));
    104104            } else {
    105                 if (type != Wasm::I64) {
     105                if (!type.isI64()) {
    106106                    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());
    108108                    jit.load64ToReg(location, tmp);
    109109                    boxWasmResult(jit, signature.returnType(i), tmp, scratch);
     
    112112            }
    113113
    114             switch (type) {
    115             case Wasm::I32:
     114            switch (type.kind) {
     115            case TypeKind::I32:
    116116                indexingType = leastUpperBoundOfIndexingTypes(indexingType, ArrayWithInt32);
    117117                break;
    118             case Wasm::F32:
    119             case Wasm::F64:
     118            case TypeKind::F32:
     119            case TypeKind::F64:
    120120                indexingType = leastUpperBoundOfIndexingTypes(indexingType, ArrayWithDouble);
    121121                break;
     
    132132                ValueLocation loc = wasmFrameConvention.results[i];
    133133                Type type = signature.returnType(i);
    134                 if (type != Wasm::I64)
     134                if (!type.isI64())
    135135                    continue;
    136136
     
    239239            CCallHelpers::Address jsParam(GPRInfo::callFrameRegister, jsFrameConvention.params[i].offsetFromFP());
    240240            if (wasmFrameConvention.params[i].isStackArgument()) {
    241                 if (type == Wasm::I32 || type == Wasm::F32) {
     241                if (type.isI32() || type.isF32()) {
    242242                    jit.load32(jsParam, scratchReg);
    243243                    jit.store32(scratchReg, calleeFrame.withOffset(wasmFrameConvention.params[i].offsetFromSP()));
     
    247247                }
    248248            } else {
    249                 if (type == Wasm::I32 || type == Wasm::F32)
     249                if (type.isI32() || type.isF32())
    250250                    jit.load32ToReg(jsParam, wasmFrameConvention.params[i].reg());
    251251                else
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h

    r272071 r273813  
    139139{
    140140    ASSERT(Wasm::isRefType(type));
    141     if (type == Wasm::Type::Externref)
     141    if (type.isExternref())
    142142        return jsUndefined();
    143     ASSERT(type == Wasm::Type::Funcref);
     143    ASSERT(type.isFuncref());
    144144    return jsNull();
    145145}
  • trunk/Source/JavaScriptCore/wasm/js/WasmToJS.cpp

    r271168 r273813  
    102102        for (unsigned argNum = 0; argNum < argCount; ++argNum) {
    103103            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:
    107107                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: {
    112112                GPRReg gprReg;
    113113                if (marshalledGPRs < wasmCC.gprArgs.size())
     
    120120                }
    121121                ++marshalledGPRs;
    122                 if (argType == I32) {
     122                if (argType.isI32()) {
    123123                    jit.zeroExtend32ToWord(gprReg, gprReg); // Clear non-int32 and non-tag bits.
    124124                    jit.boxInt32(gprReg, JSValueRegs(gprReg), DoNotHaveTagRegisters);
     
    128128                break;
    129129            }
    130             case F32:
    131             case F64:
     130            case TypeKind::F32:
     131            case TypeKind::F64:
    132132                // Skipped: handled below.
    133133                if (marshalledFPRs >= wasmCC.fprArgs.size())
     
    174174        for (unsigned argNum = 0; argNum < argCount; ++argNum) {
    175175            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:
    179179                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: {
    184184                // Skipped: handled above.
    185185                if (marshalledGPRs >= wasmCC.gprArgs.size())
     
    189189                break;
    190190            }
    191             case F32: {
     191            case TypeKind::F32: {
    192192                FPRReg fprReg;
    193193                if (marshalledFPRs < wasmCC.fprArgs.size())
     
    203203                break;
    204204            }
    205             case F64: {
     205            case TypeKind::F64: {
    206206                FPRReg fprReg;
    207207                if (marshalledFPRs < wasmCC.fprArgs.size())
     
    227227        unsigned calleeFrameOffset = CallFrameSlot::firstArgument * static_cast<int>(sizeof(Register));
    228228        for (unsigned argNum = 0; argNum < argCount; ++argNum) {
    229             if (signature.argument(argNum) == I64) {
     229            if (signature.argument(argNum).isI64()) {
    230230                jit.loadWasmContextInstance(GPRInfo::argumentGPR0);
    231231                jit.load64(calleeFrame.withOffset(calleeFrameOffset), GPRInfo::argumentGPR1);
     
    275275
    276276    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:
    280280            // For the JavaScript embedding, imports with these types in their signature return are a WebAssembly.Module validation error.
    281281            RELEASE_ASSERT_NOT_REACHED();
    282282            break;
    283         case I64: {
     283        case TypeKind::I64: {
    284284            // FIXME: Optimize I64 extraction from BigInt.
    285285            // https://bugs.webkit.org/show_bug.cgi?id=220053
     
    295295            break;
    296296        }
    297         case I32: {
     297        case TypeKind::I32: {
    298298            CCallHelpers::JumpList done;
    299299            CCallHelpers::JumpList slowPath;
     
    318318            break;
    319319        }
    320         case Funcref:
    321         case Externref:
     320        case TypeKind::Funcref:
     321        case TypeKind::Externref:
    322322            jit.move(GPRInfo::returnValueGPR, wasmCallInfo.results[0].gpr());
    323323            break;
    324         case F32: {
     324        case TypeKind::F32: {
    325325            CCallHelpers::JumpList done;
    326326            FPRReg dest = wasmCallInfo.results[0].fpr();
     
    353353            break;
    354354        }
    355         case F64: {
     355        case TypeKind::F64: {
    356356            CCallHelpers::JumpList done;
    357357            FPRReg dest = wasmCallInfo.results[0].fpr();
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp

    r273138 r273813  
    8080    for (unsigned argIndex = 0; argIndex < signature.argumentCount(); ++argIndex) {
    8181        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:
    8484            arg = JSValue::decode(arg.toInt32(globalObject));
    8585            break;
    86         case Wasm::Funcref: {
     86        case Wasm::TypeKind::Funcref: {
    8787            if (!isWebAssemblyHostFunction(vm, arg) && !arg.isNull())
    8888                return JSValue::encode(throwException(globalObject, scope, createJSWebAssemblyRuntimeError(globalObject, vm, "Funcref must be an exported wasm function")));
    8989            break;
    9090        }
    91         case Wasm::Externref:
    92             break;
    93         case Wasm::I64:
     91        case Wasm::TypeKind::Externref:
     92            break;
     93        case Wasm::TypeKind::I64:
    9494            arg = JSValue::decode(bitwise_cast<uint64_t>(arg.toBigInt64(globalObject)));
    9595            break;
    96         case Wasm::F32:
     96        case Wasm::TypeKind::F32:
    9797            arg = JSValue::decode(bitwise_cast<uint32_t>(arg.toFloat(globalObject)));
    9898            break;
    99         case Wasm::F64:
     99        case Wasm::TypeKind::F64:
    100100            arg = JSValue::decode(bitwise_cast<uint64_t>(arg.toNumber(globalObject)));
    101101            break;
    102         case Wasm::Void:
    103         case Wasm::Func:
     102        case Wasm::TypeKind::Void:
     103        case Wasm::TypeKind::Func:
    104104            RELEASE_ASSERT_NOT_REACHED();
    105105        }
     
    261261
    262262        auto type = signature.argument(i);
    263         switch (type) {
    264         case Wasm::I32: {
     263        switch (type.kind) {
     264        case Wasm::TypeKind::I32: {
    265265            jit.load64(jsParam, scratchGPR);
    266266            slowPath.append(jit.branchIfNotInt32(scratchGPR));
     
    271271            break;
    272272        }
    273         case Wasm::Funcref: {
     273        case Wasm::TypeKind::Funcref: {
    274274            // Ensure we have a WASM exported function.
    275275            jit.load64(jsParam, scratchGPR);
     
    291291            FALLTHROUGH;
    292292        }
    293         case Wasm::Externref: {
     293        case Wasm::TypeKind::Externref: {
    294294            if (isStack) {
    295295                jit.load64(jsParam, scratchGPR);
     
    299299            break;
    300300        }
    301         case Wasm::F32:
    302         case Wasm::F64: {
     301        case Wasm::TypeKind::F32:
     302        case Wasm::TypeKind::F64: {
    303303            if (!isStack)
    304304                scratchFPR = wasmCallInfo.params[i].fpr();
    305305            auto moveToDestination = [&] () {
    306306                if (isStack) {
    307                     if (signature.argument(i) == Wasm::F32)
     307                    if (signature.argument(i).isF32())
    308308                        jit.storeFloat(scratchFPR, calleeFrame.withOffset(wasmCallInfo.params[i].offsetFromSP()));
    309309                    else
     
    317317
    318318            jit.unboxDouble(scratchGPR, scratchGPR, scratchFPR);
    319             if (signature.argument(i) == Wasm::F32)
     319            if (signature.argument(i).isF32())
    320320                jit.convertDoubleToFloat(scratchFPR, scratchFPR);
    321321            moveToDestination();
     
    323323
    324324            isInt32.link(&jit);
    325             if (signature.argument(i) == Wasm::F32) {
     325            if (signature.argument(i).isF32()) {
    326326                jit.convertInt32ToFloat(scratchGPR, scratchFPR);
    327327                moveToDestination();
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp

    r273661 r273813  
    8888        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    8989        if (valueString == "i32"_s)
    90             type = Wasm::Type::I32;
     90            type = Wasm::Types::I32;
    9191        else if (valueString == "i64"_s)
    92             type = Wasm::Type::I64;
     92            type = Wasm::Types::I64;
    9393        else if (valueString == "f32"_s)
    94             type = Wasm::Type::F32;
     94            type = Wasm::Types::F32;
    9595        else if (valueString == "f64"_s)
    96             type = Wasm::Type::F64;
     96            type = Wasm::Types::F64;
    9797        else if (Options::useWebAssemblyReferences() && (valueString == "anyfunc"_s || valueString == "funcref"_s))
    98             type = Wasm::Type::Funcref;
     98            type = Wasm::Types::Funcref;
    9999        else if (Options::useWebAssemblyReferences() && valueString == "externref"_s)
    100             type = Wasm::Type::Externref;
     100            type = Wasm::Types::Externref;
    101101        else
    102102            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)));
     
    105105    uint64_t initialValue = 0;
    106106    JSValue argument = callFrame->argument(1);
    107     switch (type) {
    108     case Wasm::Type::I32: {
     107    switch (type.kind) {
     108    case Wasm::TypeKind::I32: {
    109109        if (!argument.isUndefined()) {
    110110            int32_t value = argument.toInt32(globalObject);
     
    114114        break;
    115115    }
    116     case Wasm::Type::I64: {
     116    case Wasm::TypeKind::I64: {
    117117        if (!argument.isUndefined()) {
    118118            int64_t value = argument.toBigInt64(globalObject);
     
    122122        break;
    123123    }
    124     case Wasm::Type::F32: {
     124    case Wasm::TypeKind::F32: {
    125125        if (!argument.isUndefined()) {
    126126            float value = argument.toFloat(globalObject);
     
    130130        break;
    131131    }
    132     case Wasm::Type::F64: {
     132    case Wasm::TypeKind::F64: {
    133133        if (!argument.isUndefined()) {
    134134            double value = argument.toNumber(globalObject);
     
    138138        break;
    139139    }
    140     case Wasm::Type::Funcref: {
     140    case Wasm::TypeKind::Funcref: {
    141141        ASSERT(Options::useWebAssemblyReferences());
    142142        if (argument.isUndefined())
     
    149149        break;
    150150    }
    151     case Wasm::Type::Externref: {
     151    case Wasm::TypeKind::Externref: {
    152152        ASSERT(Options::useWebAssemblyReferences());
    153153        if (argument.isUndefined())
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp

    r273225 r273813  
    247247                    if (globalValue->global()->mutability() != Wasm::GlobalInformation::Immutable)
    248248                        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:
    251251                        value = globalValue->global()->get(globalObject);
    252252                        RETURN_IF_EXCEPTION(scope, void());
     
    255255                        m_instance->instance().setGlobal(import.kindIndex, value);
    256256                        break;
    257                     case Wasm::Externref:
     257                    case Wasm::TypeKind::Externref:
    258258                        value = globalValue->global()->get(globalObject);
    259259                        RETURN_IF_EXCEPTION(scope, void());
    260260                        m_instance->instance().setGlobal(import.kindIndex, value);
    261261                        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:
    266266                        m_instance->instance().setGlobal(import.kindIndex, globalValue->global()->getPrimitive());
    267267                        break;
     
    273273                    if (!isRefType(globalType)) {
    274274                        // 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()) {
    276276                            if (!value.isBigInt())
    277277                                return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "must be a BigInt")));
     
    283283
    284284                    // iii. Append ToWebAssemblyValue(v) to imports.
    285                     switch (globalType) {
    286                     case Wasm::Funcref:
     285                    switch (globalType.kind) {
     286                    case Wasm::TypeKind::Funcref:
    287287                        if (!isWebAssemblyHostFunction(vm, value) && !value.isNull())
    288288                            return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported global", "must be a wasm exported function or null")));
    289289                        m_instance->instance().setGlobal(import.kindIndex, value);
    290290                        break;
    291                     case Wasm::Externref:
     291                    case Wasm::TypeKind::Externref:
    292292                        m_instance->instance().setGlobal(import.kindIndex, value);
    293293                        break;
    294                     case Wasm::I32:
     294                    case Wasm::TypeKind::I32:
    295295                        m_instance->instance().setGlobal(import.kindIndex, value.toInt32(globalObject));
    296296                        break;
    297                     case Wasm::I64: {
     297                    case Wasm::TypeKind::I64: {
    298298                        int64_t bits = value.toBigInt64(globalObject);
    299299                        RETURN_IF_EXCEPTION(scope, void());
     
    301301                        break;
    302302                    }
    303                     case Wasm::F32:
     303                    case Wasm::TypeKind::F32:
    304304                        m_instance->instance().setGlobal(import.kindIndex, bitwise_cast<uint32_t>(value.toFloat(globalObject)));
    305305                        break;
    306                     case Wasm::F64:
     306                    case Wasm::TypeKind::F64:
    307307                        m_instance->instance().setGlobal(import.kindIndex, bitwise_cast<uint64_t>(value.asNumber()));
    308308                        break;
     
    488488        case Wasm::ExternalKind::Global: {
    489489            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: {
    497497                // If global is immutable, we are not creating a binding internally.
    498498                // 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.