Ignore:
Timestamp:
Mar 4, 2012, 10:52:44 PM (13 years ago)
Author:
[email protected]
Message:

JIT heuristics should be hyperbolic
https://bugs.webkit.org/show_bug.cgi?id=80055
<rdar://problem/10922260>

Source/JavaScriptCore:

Reviewed by Oliver Hunt.

Added tracking of the amount of executable memory typically used for a bytecode
instruction. Modified the execution counter scheme to use this, and the amount
of free memory, to determine how long to wait before invoking the JIT.

The result is that even if we bomb the VM with more code than can fit in our
executable memory pool, we still keep running and almost never run out of
executable memory - which ensures that if we have to JIT something critical, then
we'll likely have enough memory to do so. This also does not regress performance
on the three main benchmarks.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::predictedMachineCodeSize):
(JSC):
(JSC::CodeBlock::usesOpcode):

  • bytecode/CodeBlock.h:

(CodeBlock):
(JSC::CodeBlock::checkIfJITThresholdReached):
(JSC::CodeBlock::dontJITAnytimeSoon):
(JSC::CodeBlock::jitAfterWarmUp):
(JSC::CodeBlock::jitSoon):
(JSC::CodeBlock::llintExecuteCounter):
(JSC::CodeBlock::counterValueForOptimizeAfterWarmUp):
(JSC::CodeBlock::counterValueForOptimizeAfterLongWarmUp):
(JSC::CodeBlock::addressOfJITExecuteCounter):
(JSC::CodeBlock::offsetOfJITExecuteCounter):
(JSC::CodeBlock::offsetOfJITExecutionActiveThreshold):
(JSC::CodeBlock::offsetOfJITExecutionTotalCount):
(JSC::CodeBlock::jitExecuteCounter):
(JSC::CodeBlock::checkIfOptimizationThresholdReached):
(JSC::CodeBlock::optimizeNextInvocation):
(JSC::CodeBlock::dontOptimizeAnytimeSoon):
(JSC::CodeBlock::optimizeAfterWarmUp):
(JSC::CodeBlock::optimizeAfterLongWarmUp):
(JSC::CodeBlock::optimizeSoon):

  • bytecode/ExecutionCounter.cpp: Added.

(JSC):
(JSC::ExecutionCounter::ExecutionCounter):
(JSC::ExecutionCounter::checkIfThresholdCrossedAndSet):
(JSC::ExecutionCounter::setNewThreshold):
(JSC::ExecutionCounter::deferIndefinitely):
(JSC::ExecutionCounter::applyMemoryUsageHeuristics):
(JSC::ExecutionCounter::applyMemoryUsageHeuristicsAndConvertToInt):
(JSC::ExecutionCounter::hasCrossedThreshold):
(JSC::ExecutionCounter::setThreshold):
(JSC::ExecutionCounter::reset):

  • bytecode/ExecutionCounter.h: Added.

(JSC):
(ExecutionCounter):
(JSC::ExecutionCounter::formattedTotalCount):

  • dfg/DFGOSRExitCompiler32_64.cpp:

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

  • dfg/DFGOSRExitCompiler64.cpp:

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

  • jit/ExecutableAllocator.cpp:

(JSC::DemandExecutableAllocator::allocateNewSpace):
(JSC::ExecutableAllocator::underMemoryPressure):
(JSC):
(JSC::ExecutableAllocator::memoryPressureMultiplier):

  • jit/ExecutableAllocator.h:
  • jit/ExecutableAllocatorFixedVMPool.cpp:

(JSC::ExecutableAllocator::memoryPressureMultiplier):
(JSC):

  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::jitCompileAndSetHeuristics):

  • llint/LowLevelInterpreter32_64.asm:
  • runtime/JSGlobalData.h:

(JSGlobalData):

  • runtime/Options.cpp:

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

  • runtime/Options.h:

(Options):

  • wtf/SimpleStats.h: Added.

(WTF):
(SimpleStats):
(WTF::SimpleStats::SimpleStats):
(WTF::SimpleStats::add):
(WTF::SimpleStats::operator!):
(WTF::SimpleStats::count):
(WTF::SimpleStats::sum):
(WTF::SimpleStats::sumOfSquares):
(WTF::SimpleStats::mean):
(WTF::SimpleStats::variance):
(WTF::SimpleStats::standardDeviation):

Source/WebCore:

Reviewed by Oliver Hunt.

No new tests, since there's no new functionality.

  • ForwardingHeaders/wtf/SimpleStats.h: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r109172 r109705  
    19301930    CallFrame* callFrame = stackFrame.callFrame;
    19311931    CodeBlock* codeBlock = callFrame->codeBlock();
     1932
    19321933    unsigned bytecodeIndex = stackFrame.args[0].int32();
    1933 
     1934   
    19341935#if ENABLE(JIT_VERBOSE_OSR)
    19351936    dataLog("%p: Entered optimize_from_loop with executeCounter = %d, reoptimizationRetryCounter = %u, optimizationDelayCounter = %u\n", codeBlock, codeBlock->jitExecuteCounter(), codeBlock->reoptimizationRetryCounter(), codeBlock->optimizationDelayCounter());
    19361937#endif
     1938
     1939    if (!codeBlock->checkIfOptimizationThresholdReached())
     1940        return;
    19371941
    19381942    if (codeBlock->hasOptimizedReplacement()) {
     
    20342038#endif
    20352039
     2040    if (!codeBlock->checkIfOptimizationThresholdReached())
     2041        return;
     2042
    20362043    if (codeBlock->hasOptimizedReplacement()) {
    20372044#if ENABLE(JIT_VERBOSE_OSR)
Note: See TracChangeset for help on using the changeset viewer.