- Revision
- 153263
- Author
- [email protected]
- Date
- 2013-07-24 21:04:18 -0700 (Wed, 24 Jul 2013)
Log Message
fourthTier: add option to disable OSR entry in loops
https://bugs.webkit.org/show_bug.cgi?id=118329
Reviewed by Mark Hahnenberg.
This adds that option, and also makes the OSR exit reoptimization trigger rely less on
OSR entry failing. Now even if we never attempt OSR entry but our execution counter gets
high after a small number of OSR exits, we will recompile.
* dfg/DFGOSRExitCompilerCommon.cpp:
(JSC::DFG::handleExitCounts):
* dfg/DFGOperations.cpp:
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_loop_hint):
(JSC::JIT::emitSlow_op_loop_hint):
* runtime/Options.h:
(JSC):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (153262 => 153263)
--- trunk/Source/_javascript_Core/ChangeLog 2013-07-25 04:04:16 UTC (rev 153262)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-07-25 04:04:18 UTC (rev 153263)
@@ -1,5 +1,25 @@
2013-07-02 Filip Pizlo <[email protected]>
+ fourthTier: add option to disable OSR entry in loops
+ https://bugs.webkit.org/show_bug.cgi?id=118329
+
+ Reviewed by Mark Hahnenberg.
+
+ This adds that option, and also makes the OSR exit reoptimization trigger rely less on
+ OSR entry failing. Now even if we never attempt OSR entry but our execution counter gets
+ high after a small number of OSR exits, we will recompile.
+
+ * dfg/DFGOSRExitCompilerCommon.cpp:
+ (JSC::DFG::handleExitCounts):
+ * dfg/DFGOperations.cpp:
+ * jit/JITOpcodes.cpp:
+ (JSC::JIT::emit_op_loop_hint):
+ (JSC::JIT::emitSlow_op_loop_hint):
+ * runtime/Options.h:
+ (JSC):
+
+2013-07-02 Filip Pizlo <[email protected]>
+
fourthTier: since the FTL disassembly hacks cannot distinguish between code and data, the LLVM disassembler symbol table callback should be able to deal gracefully with arbitrary garbage
https://bugs.webkit.org/show_bug.cgi?id=118313
Modified: trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp (153262 => 153263)
--- trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp 2013-07-25 04:04:16 UTC (rev 153262)
+++ trunk/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp 2013-07-25 04:04:18 UTC (rev 153263)
@@ -45,9 +45,17 @@
jit.load32(AssemblyHelpers::Address(GPRInfo::regT0, CodeBlock::offsetOfOSRExitCounter()), GPRInfo::regT2);
jit.add32(AssemblyHelpers::TrustedImm32(1), GPRInfo::regT2);
jit.store32(GPRInfo::regT2, AssemblyHelpers::Address(GPRInfo::regT0, CodeBlock::offsetOfOSRExitCounter()));
+
jit.move(AssemblyHelpers::TrustedImmPtr(jit.baselineCodeBlock()), GPRInfo::regT0);
+ AssemblyHelpers::Jump reoptimizeNow = jit.branch32(
+ AssemblyHelpers::GreaterThanOrEqual,
+ AssemblyHelpers::Address(GPRInfo::regT0, CodeBlock::offsetOfJITExecuteCounter()),
+ AssemblyHelpers::TrustedImm32(0));
+
tooFewFails = jit.branch32(AssemblyHelpers::BelowOrEqual, GPRInfo::regT2, AssemblyHelpers::TrustedImm32(jit.codeBlock()->exitCountThresholdForReoptimization()));
+ reoptimizeNow.link(&jit);
+
// Reoptimize as soon as possible.
#if !NUMBER_OF_ARGUMENT_REGISTERS
jit.poke(GPRInfo::regT0);
Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (153262 => 153263)
--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2013-07-25 04:04:16 UTC (rev 153262)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2013-07-25 04:04:18 UTC (rev 153263)
@@ -1759,14 +1759,33 @@
// If I am my own replacement, then reoptimization has already been triggered.
// This can happen in recursive functions.
- if (codeBlock->replacement() == codeBlock)
+ if (codeBlock->replacement() == codeBlock) {
+ if (Options::verboseOSR())
+ dataLog(*codeBlock, ": Not reoptimizing because we've already been jettisoned.\n");
return;
-
+ }
+
// Otherwise, the replacement must be optimized code. Use this as an opportunity
// to check our logic.
ASSERT(codeBlock->hasOptimizedReplacement());
- ASSERT(JITCode::isOptimizingJIT(codeBlock->replacement()->jitType()));
+ CodeBlock* optimizedCodeBlock = codeBlock->replacement();
+ ASSERT(JITCode::isOptimizingJIT(optimizedCodeBlock->jitType()));
+ // In order to trigger reoptimization, one of two things must have happened:
+ // 1) We exited more than some number of times.
+ // 2) We exited and got stuck in a loop, and now we're exiting again.
+ bool didExitABunch = optimizedCodeBlock->shouldReoptimizeNow();
+ bool didGetStuckInLoop =
+ codeBlock->checkIfOptimizationThresholdReached()
+ && optimizedCodeBlock->shouldReoptimizeFromLoopNow();
+
+ if (!didExitABunch && !didGetStuckInLoop) {
+ if (Options::verboseOSR())
+ dataLog(*codeBlock, ": Not reoptimizing ", *optimizedCodeBlock, " because it either didn't exit enough or didn't loop enough after exit.\n");
+ codeBlock->optimizeAfterLongWarmUp();
+ return;
+ }
+
codeBlock->reoptimize();
}
Modified: trunk/Source/_javascript_Core/jit/JITOpcodes.cpp (153262 => 153263)
--- trunk/Source/_javascript_Core/jit/JITOpcodes.cpp 2013-07-25 04:04:16 UTC (rev 153262)
+++ trunk/Source/_javascript_Core/jit/JITOpcodes.cpp 2013-07-25 04:04:18 UTC (rev 153263)
@@ -1149,9 +1149,22 @@
void JIT::emit_op_loop_hint(Instruction*)
{
// Emit the JIT optimization check:
- if (canBeOptimized())
- addSlowCase(branchAdd32(PositiveOrZero, TrustedImm32(Options::executionCounterIncrementForLoop()),
- AbsoluteAddress(m_codeBlock->addressOfJITExecuteCounter())));
+ if (canBeOptimized()) {
+ if (Options::enableOSREntryInLoops()) {
+ addSlowCase(branchAdd32(PositiveOrZero, TrustedImm32(Options::executionCounterIncrementForLoop()),
+ AbsoluteAddress(m_codeBlock->addressOfJITExecuteCounter())));
+ } else {
+ // Add with saturation.
+ move(TrustedImmPtr(m_codeBlock->addressOfJITExecuteCounter()), regT3);
+ load32(regT3, regT2);
+ Jump dontAdd = branch32(
+ GreaterThan, regT2,
+ TrustedImm32(std::numeric_limits<int32_t>::max() - Options::executionCounterIncrementForLoop()));
+ add32(TrustedImm32(Options::executionCounterIncrementForLoop()), regT2);
+ store32(regT2, regT3);
+ dontAdd.link(this);
+ }
+ }
// Emit the watchdog timer check:
if (m_vm->watchdog.isEnabled())
@@ -1162,13 +1175,13 @@
{
#if ENABLE(DFG_JIT)
// Emit the slow path for the JIT optimization check:
- if (canBeOptimized()) {
+ if (canBeOptimized() && Options::enableOSREntryInLoops()) {
linkSlowCase(iter);
-
+
JITStubCall stubCall(this, cti_optimize);
stubCall.addArgument(TrustedImm32(m_bytecodeOffset));
stubCall.call();
-
+
emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_loop_hint));
}
#endif
Modified: trunk/Source/_javascript_Core/runtime/Options.h (153262 => 153263)
--- trunk/Source/_javascript_Core/runtime/Options.h 2013-07-25 04:04:16 UTC (rev 153262)
+++ trunk/Source/_javascript_Core/runtime/Options.h 2013-07-25 04:04:18 UTC (rev 153263)
@@ -114,6 +114,8 @@
v(bool, verboseCompilationQueue, false) \
v(bool, reportCompileTimes, false) \
\
+ v(bool, enableOSREntryInLoops, true) \
+ \
v(bool, useExperimentalFTL, false) \
v(bool, useFTLTBAA, true) \
v(bool, enableLLVMFastISel, false) \