Changeset 251468 in webkit for trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
- Timestamp:
- Oct 22, 2019, 5:55:38 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r251457 r251468 1527 1527 } 1528 1528 1529 CallLinkInfo* CodeBlock::getCallLinkInfoForBytecodeIndex( unsignedindex)1529 CallLinkInfo* CodeBlock::getCallLinkInfoForBytecodeIndex(BytecodeIndex index) 1530 1530 { 1531 1531 ConcurrentJSLocker locker(m_lock); … … 1539 1539 } 1540 1540 1541 RareCaseProfile* CodeBlock::addRareCaseProfile( int bytecodeOffset)1541 RareCaseProfile* CodeBlock::addRareCaseProfile(BytecodeIndex bytecodeIndex) 1542 1542 { 1543 1543 ConcurrentJSLocker locker(m_lock); 1544 1544 auto& jitData = ensureJITData(locker); 1545 jitData.m_rareCaseProfiles.append(RareCaseProfile(bytecode Offset));1545 jitData.m_rareCaseProfiles.append(RareCaseProfile(bytecodeIndex)); 1546 1546 return &jitData.m_rareCaseProfiles.last(); 1547 1547 } 1548 1548 1549 RareCaseProfile* CodeBlock::rareCaseProfileForBytecode Offset(const ConcurrentJSLocker&, int bytecodeOffset)1549 RareCaseProfile* CodeBlock::rareCaseProfileForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex bytecodeIndex) 1550 1550 { 1551 1551 if (auto* jitData = m_jitData.get()) { 1552 return tryBinarySearch<RareCaseProfile, int>(1553 jitData->m_rareCaseProfiles, jitData->m_rareCaseProfiles.size(), bytecode Offset,1554 getRareCaseProfileBytecode Offset);1552 return tryBinarySearch<RareCaseProfile, BytecodeIndex>( 1553 jitData->m_rareCaseProfiles, jitData->m_rareCaseProfiles.size(), bytecodeIndex, 1554 getRareCaseProfileBytecodeIndex); 1555 1555 } 1556 1556 return nullptr; 1557 1557 } 1558 1558 1559 unsigned CodeBlock::rareCaseProfileCountForBytecode Offset(const ConcurrentJSLocker& locker, int bytecodeOffset)1560 { 1561 RareCaseProfile* profile = rareCaseProfileForBytecode Offset(locker, bytecodeOffset);1559 unsigned CodeBlock::rareCaseProfileCountForBytecodeIndex(const ConcurrentJSLocker& locker, BytecodeIndex bytecodeIndex) 1560 { 1561 RareCaseProfile* profile = rareCaseProfileForBytecodeIndex(locker, bytecodeIndex); 1562 1562 if (profile) 1563 1563 return profile->m_counter; … … 1731 1731 #endif 1732 1732 1733 HandlerInfo* CodeBlock::handlerForBytecode Offset(unsigned bytecodeOffset, RequiredHandler requiredHandler)1734 { 1735 RELEASE_ASSERT(bytecode Offset< instructions().size());1736 return handlerForIndex(bytecode Offset, requiredHandler);1733 HandlerInfo* CodeBlock::handlerForBytecodeIndex(BytecodeIndex bytecodeIndex, RequiredHandler requiredHandler) 1734 { 1735 RELEASE_ASSERT(bytecodeIndex.offset() < instructions().size()); 1736 return handlerForIndex(bytecodeIndex.offset(), requiredHandler); 1737 1737 } 1738 1738 … … 1763 1763 1764 1764 1765 void CodeBlock::ensureCatchLivenessIsComputedForBytecode Offset(InstructionStream::Offset bytecodeOffset)1766 { 1767 auto& instruction = instructions().at(bytecode Offset);1765 void CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex(BytecodeIndex bytecodeIndex) 1766 { 1767 auto& instruction = instructions().at(bytecodeIndex); 1768 1768 OpCatch op = instruction->as<OpCatch>(); 1769 1769 auto& metadata = op.metadata(this); … … 1785 1785 } 1786 1786 1787 ensureCatchLivenessIsComputedForBytecode OffsetSlow(op, bytecodeOffset);1788 } 1789 1790 void CodeBlock::ensureCatchLivenessIsComputedForBytecode OffsetSlow(const OpCatch& op, InstructionStream::Offset bytecodeOffset)1787 ensureCatchLivenessIsComputedForBytecodeIndexSlow(op, bytecodeIndex); 1788 } 1789 1790 void CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndexSlow(const OpCatch& op, BytecodeIndex bytecodeIndex) 1791 1791 { 1792 1792 BytecodeLivenessAnalysis& bytecodeLiveness = livenessAnalysis(); … … 1797 1797 // into the DFG. 1798 1798 1799 auto nextOffset = instructions().at(bytecode Offset).next().offset();1800 FastBitVector liveLocals = bytecodeLiveness.getLivenessInfoAtBytecode Offset(this, nextOffset);1799 auto nextOffset = instructions().at(bytecodeIndex).next().offset(); 1800 FastBitVector liveLocals = bytecodeLiveness.getLivenessInfoAtBytecodeIndex(this, BytecodeIndex(nextOffset)); 1801 1801 Vector<VirtualRegister> liveOperands; 1802 1802 liveOperands.reserveInitialCapacity(liveLocals.bitCount()); … … 1843 1843 } 1844 1844 1845 unsigned CodeBlock::lineNumberForBytecode Offset(unsigned bytecodeOffset)1846 { 1847 RELEASE_ASSERT(bytecode Offset< instructions().size());1848 return ownerExecutable()->firstLine() + m_unlinkedCode->lineNumberForBytecode Offset(bytecodeOffset);1849 } 1850 1851 unsigned CodeBlock::columnNumberForBytecode Offset(unsigned bytecodeOffset)1845 unsigned CodeBlock::lineNumberForBytecodeIndex(BytecodeIndex bytecodeIndex) 1846 { 1847 RELEASE_ASSERT(bytecodeIndex.offset() < instructions().size()); 1848 return ownerExecutable()->firstLine() + m_unlinkedCode->lineNumberForBytecodeIndex(bytecodeIndex); 1849 } 1850 1851 unsigned CodeBlock::columnNumberForBytecodeIndex(BytecodeIndex bytecodeIndex) 1852 1852 { 1853 1853 int divot; … … 1856 1856 unsigned line; 1857 1857 unsigned column; 1858 expressionRangeForBytecode Offset(bytecodeOffset, divot, startOffset, endOffset, line, column);1858 expressionRangeForBytecodeIndex(bytecodeIndex, divot, startOffset, endOffset, line, column); 1859 1859 return column; 1860 1860 } 1861 1861 1862 void CodeBlock::expressionRangeForBytecode Offset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) const1863 { 1864 m_unlinkedCode->expressionRangeForBytecode Offset(bytecodeOffset, divot, startOffset, endOffset, line, column);1862 void CodeBlock::expressionRangeForBytecodeIndex(BytecodeIndex bytecodeIndex, int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column) const 1863 { 1864 m_unlinkedCode->expressionRangeForBytecodeIndex(bytecodeIndex, divot, startOffset, endOffset, line, column); 1865 1865 divot += sourceOffset(); 1866 1866 column += line ? 1 : firstLineColumnOffset(); … … 1876 1876 unsigned opDebugLine; 1877 1877 unsigned opDebugColumn; 1878 expressionRangeForBytecode Offset(it.offset(), unused, unused, unused, opDebugLine, opDebugColumn);1878 expressionRangeForBytecodeIndex(it.index(), unused, unused, unused, opDebugLine, opDebugColumn); 1879 1879 if (line == opDebugLine && (!column || column == opDebugColumn)) 1880 1880 return true; … … 2624 2624 #endif 2625 2625 2626 ArrayProfile* CodeBlock::getArrayProfile(const ConcurrentJSLocker&, unsigned bytecodeOffset)2627 { 2628 auto instruction = instructions().at(bytecode Offset);2626 ArrayProfile* CodeBlock::getArrayProfile(const ConcurrentJSLocker&, BytecodeIndex bytecodeIndex) 2627 { 2628 auto instruction = instructions().at(bytecodeIndex); 2629 2629 switch (instruction->opcodeID()) { 2630 2630 #define CASE1(Op) \ … … 2656 2656 } 2657 2657 2658 ArrayProfile* CodeBlock::getArrayProfile( unsigned bytecodeOffset)2658 ArrayProfile* CodeBlock::getArrayProfile(BytecodeIndex bytecodeIndex) 2659 2659 { 2660 2660 ConcurrentJSLocker locker(m_lock); 2661 return getArrayProfile(locker, bytecode Offset);2661 return getArrayProfile(locker, bytecodeIndex); 2662 2662 } 2663 2663 … … 2967 2967 } 2968 2968 2969 ValueProfile* CodeBlock::tryGetValueProfileForBytecode Offset(int bytecodeOffset)2970 { 2971 auto instruction = instructions().at(bytecode Offset);2969 ValueProfile* CodeBlock::tryGetValueProfileForBytecodeIndex(BytecodeIndex bytecodeIndex) 2970 { 2971 auto instruction = instructions().at(bytecodeIndex); 2972 2972 switch (instruction->opcodeID()) { 2973 2973 … … 2986 2986 } 2987 2987 2988 SpeculatedType CodeBlock::valueProfilePredictionForBytecode Offset(const ConcurrentJSLocker& locker, int bytecodeOffset)2989 { 2990 if (ValueProfile* valueProfile = tryGetValueProfileForBytecode Offset(bytecodeOffset))2988 SpeculatedType CodeBlock::valueProfilePredictionForBytecodeIndex(const ConcurrentJSLocker& locker, BytecodeIndex bytecodeIndex) 2989 { 2990 if (ValueProfile* valueProfile = tryGetValueProfileForBytecodeIndex(bytecodeIndex)) 2991 2991 return valueProfile->computeUpdatedPrediction(locker); 2992 2992 return SpecNone; 2993 2993 } 2994 2994 2995 ValueProfile& CodeBlock::valueProfileForBytecode Offset(int bytecodeOffset)2996 { 2997 return *tryGetValueProfileForBytecode Offset(bytecodeOffset);2995 ValueProfile& CodeBlock::valueProfileForBytecodeIndex(BytecodeIndex bytecodeIndex) 2996 { 2997 return *tryGetValueProfileForBytecodeIndex(bytecodeIndex); 2998 2998 } 2999 2999 … … 3002 3002 BytecodeLivenessAnalysis liveness(this); // Compute directly from scratch so it doesn't effect CodeBlock footprint. 3003 3003 3004 FastBitVector liveAtHead = liveness.getLivenessInfoAtBytecode Offset(this, 0);3004 FastBitVector liveAtHead = liveness.getLivenessInfoAtBytecodeIndex(this, BytecodeIndex(0)); 3005 3005 3006 3006 if (liveAtHead.numBits() != static_cast<size_t>(m_numCalleeLocals)) { … … 3026 3026 for (const auto& instruction : instructionStream) { 3027 3027 OpcodeID opcode = instruction->opcodeID(); 3028 if (!!baselineAlternative()->handlerForBytecode Offset(instruction.offset())) {3028 if (!!baselineAlternative()->handlerForBytecodeIndex(BytecodeIndex(instruction.offset()))) { 3029 3029 if (opcode == op_catch || opcode == op_enter) { 3030 3030 // op_catch/op_enter logically represent an entrypoint. Entrypoints are not allowed to be … … 3084 3084 } 3085 3085 3086 ArithProfile* CodeBlock::arithProfileForBytecode Offset(InstructionStream::Offset bytecodeOffset)3087 { 3088 return arithProfileForPC(instructions().at(bytecode Offset).ptr());3086 ArithProfile* CodeBlock::arithProfileForBytecodeIndex(BytecodeIndex bytecodeIndex) 3087 { 3088 return arithProfileForPC(instructions().at(bytecodeIndex.offset()).ptr()); 3089 3089 } 3090 3090 … … 3109 3109 } 3110 3110 3111 bool CodeBlock::couldTakeSpecial FastCase(InstructionStream::Offset bytecodeOffset)3111 bool CodeBlock::couldTakeSpecialArithFastCase(BytecodeIndex bytecodeIndex) 3112 3112 { 3113 3113 if (!hasBaselineJITProfiling()) 3114 3114 return false; 3115 ArithProfile* profile = arithProfileForBytecode Offset(bytecodeOffset);3115 ArithProfile* profile = arithProfileForBytecodeIndex(bytecodeIndex); 3116 3116 if (!profile) 3117 3117 return false; … … 3232 3232 #endif // ENABLE(JIT) 3233 3233 3234 Optional< unsigned> CodeBlock::bytecodeOffsetFromCallSiteIndex(CallSiteIndex callSiteIndex)3235 { 3236 Optional< unsigned> bytecodeOffset;3234 Optional<BytecodeIndex> CodeBlock::bytecodeIndexFromCallSiteIndex(CallSiteIndex callSiteIndex) 3235 { 3236 Optional<BytecodeIndex> bytecodeIndex; 3237 3237 JITType jitType = this->jitType(); 3238 3238 if (jitType == JITType::InterpreterThunk || jitType == JITType::BaselineJIT) { 3239 3239 #if USE(JSVALUE64) 3240 bytecode Offset = callSiteIndex.bits();3240 bytecodeIndex = callSiteIndex.bytecodeIndex(); 3241 3241 #else 3242 3242 Instruction* instruction = bitwise_cast<Instruction*>(callSiteIndex.bits()); 3243 bytecode Offset = this->bytecodeOffset(instruction);3243 bytecodeIndex = this->bytecodeIndex(instruction); 3244 3244 #endif 3245 3245 } else if (jitType == JITType::DFGJIT || jitType == JITType::FTLJIT) { … … 3247 3247 RELEASE_ASSERT(canGetCodeOrigin(callSiteIndex)); 3248 3248 CodeOrigin origin = codeOrigin(callSiteIndex); 3249 bytecode Offset= origin.bytecodeIndex();3249 bytecodeIndex = origin.bytecodeIndex(); 3250 3250 #else 3251 3251 RELEASE_ASSERT_NOT_REACHED(); … … 3253 3253 } 3254 3254 3255 return bytecode Offset;3255 return bytecodeIndex; 3256 3256 } 3257 3257
Note:
See TracChangeset
for help on using the changeset viewer.