Ignore:
Timestamp:
Sep 21, 2011, 4:36:35 PM (14 years ago)
Author:
[email protected]
Message:

DFG should support continuous optimization
https://bugs.webkit.org/show_bug.cgi?id=68329

Reviewed by Geoffrey Garen.

This adds the ability to reoptimize a code block if speculation
failures happen frequently. 6% speed-up on Kraken, 1% slow-down
on V8, neutral on SunSpider.

(JSC::CodeBlock::CodeBlock):
(JSC::ProgramCodeBlock::jettison):
(JSC::EvalCodeBlock::jettison):
(JSC::FunctionCodeBlock::jettison):
(JSC::CodeBlock::shouldOptimizeNow):
(JSC::CodeBlock::dumpValueProfiles):

  • bytecode/CodeBlock.h:
  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::getStrongPrediction):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::exitSpeculativeWithOSR):
(JSC::DFG::JITCompiler::compileEntry):
(JSC::DFG::JITCompiler::compileBody):

  • dfg/DFGJITCompiler.h:

(JSC::DFG::JITCompiler::noticeOSREntry):

  • dfg/DFGOSREntry.cpp:

(JSC::DFG::prepareOSREntry):

  • dfg/DFGOSREntry.h:

(JSC::DFG::getOSREntryDataBytecodeIndex):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • heap/ConservativeRoots.cpp:

(JSC::ConservativeRoots::ConservativeRoots):
(JSC::ConservativeRoots::~ConservativeRoots):
(JSC::DummyMarkHook::mark):
(JSC::ConservativeRoots::genericAddPointer):
(JSC::ConservativeRoots::genericAddSpan):
(JSC::ConservativeRoots::add):

  • heap/ConservativeRoots.h:
  • heap/Heap.cpp:

(JSC::Heap::addJettisonCodeBlock):
(JSC::Heap::markRoots):

  • heap/Heap.h:
  • heap/JettisonedCodeBlocks.cpp: Added.

(JSC::JettisonedCodeBlocks::JettisonedCodeBlocks):
(JSC::JettisonedCodeBlocks::~JettisonedCodeBlocks):
(JSC::JettisonedCodeBlocks::addCodeBlock):
(JSC::JettisonedCodeBlocks::clearMarks):
(JSC::JettisonedCodeBlocks::deleteUnmarkedCodeBlocks):
(JSC::JettisonedCodeBlocks::traceCodeBlocks):

  • heap/JettisonedCodeBlocks.h: Added.

(JSC::JettisonedCodeBlocks::mark):

  • interpreter/RegisterFile.cpp:

(JSC::RegisterFile::gatherConservativeRoots):

  • interpreter/RegisterFile.h:
  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • runtime/Executable.cpp:

(JSC::jettisonCodeBlock):
(JSC::EvalExecutable::jettisonOptimizedCode):
(JSC::ProgramExecutable::jettisonOptimizedCode):
(JSC::FunctionExecutable::jettisonOptimizedCodeForCall):
(JSC::FunctionExecutable::jettisonOptimizedCodeForConstruct):

  • runtime/Executable.h:

(JSC::FunctionExecutable::jettisonOptimizedCodeFor):

  • wtf/BitVector.h: Added.

(WTF::BitVector::BitVector):
(WTF::BitVector::~BitVector):
(WTF::BitVector::operator=):
(WTF::BitVector::size):
(WTF::BitVector::ensureSize):
(WTF::BitVector::resize):
(WTF::BitVector::clearAll):
(WTF::BitVector::get):
(WTF::BitVector::set):
(WTF::BitVector::clear):
(WTF::BitVector::bitsInPointer):
(WTF::BitVector::maxInlineBits):
(WTF::BitVector::byteCount):
(WTF::BitVector::makeInlineBits):
(WTF::BitVector::OutOfLineBits::numBits):
(WTF::BitVector::OutOfLineBits::numWords):
(WTF::BitVector::OutOfLineBits::bits):
(WTF::BitVector::OutOfLineBits::create):
(WTF::BitVector::OutOfLineBits::destroy):
(WTF::BitVector::OutOfLineBits::OutOfLineBits):
(WTF::BitVector::isInline):
(WTF::BitVector::outOfLineBits):
(WTF::BitVector::resizeOutOfLine):
(WTF::BitVector::bits):

File:
1 edited

Legend:

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

    r95676 r95681  
    14291429    , m_symbolTable(symTab)
    14301430    , m_alternative(alternative)
     1431    , m_speculativeSuccessCounter(0)
     1432    , m_speculativeFailCounter(0)
    14311433    , m_optimizationDelayCounter(0)
     1434    , m_reoptimizationRetryCounter(0)
    14321435{
    14331436    ASSERT(m_source);
     
    19361939    return DFG::canCompileFunctionForCall(this);
    19371940}
     1941
     1942void ProgramCodeBlock::jettison(JSGlobalData& globalData)
     1943{
     1944    ASSERT(getJITType() != JITCode::BaselineJIT);
     1945    ASSERT(this == replacement());
     1946    static_cast<ProgramExecutable*>(ownerExecutable())->jettisonOptimizedCode(globalData);
     1947}
     1948
     1949void EvalCodeBlock::jettison(JSGlobalData& globalData)
     1950{
     1951    ASSERT(getJITType() != JITCode::BaselineJIT);
     1952    ASSERT(this == replacement());
     1953    static_cast<EvalExecutable*>(ownerExecutable())->jettisonOptimizedCode(globalData);
     1954}
     1955
     1956void FunctionCodeBlock::jettison(JSGlobalData& globalData)
     1957{
     1958    ASSERT(getJITType() != JITCode::BaselineJIT);
     1959    ASSERT(this == replacement());
     1960    static_cast<FunctionExecutable*>(ownerExecutable())->jettisonOptimizedCodeFor(globalData, m_isConstructor ? CodeForConstruct : CodeForCall);
     1961}
    19381962#endif
    19391963
     
    19751999#endif
    19762000
    1977     if ((double)numberOfLiveNonArgumentValueProfiles / numberOfNonArgumentValueProfiles >= 0.75
    1978         && (double)numberOfSamplesInProfiles / ValueProfile::numberOfBuckets / numberOfValueProfiles() >= 0.5)
     2001    if ((!numberOfNonArgumentValueProfiles || (double)numberOfLiveNonArgumentValueProfiles / numberOfNonArgumentValueProfiles >= 0.75)
     2002        && (!numberOfValueProfiles() || (double)numberOfSamplesInProfiles / ValueProfile::numberOfBuckets / numberOfValueProfiles() >= 0.5))
    19792003        return true;
    19802004   
     
    20182042        fprintf(stderr, "   bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
    20192043    }
     2044    fprintf(stderr, "SpecialFastCaseProfile for %p:\n", this);
     2045    for (unsigned i = 0; i < numberOfSpecialFastCaseProfiles(); ++i) {
     2046        RareCaseProfile* profile = specialFastCaseProfile(i);
     2047        fprintf(stderr, "   bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
     2048    }
    20202049}
    20212050#endif
Note: See TracChangeset for help on using the changeset viewer.