Title: [280233] releases/WebKitGTK/webkit-2.32/Source/_javascript_Core
Revision
280233
Author
[email protected]
Date
2021-07-23 02:00:00 -0700 (Fri, 23 Jul 2021)

Log Message

Merge r276609 - numCalleeLocals, numParameters, and numVars should be unsigned
https://bugs.webkit.org/show_bug.cgi?id=224995

Patch by Keith Miller <[email protected]> on 2021-04-26
Reviewed by Mark Lam.

All of the various CodeBlock classes currently have the
numCalleeLocals and numVars marked as ints. I believe this is just
a historical artifact or because VirtualRegister's offset is an
int to make handling constants easier. Regardless, it's a bit
strange to not handle the sign conversion at the point of
comparison between a VirtualRegister offset and the local/var
count. This doesn't completely fix every place we use ints for
these values but starts on the right track. Lastly, I also added
some Check<unsigned>s to the wasm parser for sanity checking.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::setNumParameters):
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndexSlow):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::numParameters const):
(JSC::CodeBlock::numberOfArgumentsToSkip const):
(JSC::CodeBlock::numCalleeLocals const):
(JSC::CodeBlock::numVars const):
(JSC::CodeBlock::numTmps const):
(JSC::CodeBlock::addressOfNumParameters):
(JSC::CodeBlock::isTemporaryRegister):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedCodeBlock::numCalleeLocals const):
(JSC::UnlinkedCodeBlock::numVars const):
* bytecode/UnlinkedCodeBlockGenerator.h:
(JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const):
(JSC::UnlinkedCodeBlockGenerator::numVars const):
(JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals):
(JSC::UnlinkedCodeBlockGenerator::setNumVars):
(JSC::UnlinkedCodeBlockGenerator::setNumParameters):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::emitPushFunctionNameScope):
* bytecompiler/BytecodeGeneratorBaseInlines.h:
(JSC::BytecodeGeneratorBase<Traits>::newRegister):
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::handleRecursiveTailCall):
(JSC::DFG::ByteCodeParser::inliningCost):
(JSC::DFG::ByteCodeParser::parseBlock):
* dfg/DFGOSREntrypointCreationPhase.cpp:
(JSC::DFG::OSREntrypointCreationPhase::run):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::checkArgumentTypes):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::lower):
* ftl/FTLOSREntry.cpp:
(JSC::FTL::prepareOSREntry):
* interpreter/CallFrameClosure.h:
* interpreter/ProtoCallFrameInlines.h:
(JSC::ProtoCallFrame::init):
* jit/JIT.cpp:
(JSC::JIT::compileWithoutLinking):
* runtime/CommonSlowPaths.h:
(JSC::CommonSlowPaths::numberOfStackPaddingSlots):
(JSC::CommonSlowPaths::numberOfStackPaddingSlotsWithExtraSlots):
* wasm/WasmFunctionCodeBlock.h:
(JSC::Wasm::FunctionCodeBlock::numVars const):
(JSC::Wasm::FunctionCodeBlock::numCalleeLocals const):
(JSC::Wasm::FunctionCodeBlock::setNumVars):
(JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::push):
(JSC::Wasm::LLIntGenerator::getDropKeepCount):
(JSC::Wasm::LLIntGenerator::walkExpressionStack):
(JSC::Wasm::LLIntGenerator::checkConsistency):
(JSC::Wasm::LLIntGenerator::materializeConstantsAndLocals):
(JSC::Wasm::LLIntGenerator::splitStack):
(JSC::Wasm::LLIntGenerator::finalize):
(JSC::Wasm::LLIntGenerator::callInformationForCaller):
(JSC::Wasm::LLIntGenerator::addLoop):
(JSC::Wasm::LLIntGenerator::addTopLevel):
(JSC::Wasm::LLIntGenerator::addBlock):
(JSC::Wasm::LLIntGenerator::addIf):
(JSC::Wasm::LLIntGenerator::addElseToUnreachable):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ChangeLog (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ChangeLog	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ChangeLog	2021-07-23 09:00:00 UTC (rev 280233)
@@ -1,3 +1,85 @@
+2021-04-26  Keith Miller  <[email protected]>
+
+        numCalleeLocals, numParameters, and numVars should be unsigned
+        https://bugs.webkit.org/show_bug.cgi?id=224995
+
+        Reviewed by Mark Lam.
+
+        All of the various CodeBlock classes currently have the
+        numCalleeLocals and numVars marked as ints. I believe this is just
+        a historical artifact or because VirtualRegister's offset is an
+        int to make handling constants easier. Regardless, it's a bit
+        strange to not handle the sign conversion at the point of
+        comparison between a VirtualRegister offset and the local/var
+        count. This doesn't completely fix every place we use ints for
+        these values but starts on the right track. Lastly, I also added
+        some Check<unsigned>s to the wasm parser for sanity checking.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::setNumParameters):
+        (JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndexSlow):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::numParameters const):
+        (JSC::CodeBlock::numberOfArgumentsToSkip const):
+        (JSC::CodeBlock::numCalleeLocals const):
+        (JSC::CodeBlock::numVars const):
+        (JSC::CodeBlock::numTmps const):
+        (JSC::CodeBlock::addressOfNumParameters):
+        (JSC::CodeBlock::isTemporaryRegister):
+        * bytecode/UnlinkedCodeBlock.h:
+        (JSC::UnlinkedCodeBlock::numCalleeLocals const):
+        (JSC::UnlinkedCodeBlock::numVars const):
+        * bytecode/UnlinkedCodeBlockGenerator.h:
+        (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const):
+        (JSC::UnlinkedCodeBlockGenerator::numVars const):
+        (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals):
+        (JSC::UnlinkedCodeBlockGenerator::setNumVars):
+        (JSC::UnlinkedCodeBlockGenerator::setNumParameters):
+        * bytecompiler/BytecodeGenerator.cpp:
+        (JSC::BytecodeGenerator::generate):
+        (JSC::BytecodeGenerator::emitPushFunctionNameScope):
+        * bytecompiler/BytecodeGeneratorBaseInlines.h:
+        (JSC::BytecodeGeneratorBase<Traits>::newRegister):
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::handleRecursiveTailCall):
+        (JSC::DFG::ByteCodeParser::inliningCost):
+        (JSC::DFG::ByteCodeParser::parseBlock):
+        * dfg/DFGOSREntrypointCreationPhase.cpp:
+        (JSC::DFG::OSREntrypointCreationPhase::run):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::checkArgumentTypes):
+        * ftl/FTLLowerDFGToB3.cpp:
+        (JSC::FTL::DFG::LowerDFGToB3::lower):
+        * ftl/FTLOSREntry.cpp:
+        (JSC::FTL::prepareOSREntry):
+        * interpreter/CallFrameClosure.h:
+        * interpreter/ProtoCallFrameInlines.h:
+        (JSC::ProtoCallFrame::init):
+        * jit/JIT.cpp:
+        (JSC::JIT::compileWithoutLinking):
+        * runtime/CommonSlowPaths.h:
+        (JSC::CommonSlowPaths::numberOfStackPaddingSlots):
+        (JSC::CommonSlowPaths::numberOfStackPaddingSlotsWithExtraSlots):
+        * wasm/WasmFunctionCodeBlock.h:
+        (JSC::Wasm::FunctionCodeBlock::numVars const):
+        (JSC::Wasm::FunctionCodeBlock::numCalleeLocals const):
+        (JSC::Wasm::FunctionCodeBlock::setNumVars):
+        (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals):
+        * wasm/WasmLLIntGenerator.cpp:
+        (JSC::Wasm::LLIntGenerator::push):
+        (JSC::Wasm::LLIntGenerator::getDropKeepCount):
+        (JSC::Wasm::LLIntGenerator::walkExpressionStack):
+        (JSC::Wasm::LLIntGenerator::checkConsistency):
+        (JSC::Wasm::LLIntGenerator::materializeConstantsAndLocals):
+        (JSC::Wasm::LLIntGenerator::splitStack):
+        (JSC::Wasm::LLIntGenerator::finalize):
+        (JSC::Wasm::LLIntGenerator::callInformationForCaller):
+        (JSC::Wasm::LLIntGenerator::addLoop):
+        (JSC::Wasm::LLIntGenerator::addTopLevel):
+        (JSC::Wasm::LLIntGenerator::addBlock):
+        (JSC::Wasm::LLIntGenerator::addIf):
+        (JSC::Wasm::LLIntGenerator::addElseToUnreachable):
+
 2021-04-23  Michael Saboff  <[email protected]>
 
         [YARR Interpreter] Improper backtrack of parentheses with non-zero based greedy quantifiers

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/CodeBlock.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/CodeBlock.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/CodeBlock.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -945,7 +945,7 @@
     m_alternative.set(vm, this, alternative);
 }
 
