Ignore:
Timestamp:
Jun 25, 2012, 7:14:07 PM (13 years ago)
Author:
[email protected]
Message:

Value profiling should use tier-up threshold randomization to get more coverage
https://bugs.webkit.org/show_bug.cgi?id=89802

Source/JavaScriptCore:

Reviewed by Gavin Barraclough.

This patch causes both LLInt and Baseline JIT code to take the OSR slow path several
times before actually doing OSR. If we take the OSR slow path before the execution
count threshold is reached, then we just call CodeBlock::updateAllPredictions() to
compute the current latest least-upper-bound SpecType of all values seen in each
ValueProfile.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::stronglyVisitStrongReferences):
(JSC::CodeBlock::updateAllPredictionsAndCountLiveness):
(JSC):
(JSC::CodeBlock::updateAllPredictions):
(JSC::CodeBlock::shouldOptimizeNow):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::llintExecuteCounter):
(JSC::CodeBlock::jitExecuteCounter):
(CodeBlock):
(JSC::CodeBlock::updateAllPredictions):

  • bytecode/ExecutionCounter.cpp:

(JSC::ExecutionCounter::setThreshold):
(JSC::ExecutionCounter::status):
(JSC):

  • bytecode/ExecutionCounter.h:

(JSC::ExecutionCounter::count):
(ExecutionCounter):

  • dfg/DFGAbstractState.cpp:

(JSC::DFG::AbstractState::execute):

  • dfg/DFGOperations.cpp:
  • dfg/DFGSpeculativeJIT.cpp:

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

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::jitCompileAndSetHeuristics):
(JSC::LLInt::entryOSR):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::JSGlobalObject):
(JSC):

  • runtime/JSGlobalObject.h:

(JSGlobalObject):
(JSC::JSGlobalObject::weakRandomInteger):

  • runtime/Options.cpp:

(Options):
(JSC::Options::initializeOptions):

  • runtime/Options.h:

(Options):

  • runtime/WeakRandom.h:

(WeakRandom):
(JSC::WeakRandom::seedUnsafe):

LayoutTests:

Reviewed by Gavin Barraclough.

  • fast/js/dfg-store-unexpected-value-into-argument-and-osr-exit-expected.txt: Added.
  • fast/js/dfg-store-unexpected-value-into-argument-and-osr-exit.html: Added.
  • fast/js/script-tests/dfg-store-unexpected-value-into-argument-and-osr-exit.js: Added.

(foo):

File:
1 edited

Legend:

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

    r121073 r121215  
    21052105#endif
    21062106
    2107 #if ENABLE(DFG_JIT)
    2108     if (hasCodeOrigins()) {
    2109         // Make sure that executables that we have inlined don't die.
    2110         // FIXME: If they would have otherwise died, we should probably trigger recompilation.
    2111         for (size_t i = 0; i < inlineCallFrames().size(); ++i) {
    2112             InlineCallFrame& inlineCallFrame = inlineCallFrames()[i];
    2113             visitor.append(&inlineCallFrame.executable);
    2114             visitor.append(&inlineCallFrame.callee);
    2115         }
    2116     }
    2117    
    2118     m_lazyOperandValueProfiles.computeUpdatedPredictions(Collection);
    2119 #endif
    2120 
    2121 #if ENABLE(VALUE_PROFILER)
    2122     for (unsigned profileIndex = 0; profileIndex < numberOfArgumentValueProfiles(); ++profileIndex)
    2123         valueProfileForArgument(profileIndex)->computeUpdatedPrediction(Collection);
    2124     for (unsigned profileIndex = 0; profileIndex < numberOfValueProfiles(); ++profileIndex)
    2125         valueProfile(profileIndex)->computeUpdatedPrediction(Collection);
    2126 #endif
     2107    updateAllPredictions(Collection);
    21272108}
    21282109
     
    25752556
    25762557#if ENABLE(VALUE_PROFILER)
    2577 bool CodeBlock::shouldOptimizeNow()
    2578 {
    2579 #if ENABLE(JIT_VERBOSE_OSR)
    2580     dataLog("Considering optimizing %p...\n", this);
    2581 #endif
    2582 
    2583 #if ENABLE(VERBOSE_VALUE_PROFILE)
    2584     dumpValueProfiles();
    2585 #endif
    2586 
    2587     if (m_optimizationDelayCounter >= Options::maximumOptimizationDelay)
    2588         return true;
    2589    
    2590     unsigned numberOfLiveNonArgumentValueProfiles = 0;
    2591     unsigned numberOfSamplesInProfiles = 0; // If this divided by ValueProfile::numberOfBuckets equals numberOfValueProfiles() then value profiles are full.
     2558void CodeBlock::updateAllPredictionsAndCountLiveness(
     2559    OperationInProgress operation, unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles)
     2560{
     2561    numberOfLiveNonArgumentValueProfiles = 0;
     2562    numberOfSamplesInProfiles = 0; // If this divided by ValueProfile::numberOfBuckets equals numberOfValueProfiles() then value profiles are full.
    25922563    for (unsigned i = 0; i < totalNumberOfValueProfiles(); ++i) {
    25932564        ValueProfile* profile = getFromAllValueProfiles(i);
     
    25972568        numberOfSamplesInProfiles += numSamples;
    25982569        if (profile->m_bytecodeOffset < 0) {
    2599             profile->computeUpdatedPrediction();
     2570            profile->computeUpdatedPrediction(operation);
    26002571            continue;
    26012572        }
    26022573        if (profile->numberOfSamples() || profile->m_prediction != SpecNone)
    26032574            numberOfLiveNonArgumentValueProfiles++;
    2604         profile->computeUpdatedPrediction();
    2605     }
     2575        profile->computeUpdatedPrediction(operation);
     2576    }
     2577   
     2578#if ENABLE(DFG_JIT)
     2579    m_lazyOperandValueProfiles.computeUpdatedPredictions(operation);
     2580#endif
     2581}
     2582
     2583void CodeBlock::updateAllPredictions(OperationInProgress operation)
     2584{
     2585    unsigned ignoredValue1, ignoredValue2;
     2586    updateAllPredictionsAndCountLiveness(operation, ignoredValue1, ignoredValue2);
     2587}
     2588
     2589bool CodeBlock::shouldOptimizeNow()
     2590{
     2591#if ENABLE(JIT_VERBOSE_OSR)
     2592    dataLog("Considering optimizing %p...\n", this);
     2593#endif
     2594
     2595#if ENABLE(VERBOSE_VALUE_PROFILE)
     2596    dumpValueProfiles();
     2597#endif
     2598
     2599    if (m_optimizationDelayCounter >= Options::maximumOptimizationDelay)
     2600        return true;
     2601   
     2602    unsigned numberOfLiveNonArgumentValueProfiles;
     2603    unsigned numberOfSamplesInProfiles;
     2604    updateAllPredictionsAndCountLiveness(NoOperation, numberOfLiveNonArgumentValueProfiles, numberOfSamplesInProfiles);
    26062605
    26072606#if ENABLE(JIT_VERBOSE_OSR)
Note: See TracChangeset for help on using the changeset viewer.