Changeset 146669 in webkit
- Timestamp:
- Mar 22, 2013 4:00:57 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r146653 r146669 1 2013-03-21 Filip Pizlo <fpizlo@apple.com> 2 3 Fix some minor issues in the DFG's profiling of heap accesses 4 https://bugs.webkit.org/show_bug.cgi?id=113010 5 6 Reviewed by Goeffrey Garen. 7 8 1) If a CodeBlock gets jettisoned by GC, we should count the exit sites. 9 10 2) If a CodeBlock clears a structure stub during GC, it should record this, and 11 the DFG should prefer to not inline that access (i.e. treat it as if it had an 12 exit site). 13 14 3) If a PutById was seen by the baseline JIT, and the JIT attempted to cache it, 15 but it chose not to, then assume that it will take slow path. 16 17 4) If we frequently exited because of a structure check on a weak constant, 18 don't try to inline that access in the future. 19 20 5) Treat all exits that were counted as being frequent. 21 22 81% speed-up on Octane/gbemu. Small speed-ups elsewhere, and no regressions. 23 24 * bytecode/CodeBlock.cpp: 25 (JSC::CodeBlock::finalizeUnconditionally): 26 (JSC): 27 (JSC::CodeBlock::resetStubDuringGCInternal): 28 (JSC::CodeBlock::reoptimize): 29 (JSC::CodeBlock::jettison): 30 (JSC::ProgramCodeBlock::jettisonImpl): 31 (JSC::EvalCodeBlock::jettisonImpl): 32 (JSC::FunctionCodeBlock::jettisonImpl): 33 (JSC::CodeBlock::tallyFrequentExitSites): 34 * bytecode/CodeBlock.h: 35 (CodeBlock): 36 (JSC::CodeBlock::tallyFrequentExitSites): 37 (ProgramCodeBlock): 38 (EvalCodeBlock): 39 (FunctionCodeBlock): 40 * bytecode/GetByIdStatus.cpp: 41 (JSC::GetByIdStatus::computeFor): 42 * bytecode/PutByIdStatus.cpp: 43 (JSC::PutByIdStatus::computeFor): 44 * bytecode/StructureStubInfo.h: 45 (JSC::StructureStubInfo::StructureStubInfo): 46 (StructureStubInfo): 47 * dfg/DFGByteCodeParser.cpp: 48 (JSC::DFG::ByteCodeParser::handleGetById): 49 (JSC::DFG::ByteCodeParser::parseBlock): 50 * dfg/DFGOSRExit.cpp: 51 (JSC::DFG::OSRExit::considerAddingAsFrequentExitSiteSlow): 52 * dfg/DFGOSRExit.h: 53 (JSC::DFG::OSRExit::considerAddingAsFrequentExitSite): 54 (OSRExit): 55 * jit/JITStubs.cpp: 56 (JSC::DEFINE_STUB_FUNCTION): 57 * runtime/Options.h: 58 (JSC): 59 1 60 2013-03-22 Filip Pizlo <fpizlo@apple.com> 2 61 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r146552 r146669 2339 2339 dataLog(*this, " has dead weak references, jettisoning during GC.\n"); 2340 2340 2341 // Make sure that the baseline JIT knows that it should re-warm-up before2342 // optimizing.2343 alternative()->optimizeAfterWarmUp();2344 2345 2341 if (DFG::shouldShowDisassembly()) { 2346 2342 dataLog(*this, " will be jettisoned because of the following dead references:\n"); … … 2428 2424 continue; 2429 2425 2430 resetStub Internal(repatchBuffer, stubInfo);2426 resetStubDuringGCInternal(repatchBuffer, stubInfo); 2431 2427 } 2432 2428 } … … 2465 2461 2466 2462 stubInfo.reset(); 2463 } 2464 2465 void CodeBlock::resetStubDuringGCInternal(RepatchBuffer& repatchBuffer, StructureStubInfo& stubInfo) 2466 { 2467 resetStubInternal(repatchBuffer, stubInfo); 2468 stubInfo.resetByGC = true; 2467 2469 } 2468 2470 #endif … … 2843 2845 ASSERT(replacement() != this); 2844 2846 ASSERT(replacement()->alternative() == this); 2845 replacement()->tallyFrequentExitSites();2846 2847 if (DFG::shouldShowDisassembly()) 2847 2848 dataLog(*replacement(), " will be jettisoned due to reoptimization of ", *this, ".\n"); 2848 2849 replacement()->jettison(); 2849 2850 countReoptimization(); 2850 optimizeAfterWarmUp();2851 2851 } 2852 2852 … … 2907 2907 } 2908 2908 2909 void ProgramCodeBlock::jettison()2909 void CodeBlock::jettison() 2910 2910 { 2911 2911 ASSERT(JITCode::isOptimizingJIT(getJITType())); 2912 2912 ASSERT(this == replacement()); 2913 alternative()->optimizeAfterWarmUp(); 2914 tallyFrequentExitSites(); 2913 2915 if (DFG::shouldShowDisassembly()) 2914 2916 dataLog("Jettisoning ", *this, ".\n"); 2917 jettisonImpl(); 2918 } 2919 2920 void ProgramCodeBlock::jettisonImpl() 2921 { 2915 2922 static_cast<ProgramExecutable*>(ownerExecutable())->jettisonOptimizedCode(*globalData()); 2916 2923 } 2917 2924 2918 void EvalCodeBlock::jettison() 2919 { 2920 ASSERT(JITCode::isOptimizingJIT(getJITType())); 2921 ASSERT(this == replacement()); 2922 if (DFG::shouldShowDisassembly()) 2923 dataLog("Jettisoning ", *this, ".\n"); 2925 void EvalCodeBlock::jettisonImpl() 2926 { 2924 2927 static_cast<EvalExecutable*>(ownerExecutable())->jettisonOptimizedCode(*globalData()); 2925 2928 } 2926 2929 2927 void FunctionCodeBlock::jettison() 2928 { 2929 ASSERT(JITCode::isOptimizingJIT(getJITType())); 2930 ASSERT(this == replacement()); 2931 if (DFG::shouldShowDisassembly()) 2932 dataLog("Jettisoning ", *this, ".\n"); 2930 void FunctionCodeBlock::jettisonImpl() 2931 { 2933 2932 static_cast<FunctionExecutable*>(ownerExecutable())->jettisonOptimizedCodeFor(*globalData(), m_isConstructor ? CodeForConstruct : CodeForCall); 2934 2933 } … … 3273 3272 DFG::OSRExit& exit = m_dfgData->osrExit[i]; 3274 3273 3275 if (!exit.considerAddingAsFrequentExitSite( this,profiledBlock))3274 if (!exit.considerAddingAsFrequentExitSite(profiledBlock)) 3276 3275 continue; 3277 3276 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r146089 r146669 438 438 ExecutableMemoryHandle* executableMemory() { return getJITCode().getExecutableMemory(); } 439 439 virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex) = 0; 440 v irtual void jettison() = 0;440 void jettison(); 441 441 enum JITCompilationResult { AlreadyCompiled, CouldNotCompile, CompiledSuccessfully }; 442 442 JITCompilationResult jitCompile(ExecState* exec) … … 1052 1052 #if ENABLE(JIT) 1053 1053 virtual bool jitCompileImpl(ExecState*) = 0; 1054 virtual void jettisonImpl() = 0; 1054 1055 #endif 1055 1056 virtual void visitWeakReferences(SlotVisitor&); 1056 1057 virtual void finalizeUnconditionally(); 1057 1058 1058 private:1059 friend class DFGCodeBlocks;1060 1061 double optimizationThresholdScalingFactor();1062 1063 #if ENABLE(JIT)1064 ClosureCallStubRoutine* findClosureCallForReturnPC(ReturnAddressPtr);1065 #endif1066 1067 1059 #if ENABLE(DFG_JIT) 1068 1060 void tallyFrequentExitSites(); … … 1070 1062 void tallyFrequentExitSites() { } 1071 1063 #endif 1064 1065 private: 1066 friend class DFGCodeBlocks; 1067 1068 double optimizationThresholdScalingFactor(); 1069 1070 #if ENABLE(JIT) 1071 ClosureCallStubRoutine* findClosureCallForReturnPC(ReturnAddressPtr); 1072 #endif 1073 1072 1074 #if ENABLE(VALUE_PROFILER) 1073 1075 void updateAllPredictionsAndCountLiveness(OperationInProgress, unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles); … … 1146 1148 #if ENABLE(JIT) 1147 1149 void resetStubInternal(RepatchBuffer&, StructureStubInfo&); 1150 void resetStubDuringGCInternal(RepatchBuffer&, StructureStubInfo&); 1148 1151 #endif 1149 1152 WriteBarrier<UnlinkedCodeBlock> m_unlinkedCode; … … 1321 1324 protected: 1322 1325 virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex); 1323 virtual void jettison ();1326 virtual void jettisonImpl(); 1324 1327 virtual bool jitCompileImpl(ExecState*); 1325 1328 virtual CodeBlock* replacement(); … … 1346 1349 protected: 1347 1350 virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex); 1348 virtual void jettison ();1351 virtual void jettisonImpl(); 1349 1352 virtual bool jitCompileImpl(ExecState*); 1350 1353 virtual CodeBlock* replacement(); … … 1371 1374 protected: 1372 1375 virtual JSObject* compileOptimized(ExecState*, JSScope*, unsigned bytecodeIndex); 1373 virtual void jettison ();1376 virtual void jettisonImpl(); 1374 1377 virtual bool jitCompileImpl(ExecState*); 1375 1378 virtual CodeBlock* replacement(); -
trunk/Source/JavaScriptCore/bytecode/GetByIdStatus.cpp
r139541 r146669 126 126 return computeFromLLInt(profiledBlock, bytecodeIndex, ident); 127 127 128 if (stubInfo.resetByGC) 129 return GetByIdStatus(TakesSlowPath, true); 130 128 131 PolymorphicAccessStructureList* list; 129 132 int listSize; -
trunk/Source/JavaScriptCore/bytecode/PutByIdStatus.cpp
r146653 r146669 95 95 return computeFromLLInt(profiledBlock, bytecodeIndex, ident); 96 96 97 if (stubInfo.resetByGC) 98 return PutByIdStatus(TakesSlowPath, 0, 0, 0, invalidOffset); 99 97 100 switch (stubInfo.accessType) { 98 101 case access_unset: 99 return computeFromLLInt(profiledBlock, bytecodeIndex, ident); 102 // If the JIT saw it but didn't optimize it, then assume that this takes slow path. 103 return PutByIdStatus(TakesSlowPath, 0, 0, 0, invalidOffset); 100 104 101 105 case access_put_by_id_replace: { -
trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h
r143392 r146669 98 98 : accessType(access_unset) 99 99 , seen(false) 100 , resetByGC(false) 100 101 { 101 102 } … … 201 202 202 203 int8_t accessType; 203 int8_t seen; 204 bool seen : 1; 205 bool resetByGC : 1; 204 206 205 207 #if ENABLE(DFG_JIT) -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r146548 r146669 1709 1709 { 1710 1710 if (!getByIdStatus.isSimple() 1711 || m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache)) { 1711 || m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache) 1712 || m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadWeakConstantCache)) { 1712 1713 set(destinationOperand, 1713 1714 addToGraph( … … 2609 2610 } 2610 2611 2611 bool hasExitSite = m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache); 2612 bool hasExitSite = 2613 m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadCache) 2614 || m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadWeakConstantCache); 2612 2615 2613 2616 if (!hasExitSite && putByIdStatus.isSimpleReplace()) { -
trunk/Source/JavaScriptCore/dfg/DFGOSRExit.cpp
r141069 r146669 73 73 } 74 74 75 bool OSRExit::considerAddingAsFrequentExitSiteSlow(CodeBlock* dfgCodeBlock, CodeBlock*profiledCodeBlock)75 bool OSRExit::considerAddingAsFrequentExitSiteSlow(CodeBlock* profiledCodeBlock) 76 76 { 77 if (static_cast<double>(m_count) / dfgCodeBlock->osrExitCounter() <= Options::osrExitProminenceForFrequentExitSite())78 return false;79 80 77 FrequentExitSite exitSite; 81 78 -
trunk/Source/JavaScriptCore/dfg/DFGOSRExit.h
r141069 r146669 101 101 uint32_t m_count; 102 102 103 bool considerAddingAsFrequentExitSite(CodeBlock* dfgCodeBlock, CodeBlock*profiledCodeBlock)103 bool considerAddingAsFrequentExitSite(CodeBlock* profiledCodeBlock) 104 104 { 105 105 if (!m_count || !exitKindIsCountable(m_kind)) 106 106 return false; 107 return considerAddingAsFrequentExitSiteSlow( dfgCodeBlock,profiledCodeBlock);107 return considerAddingAsFrequentExitSiteSlow(profiledCodeBlock); 108 108 } 109 109 … … 119 119 120 120 private: 121 bool considerAddingAsFrequentExitSiteSlow(CodeBlock* dfgCodeBlock, CodeBlock*profiledCodeBlock);121 bool considerAddingAsFrequentExitSiteSlow(CodeBlock* profiledCodeBlock); 122 122 }; 123 123 -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r146552 r146669 1457 1457 1458 1458 if (accessType == static_cast<AccessType>(stubInfo->accessType)) { 1459 if (!stubInfo->seenOnce()) 1460 stubInfo->setSeen(); 1461 else 1462 tryCachePutByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, stackFrame.args[0].jsValue(), slot, stubInfo, false); 1459 stubInfo->setSeen(); 1460 tryCachePutByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, stackFrame.args[0].jsValue(), slot, stubInfo, false); 1463 1461 } 1464 1462 … … 1483 1481 1484 1482 if (accessType == static_cast<AccessType>(stubInfo->accessType)) { 1485 if (!stubInfo->seenOnce()) 1486 stubInfo->setSeen(); 1487 else 1488 tryCachePutByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, stackFrame.args[0].jsValue(), slot, stubInfo, true); 1483 stubInfo->setSeen(); 1484 tryCachePutByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, stackFrame.args[0].jsValue(), slot, stubInfo, true); 1489 1485 } 1490 1486 -
trunk/Source/JavaScriptCore/runtime/Options.h
r142377 r146669 112 112 v(unsigned, couldTakeSlowCaseMinimumCount, 10) \ 113 113 \ 114 v(double, osrExitProminenceForFrequentExitSite, 0.3) \115 114 v(unsigned, osrExitCountForReoptimization, 100) \ 116 115 v(unsigned, osrExitCountForReoptimizationFromLoop, 5) \
Note: See TracChangeset
for help on using the changeset viewer.