⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 99375 in webkit


Ignore:
Timestamp:
Nov 6, 2011, 3:54:59 AM (15 years ago)
Author:
fpizlo@apple.com
Message:

Value profiling should just use two buckets
https://bugs.webkit.org/show_bug.cgi?id=71619

Reviewed by Gavin Barraclough.

Added one more configuration options (like Heuristics::minimumOptimizationDelay),
improved debugging in JIT optimization support, changed the number of buckets
in the value profile from 9 to 2, and wrote a more optimal value profiling path
in the old JIT to take advantage of this. It's still possible to play around with
larger numbers of buckets, and we should probably keep this for a little while
until we convince ourselves that using just two buckets is the right call.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::shouldOptimizeNow):

  • bytecode/ValueProfile.h:
  • jit/JITInlineMethods.h:

(JSC::JIT::emitValueProfilingSite):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • runtime/Heuristics.cpp:

(JSC::Heuristics::initializeHeuristics):

  • runtime/Heuristics.h:
Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r99374 r99375  
     12011-11-05  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Value profiling should just use two buckets
     4        https://bugs.webkit.org/show_bug.cgi?id=71619
     5
     6        Reviewed by Gavin Barraclough.
     7       
     8        Added one more configuration options (like Heuristics::minimumOptimizationDelay),
     9        improved debugging in JIT optimization support, changed the number of buckets
     10        in the value profile from 9 to 2, and wrote a more optimal value profiling path
     11        in the old JIT to take advantage of this. It's still possible to play around with
     12        larger numbers of buckets, and we should probably keep this for a little while
     13        until we convince ourselves that using just two buckets is the right call.
     14
     15        * bytecode/CodeBlock.cpp:
     16        (JSC::CodeBlock::shouldOptimizeNow):
     17        * bytecode/ValueProfile.h:
     18        * jit/JITInlineMethods.h:
     19        (JSC::JIT::emitValueProfilingSite):
     20        * jit/JITStubs.cpp:
     21        (JSC::DEFINE_STUB_FUNCTION):
     22        * runtime/Heuristics.cpp:
     23        (JSC::Heuristics::initializeHeuristics):
     24        * runtime/Heuristics.h:
     25
    1262011-11-03  Filip Pizlo  <fpizlo@apple.com>
    227
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r98831 r99375  
    19571957
    19581958    if ((!numberOfNonArgumentValueProfiles || (double)numberOfLiveNonArgumentValueProfiles / numberOfNonArgumentValueProfiles >= Heuristics::desiredProfileLivenessRate)
    1959         && (!numberOfValueProfiles() || (double)numberOfSamplesInProfiles / ValueProfile::numberOfBuckets / numberOfValueProfiles() >= Heuristics::desiredProfileFullnessRate))
     1959        && (!numberOfValueProfiles() || (double)numberOfSamplesInProfiles / ValueProfile::numberOfBuckets / numberOfValueProfiles() >= Heuristics::desiredProfileFullnessRate)
     1960        && static_cast<unsigned>(m_optimizationDelayCounter) + 1 >= Heuristics::minimumOptimizationDelay)
    19601961        return true;
    19611962   
     1963    ASSERT(m_optimizationDelayCounter < std::numeric_limits<uint8_t>::max());
    19621964    m_optimizationDelayCounter++;
    19631965    optimizeAfterWarmUp();
  • trunk/Source/JavaScriptCore/bytecode/ValueProfile.h

    r98912 r99375  
    3939#if ENABLE(VALUE_PROFILER)
    4040struct ValueProfile {
    41     static const unsigned logNumberOfBuckets = 3; // 8 buckets
     41    static const unsigned logNumberOfBuckets = 0; // 1 bucket
    4242    static const unsigned numberOfBuckets = 1 << logNumberOfBuckets;
    4343    static const unsigned numberOfSpecFailBuckets = 1;
  • trunk/Source/JavaScriptCore/jit/JITInlineMethods.h

    r98674 r99375  
    463463   
    464464    const RegisterID value = regT0;
     465#if USE(JSVALUE32_64)
     466    const RegisterID valueTag = regT1;
     467#endif
    465468    const RegisterID scratch = regT3;
    466469   
     
    475478    ASSERT(valueProfile);
    476479   
     480    if (ValueProfile::numberOfBuckets == 1) {
     481        // We're in a simple configuration: only one bucket, so we can just do a direct
     482        // store.
     483#if USE(JSVALUE64)
     484        storePtr(value, valueProfile->m_buckets);
     485#else
     486        EncodedValueDescriptor* descriptor = bitwise_cast<EncodedValueDescriptor*>(valueProfile->m_buckets);
     487        store32(value, &descriptor->asBits.payload);
     488        store32(valueTag, &descriptor->asBits.tag);
     489#endif
     490        return;
     491    }
     492   
    477493    if (m_randomGenerator.getUint32() & 1)
    478494        add32(Imm32(1), bucketCounterRegister);
     
    484500    storePtr(value, BaseIndex(scratch, bucketCounterRegister, TimesEight));
    485501#elif USE(JSVALUE32_64)
    486     const RegisterID valueTag = regT1;
    487502    store32(value, BaseIndex(scratch, bucketCounterRegister, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload)));
    488503    store32(valueTag, BaseIndex(scratch, bucketCounterRegister, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag)));
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r99312 r99375  
    19591959    if (void* address = DFG::prepareOSREntry(callFrame, optimizedCodeBlock, bytecodeIndex)) {
    19601960#if ENABLE(JIT_VERBOSE_OSR)
    1961         printf("Optimizing %p from loop succeeded, performing OSR.\n", codeBlock);
     1961        printf("Optimizing %p from loop succeeded, performing OSR after a delay of %u.\n", codeBlock, codeBlock->optimizationDelayCounter());
    19621962#endif
    19631963
     
    19691969   
    19701970#if ENABLE(JIT_VERBOSE_OSR)
    1971     printf("Optimizing %p from loop succeeded, OSR failed.\n", codeBlock);
     1971    printf("Optimizing %p from loop succeeded, OSR failed, after a delay of %u.\n", codeBlock, codeBlock->optimizationDelayCounter());
    19721972#endif
    19731973
     
    20592059
    20602060#if ENABLE(JIT_VERBOSE_OSR)
    2061     printf("Optimizing %p from return succeeded.\n", codeBlock);
     2061    printf("Optimizing %p from return succeeded after a delay of %u.\n", codeBlock, codeBlock->optimizationDelayCounter());
    20622062#endif
    20632063   
  • trunk/Source/JavaScriptCore/runtime/Heuristics.cpp

    r98937 r99375  
    7575unsigned reoptimizationRetryCounterStep;
    7676
     77unsigned minimumOptimizationDelay;
    7778unsigned maximumOptimizationDelay;
    7879double desiredProfileLivenessRate;
     
    158159    SET(reoptimizationRetryCounterStep, 1);
    159160
     161    SET(minimumOptimizationDelay,   1);
    160162    SET(maximumOptimizationDelay,   5);
    161163    SET(desiredProfileLivenessRate, 0.75);
  • trunk/Source/JavaScriptCore/runtime/Heuristics.h

    r98937 r99375  
    6161extern unsigned reoptimizationRetryCounterStep;
    6262
     63extern unsigned minimumOptimizationDelay;
    6364extern unsigned maximumOptimizationDelay;
    6465extern double desiredProfileLivenessRate;
Note: See TracChangeset for help on using the changeset viewer.