Changeset 95676 in webkit


Ignore:
Timestamp:
Sep 21, 2011 3:43:11 PM (13 years ago)
Author:
barraclough@apple.com
Message:

Should support value profiling on CPU(X86)
https://bugs.webkit.org/show_bug.cgi?id=68575

Reviewed by Sam Weinig.

Fix verbose profiling in ToT (SlowCaseProfile had been
partially renamed to RareCaseProfile), add in-memory
bucket counter for CPU(X86), move JIT::m_canBeOptimized
out of the DFG_JIT ifdef.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::resetRareCaseProfiles):
(JSC::CodeBlock::dumpValueProfiles):

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

(JSC::DFG::ByteCodeParser::makeSafe):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileSlowCases):
(JSC::JIT::privateCompile):

  • jit/JIT.h:
  • jit/JITInlineMethods.h:

(JSC::JIT::emitValueProfilingSite):

Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95672 r95676  
     12011-09-21  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Should support value profiling on CPU(X86)
     4        https://bugs.webkit.org/show_bug.cgi?id=68575
     5
     6        Reviewed by Sam Weinig.
     7
     8        Fix verbose profiling in ToT (SlowCaseProfile had been
     9        partially renamed to RareCaseProfile), add in-memory
     10        bucket counter for CPU(X86), move JIT::m_canBeOptimized
     11        out of the DFG_JIT ifdef.
     12
     13        * bytecode/CodeBlock.cpp:
     14        (JSC::CodeBlock::resetRareCaseProfiles):
     15        (JSC::CodeBlock::dumpValueProfiles):
     16        * bytecode/CodeBlock.h:
     17        * dfg/DFGByteCodeParser.cpp:
     18        (JSC::DFG::ByteCodeParser::makeSafe):
     19        * jit/JIT.cpp:
     20        (JSC::JIT::privateCompileSlowCases):
     21        (JSC::JIT::privateCompile):
     22        * jit/JIT.h:
     23        * jit/JITInlineMethods.h:
     24        (JSC::JIT::emitValueProfilingSite):
     25
    1262011-09-21  Filip Pizlo  <fpizlo@apple.com>
    227
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r95484 r95676  
    19881988void CodeBlock::resetRareCaseProfiles()
    19891989{
    1990     for (unsigned i = 0; i < numberOfSlowCaseProfiles(); ++i)
    1991         slowCaseProfile(i)->m_counter = 0;
     1990    for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i)
     1991        rareCaseProfile(i)->m_counter = 0;
    19921992    for (unsigned i = 0; i < numberOfSpecialFastCaseProfiles(); ++i)
    19931993        specialFastCaseProfile(i)->m_counter = 0;
     
    20132013        fprintf(stderr, "\n");
    20142014    }
    2015     fprintf(stderr, "SlowCaseProfile for %p:\n", this);
    2016     for (unsigned i = 0; i < numberOfSlowCaseProfiles(); ++i) {
    2017         SlowCaseProfile* profile = slowCaseProfile(i);
     2015    fprintf(stderr, "RareCaseProfile for %p:\n", this);
     2016    for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i) {
     2017        RareCaseProfile* profile = rareCaseProfile(i);
    20182018        fprintf(stderr, "   bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter);
    20192019    }
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r95484 r95676  
    490490        }
    491491       
    492         RareCaseProfile* addSlowCaseProfile(int bytecodeOffset)
    493         {
    494             m_slowCaseProfiles.append(RareCaseProfile(bytecodeOffset));
    495             return &m_slowCaseProfiles.last();
    496         }
    497         unsigned numberOfSlowCaseProfiles() { return m_slowCaseProfiles.size(); }
    498         RareCaseProfile* slowCaseProfile(int index) { return &m_slowCaseProfiles[index]; }
    499         RareCaseProfile* slowCaseProfileForBytecodeOffset(int bytecodeOffset)
    500         {
    501             return WTF::genericBinarySearch<RareCaseProfile, int, getRareCaseProfileBytecodeOffset>(m_slowCaseProfiles, m_slowCaseProfiles.size(), bytecodeOffset);
     492        RareCaseProfile* addRareCaseProfile(int bytecodeOffset)
     493        {
     494            m_rareCaseProfiles.append(RareCaseProfile(bytecodeOffset));
     495            return &m_rareCaseProfiles.last();
     496        }
     497        unsigned numberOfRareCaseProfiles() { return m_rareCaseProfiles.size(); }
     498        RareCaseProfile* rareCaseProfile(int index) { return &m_rareCaseProfiles[index]; }
     499        RareCaseProfile* rareCaseProfileForBytecodeOffset(int bytecodeOffset)
     500        {
     501            return WTF::genericBinarySearch<RareCaseProfile, int, getRareCaseProfileBytecodeOffset>(m_rareCaseProfiles, m_rareCaseProfiles.size(), bytecodeOffset);
    502502        }
    503503       
     
    505505        bool likelyToTakeSlowCase(int bytecodeOffset)
    506506        {
    507             return slowCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter >= slowCaseThreshold();
     507            return rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter >= slowCaseThreshold();
    508508        }
    509509       
     
    522522        bool likelyToTakeDeepestSlowCase(int bytecodeOffset)
    523523        {
    524             unsigned slowCaseCount = slowCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
     524            unsigned slowCaseCount = rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
    525525            unsigned specialFastCaseCount = specialFastCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;
    526526            return (slowCaseCount - specialFastCaseCount) >= slowCaseThreshold();
     
    831831#if ENABLE(VALUE_PROFILER)
    832832        SegmentedVector<ValueProfile, 8> m_valueProfiles;
    833         SegmentedVector<RareCaseProfile, 8> m_slowCaseProfiles;
     833        SegmentedVector<RareCaseProfile, 8> m_rareCaseProfiles;
    834834        SegmentedVector<RareCaseProfile, 8> m_specialFastCaseProfiles;
    835835#endif
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r95672 r95676  
    514514       
    515515#if ENABLE(DFG_DEBUG_VERBOSE)
    516         printf("Making %s @%u safe at bc#%u because slow-case counter is at %u\n", Graph::opName(m_graph[nodeIndex].op), nodeIndex, m_currentIndex, m_profiledBlock->slowCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);
     516        printf("Making %s @%u safe at bc#%u because slow-case counter is at %u\n", Graph::opName(m_graph[nodeIndex].op), nodeIndex, m_currentIndex, m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);
    517517#endif
    518518       
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r95484 r95676  
    416416       
    417417#if ENABLE(VALUE_PROFILER)
    418         RareCaseProfile* slowCaseProfile = 0;
     418        RareCaseProfile* rareCaseProfile = 0;
    419419        if (m_canBeOptimized)
    420             slowCaseProfile = m_codeBlock->addSlowCaseProfile(m_bytecodeOffset);
     420            rareCaseProfile = m_codeBlock->addRareCaseProfile(m_bytecodeOffset);
    421421#endif
    422422
     
    495495#if ENABLE(VALUE_PROFILER)
    496496        if (m_canBeOptimized)
    497             add32(Imm32(1), AbsoluteAddress(&slowCaseProfile->m_counter));
     497            add32(Imm32(1), AbsoluteAddress(&rareCaseProfile->m_counter));
    498498#endif
    499499
     
    515515JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck)
    516516{
     517#if ENABLE(VALUE_PROFILER)
     518    m_canBeOptimized = m_codeBlock->canCompileWithDFG();
     519#endif
    517520#if ENABLE(DFG_JIT)
    518     m_canBeOptimized = m_codeBlock->canCompileWithDFG();
    519521    if (m_canBeOptimized)
    520522        m_startOfCode = label();
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r95666 r95676  
    10751075        WeakRandom m_randomGenerator;
    10761076        static CodeRef stringGetByValStubGenerator(JSGlobalData*);
    1077        
     1077
     1078#if ENABLE(VALUE_PROFILER)
     1079        bool m_canBeOptimized;
     1080#endif
    10781081#if ENABLE(DFG_JIT)
    1079         bool m_canBeOptimized;
    10801082        Label m_startOfCode;
    10811083        CompactJITCodeMap::Encoder m_jitCodeMapEncoder;
  • trunk/Source/JavaScriptCore/jit/JITInlineMethods.h

    r95666 r95676  
    447447}
    448448
     449#if CPU(X86)
     450static int bucketCounter;
     451#endif
     452
    449453#if ENABLE(VALUE_PROFILER)
    450454inline void JIT::emitValueProfilingSite(ValueProfilingSiteKind siteKind)
     
    466470    ASSERT(valueProfile);
    467471   
     472#if CPU(X86)
     473    if (m_randomGenerator.getUint32() & 1)
     474        add32(Imm32(1), AbsoluteAddress(&bucketCounter));
     475    else
     476        add32(Imm32(3), AbsoluteAddress(&bucketCounter));
     477    and32(Imm32(ValueProfile::bucketIndexMask), AbsoluteAddress(&bucketCounter));
     478    load32(&bucketCounter, scratch);
     479    lshift32(TrustedImm32(3), scratch);
     480    addPtr(ImmPtr(valueProfile->m_buckets), scratch);
     481    storePtr(value, scratch);
     482#else
    468483    if (m_randomGenerator.getUint32() & 1)
    469484        add32(Imm32(1), bucketCounterRegister);
     
    473488    move(ImmPtr(valueProfile->m_buckets), scratch);
    474489    storePtr(value, BaseIndex(scratch, bucketCounterRegister, TimesEight));
     490#endif
    475491}
    476492#endif
Note: See TracChangeset for help on using the changeset viewer.