Ignore:
Timestamp:
Dec 9, 2011, 4:09:55 PM (13 years ago)
Author:
[email protected]
Message:

DFG's interpretation of rare case profiles should be frequency-based not count-based
https://bugs.webkit.org/show_bug.cgi?id=74170

Reviewed by Geoff Garen.

DFG optimizes for rare cases only when the rare case counter is above some threshold
and it also constitutes a large enough fraction of total function executions. Also
added some minor debug logic.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::likelyToTakeSlowCase):
(JSC::CodeBlock::couldTakeSlowCase):
(JSC::CodeBlock::likelyToTakeSpecialFastCase):
(JSC::CodeBlock::likelyToTakeDeepestSlowCase):
(JSC::CodeBlock::likelyToTakeAnySlowCase):
(JSC::CodeBlock::executionEntryCount):

  • dfg/DFGByteCodeParser.cpp:

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

  • dfg/DFGDriver.cpp:

(JSC::DFG::compile):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • runtime/Heuristics.cpp:

(JSC::Heuristics::initializeHeuristics):

  • runtime/Heuristics.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r102442 r102489  
    6868            m_preservedVars.set(i);
    6969    }
    70 
     70   
    7171    // Parse a full CodeBlock of bytecode.
    7272    bool parse();
     
    647647           
    648648        case ArithMul:
    649             if (m_inlineStackTop->m_profiledBlock->likelyToTakeDeepestSlowCase(m_currentIndex))
     649            if (m_inlineStackTop->m_profiledBlock->likelyToTakeDeepestSlowCase(m_currentIndex)) {
     650#if DFG_ENABLE(DEBUG_VERBOSE)
     651                printf("Making ArithMul @%u take deepest slow case.\n", nodeIndex);
     652#endif
    650653                m_graph[nodeIndex].mergeArithNodeFlags(NodeMayOverflow | NodeMayNegZero);
    651             else
     654            } else {
     655#if DFG_ENABLE(DEBUG_VERBOSE)
     656                printf("Making ArithMul @%u take faster slow case.\n", nodeIndex);
     657#endif
    652658                m_graph[nodeIndex].mergeArithNodeFlags(NodeMayNegZero);
     659            }
    653660            break;
    654661           
     
    673680        if (!m_inlineStackTop->m_profiledBlock->likelyToTakeSpecialFastCase(m_currentIndex))
    674681            return nodeIndex;
     682       
     683#if DFG_ENABLE(DEBUG_VERBOSE)
     684        printf("Making %s @%u safe at bc#%u because special fast-case counter is at %u\n", Graph::opName(m_graph[nodeIndex].op), nodeIndex, m_currentIndex, m_inlineStackTop->m_profiledBlock->specialFastCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);
     685#endif
    675686       
    676687        m_graph[nodeIndex].mergeArithNodeFlags(NodeMayOverflow | NodeMayNegZero);
     
    875886           
    876887#if DFG_ENABLE(DEBUG_VERBOSE)
    877     printf("Slow case count for call at @%lu bc#%u: %u.\n", m_graph.size(), m_currentIndex, m_inlineStackTop->m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);
     888    printf("Slow case count for call at @%lu bc#%u: %u/%u.\n", m_graph.size(), m_currentIndex, m_inlineStackTop->m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter, m_inlineStackTop->m_profiledBlock->executionEntryCount());
    878889#endif
    879890           
     
    12471258    bool shouldContinueParsing = true;
    12481259   
     1260    Interpreter* interpreter = m_globalData->interpreter;
     1261    Instruction* instructionsBegin = m_inlineStackTop->m_codeBlock->instructions().begin();
     1262    unsigned blockBegin = m_currentIndex;
     1263   
    12491264    // If we are the first basic block, introduce markers for arguments. This allows
    12501265    // us to track if a use of an argument may use the actual argument passed, as
     
    12601275    }
    12611276
    1262     Interpreter* interpreter = m_globalData->interpreter;
    1263     Instruction* instructionsBegin = m_inlineStackTop->m_codeBlock->instructions().begin();
    1264     unsigned blockBegin = m_currentIndex;
    12651277    while (true) {
    12661278        // Don't extend over jump destinations.
     
    16911703            Identifier identifier = m_codeBlock->identifier(identifierNumber);
    16921704            StructureStubInfo& stubInfo = m_inlineStackTop->m_profiledBlock->getStubInfo(m_currentIndex);
     1705           
     1706#if DFG_ENABLE(DEBUG_VERBOSE)
     1707            printf("Slow case count for GetById @%lu bc#%u: %u\n", m_graph.size(), m_currentIndex, m_inlineStackTop->m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);
     1708#endif
    16931709           
    16941710            size_t offset = notFound;
     
    17821798            bool alreadyGenerated = false;
    17831799           
     1800#if DFG_ENABLE(DEBUG_VERBOSE)
     1801            printf("Slow case count for PutById @%lu bc#%u: %u\n", m_graph.size(), m_currentIndex, m_inlineStackTop->m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);
     1802#endif           
     1803
    17841804            if (stubInfo.seen && !m_inlineStackTop->m_profiledBlock->likelyToTakeSlowCase(m_currentIndex)) {
    17851805                switch (stubInfo.accessType) {
Note: See TracChangeset for help on using the changeset viewer.