Bläddra i källkod

Cleanup integer type usage in WasmReader project,
- use `int32` not `INT`,`int`,`INT32`,`long`
- use `uint32` not `UINT`,`uint`,`UINT32`,`unsigned int`,`unsigned long`
- use `int64` not `INT64`,`long long`
- use `uint64` not `UINT64`,`unsigned long long`

Michael Ferris 8 år sedan
förälder
incheckning
a2b53ecd43

+ 2 - 2
lib/WasmReader/EmptyWasmByteCodeWriter.h

@@ -32,8 +32,8 @@ namespace Js
         virtual void AsmBrReg1(OpCodeAsmJs op, ByteCodeLabel labelID, RegSlot R1) override {}
         virtual void AsmBrReg1Const1(OpCodeAsmJs op, ByteCodeLabel labelID, RegSlot R1, int C1) override {}
         virtual void WasmMemAccess(OpCodeAsmJs op, RegSlot value, uint32 slotIndex, uint32 offset, ArrayBufferView::ViewType viewType) override {}
-        virtual uint EnterLoop(ByteCodeLabel loopEntrance) override {return 0;}
-        virtual void ExitLoop(uint loopId) override {}
+        virtual uint32 EnterLoop(ByteCodeLabel loopEntrance) override {return 0;}
+        virtual void ExitLoop(uint32 loopId) override {}
         virtual void AsmStartCall(OpCodeAsmJs op, ArgSlot ArgCount, bool isPatching = false) override {}
         virtual void AsmCall(OpCodeAsmJs op, RegSlot returnValueRegister, RegSlot functionRegister, ArgSlot givenArgCount, AsmJsRetType retType) override {}
     };

+ 49 - 49
lib/WasmReader/WasmBinaryReader.cpp

@@ -19,7 +19,7 @@ namespace WasmTypes
 bool IsLocalType(WasmTypes::WasmType type)
 {
     // Check if type in range ]Void,Limit[
-    return (uint)(type - 1) < (WasmTypes::Limit - 1);
+    return (uint32)(type - 1) < (WasmTypes::Limit - 1);
 }
 
 uint32 GetTypeByteSize(WasmType type)
@@ -203,7 +203,7 @@ WasmBinaryReader::ReadSectionHeader()
     header.start = m_pc;
     header.code = bSectLimit;
 
-    UINT len = 0;
+    uint32 len = 0;
     CompileAssert(sizeof(SectionCode) == sizeof(uint8));
     SectionCode sectionId = (SectionCode)ReadVarUInt7();
 
@@ -212,7 +212,7 @@ WasmBinaryReader::ReadSectionHeader()
         ThrowDecodingError(_u("Invalid known section opcode %u"), sectionId);
     }
 
-    UINT32 sectionSize = LEB128(len);
+    uint32 sectionSize = LEB128(len);
     header.end = m_pc + sectionSize;
     CheckBytesLeft(sectionSize);
 
@@ -460,8 +460,8 @@ WasmBinaryReader::ValidateModuleHeader()
         ThrowDecodingError(_u("Module too big"));
     }
 