-void CodeBlock::setNumParameters(int newValue)
+void CodeBlock::setNumParameters(unsigned newValue)
 {
     m_numParameters = newValue;
 
@@ -2051,7 +2051,7 @@
         liveOperands.append(virtualRegisterForLocal(liveLocal));
     });
 
-    for (int i = 0; i < numParameters(); ++i)
+    for (unsigned i = 0; i < numParameters(); ++i)
         liveOperands.append(virtualRegisterForArgumentIncludingThis(i));
 
     auto profiles = makeUnique<ValueProfileAndVirtualRegisterBuffer>(liveOperands.size());

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/CodeBlock.h (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/CodeBlock.h	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/CodeBlock.h	2021-07-23 09:00:00 UTC (rev 280233)
@@ -156,17 +156,17 @@
 
     MetadataTable* metadataTable() const { return m_metadata.get(); }
 
-    int numParameters() const { return m_numParameters; }
-    void setNumParameters(int newValue);
+    unsigned numParameters() const { return m_numParameters; }
+    void setNumParameters(unsigned newValue);
 
-    int numberOfArgumentsToSkip() const { return m_numberOfArgumentsToSkip; }
+    unsigned numberOfArgumentsToSkip() const { return m_numberOfArgumentsToSkip; }
 
-    int numCalleeLocals() const { return m_numCalleeLocals; }
+    unsigned numCalleeLocals() const { return m_numCalleeLocals; }
 
-    int numVars() const { return m_numVars; }
-    int numTmps() const { return m_unlinkedCode->hasCheckpoints() * maxNumCheckpointTmps; }
+    unsigned numVars() const { return m_numVars; }
+    unsigned numTmps() const { return m_unlinkedCode->hasCheckpoints() * maxNumCheckpointTmps; }
 
-    int* addressOfNumParameters() { return &m_numParameters; }
+    unsigned* addressOfNumParameters() { return &m_numParameters; }
     static ptrdiff_t offsetOfNumParameters() { return OBJECT_OFFSETOF(CodeBlock, m_numParameters); }
 
     CodeBlock* alternative() const { return static_cast<CodeBlock*>(m_alternative.get()); }
@@ -243,7 +243,7 @@
 
     ALWAYS_INLINE bool isTemporaryRegister(VirtualRegister reg)
     {
-        return reg.offset() >= m_numVars;
+        return reg.offset() >= static_cast<int>(m_numVars);
     }
 
     HandlerInfo* handlerForBytecodeIndex(BytecodeIndex, RequiredHandler = RequiredHandler::AnyHandler);
@@ -996,10 +996,10 @@
     void insertBasicBlockBoundariesForControlFlowProfiler();
     void ensureCatchLivenessIsComputedForBytecodeIndexSlow(const OpCatch&, BytecodeIndex);
 
-    int m_numCalleeLocals;
-    int m_numVars;
-    int m_numParameters;
-    int m_numberOfArgumentsToSkip { 0 };
+    unsigned m_numCalleeLocals;
+    unsigned m_numVars;
+    unsigned m_numParameters;
+    unsigned m_numberOfArgumentsToSkip { 0 };
     unsigned m_numberOfNonArgumentValueProfiles { 0 };
     union {
         unsigned m_debuggerRequests;

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h	2021-07-23 09:00:00 UTC (rev 280233)
@@ -179,8 +179,8 @@
 
     const InstructionStream& instructions() const;
 
-    int numCalleeLocals() const { return m_numCalleeLocals; }
-    int numVars() const { return m_numVars; }
+    unsigned numCalleeLocals() const { return m_numCalleeLocals; }
+    unsigned numVars() const { return m_numVars; }
 
     // Jump Tables
 
@@ -366,9 +366,9 @@
     unsigned m_lineCount { 0 };
     unsigned m_endColumn { UINT_MAX };
 
-    int m_numVars { 0 };
-    int m_numCalleeLocals { 0 };
-    int m_numParameters { 0 };
+    unsigned m_numVars { 0 };
+    unsigned m_numCalleeLocals { 0 };
+    unsigned m_numParameters { 0 };
 
     PackedRefPtr<StringImpl> m_sourceURLDirective;
     PackedRefPtr<StringImpl> m_sourceMappingURLDirective;

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/UnlinkedCodeBlockGenerator.h (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/UnlinkedCodeBlockGenerator.h	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecode/UnlinkedCodeBlockGenerator.h	2021-07-23 09:00:00 UTC (rev 280233)
@@ -58,8 +58,8 @@
     EvalContextType evalContextType() const { return m_codeBlock->evalContextType(); }
     bool isArrowFunctionContext() const { return m_codeBlock->isArrowFunctionContext(); }
     bool isClassContext() const { return m_codeBlock->isClassContext(); }
-    int numCalleeLocals() const { return m_codeBlock->m_numCalleeLocals; }
-    int numVars() const { return m_codeBlock->m_numVars; }
+    unsigned numCalleeLocals() const { return m_codeBlock->m_numCalleeLocals; }
+    unsigned numVars() const { return m_codeBlock->m_numVars; }
     unsigned numParameters() const { return m_codeBlock->numParameters(); }
     VirtualRegister thisRegister() const { return m_codeBlock->thisRegister(); }
     VirtualRegister scopeRegister() const { return m_codeBlock->scopeRegister(); }
@@ -70,11 +70,11 @@
     // Updating UnlinkedCodeBlock.
     void setHasCheckpoints() { m_codeBlock->setHasCheckpoints(); }
     void setHasTailCalls() { m_codeBlock->setHasTailCalls(); }
-    void setNumCalleeLocals(int numCalleeLocals) { m_codeBlock->m_numCalleeLocals = numCalleeLocals; }
-    void setNumVars(int numVars) { m_codeBlock->m_numVars = numVars; }
+    void setNumCalleeLocals(unsigned numCalleeLocals) { m_codeBlock->m_numCalleeLocals = numCalleeLocals; }
+    void setNumVars(unsigned numVars) { m_codeBlock->m_numVars = numVars; }
     void setThisRegister(VirtualRegister thisRegister) { m_codeBlock->setThisRegister(thisRegister); }
     void setScopeRegister(VirtualRegister thisRegister) { m_codeBlock->setScopeRegister(thisRegister); }
-    void setNumParameters(int newValue) { m_codeBlock->setNumParameters(newValue); }
+    void setNumParameters(unsigned newValue) { m_codeBlock->setNumParameters(newValue); }
 
     UnlinkedMetadataTable& metadata() { return m_codeBlock->metadata(); }
     void addExpressionInfo(unsigned instructionOffset, int divot, int startOffset, int endOffset, unsigned line, unsigned column);

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -283,7 +283,7 @@
     if (m_isAsync)
         performGeneratorification(*this, m_codeBlock.get(), m_writer, m_generatorFrameSymbolTable.get(), m_generatorFrameSymbolTableIndex);
 
-    RELEASE_ASSERT(static_cast<unsigned>(m_codeBlock->numCalleeLocals()) < static_cast<unsigned>(FirstConstantRegisterIndex));
+    RELEASE_ASSERT(m_codeBlock->numCalleeLocals() < static_cast<unsigned>(FirstConstantRegisterIndex));
     m_codeBlock->finalize(m_writer.finalize());
     if (m_expressionTooDeep)
         return ParserError(ParserError::OutOfMemory);
@@ -4000,7 +4000,7 @@
     addResult.iterator->value.setIsConst(); // The function name scope name acts like a const variable.
     unsigned numVars = m_codeBlock->numVars();
     pushLexicalScopeInternal(nameScopeEnvironment, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, TDZRequirement::NotUnderTDZ, ScopeType::FunctionNameScope, ScopeRegisterType::Var);
-    ASSERT_UNUSED(numVars, m_codeBlock->numVars() == static_cast<int>(numVars + 1)); // Should have only created one new "var" for the function name scope.
+    ASSERT_UNUSED(numVars, m_codeBlock->numVars() == numVars + 1); // Should have only created one new "var" for the function name scope.
     bool shouldTreatAsLexicalVariable = ecmaMode().isStrict();
     Variable functionVar = variableForLocalEntry(property, m_lexicalScopeStack.last().m_symbolTable->get(NoLockingNecessary, property.impl()), m_lexicalScopeStack.last().m_symbolTableConstantIndex, shouldTreatAsLexicalVariable);
     emitPutToScope(m_lexicalScopeStack.last().m_scope, functionVar, callee, ThrowIfNotFound, InitializationMode::NotInitialization);

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecompiler/BytecodeGeneratorBaseInlines.h (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecompiler/BytecodeGeneratorBaseInlines.h	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/bytecompiler/BytecodeGeneratorBaseInlines.h	2021-07-23 09:00:00 UTC (rev 280233)
@@ -161,9 +161,10 @@
 RegisterID* BytecodeGeneratorBase<Traits>::newRegister()
 {
     m_calleeLocals.append(virtualRegisterForLocal(m_calleeLocals.size()));
-    int numCalleeLocals = std::max<int>(m_codeBlock->numCalleeLocals(), m_calleeLocals.size());
+    size_t numCalleeLocals = std::max<size_t>(m_codeBlock->numCalleeLocals(), m_calleeLocals.size());
     numCalleeLocals = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), numCalleeLocals);
-    m_codeBlock->setNumCalleeLocals(numCalleeLocals);
+    m_codeBlock->setNumCalleeLocals(static_cast<unsigned>(numCalleeLocals));
+    RELEASE_ASSERT(numCalleeLocals == m_codeBlock->numCalleeLocals());
     return &m_calleeLocals.last();
 }
 

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -1497,7 +1497,7 @@
 
             // Some code may statically use the argument count from the InlineCallFrame, so it would be invalid to loop back if it does not match.
             // We "continue" instead of returning false in case another stack entry further on the stack has the right number of arguments.
-            if (argumentCountIncludingThis != static_cast<int>(callFrame->argumentCountIncludingThis))
+            if (argumentCountIncludingThis != callFrame->argumentCountIncludingThis)
                 continue;
             // If the target InlineCallFrame is Varargs, we do not know how many arguments are actually filled by LoadVarargs. Varargs InlineCallFrame's
             // argumentCountIncludingThis is maximum number of potentially filled arguments by xkLoadVarargs. We "continue" to the upper frame which may be
@@ -1507,7 +1507,7 @@
         } else {
             // We are in the machine code entry (i.e. the original caller).
             // If we have more arguments than the number of parameters to the function, it is not clear where we could put them on the stack.
-            if (argumentCountIncludingThis > m_codeBlock->numParameters())
+            if (static_cast<unsigned>(argumentCountIncludingThis) > m_codeBlock->numParameters())
                 return false;
         }
 
@@ -1533,8 +1533,8 @@
         // We must set the arguments to the right values
         if (!stackEntry->m_inlineCallFrame)
             addToGraph(SetArgumentCountIncludingThis, OpInfo(argumentCountIncludingThis));
-        int argIndex = 0;
-        for (; argIndex < argumentCountIncludingThis; ++argIndex) {
+        unsigned argIndex = 0;
+        for (; argIndex < static_cast<unsigned>(argumentCountIncludingThis); ++argIndex) {
             Node* value = get(virtualRegisterForArgumentIncludingThis(argIndex, registerOffset));
             setDirect(stackEntry->remapOperand(virtualRegisterForArgumentIncludingThis(argIndex)), value, NormalSet);
         }
@@ -1544,7 +1544,7 @@
 
         // We must repeat the work of op_enter here as we will jump right after it.
         // We jump right after it and not before it, because of some invariant saying that a CFG root cannot have predecessors in the IR.
-        for (int i = 0; i < stackEntry->m_codeBlock->numVars(); ++i)
+        for (unsigned i = 0; i < stackEntry->m_codeBlock->numVars(); ++i)
             setDirect(stackEntry->remapOperand(virtualRegisterForLocal(i)), undefined, NormalSet);
 
         // We want to emit the SetLocals with an exit origin that points to the place we are jumping to.
@@ -1600,7 +1600,7 @@
     }
 
     if (!Options::useArityFixupInlining()) {
-        if (codeBlock->numParameters() > argumentCountIncludingThis) {
+        if (codeBlock->numParameters() > static_cast<unsigned>(argumentCountIncludingThis)) {
             VERBOSE_LOG("    Failing because of arity mismatch.\n");
             return UINT_MAX;
         }
@@ -5372,7 +5372,7 @@
         case op_enter: {
             Node* undefined = addToGraph(JSConstant, OpInfo(m_constantUndefined));
             // Initialize all locals to undefined.
-            for (int i = 0; i < m_inlineStackTop->m_codeBlock->numVars(); ++i)
+            for (unsigned i = 0; i < m_inlineStackTop->m_codeBlock->numVars(); ++i)
                 set(virtualRegisterForLocal(i), undefined, ImmediateNakedSet);
 
             NEXT_OPCODE(op_enter);

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGOSREntrypointCreationPhase.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGOSREntrypointCreationPhase.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGOSREntrypointCreationPhase.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -94,7 +94,7 @@
         NodeOrigin origin = NodeOrigin(CodeOrigin(BytecodeIndex(0)), CodeOrigin(BytecodeIndex(0)), false);
         
         Vector<Node*> locals(baseline->numCalleeLocals());
-        for (int local = 0; local < baseline->numCalleeLocals(); ++local) {
+        for (unsigned local = 0; local < baseline->numCalleeLocals(); ++local) {
             Node* previousHead = target->variablesAtHead.local(local);
             if (!previousHead)
                 continue;
@@ -113,7 +113,7 @@
         origin = target->at(0)->origin;
         
         ArgumentsVector newArguments = m_graph.m_rootToArguments.find(m_graph.block(0))->value;
-        for (int argument = 0; argument < baseline->numParameters(); ++argument) {
+        for (unsigned argument = 0; argument < baseline->numParameters(); ++argument) {
             Node* oldNode = target->variablesAtHead.argument(argument);
             if (!oldNode) {
                 // Just for sanity, always have a SetArgumentDefinitely even if it's not needed.
@@ -125,7 +125,7 @@
             newArguments[argument] = node;
         }
 
-        for (int local = 0; local < baseline->numCalleeLocals(); ++local) {
+        for (unsigned local = 0; local < baseline->numCalleeLocals(); ++local) {
             Node* previousHead = target->variablesAtHead.local(local);
             if (!previousHead)
                 continue;

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -2079,7 +2079,7 @@
     m_origin = NodeOrigin(CodeOrigin(BytecodeIndex(0)), CodeOrigin(BytecodeIndex(0)), true);
 
     auto& arguments = m_jit.graph().m_rootToArguments.find(m_jit.graph().block(0))->value;
-    for (int i = 0; i < m_jit.codeBlock()->numParameters(); ++i) {
+    for (unsigned i = 0; i < m_jit.codeBlock()->numParameters(); ++i) {
         Node* node = arguments[i];
         if (!node) {
             // The argument is dead. We don't do any checks for such arguments.

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -362,7 +362,7 @@
             if (m_graph.m_plan.mode() == FTLForOSREntryMode) {
                 auto* jitCode = m_ftlState.jitCode->ftlForOSREntry();
                 jitCode->argumentFlushFormats().reserveInitialCapacity(codeBlock()->numParameters());
-                for (int i = 0; i < codeBlock()->numParameters(); ++i)
+                for (unsigned i = 0; i < codeBlock()->numParameters(); ++i)
                     jitCode->argumentFlushFormats().uncheckedAppend(m_graph.m_argumentFormats[0][i]);
             } else {
                 for (unsigned i = codeBlock()->numParameters(); i--;) {

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ftl/FTLOSREntry.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ftl/FTLOSREntry.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/ftl/FTLOSREntry.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -113,8 +113,7 @@
         RELEASE_ASSERT_NOT_REACHED();
     }
     
-    RELEASE_ASSERT(
-        static_cast<int>(values.numberOfLocals()) == baseline->numCalleeLocals());
+    RELEASE_ASSERT(values.numberOfLocals() == baseline->numCalleeLocals());
     
     EncodedJSValue* scratch = static_cast<EncodedJSValue*>(
         entryCode->entryBuffer()->dataBuffer());

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/interpreter/CallFrameClosure.h (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/interpreter/CallFrameClosure.h	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/interpreter/CallFrameClosure.h	2021-07-23 09:00:00 UTC (rev 280233)
@@ -36,7 +36,7 @@
     FunctionExecutable* functionExecutable;
     VM* vm;
     JSScope* scope;
-    int parameterCountIncludingThis;
+    unsigned parameterCountIncludingThis;
     int argumentCountIncludingThis;
     
     void setThis(JSValue value)

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/interpreter/ProtoCallFrameInlines.h (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/interpreter/ProtoCallFrameInlines.h	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/interpreter/ProtoCallFrameInlines.h	2021-07-23 09:00:00 UTC (rev 280233)
@@ -37,7 +37,7 @@
     this->setCallee(callee);
     this->setGlobalObject(globalObject);
     this->setArgumentCountIncludingThis(argCountIncludingThis);
-    if (codeBlock && argCountIncludingThis < codeBlock->numParameters())
+    if (codeBlock && static_cast<unsigned>(argCountIncludingThis) < codeBlock->numParameters())
         this->hasArityMismatch = true;
     else
         this->hasArityMismatch = false;

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/jit/JIT.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/jit/JIT.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/jit/JIT.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -755,7 +755,7 @@
     if (m_codeBlock->codeType() == FunctionCode) {
         ASSERT(!m_bytecodeIndex);
         if (shouldEmitProfiling()) {
-            for (int argument = 0; argument < m_codeBlock->numParameters(); ++argument) {
+            for (unsigned argument = 0; argument < m_codeBlock->numParameters(); ++argument) {
                 // If this is a constructor, then we want to put in a dummy profiling site (to
                 // keep things consistent) but we don't actually want to record the dummy value.
                 if (m_codeBlock->isConstructor() && !argument)

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/CommonSlowPaths.h (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/CommonSlowPaths.h	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/runtime/CommonSlowPaths.h	2021-07-23 09:00:00 UTC (rev 280233)
@@ -57,7 +57,7 @@
 
 ALWAYS_INLINE int numberOfStackPaddingSlots(CodeBlock* codeBlock, int argumentCountIncludingThis)
 {
-    if (argumentCountIncludingThis >= codeBlock->numParameters())
+    if (static_cast<unsigned>(argumentCountIncludingThis) >= codeBlock->numParameters())
         return 0;
     int alignedFrameSize = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), argumentCountIncludingThis + CallFrame::headerSizeInRegisters);
     int alignedFrameSizeForParameters = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), codeBlock->numParameters() + CallFrame::headerSizeInRegisters);
@@ -66,7 +66,7 @@
 
 ALWAYS_INLINE int numberOfStackPaddingSlotsWithExtraSlots(CodeBlock* codeBlock, int argumentCountIncludingThis)
 {
-    if (argumentCountIncludingThis >= codeBlock->numParameters())
+    if (static_cast<unsigned>(argumentCountIncludingThis) >= codeBlock->numParameters())
         return 0;
     return numberOfStackPaddingSlots(codeBlock, argumentCountIncludingThis) + numberOfExtraSlots(argumentCountIncludingThis);
 }

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/tools/VMInspector.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/tools/VMInspector.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/tools/VMInspector.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -467,7 +467,7 @@
         end = it; // Stop the dump
     } else {
         end = bitwise_cast<const Register*>(nextCallFrame);
-        RELEASE_ASSERT(it - end < codeBlock->numCalleeLocals() - codeBlock->numVars());
+        RELEASE_ASSERT(static_cast<unsigned>(it - end) < codeBlock->numCalleeLocals() - codeBlock->numVars());
     }
 
     if (it != end) {

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.h (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.h	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/wasm/WasmFunctionCodeBlock.h	2021-07-23 09:00:00 UTC (rev 280233)
@@ -65,15 +65,15 @@
     }
 
     uint32_t functionIndex() const { return m_functionIndex; }
-    int numVars() const { return m_numVars; }
-    int numCalleeLocals() const { return m_numCalleeLocals; }
+    unsigned numVars() const { return m_numVars; }
+    unsigned numCalleeLocals() const { return m_numCalleeLocals; }
     uint32_t numArguments() const { return m_numArguments; }
     const Vector<Type>& constantTypes() const { return m_constantTypes; }
     const Vector<uint64_t>& constants() const { return m_constants; }
     const InstructionStream& instructions() const { return *m_instructions; }
 
-    void setNumVars(int numVars) { m_numVars = numVars; }
-    void setNumCalleeLocals(int numCalleeLocals) { m_numCalleeLocals = numCalleeLocals; }
+    void setNumVars(unsigned numVars) { m_numVars = numVars; }
+    void setNumCalleeLocals(unsigned numCalleeLocals) { m_numCalleeLocals = numCalleeLocals; }
 
     ALWAYS_INLINE uint64_t getConstant(VirtualRegister reg) const { return m_constants[reg.toConstantIndex()]; }
     ALWAYS_INLINE Type getConstantType(VirtualRegister reg) const
@@ -126,9 +126,9 @@
     uint32_t m_functionIndex;
 
     // Used for the number of WebAssembly locals, as in https://webassembly.github.io/spec/core/syntax/modules.html#syntax-local
-    int m_numVars { 0 };
+    unsigned m_numVars { 0 };
     // Number of VirtualRegister. The naming is unfortunate, but has to match UnlinkedCodeBlock
-    int m_numCalleeLocals { 0 };
+    unsigned m_numCalleeLocals { 0 };
     uint32_t m_numArguments { 0 };
     Vector<Type> m_constantTypes;
     Vector<uint64_t> m_constants;

Modified: releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp (280232 => 280233)


--- releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp	2021-07-23 08:59:50 UTC (rev 280232)
+++ releases/WebKitGTK/webkit-2.32/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp	2021-07-23 09:00:00 UTC (rev 280233)
@@ -169,7 +169,7 @@
     ExpressionType push(NoConsistencyCheckTag)
     {
         m_maxStackSize = std::max(m_maxStackSize, ++m_stackSize);
-        return virtualRegisterForLocal(m_stackSize - 1);
+        return virtualRegisterForLocal((m_stackSize - 1).unsafeGet());
     }
 
     ExpressionType push()
@@ -315,7 +315,7 @@
     {
         startOffset = target.stackSize() + 1;
         keep = target.branchTargetArity();
-        drop = m_stackSize - target.stackSize() - target.branchTargetArity();
+        drop = (m_stackSize - target.stackSize() - target.branchTargetArity()).unsafeGet();
     }
 
     void dropKeep(Stack& values, const ControlType& target, bool dropValues)
@@ -348,7 +348,7 @@
     template<typename Functor>
     void walkExpressionStack(Stack& expressionStack, const Functor& functor)
     {
-        walkExpressionStack(expressionStack, m_stackSize, functor);
+        walkExpressionStack(expressionStack, m_stackSize.unsafeGet(), functor);
     }
 
     template<typename Functor>
@@ -373,7 +373,7 @@
             });
         }
         walkExpressionStack(m_parser->expressionStack(), [&](VirtualRegister _expression_, VirtualRegister slot) {
-            ASSERT(_expression_ == slot || _expression_.isConstant() || _expression_.isArgument() || _expression_.toLocal() < m_codeBlock->m_numVars);
+            ASSERT(_expression_ == slot || _expression_.isConstant() || _expression_.isArgument() || static_cast<unsigned>(_expression_.toLocal()) < m_codeBlock->m_numVars);
         });
 #endif // ASSERT_ENABLED
     }
@@ -385,7 +385,7 @@
 
         checkConsistency();
         walkExpressionStack(expressionStack, [&](TypedExpression& _expression_, VirtualRegister slot) {
-            ASSERT(_expression_.value() == slot || _expression_.value().isConstant() || _expression_.value().isArgument() || _expression_.value().toLocal() < m_codeBlock->m_numVars);
+            ASSERT(_expression_.value() == slot || _expression_.value().isConstant() || _expression_.value().isArgument() || static_cast<unsigned>(_expression_.value().toLocal()) < m_codeBlock->m_numVars);
             if (_expression_.value() == slot)
                 return;
             WasmMov::emit(this, slot, _expression_);
@@ -401,7 +401,7 @@
         m_stackSize -= newStack.size();
         checkConsistency();
         walkExpressionStack(enclosingStack, [&](TypedExpression& _expression_, VirtualRegister slot) {
-            ASSERT(_expression_.value() == slot || _expression_.value().isConstant() || _expression_.value().isArgument() || _expression_.value().toLocal() < m_codeBlock->m_numVars);
+            ASSERT(_expression_.value() == slot || _expression_.value().isConstant() || _expression_.value().isArgument() || static_cast<unsigned>(_expression_.value().toLocal()) < m_codeBlock->m_numVars);
             if (_expression_.value() == slot || _expression_.value().isConstant())
                 return;
             WasmMov::emit(this, slot, _expression_);
@@ -432,8 +432,8 @@
     ResultList m_unitializedLocals;
     HashMap<EncodedJSValue, VirtualRegister, WTF::IntHash<EncodedJSValue>, ConstantMapHashTraits> m_constantMap;
     Vector<VirtualRegister, 2> m_results;
-    unsigned m_stackSize { 0 };
-    unsigned m_maxStackSize { 0 };
+    Checked<unsigned> m_stackSize { 0 };
+    Checked<unsigned> m_maxStackSize { 0 };
 };
 
 Expected<std::unique_ptr<FunctionCodeBlock>, String> parseAndCompileBytecode(const uint8_t* functionStart, size_t functionLength, const Signature& signature, const ModuleInformation& info, uint32_t functionIndex)
@@ -482,7 +482,9 @@
 std::unique_ptr<FunctionCodeBlock> LLIntGenerator::finalize()
 {
     RELEASE_ASSERT(m_codeBlock);
-    m_codeBlock->m_numCalleeLocals = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_maxStackSize);
+    size_t numCalleeLocals = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_maxStackSize.unsafeGet());
+    m_codeBlock->m_numCalleeLocals = numCalleeLocals;
+    RELEASE_ASSERT(numCalleeLocals == m_codeBlock->m_numCalleeLocals);
 
     auto& threadSpecific = threadSpecificBuffer();
     Buffer usedBuffer;
@@ -570,7 +572,7 @@
     // FIXME: we are allocating the extra space for the argument/return count in order to avoid interference, but we could do better
     // NOTE: We increase arg count by 1 for the case of indirect calls
     m_stackSize += std::max(signature.argumentCount() + 1, signature.returnCount()) + gprCount + fprCount + stackCount + CallFrame::headerSizeInRegisters;
-    if (m_stackSize % stackAlignmentRegisters())
+    if (m_stackSize.unsafeGet() % stackAlignmentRegisters())
         ++m_stackSize;
     if (m_maxStackSize < m_stackSize)
         m_maxStackSize = m_stackSize;
@@ -579,7 +581,7 @@
     ResultList arguments(signature.argumentCount());
     ResultList temporaryResults(signature.returnCount());
 
-    const unsigned stackOffset = m_stackSize;
+    const unsigned stackOffset = m_stackSize.unsafeGet();
     const unsigned base = stackOffset - CallFrame::headerSizeInRegisters;
 
     const uint32_t gprLimit = base - stackCount - gprCount;
@@ -868,7 +870,7 @@
     Ref<Label> body = newEmittedLabel();
     Ref<Label> continuation = newLabel();
 
-    block = ControlType::loop(signature, m_stackSize, WTFMove(body), WTFMove(continuation));
+    block = ControlType::loop(signature, m_stackSize.unsafeGet(), WTFMove(body), WTFMove(continuation));
 
     Vector<VirtualRegister> osrEntryData;
     for (uint32_t i = 0; i < m_codeBlock->m_numArguments; i++)
@@ -877,7 +879,7 @@
     const auto& callingConvention = wasmCallingConvention();
     const uint32_t gprCount = callingConvention.gprArgs.size();
     const uint32_t fprCount = callingConvention.fprArgs.size();
-    for (int32_t i = gprCount + fprCount + numberOfLLIntCalleeSaveRegisters; i < m_codeBlock->m_numVars; i++)
+    for (uint32_t i = gprCount + fprCount + numberOfLLIntCalleeSaveRegisters; i < m_codeBlock->m_numVars; i++)
         osrEntryData.append(virtualRegisterForLocal(i));
     for (unsigned controlIndex = 0; controlIndex < m_parser->controlStack().size(); ++controlIndex) {
         Stack& expressionStack = m_parser->controlStack()[controlIndex].enclosedExpressionStack;
@@ -896,13 +898,13 @@
 
 auto LLIntGenerator::addTopLevel(BlockSignature signature) -> ControlType
 {
-    return ControlType::topLevel(signature, m_stackSize, newLabel());
+    return ControlType::topLevel(signature, m_stackSize.unsafeGet(), newLabel());
 }
 
 auto LLIntGenerator::addBlock(BlockSignature signature, Stack& enclosingStack, ControlType& newBlock, Stack& newStack) -> PartialResult
 {
     splitStack(signature, enclosingStack, newStack);
-    newBlock = ControlType::block(signature, m_stackSize, newLabel());
+    newBlock = ControlType::block(signature, m_stackSize.unsafeGet(), newLabel());
     return { };
 }
 
@@ -915,7 +917,7 @@
 
     WasmJfalse::emit(this, condition, alternate->bind(this));
 
-    result = ControlType::if_(signature, m_stackSize, WTFMove(alternate), WTFMove(continuation));
+    result = ControlType::if_(signature, m_stackSize.unsafeGet(), WTFMove(alternate), WTFMove(continuation));
     return { };
 }
 
@@ -933,7 +935,7 @@
 
     ControlIf& control = WTF::get<ControlIf>(data);
     emitLabel(control.m_alternate.get());
-    data = "" m_stackSize, WTFMove(data.m_continuation));
+    data = "" m_stackSize.unsafeGet(), WTFMove(data.m_continuation));
     return { };
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to