Title: [192599] trunk/Source/_javascript_Core
Revision
192599
Author
mark....@apple.com
Date
2015-11-18 16:30:37 -0800 (Wed, 18 Nov 2015)

Log Message

Remove some unnecessary jumps in snippet code.
https://bugs.webkit.org/show_bug.cgi?id=151415

Reviewed by Geoffrey Garen.

Previously, the snippet generators always emit a jump at the end of the fast
path.  In the baseline JIT and FTL, this results in a jump to the very next
instruction.  I've change it to assume that the fast path will just fall thru,
and let the client decide instead if it wants/needs a jump or not after the fast
path.

I also changed the generators to provide a didEmitFastPath() query explicitly
declare if they actually generated the fast path, instead of having the client
infer it from an empty endJumpList.

Benchmarks show that perf is neutral with this change (tested on x86_64).

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileValueAdd):
(JSC::DFG::SpeculativeJIT::compileArithSub):
* ftl/FTLCompile.cpp:
(JSC::FTL::mmAllocateDataSection):
* jit/JITAddGenerator.cpp:
(JSC::JITAddGenerator::generateFastPath):
* jit/JITAddGenerator.h:
(JSC::JITAddGenerator::didEmitFastPath):
(JSC::JITAddGenerator::endJumpList):
(JSC::JITAddGenerator::slowPathJumpList):
* jit/JITArithmetic.cpp:
(JSC::JIT::emit_op_add):
(JSC::JIT::emit_op_sub):
* jit/JITSubGenerator.cpp:
(JSC::JITSubGenerator::generateFastPath):
* jit/JITSubGenerator.h:
(JSC::JITSubGenerator::didEmitFastPath):
(JSC::JITSubGenerator::endJumpList):
(JSC::JITSubGenerator::slowPathJumpList):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (192598 => 192599)


--- trunk/Source/_javascript_Core/ChangeLog	2015-11-19 00:20:41 UTC (rev 192598)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-11-19 00:30:37 UTC (rev 192599)
@@ -1,3 +1,43 @@
+2015-11-18  Mark Lam  <mark....@apple.com>
+
+        Remove some unnecessary jumps in snippet code.
+        https://bugs.webkit.org/show_bug.cgi?id=151415
+
+        Reviewed by Geoffrey Garen.
+
+        Previously, the snippet generators always emit a jump at the end of the fast
+        path.  In the baseline JIT and FTL, this results in a jump to the very next
+        instruction.  I've change it to assume that the fast path will just fall thru,
+        and let the client decide instead if it wants/needs a jump or not after the fast
+        path.
+
+        I also changed the generators to provide a didEmitFastPath() query explicitly
+        declare if they actually generated the fast path, instead of having the client
+        infer it from an empty endJumpList.
+
+        Benchmarks show that perf is neutral with this change (tested on x86_64).
+
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileValueAdd):
+        (JSC::DFG::SpeculativeJIT::compileArithSub):
+        * ftl/FTLCompile.cpp:
+        (JSC::FTL::mmAllocateDataSection):
+        * jit/JITAddGenerator.cpp:
+        (JSC::JITAddGenerator::generateFastPath):
+        * jit/JITAddGenerator.h:
+        (JSC::JITAddGenerator::didEmitFastPath):
+        (JSC::JITAddGenerator::endJumpList):
+        (JSC::JITAddGenerator::slowPathJumpList):
+        * jit/JITArithmetic.cpp:
+        (JSC::JIT::emit_op_add):
+        (JSC::JIT::emit_op_sub):
+        * jit/JITSubGenerator.cpp:
+        (JSC::JITSubGenerator::generateFastPath):
+        * jit/JITSubGenerator.h:
+        (JSC::JITSubGenerator::didEmitFastPath):
+        (JSC::JITSubGenerator::endJumpList):
+        (JSC::JITSubGenerator::slowPathJumpList):
+
 2015-11-18  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r192436 and r192586.

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (192598 => 192599)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2015-11-19 00:20:41 UTC (rev 192598)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2015-11-19 00:30:37 UTC (rev 192599)
@@ -2880,6 +2880,9 @@
         leftFPR, rightFPR, scratchGPR, scratchFPR);
     gen.generateFastPath(m_jit);
 
+    ASSERT(gen.didEmitFastPath());
+    gen.endJumpList().append(m_jit.jump());
+
     gen.slowPathJumpList().link(&m_jit);
 
     silentSpillAllRegisters(resultRegs);
@@ -3240,6 +3243,9 @@
             leftFPR, rightFPR, scratchGPR, scratchFPR);
         gen.generateFastPath(m_jit);
 
+        ASSERT(gen.didEmitFastPath());
+        gen.endJumpList().append(m_jit.jump());
+
         gen.slowPathJumpList().link(&m_jit);
         silentSpillAllRegisters(resultRegs);
         callOperation(operationValueSub, resultRegs, leftRegs, rightRegs);

Modified: trunk/Source/_javascript_Core/ftl/FTLCompile.cpp (192598 => 192599)


--- trunk/Source/_javascript_Core/ftl/FTLCompile.cpp	2015-11-19 00:20:41 UTC (rev 192598)
+++ trunk/Source/_javascript_Core/ftl/FTLCompile.cpp	2015-11-19 00:30:37 UTC (rev 192599)
@@ -462,6 +462,7 @@
         context.initializeRegisters(fastPathJIT);
         gen.generateFastPath(fastPathJIT);
 
