Ignore:
Timestamp:
Apr 8, 2012, 1:46:12 PM (13 years ago)
Author:
[email protected]
Message:

Forced OSR exits should lead to recompilation based on count, not rate
https://bugs.webkit.org/show_bug.cgi?id=83247
<rdar://problem/10720925>

Reviewed by Geoff Garen.

Track which OSR exits happen because of inadequate coverage. Count them
separately. If the count reaches a threshold, immediately trigger
reoptimization.

This is in contrast to the recompilation trigger for all other OSR exits.
Normally recomp is triggered when the exit rate exceeds a certain ratio.

Looks like a slight V8 speedup (sub 1%).

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::forcedOSRExitCounter):
(JSC::CodeBlock::addressOfForcedOSRExitCounter):
(JSC::CodeBlock::offsetOfForcedOSRExitCounter):
(JSC::CodeBlock::shouldReoptimizeNow):
(JSC::CodeBlock::shouldReoptimizeFromLoopNow):
(CodeBlock):

  • bytecode/DFGExitProfile.h:

(JSC::DFG::exitKindToString):

  • dfg/DFGOSRExitCompiler.cpp:

(JSC::DFG::OSRExitCompiler::handleExitCounts):
(DFG):

  • dfg/DFGOSRExitCompiler.h:

(OSRExitCompiler):

  • dfg/DFGOSRExitCompiler32_64.cpp:

(JSC::DFG::OSRExitCompiler::compileExit):

  • dfg/DFGOSRExitCompiler64.cpp:

(JSC::DFG::OSRExitCompiler::compileExit):

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

(JSC::DFG::SpeculativeJIT::compileGetIndexedPropertyStorage):

  • dfg/DFGSpeculativeJIT32_64.cpp:

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

  • dfg/DFGSpeculativeJIT64.cpp:

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

  • runtime/Options.cpp:

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

  • runtime/Options.h:

(Options):

Location:
trunk/Source/JavaScriptCore/bytecode
Files:
3 edited

Legend:

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

    r113136 r113552  
    14331433    , m_speculativeSuccessCounter(0)
    14341434    , m_speculativeFailCounter(0)
     1435    , m_forcedOSRExitCounter(0)
    14351436    , m_optimizationDelayCounter(0)
    14361437    , m_reoptimizationRetryCounter(0)
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r112320 r113552  
    10071007        uint32_t speculativeSuccessCounter() const { return m_speculativeSuccessCounter; }
    10081008        uint32_t speculativeFailCounter() const { return m_speculativeFailCounter; }
     1009        uint32_t forcedOSRExitCounter() const { return m_forcedOSRExitCounter; }
    10091010       
    10101011        uint32_t* addressOfSpeculativeSuccessCounter() { return &m_speculativeSuccessCounter; }
    10111012        uint32_t* addressOfSpeculativeFailCounter() { return &m_speculativeFailCounter; }
     1013        uint32_t* addressOfForcedOSRExitCounter() { return &m_forcedOSRExitCounter; }
    10121014       
    10131015        static ptrdiff_t offsetOfSpeculativeSuccessCounter() { return OBJECT_OFFSETOF(CodeBlock, m_speculativeSuccessCounter); }
    10141016        static ptrdiff_t offsetOfSpeculativeFailCounter() { return OBJECT_OFFSETOF(CodeBlock, m_speculativeFailCounter); }
     1017        static ptrdiff_t offsetOfForcedOSRExitCounter() { return OBJECT_OFFSETOF(CodeBlock, m_forcedOSRExitCounter); }
    10151018
    10161019#if ENABLE(JIT)
     
    10211024        bool shouldReoptimizeNow()
    10221025        {
    1023             return Options::desiredSpeculativeSuccessFailRatio * speculativeFailCounter() >= speculativeSuccessCounter() && speculativeFailCounter() >= largeFailCountThreshold();
     1026            return (Options::desiredSpeculativeSuccessFailRatio *
     1027                        speculativeFailCounter() >= speculativeSuccessCounter()
     1028                    && speculativeFailCounter() >= largeFailCountThreshold())
     1029                || forcedOSRExitCounter() >=
     1030                       Options::forcedOSRExitCountForReoptimization;
    10241031        }
    10251032
    10261033        bool shouldReoptimizeFromLoopNow()
    10271034        {
    1028             return Options::desiredSpeculativeSuccessFailRatio * speculativeFailCounter() >= speculativeSuccessCounter() && speculativeFailCounter() >= largeFailCountThresholdForLoop();
     1035            return (Options::desiredSpeculativeSuccessFailRatio *
     1036                        speculativeFailCounter() >= speculativeSuccessCounter()
     1037                    && speculativeFailCounter() >= largeFailCountThresholdForLoop())
     1038                || forcedOSRExitCounter() >=
     1039                       Options::forcedOSRExitCountForReoptimization;
    10291040        }
    10301041#endif
     
    12291240        uint32_t m_speculativeSuccessCounter;
    12301241        uint32_t m_speculativeFailCounter;
     1242        uint32_t m_forcedOSRExitCounter;
    12311243        uint16_t m_optimizationDelayCounter;
    12321244        uint16_t m_reoptimizationRetryCounter;
  • trunk/Source/JavaScriptCore/bytecode/DFGExitProfile.h

    r106590 r113552  
    3939    Overflow, // We exited because of overflow.
    4040    NegativeZero, // We exited because we encountered negative zero.
     41    InadequateCoverage, // We exited because we ended up in code that didn't have profiling coverage.
    4142    Uncountable, // We exited for none of the above reasons, and we should not count it. Most uses of this should be viewed as a FIXME.
    4243};
     
    5556    case NegativeZero:
    5657        return "NegativeZero";
     58    case InadequateCoverage:
     59        return "InadequateCoverage";
    5760    default:
    5861        return "Unknown";
Note: See TracChangeset for help on using the changeset viewer.