Changeset 276609 in webkit
- Timestamp:
- Apr 26, 2021, 1:20:13 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 19 edited
-
ChangeLog (modified) (1 diff)
-
bytecode/CodeBlock.cpp (modified) (2 diffs)
-
bytecode/CodeBlock.h (modified) (3 diffs)
-
bytecode/UnlinkedCodeBlock.h (modified) (2 diffs)
-
bytecode/UnlinkedCodeBlockGenerator.h (modified) (2 diffs)
-
bytecompiler/BytecodeGenerator.cpp (modified) (2 diffs)
-
bytecompiler/BytecodeGeneratorBaseInlines.h (modified) (1 diff)
-
dfg/DFGByteCodeParser.cpp (modified) (6 diffs)
-
dfg/DFGOSREntrypointCreationPhase.cpp (modified) (3 diffs)
-
dfg/DFGSpeculativeJIT.cpp (modified) (1 diff)
-
ftl/FTLLowerDFGToB3.cpp (modified) (1 diff)
-
ftl/FTLOSREntry.cpp (modified) (1 diff)
-
interpreter/CallFrameClosure.h (modified) (1 diff)
-
interpreter/ProtoCallFrameInlines.h (modified) (1 diff)
-
jit/JIT.cpp (modified) (1 diff)
-
runtime/CommonSlowPaths.h (modified) (2 diffs)
-
tools/VMInspector.cpp (modified) (1 diff)
-
wasm/WasmFunctionCodeBlock.h (modified) (3 diffs)
-
wasm/WasmLLIntGenerator.cpp (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r276592 r276609 1 2021-04-26 Keith Miller <keith_miller@apple.com> 2 3 numCalleeLocals, numParameters, and numVars should be unsigned 4 https://bugs.webkit.org/show_bug.cgi?id=224995 5 6 Reviewed by Mark Lam. 7 8 All of the various CodeBlock classes currently have the 9 numCalleeLocals and numVars marked as ints. I believe this is just 10 a historical artifact or because VirtualRegister's offset is an 11 int to make handling constants easier. Regardless, it's a bit 12 strange to not handle the sign conversion at the point of 13 comparison between a VirtualRegister offset and the local/var 14 count. This doesn't completely fix every place we use ints for 15 these values but starts on the right track. Lastly, I also added 16 some Check<unsigned>s to the wasm parser for sanity checking. 17 18 * bytecode/CodeBlock.cpp: 19 (JSC::CodeBlock::setNumParameters): 20 (JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndexSlow): 21 * bytecode/CodeBlock.h: 22 (JSC::CodeBlock::numParameters const): 23 (JSC::CodeBlock::numberOfArgumentsToSkip const): 24 (JSC::CodeBlock::numCalleeLocals const): 25 (JSC::CodeBlock::numVars const): 26 (JSC::CodeBlock::numTmps const): 27 (JSC::CodeBlock::addressOfNumParameters): 28 (JSC::CodeBlock::isTemporaryRegister): 29 * bytecode/UnlinkedCodeBlock.h: 30 (JSC::UnlinkedCodeBlock::numCalleeLocals const): 31 (JSC::UnlinkedCodeBlock::numVars const): 32 * bytecode/UnlinkedCodeBlockGenerator.h: 33 (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const): 34 (JSC::UnlinkedCodeBlockGenerator::numVars const): 35 (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals): 36 (JSC::UnlinkedCodeBlockGenerator::setNumVars): 37 (JSC::UnlinkedCodeBlockGenerator::setNumParameters): 38 * bytecompiler/BytecodeGenerator.cpp: 39 (JSC::BytecodeGenerator::generate): 40 (JSC::BytecodeGenerator::emitPushFunctionNameScope): 41 * bytecompiler/BytecodeGeneratorBaseInlines.h: 42 (JSC::BytecodeGeneratorBase<Traits>::newRegister): 43 * dfg/DFGByteCodeParser.cpp: 44 (JSC::DFG::ByteCodeParser::handleRecursiveTailCall): 45 (JSC::DFG::ByteCodeParser::inliningCost): 46 (JSC::DFG::ByteCodeParser::parseBlock): 47 * dfg/DFGOSREntrypointCreationPhase.cpp: 48 (JSC::DFG::OSREntrypointCreationPhase::run): 49 * dfg/DFGSpeculativeJIT.cpp: 50 (JSC::DFG::SpeculativeJIT::checkArgumentTypes): 51 * ftl/FTLLowerDFGToB3.cpp: 52 (JSC::FTL::DFG::LowerDFGToB3::lower): 53 * ftl/FTLOSREntry.cpp: 54 (JSC::FTL::prepareOSREntry): 55 * interpreter/CallFrameClosure.h: 56 * interpreter/ProtoCallFrameInlines.h: 57 (JSC::ProtoCallFrame::init): 58 * jit/JIT.cpp: 59 (JSC::JIT::compileWithoutLinking): 60 * runtime/CommonSlowPaths.h: 61 (JSC::CommonSlowPaths::numberOfStackPaddingSlots): 62 (JSC::CommonSlowPaths::numberOfStackPaddingSlotsWithExtraSlots): 63 * wasm/WasmFunctionCodeBlock.h: 64 (JSC::Wasm::FunctionCodeBlock::numVars const): 65 (JSC::Wasm::FunctionCodeBlock::numCalleeLocals const): 66 (JSC::Wasm::FunctionCodeBlock::setNumVars): 67 (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals): 68 * wasm/WasmLLIntGenerator.cpp: 69 (JSC::Wasm::LLIntGenerator::push): 70 (JSC::Wasm::LLIntGenerator::getDropKeepCount): 71 (JSC::Wasm::LLIntGenerator::walkExpressionStack): 72 (JSC::Wasm::LLIntGenerator::checkConsistency): 73 (JSC::Wasm::LLIntGenerator::materializeConstantsAndLocals): 74 (JSC::Wasm::LLIntGenerator::splitStack): 75 (JSC::Wasm::LLIntGenerator::finalize): 76 (JSC::Wasm::LLIntGenerator::callInformationForCaller): 77 (JSC::Wasm::LLIntGenerator::addLoop): 78 (JSC::Wasm::LLIntGenerator::addTopLevel): 79 (JSC::Wasm::LLIntGenerator::addBlock): 80 (JSC::Wasm::LLIntGenerator::addIf): 81 (JSC::Wasm::LLIntGenerator::addElseToUnreachable): 82 1 83 2021-04-26 Alexey Shvayka <shvaikalesh@gmail.com> 2 84 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r276224 r276609 925 925 } 926 926 927 void CodeBlock::setNumParameters( intnewValue)927 void CodeBlock::setNumParameters(unsigned newValue) 928 928 { 929 929 m_numParameters = newValue; … … 2016 2016 }); 2017 2017 2018 for ( inti = 0; i < numParameters(); ++i)2018 for (unsigned i = 0; i < numParameters(); ++i) 2019 2019 liveOperands.append(virtualRegisterForArgumentIncludingThis(i)); 2020 2020 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r276290 r276609 157 157 MetadataTable* metadataTable() const { return m_metadata.get(); } 158 158 159 intnumParameters() const { return m_numParameters; }160 void setNumParameters( intnewValue);161 162 intnumberOfArgumentsToSkip() const { return m_numberOfArgumentsToSkip; }163 164 intnumCalleeLocals() const { return m_numCalleeLocals; }165 166 intnumVars() const { return m_numVars; }167 intnumTmps() const { return m_unlinkedCode->hasCheckpoints() * maxNumCheckpointTmps; }168 169 int* addressOfNumParameters() { return &m_numParameters; }159 unsigned numParameters() const { return m_numParameters; } 160 void setNumParameters(unsigned newValue); 161 162 unsigned numberOfArgumentsToSkip() const { return m_numberOfArgumentsToSkip; } 163 164 unsigned numCalleeLocals() const { return m_numCalleeLocals; } 165 166 unsigned numVars() const { return m_numVars; } 167 unsigned numTmps() const { return m_unlinkedCode->hasCheckpoints() * maxNumCheckpointTmps; } 168 169 unsigned* addressOfNumParameters() { return &m_numParameters; } 170 170 static ptrdiff_t offsetOfNumParameters() { return OBJECT_OFFSETOF(CodeBlock, m_numParameters); } 171 171 … … 244 244 ALWAYS_INLINE bool isTemporaryRegister(VirtualRegister reg) 245 245 { 246 return reg.offset() >= m_numVars;246 return reg.offset() >= static_cast<int>(m_numVars); 247 247 } 248 248 … … 990 990 void ensureCatchLivenessIsComputedForBytecodeIndexSlow(const OpCatch&, BytecodeIndex); 991 991 992 intm_numCalleeLocals;993 intm_numVars;994 intm_numParameters;995 intm_numberOfArgumentsToSkip { 0 };992 unsigned m_numCalleeLocals; 993 unsigned m_numVars; 994 unsigned m_numParameters; 995 unsigned m_numberOfArgumentsToSkip { 0 }; 996 996 unsigned m_numberOfNonArgumentValueProfiles { 0 }; 997 997 union { -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
r276427 r276609 210 210 const InstructionStream& instructions() const; 211 211 212 intnumCalleeLocals() const { return m_numCalleeLocals; }213 intnumVars() const { return m_numVars; }212 unsigned numCalleeLocals() const { return m_numCalleeLocals; } 213 unsigned numVars() const { return m_numVars; } 214 214 215 215 // Jump Tables … … 397 397 unsigned m_endColumn { UINT_MAX }; 398 398 399 intm_numVars { 0 };400 intm_numCalleeLocals { 0 };401 intm_numParameters { 0 };399 unsigned m_numVars { 0 }; 400 unsigned m_numCalleeLocals { 0 }; 401 unsigned m_numParameters { 0 }; 402 402 403 403 PackedRefPtr<StringImpl> m_sourceURLDirective; -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.h
r275995 r276609 60 60 bool isArrowFunctionContext() const { return m_codeBlock->isArrowFunctionContext(); } 61 61 bool isClassContext() const { return m_codeBlock->isClassContext(); } 62 intnumCalleeLocals() const { return m_codeBlock->m_numCalleeLocals; }63 intnumVars() const { return m_codeBlock->m_numVars; }62 unsigned numCalleeLocals() const { return m_codeBlock->m_numCalleeLocals; } 63 unsigned numVars() const { return m_codeBlock->m_numVars; } 64 64 unsigned numParameters() const { return m_codeBlock->numParameters(); } 65 65 VirtualRegister thisRegister() const { return m_codeBlock->thisRegister(); } … … 72 72 void setHasCheckpoints() { m_codeBlock->setHasCheckpoints(); } 73 73 void setHasTailCalls() { m_codeBlock->setHasTailCalls(); } 74 void setNumCalleeLocals( intnumCalleeLocals) { m_codeBlock->m_numCalleeLocals = numCalleeLocals; }75 void setNumVars( intnumVars) { m_codeBlock->m_numVars = numVars; }74 void setNumCalleeLocals(unsigned numCalleeLocals) { m_codeBlock->m_numCalleeLocals = numCalleeLocals; } 75 void setNumVars(unsigned numVars) { m_codeBlock->m_numVars = numVars; } 76 76 void setThisRegister(VirtualRegister thisRegister) { m_codeBlock->setThisRegister(thisRegister); } 77 77 void setScopeRegister(VirtualRegister thisRegister) { m_codeBlock->setScopeRegister(thisRegister); } 78 void setNumParameters( intnewValue) { m_codeBlock->setNumParameters(newValue); }78 void setNumParameters(unsigned newValue) { m_codeBlock->setNumParameters(newValue); } 79 79 80 80 UnlinkedMetadataTable& metadata() { return m_codeBlock->metadata(); } -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r276384 r276609 283 283 performGeneratorification(*this, m_codeBlock.get(), m_writer, m_generatorFrameSymbolTable.get(), m_generatorFrameSymbolTableIndex); 284 284 285 RELEASE_ASSERT( static_cast<unsigned>(m_codeBlock->numCalleeLocals()) < static_cast<unsigned>(FirstConstantRegisterIndex));285 RELEASE_ASSERT(m_codeBlock->numCalleeLocals() < static_cast<unsigned>(FirstConstantRegisterIndex)); 286 286 m_codeBlock->finalize(m_writer.finalize()); 287 287 if (m_expressionTooDeep) … … 3988 3988 unsigned numVars = m_codeBlock->numVars(); 3989 3989 pushLexicalScopeInternal(nameScopeEnvironment, TDZCheckOptimization::Optimize, NestedScopeType::IsNotNested, nullptr, TDZRequirement::NotUnderTDZ, ScopeType::FunctionNameScope, ScopeRegisterType::Var); 3990 ASSERT_UNUSED(numVars, m_codeBlock->numVars() == static_cast<int>(numVars + 1)); // Should have only created one new "var" for the function name scope.3990 ASSERT_UNUSED(numVars, m_codeBlock->numVars() == numVars + 1); // Should have only created one new "var" for the function name scope. 3991 3991 bool shouldTreatAsLexicalVariable = ecmaMode().isStrict(); 3992 3992 Variable functionVar = variableForLocalEntry(property, m_lexicalScopeStack.last().m_symbolTable->get(NoLockingNecessary, property.impl()), m_lexicalScopeStack.last().m_symbolTableConstantIndex, shouldTreatAsLexicalVariable); -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGeneratorBaseInlines.h
r255687 r276609 162 162 { 163 163 m_calleeLocals.append(virtualRegisterForLocal(m_calleeLocals.size())); 164 int numCalleeLocals = std::max<int>(m_codeBlock->numCalleeLocals(), m_calleeLocals.size());164 size_t numCalleeLocals = std::max<size_t>(m_codeBlock->numCalleeLocals(), m_calleeLocals.size()); 165 165 numCalleeLocals = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), numCalleeLocals); 166 m_codeBlock->setNumCalleeLocals(numCalleeLocals); 166 m_codeBlock->setNumCalleeLocals(static_cast<unsigned>(numCalleeLocals)); 167 RELEASE_ASSERT(numCalleeLocals == m_codeBlock->numCalleeLocals()); 167 168 return &m_calleeLocals.last(); 168 169 } -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r276427 r276609 1495 1495 // Some code may statically use the argument count from the InlineCallFrame, so it would be invalid to loop back if it does not match. 1496 1496 // We "continue" instead of returning false in case another stack entry further on the stack has the right number of arguments. 1497 if (argumentCountIncludingThis != static_cast<int>(callFrame->argumentCountIncludingThis))1497 if (argumentCountIncludingThis != callFrame->argumentCountIncludingThis) 1498 1498 continue; 1499 1499 // If the target InlineCallFrame is Varargs, we do not know how many arguments are actually filled by LoadVarargs. Varargs InlineCallFrame's … … 1505 1505 // We are in the machine code entry (i.e. the original caller). 1506 1506 // 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. 1507 if ( argumentCountIncludingThis> m_codeBlock->numParameters())1507 if (static_cast<unsigned>(argumentCountIncludingThis) > m_codeBlock->numParameters()) 1508 1508 return false; 1509 1509 } … … 1531 1531 if (!stackEntry->m_inlineCallFrame) 1532 1532 addToGraph(SetArgumentCountIncludingThis, OpInfo(argumentCountIncludingThis)); 1533 intargIndex = 0;1534 for (; argIndex < argumentCountIncludingThis; ++argIndex) {1533 unsigned argIndex = 0; 1534 for (; argIndex < static_cast<unsigned>(argumentCountIncludingThis); ++argIndex) { 1535 1535 Node* value = get(virtualRegisterForArgumentIncludingThis(argIndex, registerOffset)); 1536 1536 setDirect(stackEntry->remapOperand(virtualRegisterForArgumentIncludingThis(argIndex)), value, NormalSet); … … 1542 1542 // We must repeat the work of op_enter here as we will jump right after it. 1543 1543 // We jump right after it and not before it, because of some invariant saying that a CFG root cannot have predecessors in the IR. 1544 for ( inti = 0; i < stackEntry->m_codeBlock->numVars(); ++i)1544 for (unsigned i = 0; i < stackEntry->m_codeBlock->numVars(); ++i) 1545 1545 setDirect(stackEntry->remapOperand(virtualRegisterForLocal(i)), undefined, NormalSet); 1546 1546 … … 1598 1598 1599 1599 if (!Options::useArityFixupInlining()) { 1600 if (codeBlock->numParameters() > argumentCountIncludingThis) {1600 if (codeBlock->numParameters() > static_cast<unsigned>(argumentCountIncludingThis)) { 1601 1601 VERBOSE_LOG(" Failing because of arity mismatch.\n"); 1602 1602 return UINT_MAX; … … 5419 5419 Node* undefined = addToGraph(JSConstant, OpInfo(m_constantUndefined)); 5420 5420 // Initialize all locals to undefined. 5421 for ( inti = 0; i < m_inlineStackTop->m_codeBlock->numVars(); ++i)5421 for (unsigned i = 0; i < m_inlineStackTop->m_codeBlock->numVars(); ++i) 5422 5422 set(virtualRegisterForLocal(i), undefined, ImmediateNakedSet); 5423 5423 -
trunk/Source/JavaScriptCore/dfg/DFGOSREntrypointCreationPhase.cpp
r261895 r276609 95 95 96 96 Vector<Node*> locals(baseline->numCalleeLocals()); 97 for ( intlocal = 0; local < baseline->numCalleeLocals(); ++local) {97 for (unsigned local = 0; local < baseline->numCalleeLocals(); ++local) { 98 98 Node* previousHead = target->variablesAtHead.local(local); 99 99 if (!previousHead) … … 114 114 115 115 ArgumentsVector newArguments = m_graph.m_rootToArguments.find(m_graph.block(0))->value; 116 for ( intargument = 0; argument < baseline->numParameters(); ++argument) {116 for (unsigned argument = 0; argument < baseline->numParameters(); ++argument) { 117 117 Node* oldNode = target->variablesAtHead.argument(argument); 118 118 if (!oldNode) { … … 126 126 } 127 127 128 for ( intlocal = 0; local < baseline->numCalleeLocals(); ++local) {128 for (unsigned local = 0; local < baseline->numCalleeLocals(); ++local) { 129 129 Node* previousHead = target->variablesAtHead.local(local); 130 130 if (!previousHead) -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r276449 r276609 2080 2080 2081 2081 auto& arguments = m_jit.graph().m_rootToArguments.find(m_jit.graph().block(0))->value; 2082 for ( inti = 0; i < m_jit.codeBlock()->numParameters(); ++i) {2082 for (unsigned i = 0; i < m_jit.codeBlock()->numParameters(); ++i) { 2083 2083 Node* node = arguments[i]; 2084 2084 if (!node) { -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r276427 r276609 363 363 auto* jitCode = m_ftlState.jitCode->ftlForOSREntry(); 364 364 FixedVector<DFG::FlushFormat> argumentFlushFormats(codeBlock()->numParameters()); 365 for ( inti = 0; i < codeBlock()->numParameters(); ++i)365 for (unsigned i = 0; i < codeBlock()->numParameters(); ++i) 366 366 argumentFlushFormats[i] = m_graph.m_argumentFormats[0][i]; 367 367 jitCode->setArgumentFlushFormats(WTFMove(argumentFlushFormats)); -
trunk/Source/JavaScriptCore/ftl/FTLOSREntry.cpp
r268783 r276609 114 114 } 115 115 116 RELEASE_ASSERT( 117 static_cast<int>(values.numberOfLocals()) == baseline->numCalleeLocals()); 116 RELEASE_ASSERT(values.numberOfLocals() == baseline->numCalleeLocals()); 118 117 119 118 EncodedJSValue* scratch = static_cast<EncodedJSValue*>( -
trunk/Source/JavaScriptCore/interpreter/CallFrameClosure.h
r206525 r276609 37 37 VM* vm; 38 38 JSScope* scope; 39 intparameterCountIncludingThis;39 unsigned parameterCountIncludingThis; 40 40 int argumentCountIncludingThis; 41 41 -
trunk/Source/JavaScriptCore/interpreter/ProtoCallFrameInlines.h
r251584 r276609 38 38 this->setGlobalObject(globalObject); 39 39 this->setArgumentCountIncludingThis(argCountIncludingThis); 40 if (codeBlock && argCountIncludingThis< codeBlock->numParameters())40 if (codeBlock && static_cast<unsigned>(argCountIncludingThis) < codeBlock->numParameters()) 41 41 this->hasArityMismatch = true; 42 42 else -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r276470 r276609 770 770 ASSERT(!m_bytecodeIndex); 771 771 if (shouldEmitProfiling()) { 772 for ( intargument = 0; argument < m_codeBlock->numParameters(); ++argument) {772 for (unsigned argument = 0; argument < m_codeBlock->numParameters(); ++argument) { 773 773 // If this is a constructor, then we want to put in a dummy profiling site (to 774 774 // keep things consistent) but we don't actually want to record the dummy value. -
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h
r271120 r276609 58 58 ALWAYS_INLINE int numberOfStackPaddingSlots(CodeBlock* codeBlock, int argumentCountIncludingThis) 59 59 { 60 if ( argumentCountIncludingThis>= codeBlock->numParameters())60 if (static_cast<unsigned>(argumentCountIncludingThis) >= codeBlock->numParameters()) 61 61 return 0; 62 62 int alignedFrameSize = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), argumentCountIncludingThis + CallFrame::headerSizeInRegisters); … … 67 67 ALWAYS_INLINE int numberOfStackPaddingSlotsWithExtraSlots(CodeBlock* codeBlock, int argumentCountIncludingThis) 68 68 { 69 if ( argumentCountIncludingThis>= codeBlock->numParameters())69 if (static_cast<unsigned>(argumentCountIncludingThis) >= codeBlock->numParameters()) 70 70 return 0; 71 71 return numberOfStackPaddingSlots(codeBlock, argumentCountIncludingThis) + numberOfExtraSlots(argumentCountIncludingThis); -
trunk/Source/JavaScriptCore/tools/VMInspector.cpp
r271082 r276609 468 468 } else { 469 469 end = bitwise_cast<const Register*>(nextCallFrame); 470 RELEASE_ASSERT( it - end< codeBlock->numCalleeLocals() - codeBlock->numVars());470 RELEASE_ASSERT(static_cast<unsigned>(it - end) < codeBlock->numCalleeLocals() - codeBlock->numVars()); 471 471 } 472 472 -
trunk/Source/JavaScriptCore/wasm/WasmFunctionCodeBlock.h
r273813 r276609 66 66 67 67 uint32_t functionIndex() const { return m_functionIndex; } 68 intnumVars() const { return m_numVars; }69 intnumCalleeLocals() const { return m_numCalleeLocals; }68 unsigned numVars() const { return m_numVars; } 69 unsigned numCalleeLocals() const { return m_numCalleeLocals; } 70 70 uint32_t numArguments() const { return m_numArguments; } 71 71 const Vector<Type>& constantTypes() const { return m_constantTypes; } … … 73 73 const InstructionStream& instructions() const { return *m_instructions; } 74 74 75 void setNumVars( intnumVars) { m_numVars = numVars; }76 void setNumCalleeLocals( intnumCalleeLocals) { m_numCalleeLocals = numCalleeLocals; }75 void setNumVars(unsigned numVars) { m_numVars = numVars; } 76 void setNumCalleeLocals(unsigned numCalleeLocals) { m_numCalleeLocals = numCalleeLocals; } 77 77 78 78 ALWAYS_INLINE uint64_t getConstant(VirtualRegister reg) const { return m_constants[reg.toConstantIndex()]; } … … 127 127 128 128 // Used for the number of WebAssembly locals, as in https://webassembly.github.io/spec/core/syntax/modules.html#syntax-local 129 intm_numVars { 0 };129 unsigned m_numVars { 0 }; 130 130 // Number of VirtualRegister. The naming is unfortunate, but has to match UnlinkedCodeBlock 131 intm_numCalleeLocals { 0 };131 unsigned m_numCalleeLocals { 0 }; 132 132 uint32_t m_numArguments { 0 }; 133 133 Vector<Type> m_constantTypes; -
trunk/Source/JavaScriptCore/wasm/WasmLLIntGenerator.cpp
r275650 r276609 170 170 { 171 171 m_maxStackSize = std::max(m_maxStackSize, ++m_stackSize); 172 return virtualRegisterForLocal( m_stackSize - 1);172 return virtualRegisterForLocal((m_stackSize - 1).unsafeGet()); 173 173 } 174 174 … … 316 316 startOffset = target.stackSize() + 1; 317 317 keep = target.branchTargetArity(); 318 drop = m_stackSize - target.stackSize() - target.branchTargetArity();318 drop = (m_stackSize - target.stackSize() - target.branchTargetArity()).unsafeGet(); 319 319 } 320 320 … … 349 349 void walkExpressionStack(Stack& expressionStack, const Functor& functor) 350 350 { 351 walkExpressionStack(expressionStack, m_stackSize , functor);351 walkExpressionStack(expressionStack, m_stackSize.unsafeGet(), functor); 352 352 } 353 353 … … 374 374 } 375 375 walkExpressionStack(m_parser->expressionStack(), [&](VirtualRegister expression, VirtualRegister slot) { 376 ASSERT(expression == slot || expression.isConstant() || expression.isArgument() || expression.toLocal() < m_codeBlock->m_numVars);376 ASSERT(expression == slot || expression.isConstant() || expression.isArgument() || static_cast<unsigned>(expression.toLocal()) < m_codeBlock->m_numVars); 377 377 }); 378 378 #endif // ASSERT_ENABLED … … 386 386 checkConsistency(); 387 387 walkExpressionStack(expressionStack, [&](TypedExpression& expression, VirtualRegister slot) { 388 ASSERT(expression.value() == slot || expression.value().isConstant() || expression.value().isArgument() || expression.value().toLocal() < m_codeBlock->m_numVars);388 ASSERT(expression.value() == slot || expression.value().isConstant() || expression.value().isArgument() || static_cast<unsigned>(expression.value().toLocal()) < m_codeBlock->m_numVars); 389 389 if (expression.value() == slot) 390 390 return; … … 402 402 checkConsistency(); 403 403 walkExpressionStack(enclosingStack, [&](TypedExpression& expression, VirtualRegister slot) { 404 ASSERT(expression.value() == slot || expression.value().isConstant() || expression.value().isArgument() || expression.value().toLocal() < m_codeBlock->m_numVars);404 ASSERT(expression.value() == slot || expression.value().isConstant() || expression.value().isArgument() || static_cast<unsigned>(expression.value().toLocal()) < m_codeBlock->m_numVars); 405 405 if (expression.value() == slot || expression.value().isConstant()) 406 406 return; … … 433 433 HashMap<EncodedJSValue, VirtualRegister, WTF::IntHash<EncodedJSValue>, ConstantMapHashTraits> m_constantMap; 434 434 Vector<VirtualRegister, 2> m_results; 435 unsignedm_stackSize { 0 };436 unsignedm_maxStackSize { 0 };435 Checked<unsigned> m_stackSize { 0 }; 436 Checked<unsigned> m_maxStackSize { 0 }; 437 437 }; 438 438 … … 483 483 { 484 484 RELEASE_ASSERT(m_codeBlock); 485 m_codeBlock->m_numCalleeLocals = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_maxStackSize); 485 size_t numCalleeLocals = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), m_maxStackSize.unsafeGet()); 486 m_codeBlock->m_numCalleeLocals = numCalleeLocals; 487 RELEASE_ASSERT(numCalleeLocals == m_codeBlock->m_numCalleeLocals); 486 488 487 489 auto& threadSpecific = threadSpecificBuffer(); … … 572 574 // NOTE: We increase arg count by 1 for the case of indirect calls 573 575 m_stackSize += std::max(signature.argumentCount() + 1, signature.returnCount()) + gprCount + fprCount + stackCount + CallFrame::headerSizeInRegisters; 574 if (m_stackSize % stackAlignmentRegisters())576 if (m_stackSize.unsafeGet() % stackAlignmentRegisters()) 575 577 ++m_stackSize; 576 578 if (m_maxStackSize < m_stackSize) … … 581 583 ResultList temporaryResults(signature.returnCount()); 582 584 583 const unsigned stackOffset = m_stackSize ;585 const unsigned stackOffset = m_stackSize.unsafeGet(); 584 586 const unsigned base = stackOffset - CallFrame::headerSizeInRegisters; 585 587 … … 874 876 Ref<Label> continuation = newLabel(); 875 877 876 block = ControlType::loop(signature, m_stackSize , WTFMove(body), WTFMove(continuation));878 block = ControlType::loop(signature, m_stackSize.unsafeGet(), WTFMove(body), WTFMove(continuation)); 877 879 878 880 Vector<VirtualRegister> osrEntryData; … … 883 885 const uint32_t gprCount = callingConvention.gprArgs.size(); 884 886 const uint32_t fprCount = callingConvention.fprArgs.size(); 885 for ( int32_t i = gprCount + fprCount + numberOfLLIntCalleeSaveRegisters; i < m_codeBlock->m_numVars; i++)887 for (uint32_t i = gprCount + fprCount + numberOfLLIntCalleeSaveRegisters; i < m_codeBlock->m_numVars; i++) 886 888 osrEntryData.append(virtualRegisterForLocal(i)); 887 889 for (unsigned controlIndex = 0; controlIndex < m_parser->controlStack().size(); ++controlIndex) { … … 902 904 auto LLIntGenerator::addTopLevel(BlockSignature signature) -> ControlType 903 905 { 904 return ControlType::topLevel(signature, m_stackSize , newLabel());906 return ControlType::topLevel(signature, m_stackSize.unsafeGet(), newLabel()); 905 907 } 906 908 … … 908 910 { 909 911 splitStack(signature, enclosingStack, newStack); 910 newBlock = ControlType::block(signature, m_stackSize , newLabel());912 newBlock = ControlType::block(signature, m_stackSize.unsafeGet(), newLabel()); 911 913 return { }; 912 914 } … … 921 923 WasmJfalse::emit(this, condition, alternate->bind(this)); 922 924 923 result = ControlType::if_(signature, m_stackSize , WTFMove(alternate), WTFMove(continuation));925 result = ControlType::if_(signature, m_stackSize.unsafeGet(), WTFMove(alternate), WTFMove(continuation)); 924 926 return { }; 925 927 } … … 939 941 ControlIf& control = WTF::get<ControlIf>(data); 940 942 emitLabel(control.m_alternate.get()); 941 data = ControlType::block(data.m_signature, m_stackSize , WTFMove(data.m_continuation));943 data = ControlType::block(data.m_signature, m_stackSize.unsafeGet(), WTFMove(data.m_continuation)); 942 944 return { }; 943 945 }
Note:
See TracChangeset
for help on using the changeset viewer.