+        ASSERT(gen.didEmitFastPath());
         gen.endJumpList().link(&fastPathJIT);
         context.restoreRegisters(fastPathJIT);
         allocator.restoreReusedRegistersByPopping(fastPathJIT, numberOfBytesUsedToPreserveReusedRegisters,

Modified: trunk/Source/_javascript_Core/jit/JITAddGenerator.cpp (192598 => 192599)


--- trunk/Source/_javascript_Core/jit/JITAddGenerator.cpp	2015-11-19 00:20:41 UTC (rev 192598)
+++ trunk/Source/_javascript_Core/jit/JITAddGenerator.cpp	2015-11-19 00:30:37 UTC (rev 192599)
@@ -44,10 +44,12 @@
     ASSERT(!m_leftIsConstInt32 || !m_rightIsConstInt32);
     
     if (!m_leftType.mightBeNumber() || !m_rightType.mightBeNumber()) {
-        m_slowPathJumpList.append(jit.jump());
+        ASSERT(!m_didEmitFastPath);
         return;
     }
 
+    m_didEmitFastPath = true;
+
     if (m_leftIsConstInt32 || m_rightIsConstInt32) {
         JSValueRegs var;
         ResultType varType = ResultType::unknownType();
@@ -137,8 +139,6 @@
     // Do doubleVar + doubleVar.
     jit.addDouble(m_rightFPR, m_leftFPR);
     jit.boxDouble(m_leftFPR, m_result);
-
-    m_endJumpList.append(jit.jump());
 }
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/jit/JITAddGenerator.h (192598 => 192599)


--- trunk/Source/_javascript_Core/jit/JITAddGenerator.h	2015-11-19 00:20:41 UTC (rev 192598)
+++ trunk/Source/_javascript_Core/jit/JITAddGenerator.h	2015-11-19 00:30:37 UTC (rev 192599)
@@ -58,6 +58,7 @@
 
     void generateFastPath(CCallHelpers&);
 
+    bool didEmitFastPath() const { return m_didEmitFastPath; }
     CCallHelpers::JumpList endJumpList() { return m_endJumpList; }
     CCallHelpers::JumpList slowPathJumpList() { return m_slowPathJumpList; }
 
@@ -75,6 +76,7 @@
     FPRReg m_rightFPR;
     GPRReg m_scratchGPR;
     FPRReg m_scratchFPR;
+    bool m_didEmitFastPath { false };
 
     CCallHelpers::JumpList m_endJumpList;
     CCallHelpers::JumpList m_slowPathJumpList;

Modified: trunk/Source/_javascript_Core/jit/JITArithmetic.cpp (192598 => 192599)


--- trunk/Source/_javascript_Core/jit/JITArithmetic.cpp	2015-11-19 00:20:41 UTC (rev 192598)
+++ trunk/Source/_javascript_Core/jit/JITArithmetic.cpp	2015-11-19 00:30:37 UTC (rev 192599)
@@ -958,13 +958,14 @@
 
     gen.generateFastPath(*this);
 
-    if (!gen.endJumpList().empty()) {
+    if (gen.didEmitFastPath()) {
         gen.endJumpList().link(this);
         emitPutVirtualRegister(result, resultRegs);
         
         addSlowCase(gen.slowPathJumpList());
     } else {
-        gen.slowPathJumpList().link(this);
+        ASSERT(gen.endJumpList().empty());
+        ASSERT(gen.slowPathJumpList().empty());
         JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
         slowPathCall.call();
     }
@@ -1006,6 +1007,8 @@
         fpRegT0, fpRegT1, scratchGPR, scratchFPR);
 
     gen.generateFastPath(*this);
+
+    ASSERT(gen.didEmitFastPath());
     gen.endJumpList().link(this);
     emitPutVirtualRegister(result, resultRegs);
 

Modified: trunk/Source/_javascript_Core/jit/JITSubGenerator.cpp (192598 => 192599)


--- trunk/Source/_javascript_Core/jit/JITSubGenerator.cpp	2015-11-19 00:20:41 UTC (rev 192598)
+++ trunk/Source/_javascript_Core/jit/JITSubGenerator.cpp	2015-11-19 00:30:37 UTC (rev 192599)
@@ -40,6 +40,9 @@
     ASSERT(m_scratchGPR != m_right.tagGPR());
     ASSERT(m_scratchFPR != InvalidFPRReg);
 #endif
+
+    m_didEmitFastPath = true;
+
     CCallHelpers::Jump leftNotInt = jit.branchIfNotInt32(m_left);
     CCallHelpers::Jump rightNotInt = jit.branchIfNotInt32(m_right);
 
@@ -81,8 +84,6 @@
 
     jit.subDouble(m_rightFPR, m_leftFPR);
     jit.boxDouble(m_leftFPR, m_result);
-
-    m_endJumpList.append(jit.jump());
 }
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/jit/JITSubGenerator.h (192598 => 192599)


--- trunk/Source/_javascript_Core/jit/JITSubGenerator.h	2015-11-19 00:20:41 UTC (rev 192598)
+++ trunk/Source/_javascript_Core/jit/JITSubGenerator.h	2015-11-19 00:30:37 UTC (rev 192599)
@@ -51,6 +51,7 @@
 
     void generateFastPath(CCallHelpers&);
 
+    bool didEmitFastPath() const { return m_didEmitFastPath; }
     CCallHelpers::JumpList endJumpList() { return m_endJumpList; }
     CCallHelpers::JumpList slowPathJumpList() { return m_slowPathJumpList; }
 
@@ -64,6 +65,7 @@
     FPRReg m_rightFPR;
     GPRReg m_scratchGPR;
     FPRReg m_scratchFPR;
+    bool m_didEmitFastPath { false };
 
     CCallHelpers::JumpList m_endJumpList;
     CCallHelpers::JumpList m_slowPathJumpList;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to