JIT heuristics should be hyperbolic
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2012 06:52:44 +0000 (06:52 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2012 06:52:44 +0000 (06:52 +0000)
commit254d43bc9820a3fe7d5d9a31b98dade575894b1e
tree18fb04fb22070073c90cea19ffb87dfe2e3967b5
parent1bb94499c3a2a771e13d7b5b1a87fb45c1c8d609
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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@109705 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/Target.pri
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/CodeBlock.h
Source/JavaScriptCore/bytecode/ExecutionCounter.cpp [new file with mode: 0644]
Source/JavaScriptCore/bytecode/ExecutionCounter.h [new file with mode: 0644]
Source/JavaScriptCore/dfg/DFGOSRExitCompiler32_64.cpp
Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp
Source/JavaScriptCore/jit/ExecutableAllocator.cpp
Source/JavaScriptCore/jit/ExecutableAllocator.h
Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp
Source/JavaScriptCore/jit/JIT.cpp
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
Source/JavaScriptCore/runtime/JSGlobalData.h
Source/JavaScriptCore/runtime/Options.cpp
Source/JavaScriptCore/runtime/Options.h
Source/JavaScriptCore/wtf/SimpleStats.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/ForwardingHeaders/wtf/SimpleStats.h [new file with mode: 0644]