-    uint32 magicNumber = ReadConst<UINT32>();
-    uint32 version = ReadConst<UINT32>();
+    uint32 magicNumber = ReadConst<uint32>();
+    uint32 version = ReadConst<uint32>();
     TRACE_WASM_DECODER(_u("Module Header: Magic 0x%x, Version %u"), magicNumber, version);
     if (magicNumber != 0x6d736100)
     {
@@ -485,9 +485,9 @@ WasmBinaryReader::ValidateModuleHeader()
 void
 WasmBinaryReader::CallNode()
 {
-    UINT length = 0;
+    uint32 length = 0;
 
-    UINT32 funcNum = LEB128(length);
+    uint32 funcNum = LEB128(length);
     m_funcState.count += length;
     FunctionIndexTypes::Type funcType = m_module->GetFunctionIndexType(funcNum);
     if (funcType == FunctionIndexTypes::Invalid)
@@ -501,9 +501,9 @@ WasmBinaryReader::CallNode()
 void
 WasmBinaryReader::CallIndirectNode()
 {
-    UINT length = 0;
+    uint32 length = 0;
 
-    UINT32 funcNum = LEB128(length);
+    uint32 funcNum = LEB128(length);
     // Reserved value currently unused
     ReadConst<uint8>();
     if (!m_module->HasTable() && !m_module->HasTableImport())
@@ -531,7 +531,7 @@ void WasmBinaryReader::BlockNode()
 void
 WasmBinaryReader::BrNode()
 {
-    UINT len = 0;
+    uint32 len = 0;
     m_currentNode.br.depth = LEB128(len);
     m_funcState.count += len;
 }
@@ -539,16 +539,16 @@ WasmBinaryReader::BrNode()
 void
 WasmBinaryReader::BrTableNode()
 {
-    UINT len = 0;
+    uint32 len = 0;
     m_currentNode.brTable.numTargets = LEB128(len);
     if (m_currentNode.brTable.numTargets > Limits::GetMaxBrTableElems())
     {
         ThrowDecodingError(_u("br_table too big"));
     }
     m_funcState.count += len;
-    m_currentNode.brTable.targetTable = AnewArray(m_alloc, UINT32, m_currentNode.brTable.numTargets);
+    m_currentNode.brTable.targetTable = AnewArray(m_alloc, uint32, m_currentNode.brTable.numTargets);
 
-    for (UINT32 i = 0; i < m_currentNode.brTable.numTargets; i++)
+    for (uint32 i = 0; i < m_currentNode.brTable.numTargets; i++)
     {
         m_currentNode.brTable.targetTable[i] = LEB128(len);
         m_funcState.count += len;
@@ -560,7 +560,7 @@ WasmBinaryReader::BrTableNode()
 void
 WasmBinaryReader::MemNode()
 {
-    uint len = 0;
+    uint32 len = 0;
 
     // flags
     const uint32 flags = LEB128(len);
@@ -575,7 +575,7 @@ WasmBinaryReader::MemNode()
 void
 WasmBinaryReader::VarNode()
 {
-    UINT length;
+    uint32 length;
     m_currentNode.var.num = LEB128(length);
     m_funcState.count += length;
 }
@@ -584,7 +584,7 @@ WasmBinaryReader::VarNode()
 template <WasmTypes::WasmType localType>
 void WasmBinaryReader::ConstNode()
 {
-    UINT len = 0;
+    uint32 len = 0;
     switch (localType)
     {
     case WasmTypes::I32:
@@ -592,7 +592,7 @@ void WasmBinaryReader::ConstNode()
         m_funcState.count += len;
         break;
     case WasmTypes::I64:
-        m_currentNode.cnst.i64 = SLEB128<INT64>(len);
+        m_currentNode.cnst.i64 = SLEB128<int64>(len);
         m_funcState.count += len;
         break;
     case WasmTypes::F32:
@@ -622,8 +622,8 @@ WasmBinaryReader::EndOfModule()
 void
 WasmBinaryReader::ReadMemorySection(bool isImportSection)
 {
-    UINT length = 0;
-    UINT32 count;
+    uint32 length = 0;
+    uint32 count;
     if (isImportSection)
     {
         count = 1;
@@ -669,11 +669,11 @@ WasmBinaryReader::ReadSignatureTypeSection()
         }
 
         uint32 paramCount32 = LEB128(len);
-        if (paramCount > Limits::GetMaxFunctionParams())
+        if (paramCount > Limits::GetMaxFunctionParams() || paramCount > UINT16_MAX)
         {
             ThrowDecodingError(_u("Too many arguments in signature"));
         }
-        WasmTypes::WasmType type;
+
         Js::ArgSlot paramCount = (Js::ArgSlot)paramCount32;
         sig->AllocateParams(paramCount, m_module->GetRecycler());
         for (Js::ArgSlot j = 0; j < paramCount; j++)
@@ -699,7 +699,7 @@ WasmBinaryReader::ReadSignatureTypeSection()
 void
 WasmBinaryReader::ReadFunctionSignatures()
 {
-    UINT len = 0;
+    uint32 len = 0;
     uint32 nFunctions = LEB128(len);
 
     uint32 totalFunctions = 0;
@@ -901,7 +901,7 @@ WasmBinaryReader::ReadElementSection()
 void
 WasmBinaryReader::ReadDataSection()
 {
-    UINT len = 0;
+    uint32 len = 0;
     const uint32 numSegments = LEB128(len);
     if (numSegments > Limits::GetMaxDataSegments())
     {
@@ -915,7 +915,7 @@ WasmBinaryReader::ReadDataSection()
 
     for (uint32 i = 0; i < numSegments; ++i)
     {
-        UINT32 index = LEB128(len);
+        uint32 index = LEB128(len);
         if (index != 0 || !(m_module->HasMemory() || m_module->HasMemoryImport()))
         {
             ThrowDecodingError(_u("Unknown memory index %u"), index);
@@ -923,8 +923,8 @@ WasmBinaryReader::ReadDataSection()
         TRACE_WASM_DECODER(_u("Data Segment #%u"), i);
         WasmNode initExpr = ReadInitExpr(true);
 
-        //UINT32 offset = initExpr.cnst.i32;
-        UINT32 dataByteLen = LEB128(len);
+        //uint32 offset = initExpr.cnst.i32;
+        uint32 dataByteLen = LEB128(len);
         WasmDataSegment *dseg = Anew(m_alloc, WasmDataSegment, m_alloc, initExpr, dataByteLen, m_pc);
         CheckBytesLeft(dataByteLen);
         m_pc += dataByteLen;
@@ -935,28 +935,28 @@ WasmBinaryReader::ReadDataSection()
 void
 WasmBinaryReader::ReadNameSection()
 {
-    UINT len = 0;
-    UINT numFuncNames = LEB128(len);
+    uint32 len = 0;
+    uint32 numFuncNames = LEB128(len);
 
     if (numFuncNames > Limits::GetMaxFunctions())
     {
         ThrowDecodingError(_u("Too many function names"));
     }
 
-    for (UINT i = 0; i < numFuncNames; ++i)
+    for (uint32 i = 0; i < numFuncNames; ++i)
     {
-        UINT fnNameLen = 0;
+        uint32 fnNameLen = 0;
         WasmFunctionInfo* funsig = m_module->GetWasmFunctionInfo(i);
         const char16* name = ReadInlineName(len, fnNameLen);
         funsig->SetName(name, fnNameLen);
-        UINT numLocals = LEB128(len);
+        uint32 numLocals = LEB128(len);
         if (numLocals != funsig->GetLocalCount())
         {
             ThrowDecodingError(_u("num locals mismatch in names section"));
         }
-        for (UINT j = 0; j < numLocals; ++j)
+        for (uint32 j = 0; j < numLocals; ++j)
         {
-            UINT localNameLen = 0;
+            uint32 localNameLen = 0;
             ReadInlineName(len, localNameLen);
         }
     }
@@ -965,8 +965,8 @@ WasmBinaryReader::ReadNameSection()
 void
 WasmBinaryReader::ReadGlobalSection()
 {
-    UINT len = 0;
-    UINT numGlobals = LEB128(len);
+    uint32 len = 0;
+    uint32 numGlobals = LEB128(len);
 
     uint32 totalGlobals = 0;
     if (UInt32Math::Add(numGlobals, m_module->GetGlobalCount(), &totalGlobals) || totalGlobals > Limits::GetMaxGlobals())
@@ -974,7 +974,7 @@ WasmBinaryReader::ReadGlobalSection()
         ThrowDecodingError(_u("Too many globals"));
     }
 
-    for (UINT i = 0; i < numGlobals; ++i)
+    for (uint32 i = 0; i < numGlobals; ++i)
     {
         WasmTypes::WasmType type = ReadWasmType(len);
         bool isMutable = ReadMutableValue();
@@ -1024,7 +1024,7 @@ WasmBinaryReader::ReadCustomSection()
 const char16*
 WasmBinaryReader::ReadInlineName(uint32& length, uint32& nameLength)
 {
-    uint rawNameLength = LEB128(length);
+    uint32 rawNameLength = LEB128(length);
     if (rawNameLength > Limits::GetMaxStringSize())
     {
         ThrowDecodingError(_u("Name too long"));
@@ -1131,16 +1131,16 @@ WasmBinaryReader::ReadStartFunction()
 
 template<typename MaxAllowedType>
 MaxAllowedType
-WasmBinaryReader::LEB128(UINT &length, bool sgn)
+WasmBinaryReader::LEB128(uint32 &length, bool sgn)
 {
     MaxAllowedType result = 0;
-    uint shamt = 0;
+    uint32 shamt = 0;
     byte b = 0;
     length = 1;
-    uint maxReads = sizeof(MaxAllowedType) == 4 ? 5 : 10;
+    uint32 maxReads = sizeof(MaxAllowedType) == 4 ? 5 : 10;
     CompileAssert(sizeof(MaxAllowedType) == 4 || sizeof(MaxAllowedType) == 8);
 
-    for (uint i = 0; i < maxReads; i++, length++)
+    for (uint32 i = 0; i < maxReads; i++, length++)
     {
         CheckBytesLeft(1);
         b = *m_pc++;
@@ -1193,20 +1193,20 @@ WasmBinaryReader::LEB128(UINT &length, bool sgn)
 
 // Signed LEB128
 template<>
-INT
-WasmBinaryReader::SLEB128(UINT &length)
+int32
+WasmBinaryReader::SLEB128(uint32 &length)
 {
-    INT result = LEB128<UINT>(length, true);
+    int32 result = LEB128<uint32>(length, true);
 
     TRACE_WASM_LEB128(_u("Binary decoder: SLEB128 length = %u, value = %d (0x%x)"), length, result, result);
     return result;
 }
 
 template<>
-INT64
-WasmBinaryReader::SLEB128(UINT &length)
+int64
+WasmBinaryReader::SLEB128(uint32 &length)
 {
-    INT64 result = LEB128<UINT64>(length, true);
+    int64 result = LEB128<uint64>(length, true);
 
     TRACE_WASM_LEB128(_u("Binary decoder: SLEB128 length = %u, value = %lld (0x%llx)"), length, result, result);
     return result;
@@ -1318,9 +1318,9 @@ WasmBinaryReader::ReadWasmType(uint32& length)
 }
 
 void
-WasmBinaryReader::CheckBytesLeft(UINT bytesNeeded)
+WasmBinaryReader::CheckBytesLeft(uint32 bytesNeeded)
 {
-    UINT bytesLeft = (UINT)(m_end - m_pc);
+    uint32 bytesLeft = (uint32)(m_end - m_pc);
     if (bytesNeeded > bytesLeft)
     {
         ThrowDecodingError(_u("Out of file: Needed: %d, Left: %d"), bytesNeeded, bytesLeft);

+ 8 - 8
lib/WasmReader/WasmBinaryReader.h

@@ -35,7 +35,7 @@ namespace Wasm
         uint32 maximum;
     };
 
-    static const unsigned int binaryVersion = 0x1;
+    static const uint32 binaryVersion = 0x1;
 
     class WasmBinaryReader : public WasmReaderBase
     {
@@ -57,7 +57,7 @@ namespace Wasm
     private:
         struct ReaderState
         {
-            UINT32 count; // current entry
+            uint32 count; // current entry
             size_t size;  // number of entries
         };
 
@@ -92,21 +92,21 @@ namespace Wasm
         uint8 ReadVarUInt7();
         bool ReadMutableValue();
         const char16* ReadInlineName(uint32& length, uint32& nameLength);
-        template<typename MaxAllowedType = UINT>
-        MaxAllowedType LEB128(UINT &length, bool sgn = false);
-        template<typename MaxAllowedType = INT>
-        MaxAllowedType SLEB128(UINT &length);
+        template<typename MaxAllowedType = uint32>
+        MaxAllowedType LEB128(uint32 &length, bool sgn = false);
+        template<typename MaxAllowedType = int32>
+        MaxAllowedType SLEB128(uint32 &length);
         WasmNode ReadInitExpr(bool isOffset = false);
         SectionLimits ReadSectionLimits(uint32 maxInitial, uint32 maxMaximum, const char16* errorMsg);
 
-        void CheckBytesLeft(UINT bytesNeeded);
+        void CheckBytesLeft(uint32 bytesNeeded);
         bool EndOfFunc();
         bool EndOfModule();
         DECLSPEC_NORETURN void ThrowDecodingError(const char16* msg, ...);
         Wasm::WasmTypes::WasmType ReadWasmType(uint32& length);
 
         ArenaAllocator* m_alloc;
-        uint m_funcNumber;
+        uint32 m_funcNumber;
         const byte* m_start, *m_end, *m_pc, *m_curFuncEnd;
         SectionHeader m_currentSection;
         ReaderState m_funcState;   // func AST level

+ 30 - 30
lib/WasmReader/WasmByteCodeGenerator.cpp

@@ -11,8 +11,8 @@
 #include "EmptyWasmByteCodeWriter.h"
 
 #if DBG_DUMP
-uint opId = 0;
-uint lastOpId = 1;
+uint32 opId = 0;
+uint32 lastOpId = 1;
 #define DebugPrintOp(op) if (PHASE_TRACE(Js::WasmReaderPhase, GetFunctionBody())) { PrintOpBegin(op); }
 #define DebugPrintOpEnd() if (PHASE_TRACE(Js::WasmReaderPhase, GetFunctionBody())) { PrintOpEnd(); }
 #else
@@ -196,7 +196,7 @@ WasmModuleGenerator::GenerateModule()
         Assert(info->GetBody());
         if (PHASE_TRACE(Js::WasmInOutPhase, info->GetBody()))
         {
-            uint index = m_module->GetWasmFunctionCount();
+            uint32 index = m_module->GetWasmFunctionCount();
             WasmFunctionInfo* newInfo = m_module->AddWasmFunctionInfo(info->GetSignature());
             if (!firstThunk)
             {
@@ -330,7 +330,7 @@ WasmModuleGenerator::GenerateFunctionHeader(uint32 index)
     info->SetWasmSignature(wasmInfo->GetSignature());
     Js::ArgSlot argSizeLength = max(paramCount, 3ui16);
     info->SetArgSizeArrayLength(argSizeLength);
-    uint* argSizeArray = RecyclerNewArrayLeafZ(m_recycler, uint, argSizeLength);
+    uint32* argSizeArray = RecyclerNewArrayLeafZ(m_recycler, uint32, argSizeLength);
     info->SetArgsSizesArray(argSizeArray);
 
     if (paramCount > 0)
@@ -394,7 +394,7 @@ WasmBytecodeGenerator::WasmBytecodeGenerator(Js::ScriptContext* scriptContext, W
     GetReader()->SeekToFunctionBody(m_funcInfo);
 
     // Use binary size to estimate bytecode size
-    const long astSize = readerInfo->m_funcInfo->m_readerInfo.size;
+    const uint32 astSize = readerInfo->m_funcInfo->m_readerInfo.size;
     m_writer->InitData(&m_alloc, astSize);
 }
 
@@ -463,7 +463,7 @@ WasmBytecodeGenerator::EnregisterLocals()
     m_locals = AnewArray(&m_alloc, WasmLocal, nLocals);
 
     m_funcInfo->GetBody()->SetFirstTmpReg(nLocals);
-    for (uint i = 0; i < nLocals; ++i)
+    for (uint32 i = 0; i < nLocals; ++i)
     {
         WasmTypes::WasmType type = m_funcInfo->GetLocal(i);
         WasmRegisterSpace * regSpace = GetRegisterSpace(type);
@@ -640,7 +640,7 @@ WasmBytecodeGenerator::EmitExpr(WasmOp op)
 EmitInfo
 WasmBytecodeGenerator::EmitGetGlobal()
 {
-    uint globalIndex = GetReader()->m_currentNode.var.num;
+    uint32 globalIndex = GetReader()->m_currentNode.var.num;
     WasmGlobal* global = m_module->GetGlobal(globalIndex);
 
     WasmTypes::WasmType type = global->GetType();
@@ -670,7 +670,7 @@ WasmBytecodeGenerator::EmitGetGlobal()
 EmitInfo
 WasmBytecodeGenerator::EmitSetGlobal()
 {
-    uint globalIndex = GetReader()->m_currentNode.var.num;
+    uint32 globalIndex = GetReader()->m_currentNode.var.num;
     WasmGlobal* global = m_module->GetGlobal(globalIndex);
     Js::RegSlot slot = m_module->GetOffsetForGlobal(global);
 
@@ -699,7 +699,7 @@ WasmBytecodeGenerator::EmitSetGlobal()
 EmitInfo
 WasmBytecodeGenerator::EmitGetLocal()
 {
-    uint localIndex = GetReader()->m_currentNode.var.num;
+    uint32 localIndex = GetReader()->m_currentNode.var.num;
     if (m_funcInfo->GetLocalCount() <= localIndex)
     {
         throw WasmCompilationException(_u("%u is not a valid local"), localIndex);
@@ -720,7 +720,7 @@ WasmBytecodeGenerator::EmitGetLocal()
 EmitInfo
 WasmBytecodeGenerator::EmitSetLocal(bool tee)
 {
-    uint localNum = GetReader()->m_currentNode.var.num;
+    uint32 localNum = GetReader()->m_currentNode.var.num;
     if (localNum >= m_funcInfo->GetLocalCount())
     {
         throw WasmCompilationException(_u("%u is not a valid local"), localNum);
@@ -846,7 +846,7 @@ WasmBytecodeGenerator::EmitLoop()
     Js::ByteCodeLabel loopHeadLabel = m_writer->DefineLabel();
     Js::ByteCodeLabel loopLandingPadLabel = m_writer->DefineLabel();
 
-    uint loopId = m_writer->EnterLoop(loopHeadLabel);
+    uint32 loopId = m_writer->EnterLoop(loopHeadLabel);
 
     // Internally we create a block for loop to exit, but semantically, they don't exist so pop it
     BlockInfo implicitBlockInfo = PushLabel(loopTailLabel);
@@ -877,8 +877,8 @@ template<WasmOp wasmOp>
 EmitInfo
 WasmBytecodeGenerator::EmitCall()
 {
-    uint funcNum = Js::Constants::UninitializedValue;
-    uint signatureId = Js::Constants::UninitializedValue;
+    uint32 funcNum = Js::Constants::UninitializedValue;
+    uint32 signatureId = Js::Constants::UninitializedValue;
     WasmSignature * calleeSignature = nullptr;
     EmitInfo indirectIndexInfo;
     const bool isImportCall = GetReader()->m_currentNode.call.funcType == FunctionIndexTypes::Import;
@@ -1057,7 +1057,7 @@ WasmBytecodeGenerator::EmitCall()
     // track stack requirements for out params
 
     // + 1 for return address
-    uint maxDepthForLevel = args + 1;
+    uint32 maxDepthForLevel = args + 1;
     if (maxDepthForLevel > m_maxArgOutDepth)
     {
         m_maxArgOutDepth = maxDepthForLevel;
@@ -1104,9 +1104,9 @@ WasmBytecodeGenerator::EmitIfElseExpr()
 void
 WasmBytecodeGenerator::EmitBrTable()
 {
-    const uint numTargets = GetReader()->m_currentNode.brTable.numTargets;
-    const UINT* targetTable = GetReader()->m_currentNode.brTable.targetTable;
-    const UINT defaultEntry = GetReader()->m_currentNode.brTable.defaultTarget;
+    const uint32 numTargets = GetReader()->m_currentNode.brTable.numTargets;
+    const uint32* targetTable = GetReader()->m_currentNode.brTable.targetTable;
+    const uint32 defaultEntry = GetReader()->m_currentNode.brTable.defaultTarget;
 
     // Compile scrutinee
     EmitInfo scrutineeInfo = PopEvalStack(WasmTypes::I32, _u("br_table expression must be of type i32"));
@@ -1128,9 +1128,9 @@ WasmBytecodeGenerator::EmitBrTable()
 
 
     // Compile cases
-    for (uint i = 0; i < numTargets; i++)
+    for (uint32 i = 0; i < numTargets; i++)
     {
-        uint target = targetTable[i];
+        uint32 target = targetTable[i];
         YieldToBlock(target, yieldInfo);
         Js::ByteCodeLabel targetLabel = GetLabel(target);
         m_writer->AsmBrReg1Const1(Js::OpCodeAsmJs::Case_IntConst, targetLabel, scrutineeInfo.location, i);
@@ -1213,8 +1213,8 @@ WasmBytecodeGenerator::EmitMemAccess(WasmOp wasmOp, const WasmTypes::WasmType* s
     SetUsesMemory(0);
 
     const uint32 mask = Js::ArrayBufferView::ViewMask[viewType];
-    const uint alignment = GetReader()->m_currentNode.mem.alignment;
-    const uint offset = GetReader()->m_currentNode.mem.offset;
+    const uint32 alignment = GetReader()->m_currentNode.mem.alignment;
+    const uint32 offset = GetReader()->m_currentNode.mem.offset;
 
     if ((mask << 1) & (1 << alignment))
     {
@@ -1323,7 +1323,7 @@ WasmBytecodeGenerator::EmitSelect()
 void
 WasmBytecodeGenerator::EmitBr()
 {
-    UINT depth = GetReader()->m_currentNode.br.depth;
+    uint32 depth = GetReader()->m_currentNode.br.depth;
 
     if (ShouldYieldToBlock(depth))
     {
@@ -1341,7 +1341,7 @@ WasmBytecodeGenerator::EmitBr()
 EmitInfo
 WasmBytecodeGenerator::EmitBrIf()
 {
-    UINT depth = GetReader()->m_currentNode.br.depth;
+    uint32 depth = GetReader()->m_currentNode.br.depth;
 
     EmitInfo conditionInfo = PopEvalStack(WasmTypes::I32, _u("br_if condition must have i32 type"));
     ReleaseLocation(&conditionInfo);
@@ -1471,7 +1471,7 @@ WasmBytecodeGenerator::PushLabel(Js::ByteCodeLabel label, bool addBlockYieldInfo
 }
 
 void
-WasmBytecodeGenerator::YieldToBlock(uint relativeDepth, EmitInfo expr)
+WasmBytecodeGenerator::YieldToBlock(uint32 relativeDepth, EmitInfo expr)
 {
     BlockInfo blockInfo = GetBlockInfo(relativeDepth);
     YieldToBlock(blockInfo, expr);
@@ -1497,15 +1497,15 @@ void WasmBytecodeGenerator::YieldToBlock(BlockInfo blockInfo, EmitInfo expr)
 }
 
 bool
-WasmBytecodeGenerator::ShouldYieldToBlock(uint relativeDepth) const
+WasmBytecodeGenerator::ShouldYieldToBlock(uint32 relativeDepth) const
 {
     return GetBlockInfo(relativeDepth).HasYield();
 }
 
 Wasm::BlockInfo
-WasmBytecodeGenerator::GetBlockInfo(uint relativeDepth) const
+WasmBytecodeGenerator::GetBlockInfo(uint32 relativeDepth) const
 {
-    if (relativeDepth >= (uint)m_blockInfos.Count())
+    if (relativeDepth >= (uint32)m_blockInfos.Count())
     {
         throw WasmCompilationException(_u("Invalid branch target"));
     }
@@ -1513,7 +1513,7 @@ WasmBytecodeGenerator::GetBlockInfo(uint relativeDepth) const
 }
 
 Js::ByteCodeLabel
-WasmBytecodeGenerator::GetLabel(uint relativeDepth)
+WasmBytecodeGenerator::GetLabel(uint32 relativeDepth)
 {
     return GetBlockInfo(relativeDepth).label;
 }
@@ -1595,7 +1595,7 @@ void WasmBytecodeGenerator::SetUnreachableState(bool isUnreachable)
     {
         // Replace the current stack with the any type
         Assert(!m_evalStack.Empty());
-        uint popped = 0;
+        uint32 popped = 0;
         while (m_evalStack.Top().type != WasmTypes::Limit)
         {
             EmitInfo info = m_evalStack.Pop();
@@ -1611,7 +1611,7 @@ void WasmBytecodeGenerator::SetUnreachableState(bool isUnreachable)
 }
 
 void
-WasmBytecodeGenerator::SetUsesMemory(uint memoryIndex)
+WasmBytecodeGenerator::SetUsesMemory(uint32 memoryIndex)
 {
     // Only support one memory at this time
     Assert(memoryIndex == 0);

+ 7 - 7
lib/WasmReader/WasmByteCodeGenerator.h

@@ -131,7 +131,7 @@ namespace Wasm
         bool HasYield() const { return yieldInfo != nullptr; }
     };
 
-    typedef JsUtil::BaseDictionary<uint, LPCUTF8, ArenaAllocator> WasmExportDictionary;
+    typedef JsUtil::BaseDictionary<uint32, LPCUTF8, ArenaAllocator> WasmExportDictionary;
 
     struct WasmReaderInfo
     {
@@ -215,10 +215,10 @@ namespace Wasm
         EmitInfo PopLabel(Js::ByteCodeLabel labelValidation);
         BlockInfo PushLabel(Js::ByteCodeLabel label, bool addBlockYieldInfo = true);
         void YieldToBlock(BlockInfo blockInfo, EmitInfo expr);
-        void YieldToBlock(uint relativeDepth, EmitInfo expr);
-        bool ShouldYieldToBlock(uint relativeDepth) const;
-        BlockInfo GetBlockInfo(uint relativeDepth) const;
-        Js::ByteCodeLabel GetLabel(uint relativeDepth);
+        void YieldToBlock(uint32 relativeDepth, EmitInfo expr);
+        bool ShouldYieldToBlock(uint32 relativeDepth) const;
+        BlockInfo GetBlockInfo(uint32 relativeDepth) const;
+        Js::ByteCodeLabel GetLabel(uint32 relativeDepth);
 
         Js::OpCodeAsmJs GetLoadOp(WasmTypes::WasmType type);
         Js::OpCodeAsmJs GetReturnOp(WasmTypes::WasmType type);
@@ -232,7 +232,7 @@ namespace Wasm
         void ExitEvalStackScope();
         void SetUnreachableState(bool isUnreachable);
         bool IsUnreachable() const { return this->isUnreachable; }
-        void SetUsesMemory(uint memoryIndex);
+        void SetUsesMemory(uint32 memoryIndex);
 
         Js::FunctionBody* GetFunctionBody() const { return m_funcInfo->GetBody(); }
         WasmReaderBase* GetReader() const;
@@ -247,7 +247,7 @@ namespace Wasm
         WasmFunctionInfo* m_funcInfo;
         Js::WebAssemblyModule* m_module;
 
-        uint m_maxArgOutDepth;
+        uint32 m_maxArgOutDepth;
 
         Js::IWasmByteCodeWriter* m_writer;
         Js::IWasmByteCodeWriter* m_emptyWriter;

+ 6 - 6
lib/WasmReader/WasmElementSegment.cpp

@@ -9,7 +9,7 @@
 
 namespace Wasm
 {
-    WasmElementSegment::WasmElementSegment(ArenaAllocator * alloc, const UINT32 index, const WasmNode initExpr, const UINT32 numElem) :
+    WasmElementSegment::WasmElementSegment(ArenaAllocator * alloc, const uint32 index, const WasmNode initExpr, const uint32 numElem) :
         m_alloc(alloc),
         m_index(index),
         m_offsetExpr(initExpr),
@@ -23,12 +23,12 @@ namespace Wasm
     WasmElementSegment::Init(const Js::WebAssemblyModule& module)
     {
         Assert(m_numElem > 0);
-        m_elems = AnewArray(m_alloc, UINT32, m_numElem);
-        memset(m_elems, Js::Constants::UninitializedValue, m_numElem * sizeof(UINT32));
+        m_elems = AnewArray(m_alloc, uint32, m_numElem);
+        memset(m_elems, Js::Constants::UninitializedValue, m_numElem * sizeof(uint32));
     }
 
     void
-    WasmElementSegment::AddElement(const UINT32 funcIndex, const Js::WebAssemblyModule& module)
+    WasmElementSegment::AddElement(const uint32 funcIndex, const Js::WebAssemblyModule& module)
     {
         if (m_elems == nullptr)
         {
@@ -38,8 +38,8 @@ namespace Wasm
         m_elems[m_elemIdx++] = funcIndex;
     }
 
-    UINT32
-    WasmElementSegment::GetElement(const UINT32 tableIndex) const
+    uint32
+    WasmElementSegment::GetElement(const uint32 tableIndex) const
     {
         Assert(m_elems != nullptr);
         return m_elems[tableIndex];

+ 9 - 9
lib/WasmReader/WasmElementSegment.h

@@ -11,19 +11,19 @@ namespace Wasm
     class WasmElementSegment
     {
     public:
-        WasmElementSegment(ArenaAllocator * alloc, const UINT32 index, const WasmNode initExpr, const UINT32 numElem);
-        void AddElement(const UINT32 funcIndex, const Js::WebAssemblyModule& module);
-        UINT32 GetElement(const UINT32 tableIndex) const;
-        UINT32 GetNumElements() const { return m_numElem; }
+        WasmElementSegment(ArenaAllocator * alloc, const uint32 index, const WasmNode initExpr, const uint32 numElem);
+        void AddElement(const uint32 funcIndex, const Js::WebAssemblyModule& module);
+        uint32 GetElement(const uint32 tableIndex) const;
+        uint32 GetNumElements() const { return m_numElem; }
         WasmNode GetOffsetExpr() const { return m_offsetExpr; }
     private:
         ArenaAllocator* m_alloc;
-        UINT32 m_index;
+        uint32 m_index;
         const WasmNode m_offsetExpr;
-        UINT32 m_numElem;
-        UINT32 m_offset;
-        UINT32 m_elemIdx;
-        UINT32* m_elems;
+        uint32 m_numElem;
+        uint32 m_offset;
+        uint32 m_elemIdx;
+        uint32* m_elems;
 
         void Init(const Js::WebAssemblyModule& module);
     };

+ 3 - 3
lib/WasmReader/WasmFunctionInfo.cpp

@@ -30,16 +30,16 @@ WasmFunctionInfo::WasmFunctionInfo(ArenaAllocator * alloc, WasmSignature* signat
 }
 
 void
-WasmFunctionInfo::AddLocal(WasmTypes::WasmType type, uint count)
+WasmFunctionInfo::AddLocal(WasmTypes::WasmType type, uint32 count)
 {
-    for (uint i = 0; i < count; ++i)
+    for (uint32 i = 0; i < count; ++i)
     {
         m_locals.Add(Wasm::Local(type));
     }
 }
 
 Local
-WasmFunctionInfo::GetLocal(uint index) const
+WasmFunctionInfo::GetLocal(uint32 index) const
 {
     if (index < GetLocalCount())
     {

+ 2 - 2
lib/WasmReader/WasmFunctionInfo.h

@@ -12,8 +12,8 @@ namespace Wasm
     public:
         WasmFunctionInfo(ArenaAllocator* alloc, WasmSignature* signature, uint32 number);
 
-        void AddLocal(WasmTypes::WasmType type, uint count = 1);
-        Local GetLocal(uint index) const;
+        void AddLocal(WasmTypes::WasmType type, uint32 count = 1);
+        Local GetLocal(uint32 index) const;
         WasmTypes::WasmType GetResultType() const;
 
         uint32 GetLocalCount() const;

+ 3 - 3
lib/WasmReader/WasmGlobal.h

@@ -10,7 +10,7 @@ namespace Wasm
     class WasmGlobal
     {
     public:
-        WasmGlobal(GlobalReferenceTypes::Type refType, uint offset, WasmTypes::WasmType type, bool isMutable, WasmNode init) :
+        WasmGlobal(GlobalReferenceTypes::Type refType, uint32 offset, WasmTypes::WasmType type, bool isMutable, WasmNode init) :
             m_rType(refType),
             m_offset(offset),
             m_type(type),
@@ -19,7 +19,7 @@ namespace Wasm
         {};
         WasmTypes::WasmType GetType() const { return m_type; }
         bool IsMutable() const { return m_isMutable; }
-        uint GetOffset() const { return m_offset; }
+        uint32 GetOffset() const { return m_offset; }
         GlobalReferenceTypes::Type GetReferenceType() const { return m_rType; }
 
         WasmConstLitNode GetConstInit() const;
@@ -28,7 +28,7 @@ namespace Wasm
         GlobalReferenceTypes::Type m_rType;
         WasmTypes::WasmType m_type;
         bool m_isMutable;
-        uint m_offset;
+        uint32 m_offset;
         WasmNode m_init;
     };
 } // namespace Wasm

+ 1 - 1
lib/WasmReader/WasmParseTree.h

@@ -82,7 +82,7 @@ namespace Wasm
 
     struct WasmVarNode
     {
-        uint num;
+        uint32 num;
         union
         {
             LPCUTF8 exportName;

+ 1 - 1
lib/WasmReader/WasmSignature.h

@@ -29,7 +29,7 @@ public:
     bool IsEquivalent(const WasmSignature* sig) const;
     static WasmSignature * FromIDL(WasmSignatureIDL* sig);
 
-    static uint GetOffsetOfShortSig() { return offsetof(WasmSignature, m_shortSig); }
+    static uint32 GetOffsetOfShortSig() { return offsetof(WasmSignature, m_shortSig); }
 
     uint32 WriteSignatureToString(_Out_writes_(maxlen) char16 *out, uint32 maxlen);
     void Dump();