Changeset 277758 in webkit
- Timestamp:
- May 19, 2021, 3:30:16 PM (4 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r277757 r277758 1 2021-05-19 Mark Lam <mark.lam@apple.com> 2 3 Ripping out broken Baseline JIT rare case profiling. 4 https://bugs.webkit.org/show_bug.cgi?id=225983 5 6 Reviewed by Saam Barati and Robin Morisset. 7 8 The profiling has been broken in recent times. Fixing it to work does not appear 9 to improve performance. Ripping out the profiling appears to not hurt performance. 10 However, ripping out the profiling appears to save on code size generated for the 11 Baseline JIT. 12 13 Base New Diff 14 15 BaselineJIT: 73299112 (69.903481 MB) 65910128 (62.856796 MB) 0.90x (reduction) 16 DFG: 36850540 (35.143414 MB) 36374400 (34.689331 MB) 0.99x 17 Thunk: 23128652 (22.057201 MB) 22892292 (21.831791 MB) 0.99x 18 InlineCache: 22210972 (21.182034 MB) 22083508 (21.060474 MB) 0.99x 19 FTL: 6065064 (5.784096 MB) 6128080 (5.844193 MB) 1.01x 20 Wasm: 2305124 (2.198338 MB) 2309732 (2.202732 MB) 1.00x 21 YarrJIT: 1522712 (1.452171 MB) 1536104 (1.464943 MB) 1.01x 22 CSSJIT: 0 0 23 Uncategorized: 0 0 24 25 Cumulative diff since the start of this effort to put more code in JIT thunks: 26 27 Base New Diff 28 29 BaselineJIT: 89089964 (84.962811 MB) 65910128 (62.856796 MB) 0.74x (reduction) 30 DFG: 39117360 (37.305222 MB) 36374400 (34.689331 MB) 0.93x (reduction) 31 Thunk: 23230968 (22.154778 MB) 22892292 (21.831791 MB) 0.99x 32 InlineCache: 22027416 (21.006981 MB) 22083508 (21.060474 MB) 1.00x 33 FTL: 6575772 (6.271145 MB) 6128080 (5.844193 MB) 0.93x (reduction) 34 Wasm: 2302724 (2.196049 MB) 2309732 (2.202732 MB) 1.00x 35 YarrJIT: 1538956 (1.467663 MB) 1536104 (1.464943 MB) 1.00x 36 CSSJIT: 0 0 37 Uncategorized: 0 0 38 39 Benchmarking was done with Speedometer2 and JetSteam2 on an M1 Mac. 40 41 * bytecode/CodeBlock.cpp: 42 (JSC::CodeBlock::JITData::size const): 43 (JSC::CodeBlock::dumpValueProfiles): 44 (JSC::CodeBlock::setRareCaseProfiles): Deleted. 45 (JSC::CodeBlock::rareCaseProfileForBytecodeIndex): Deleted. 46 (JSC::CodeBlock::rareCaseProfileCountForBytecodeIndex): Deleted. 47 * bytecode/CodeBlock.h: 48 (JSC::CodeBlock::likelyToTakeSlowCase): Deleted. 49 (JSC::CodeBlock::couldTakeSlowCase): Deleted. 50 * bytecode/ValueProfile.h: 51 (JSC::RareCaseProfile::RareCaseProfile): Deleted. 52 (JSC::getRareCaseProfileBytecodeIndex): Deleted. 53 * dfg/DFGByteCodeParser.cpp: 54 (JSC::DFG::ByteCodeParser::makeSafe): 55 (JSC::DFG::ByteCodeParser::parseBlock): 56 * jit/JIT.cpp: 57 (JSC::JIT::privateCompileSlowCases): 58 1 59 2021-05-19 Yusuke Suzuki <ysuzuki@apple.com> 2 60 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r277727 r277758 1041 1041 size += m_byValInfos.estimatedAllocationSizeInBytes(); 1042 1042 size += m_callLinkInfos.estimatedAllocationSizeInBytes(); 1043 size += m_rareCaseProfiles.size() * sizeof(decltype(*m_rareCaseProfiles.data()));1044 1043 size += m_switchJumpTables.size() * sizeof(decltype(*m_switchJumpTables.data())); 1045 1044 size += m_stringSwitchJumpTables.size() * sizeof(decltype(*m_stringSwitchJumpTables.data())); … … 1763 1762 } 1764 1763 return nullptr; 1765 }1766 1767 void CodeBlock::setRareCaseProfiles(FixedVector<RareCaseProfile>&& rareCaseProfiles)1768 {1769 ConcurrentJSLocker locker(m_lock);1770 ensureJITData(locker).m_rareCaseProfiles = WTFMove(rareCaseProfiles);1771 }1772 1773 RareCaseProfile* CodeBlock::rareCaseProfileForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex bytecodeIndex)1774 {1775 if (auto* jitData = m_jitData.get()) {1776 return tryBinarySearch<RareCaseProfile, BytecodeIndex>(1777 jitData->m_rareCaseProfiles, jitData->m_rareCaseProfiles.size(), bytecodeIndex,1778 getRareCaseProfileBytecodeIndex);1779 }1780 return nullptr;1781 }1782 1783 unsigned CodeBlock::rareCaseProfileCountForBytecodeIndex(const ConcurrentJSLocker& locker, BytecodeIndex bytecodeIndex)1784 {1785 RareCaseProfile* profile = rareCaseProfileForBytecodeIndex(locker, bytecodeIndex);1786 if (profile)1787 return profile->m_counter;1788 return 0;1789 1764 } 1790 1765 … … 3138 3113 dataLogF("\n"); 3139 3114 }); 3140 dataLog("RareCaseProfile for ", *this, ":\n");3141 if (auto* jitData = m_jitData.get()) {3142 for (RareCaseProfile* profile : jitData->m_rareCaseProfiles)3143 dataLogF(" bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);3144 }3145 3115 } 3146 3116 #endif // ENABLE(VERBOSE_VALUE_PROFILE) -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r277727 r277758 282 282 SentinelLinkedList<CallLinkInfo, PackedRawSentinelNode<CallLinkInfo>> m_incomingCalls; 283 283 SentinelLinkedList<PolymorphicCallNode, PackedRawSentinelNode<PolymorphicCallNode>> m_incomingPolymorphicCalls; 284 FixedVector<RareCaseProfile> m_rareCaseProfiles;285 284 FixedVector<SimpleJumpTable> m_switchJumpTables; 286 285 FixedVector<StringJumpTable> m_stringSwitchJumpTables; … … 348 347 void setCalleeSaveRegisters(RegisterSet); 349 348 void setCalleeSaveRegisters(RegisterAtOffsetList&&); 350 351 void setRareCaseProfiles(FixedVector<RareCaseProfile>&&);352 RareCaseProfile* rareCaseProfileForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex);353 unsigned rareCaseProfileCountForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex);354 355 bool likelyToTakeSlowCase(BytecodeIndex bytecodeIndex)356 {357 if (!hasBaselineJITProfiling())358 return false;359 ConcurrentJSLocker locker(m_lock);360 unsigned value = rareCaseProfileCountForBytecodeIndex(locker, bytecodeIndex);361 return value >= Options::likelyToTakeSlowCaseMinimumCount();362 }363 364 bool couldTakeSlowCase(BytecodeIndex bytecodeIndex)365 {366 if (!hasBaselineJITProfiling())367 return false;368 ConcurrentJSLocker locker(m_lock);369 unsigned value = rareCaseProfileCountForBytecodeIndex(locker, bytecodeIndex);370 return value >= Options::couldTakeSlowCaseMinimumCount();371 }372 349 373 350 // We call this when we want to reattempt compiling something with the baseline JIT. Ideally -
trunk/Source/JavaScriptCore/bytecode/ValueProfile.h
r276102 r277758 1 1 /* 2 * Copyright (C) 2011-20 19Apple Inc. All rights reserved.2 * Copyright (C) 2011-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 159 159 }; 160 160 161 // This is a mini value profile to catch pathologies. It is a counter that gets162 // incremented when we take the slow path on any instruction.163 struct RareCaseProfile {164 RareCaseProfile(BytecodeIndex bytecodeIndex)165 : m_bytecodeIndex(bytecodeIndex)166 {167 }168 RareCaseProfile() = default;169 170 BytecodeIndex m_bytecodeIndex { };171 uint32_t m_counter { 0 };172 };173 174 inline BytecodeIndex getRareCaseProfileBytecodeIndex(RareCaseProfile* rareCaseProfile)175 {176 return rareCaseProfile->m_bytecodeIndex;177 }178 179 161 struct ValueProfileAndVirtualRegister : public ValueProfile { 180 162 VirtualRegister m_operand; -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r277117 r277758 1066 1066 default: 1067 1067 break; 1068 }1069 1070 if (m_inlineStackTop->m_profiledBlock->likelyToTakeSlowCase(m_currentIndex)) {1071 switch (node->op()) {1072 case UInt32ToNumber:1073 case ArithAdd:1074 case ArithSub:1075 case ValueAdd:1076 case ValueMod:1077 case ArithMod: // for ArithMod "MayOverflow" means we tried to divide by zero, or we saw double.1078 node->mergeFlags(NodeMayOverflowInt32InBaseline);1079 break;1080 1081 default:1082 break;1083 }1084 1068 } 1085 1069 … … 5436 5420 || !cachedStructure 5437 5421 || cachedStructure->classInfo()->methodTable.toThis != JSObject::info()->methodTable.toThis 5438 || m_inlineStackTop->m_profiledBlock->couldTakeSlowCase(m_currentIndex)5439 5422 || m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache) 5440 5423 || (op1->op() == GetLocal && op1->variableAccessData()->structureCheckHoistingFailed())) { -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r277757 r277758 516 516 m_callLinkInfoIndex = 0; 517 517 518 FixedVector<RareCaseProfile> rareCaseProfiles;519 if (shouldEmitProfiling())520 rareCaseProfiles = FixedVector<RareCaseProfile>(m_bytecodeCountHavingSlowCase);521 522 518 unsigned bytecodeCountHavingSlowCase = 0; 523 519 for (Vector<SlowCaseEntry>::iterator iter = m_slowCases.begin(); iter != m_slowCases.end();) { … … 530 526 const Instruction* currentInstruction = m_codeBlock->instructions().at(m_bytecodeIndex).ptr(); 531 527 532 RareCaseProfile* rareCaseProfile = nullptr;533 if (shouldEmitProfiling())534 rareCaseProfile = &rareCaseProfiles.at(bytecodeCountHavingSlowCase);535 536 528 if (JITInternal::verbose) 537 529 dataLogLn("Baseline JIT emitting slow code for ", m_bytecodeIndex, " at offset ", (long)debugOffset()); … … 648 640 RELEASE_ASSERT_WITH_MESSAGE(firstTo.offset() == (iter - 1)->to.offset(), "Too many jumps linked in slow case codegen."); 649 641 650 if (shouldEmitProfiling())651 add32(TrustedImm32(1), AbsoluteAddress(&rareCaseProfile->m_counter));652 653 642 emitJumpSlowToHot(jump(), 0); 654 643 ++bytecodeCountHavingSlowCase; … … 663 652 RELEASE_ASSERT(m_privateBrandAccessIndex == m_privateBrandAccesses.size()); 664 653 RELEASE_ASSERT(m_callLinkInfoIndex == m_callCompilationInfo.size()); 665 666 if (shouldEmitProfiling())667 m_codeBlock->setRareCaseProfiles(WTFMove(rareCaseProfiles));668 654 669 655 #ifndef NDEBUG
Note:
See TracChangeset
for help on using the changeset viewer.