Title: [152326] branches/dfgFourthTier/Source/_javascript_Core
Revision
152326
Author
[email protected]
Date
2013-07-02 15:54:04 -0700 (Tue, 02 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: branches/dfgFourthTier/Source/_javascript_Core/ChangeLog (152325 => 152326)


--- branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-07-02 22:18:37 UTC (rev 152325)
+++ branches/dfgFourthTier/Source/_javascript_Core/ChangeLog	2013-07-02 22:54:04 UTC (rev 152326)
@@ -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: branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp (152325 => 152326)


--- branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp	2013-07-02 22:18:37 UTC (rev 152325)
+++ branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp	2013-07-02 22:54:04 UTC (rev 152326)
@@ -44,9 +44,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: branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.cpp (152325 => 152326)


--- branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.cpp	2013-07-02 22:18:37 UTC (rev 152325)
+++ branches/dfgFourthTier/Source/_javascript_Core/dfg/DFGOperations.cpp	2013-07-02 22:54:04 UTC (rev 152326)
@@ -1740,14 +1740,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: branches/dfgFourthTier/Source/_javascript_Core/jit/JITOpcodes.cpp (152325 => 152326)


--- branches/dfgFourthTier/Source/_javascript_Core/jit/JITOpcodes.cpp	2013-07-02 22:18:37 UTC (rev 152325)
+++ branches/dfgFourthTier/Source/_javascript_Core/jit/JITOpcodes.cpp	2013-07-02 22:54:04 UTC (rev 152326)
@@ -1154,9 +1154,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())
@@ -1167,13 +1180,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: branches/dfgFourthTier/Source/_javascript_Core/runtime/Options.h (152325 => 152326)


--- branches/dfgFourthTier/Source/_javascript_Core/runtime/Options.h	2013-07-02 22:18:37 UTC (rev 152325)
+++ branches/dfgFourthTier/Source/_javascript_Core/runtime/Options.h	2013-07-02 22:54:04 UTC (rev 152326)
@@ -86,6 +86,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) \
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to