Ignore:
Timestamp:
Jul 9, 2012, 6:50:44 PM (13 years ago)
Author:
[email protected]
Message:

Unreviewed, roll out http://trac.webkit.org/changeset/121511
It made in-browser V8v7 10% slower.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):

  • bytecode/CodeBlock.h:

(CodeBlock):
(JSC::CodeBlock::countSpeculationSuccess):
(JSC::CodeBlock::countSpeculationFailure):
(JSC::CodeBlock::speculativeSuccessCounter):
(JSC::CodeBlock::speculativeFailCounter):
(JSC::CodeBlock::forcedOSRExitCounter):
(JSC::CodeBlock::addressOfSpeculativeSuccessCounter):
(JSC::CodeBlock::addressOfSpeculativeFailCounter):
(JSC::CodeBlock::addressOfForcedOSRExitCounter):
(JSC::CodeBlock::offsetOfSpeculativeSuccessCounter):
(JSC::CodeBlock::offsetOfSpeculativeFailCounter):
(JSC::CodeBlock::offsetOfForcedOSRExitCounter):
(JSC::CodeBlock::largeFailCountThreshold):
(JSC::CodeBlock::largeFailCountThresholdForLoop):
(JSC::CodeBlock::shouldReoptimizeNow):
(JSC::CodeBlock::shouldReoptimizeFromLoopNow):

  • bytecode/ExecutionCounter.cpp:

(JSC::ExecutionCounter::setThreshold):

  • bytecode/ExecutionCounter.h:

(ExecutionCounter):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::compileBody):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::OSRExit::considerAddingAsFrequentExitSiteSlow):

  • dfg/DFGOSRExitCompiler.cpp:

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

  • dfg/DFGOperations.cpp:
  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • runtime/Options.h:

(JSC):

File:
1 edited

Legend:

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

    r121798 r122182  
    10931093        }
    10941094       
    1095         uint32_t osrExitCounter() const { return m_osrExitCounter; }
    1096        
    1097         void countOSRExit() { m_osrExitCounter++; }
    1098        
    1099         uint32_t* addressOfOSRExitCounter() { return &m_osrExitCounter; }
    1100        
    1101         static ptrdiff_t offsetOfOSRExitCounter() { return OBJECT_OFFSETOF(CodeBlock, m_osrExitCounter); }
     1095        // The speculative JIT tracks its success rate, so that we can
     1096        // decide when to reoptimize. It's interesting to note that these
     1097        // counters may overflow without any protection. The success
     1098        // counter will overflow before the fail one does, becuase the
     1099        // fail one is used as a trigger to reoptimize. So the worst case
     1100        // is that the success counter overflows and we reoptimize without
     1101        // needing to. But this is harmless. If a method really did
     1102        // execute 2^32 times then compiling it again probably won't hurt
     1103        // anyone.
     1104       
     1105        void countSpeculationSuccess()
     1106        {
     1107            m_speculativeSuccessCounter++;
     1108        }
     1109       
     1110        void countSpeculationFailure()
     1111        {
     1112            m_speculativeFailCounter++;
     1113        }
     1114       
     1115        uint32_t speculativeSuccessCounter() const { return m_speculativeSuccessCounter; }
     1116        uint32_t speculativeFailCounter() const { return m_speculativeFailCounter; }
     1117        uint32_t forcedOSRExitCounter() const { return m_forcedOSRExitCounter; }
     1118       
     1119        uint32_t* addressOfSpeculativeSuccessCounter() { return &m_speculativeSuccessCounter; }
     1120        uint32_t* addressOfSpeculativeFailCounter() { return &m_speculativeFailCounter; }
     1121        uint32_t* addressOfForcedOSRExitCounter() { return &m_forcedOSRExitCounter; }
     1122       
     1123        static ptrdiff_t offsetOfSpeculativeSuccessCounter() { return OBJECT_OFFSETOF(CodeBlock, m_speculativeSuccessCounter); }
     1124        static ptrdiff_t offsetOfSpeculativeFailCounter() { return OBJECT_OFFSETOF(CodeBlock, m_speculativeFailCounter); }
     1125        static ptrdiff_t offsetOfForcedOSRExitCounter() { return OBJECT_OFFSETOF(CodeBlock, m_forcedOSRExitCounter); }
    11021126
    11031127#if ENABLE(JIT)
    1104         uint32_t adjustedExitCountThreshold(uint32_t desiredThreshold)
    1105         {
    1106             ASSERT(getJITType() == JITCode::DFGJIT);
    1107             // Compute this the lame way so we don't saturate. This is called infrequently
    1108             // enough that this loop won't hurt us.
    1109             unsigned result = desiredThreshold;
    1110             for (unsigned n = baselineVersion()->reoptimizationRetryCounter(); n--;) {
    1111                 unsigned newResult = result << 1;
    1112                 if (newResult < result)
    1113                     return std::numeric_limits<uint32_t>::max();
    1114                 result = newResult;
    1115             }
    1116             return result;
    1117         }
    1118        
    1119         uint32_t exitCountThresholdForReoptimization()
    1120         {
    1121             return adjustedExitCountThreshold(Options::osrExitCountForReoptimization());
    1122         }
    1123        
    1124         uint32_t exitCountThresholdForReoptimizationFromLoop()
    1125         {
    1126             return adjustedExitCountThreshold(Options::osrExitCountForReoptimizationFromLoop());
    1127         }
     1128        // The number of failures that triggers the use of the ratio.
     1129        unsigned largeFailCountThreshold() { return Options::largeFailCountThresholdBase() << baselineVersion()->reoptimizationRetryCounter(); }
     1130        unsigned largeFailCountThresholdForLoop() { return Options::largeFailCountThresholdBaseForLoop() << baselineVersion()->reoptimizationRetryCounter(); }
    11281131
    11291132        bool shouldReoptimizeNow()
    11301133        {
    1131             return osrExitCounter() >= exitCountThresholdForReoptimization();
    1132         }
    1133        
     1134            return (Options::desiredSpeculativeSuccessFailRatio() *
     1135                        speculativeFailCounter() >= speculativeSuccessCounter()
     1136                    && speculativeFailCounter() >= largeFailCountThreshold())
     1137                || forcedOSRExitCounter() >=
     1138                       Options::forcedOSRExitCountForReoptimization();
     1139        }
     1140
    11341141        bool shouldReoptimizeFromLoopNow()
    11351142        {
    1136             return osrExitCounter() >= exitCountThresholdForReoptimizationFromLoop();
     1143            return (Options::desiredSpeculativeSuccessFailRatio() *
     1144                        speculativeFailCounter() >= speculativeSuccessCounter()
     1145                    && speculativeFailCounter() >= largeFailCountThresholdForLoop())
     1146                || forcedOSRExitCounter() >=
     1147                       Options::forcedOSRExitCountForReoptimization();
    11371148        }
    11381149#endif
     
    13371348        ExecutionCounter m_jitExecuteCounter;
    13381349        int32_t m_totalJITExecutions;
    1339         uint32_t m_osrExitCounter;
     1350        uint32_t m_speculativeSuccessCounter;
     1351        uint32_t m_speculativeFailCounter;
     1352        uint32_t m_forcedOSRExitCounter;
    13401353        uint16_t m_optimizationDelayCounter;
    13411354        uint16_t m_reoptimizationRetryCounter;
Note: See TracChangeset for help on using the changeset viewer.