Ignore:
Timestamp:
Dec 13, 2011, 11:49:49 AM (13 years ago)
Author:
[email protected]
Message:

DFG should know exactly why recompilation was triggered
https://bugs.webkit.org/show_bug.cgi?id=74362

Reviewed by Oliver Hunt.

Each OSR exit is now individually counted, as well as counting the total number
of OSR exits that occurred in a code block. If recompilation is triggered, we
check to see if there are OSR exit sites that make up a sufficiently large
portion of the total OSR exits that occurred. For any such OSR exit sites, we
add a description of the site (bytecode index, kind) to a data structure in the
corresponding baseline CodeBlock. Then, when we recompile the code, we immediately
know which speculations would be unwise based on the fact that previous such
speculations proved to be fruitless.

This means 2% win on two of the SunSpider string tests, a 4% win on V8's deltablue,
and 5% on Kraken's imaging-darkroom. It is only a minor win in the averages, less
than 0.5%.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::tallyFrequentExitSites):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addFrequentExitSite):
(JSC::CodeBlock::exitProfile):
(JSC::CodeBlock::reoptimize):
(JSC::CodeBlock::tallyFrequentExitSites):

  • bytecode/DFGExitProfile.cpp: Added.

(JSC::DFG::ExitProfile::ExitProfile):
(JSC::DFG::ExitProfile::~ExitProfile):
(JSC::DFG::ExitProfile::add):
(JSC::DFG::QueryableExitProfile::QueryableExitProfile):
(JSC::DFG::QueryableExitProfile::~QueryableExitProfile):

  • bytecode/DFGExitProfile.h: Added.

(JSC::DFG::exitKindToString):
(JSC::DFG::exitKindIsCountable):
(JSC::DFG::FrequentExitSite::FrequentExitSite):
(JSC::DFG::FrequentExitSite::operator!):
(JSC::DFG::FrequentExitSite::operator==):
(JSC::DFG::FrequentExitSite::hash):
(JSC::DFG::FrequentExitSite::bytecodeOffset):
(JSC::DFG::FrequentExitSite::kind):
(JSC::DFG::FrequentExitSite::isHashTableDeletedValue):
(JSC::DFG::FrequentExitSiteHash::hash):
(JSC::DFG::FrequentExitSiteHash::equal):
(JSC::DFG::QueryableExitProfile::hasExitSite):

  • dfg/DFGAssemblyHelpers.h:

(JSC::DFG::AssemblyHelpers::baselineCodeBlockForOriginAndBaselineCodeBlock):
(JSC::DFG::AssemblyHelpers::baselineCodeBlockFor):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::makeSafe):
(JSC::DFG::ByteCodeParser::makeDivSafe):
(JSC::DFG::ByteCodeParser::handleCall):
(JSC::DFG::ByteCodeParser::handleIntrinsic):
(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::OSRExit::OSRExit):
(JSC::DFG::OSRExit::considerAddingAsFrequentExitSiteSlow):

  • dfg/DFGOSRExit.h:

(JSC::DFG::OSRExit::considerAddingAsFrequentExitSite):

  • dfg/DFGOSRExitCompiler.cpp:
  • dfg/DFGOSRExitCompiler32_64.cpp:

(JSC::DFG::OSRExitCompiler::compileExit):

  • dfg/DFGOSRExitCompiler64.cpp:

(JSC::DFG::OSRExitCompiler::compileExit):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compilePeepHoleObjectEquality):
(JSC::DFG::SpeculativeJIT::checkArgumentTypes):
(JSC::DFG::SpeculativeJIT::compileGetCharCodeAt):
(JSC::DFG::SpeculativeJIT::compileGetByValOnString):
(JSC::DFG::SpeculativeJIT::compilePutByValForByteArray):
(JSC::DFG::SpeculativeJIT::compileGetByValOnByteArray):
(JSC::DFG::SpeculativeJIT::compileGetTypedArrayLength):
(JSC::DFG::SpeculativeJIT::compileGetByValOnIntTypedArray):
(JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray):
(JSC::DFG::SpeculativeJIT::compileGetByValOnFloatTypedArray):
(JSC::DFG::SpeculativeJIT::compilePutByValForFloatTypedArray):
(JSC::DFG::SpeculativeJIT::compileInstanceOfForObject):
(JSC::DFG::SpeculativeJIT::compileSoftModulo):
(JSC::DFG::SpeculativeJIT::compileArithMul):
(JSC::DFG::SpeculativeJIT::compileGetIndexedPropertyStorage):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::speculationCheck):
(JSC::DFG::SpeculativeJIT::terminateSpeculativeExecution):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::fillSpeculateIntInternal):
(JSC::DFG::SpeculativeJIT::fillSpeculateDouble):
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
(JSC::DFG::SpeculativeJIT::fillSpeculateBoolean):
(JSC::DFG::SpeculativeJIT::compileObjectEquality):
(JSC::DFG::SpeculativeJIT::compileObjectOrOtherLogicalNot):
(JSC::DFG::SpeculativeJIT::emitObjectOrOtherBranch):
(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::fillSpeculateIntInternal):
(JSC::DFG::SpeculativeJIT::fillSpeculateDouble):
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
(JSC::DFG::SpeculativeJIT::fillSpeculateBoolean):
(JSC::DFG::SpeculativeJIT::compileObjectEquality):
(JSC::DFG::SpeculativeJIT::compileObjectOrOtherLogicalNot):
(JSC::DFG::SpeculativeJIT::compileLogicalNot):
(JSC::DFG::SpeculativeJIT::emitObjectOrOtherBranch):
(JSC::DFG::SpeculativeJIT::emitBranch):
(JSC::DFG::SpeculativeJIT::compile):

  • runtime/Heuristics.cpp:

(JSC::Heuristics::initializeHeuristics):

  • runtime/Heuristics.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r102489 r102694  
    22422242#endif
    22432243
     2244#if ENABLE(DFG_JIT)
     2245void CodeBlock::tallyFrequentExitSites()
     2246{
     2247    ASSERT(getJITType() == JITCode::DFGJIT);
     2248    ASSERT(alternative()->getJITType() == JITCode::BaselineJIT);
     2249    ASSERT(!!m_dfgData);
     2250   
     2251    CodeBlock* profiledBlock = alternative();
     2252   
     2253    for (unsigned i = 0; i < m_dfgData->osrExit.size(); ++i) {
     2254        DFG::OSRExit& exit = m_dfgData->osrExit[i];
     2255       
     2256        if (!exit.considerAddingAsFrequentExitSite(this, profiledBlock))
     2257            continue;
     2258       
     2259#if DFG_ENABLE(DEBUG_VERBOSE)
     2260        fprintf(stderr, "OSR exit #%u (bc#%u, @%u, %s) for code block %p occurred frequently; counting as frequent exit site.\n", i, exit.m_codeOrigin.bytecodeIndex, exit.m_nodeIndex, DFG::exitKindToString(exit.m_kind), this);
     2261#endif
     2262    }
     2263}
     2264#endif // ENABLE(DFG_JIT)
     2265
    22442266#if ENABLE(VERBOSE_VALUE_PROFILE)
    22452267void CodeBlock::dumpValueProfiles()
Note: See TracChangeset for help on using the changeset viewer.