Title: [153198] trunk/Source/_javascript_Core
Revision
153198
Author
[email protected]
Date
2013-07-24 21:01:40 -0700 (Wed, 24 Jul 2013)

Log Message

fourthTier: FTL should support ArithAbs
https://bugs.webkit.org/show_bug.cgi?id=116890

Reviewed by Oliver Hunt.

Implements ArithAbs in the FTL, and cleans up the DFG implementation. The
DFG implementation was previously doing zero extensions manually when it
is probably better to just use StrictInt32Operand instead.

* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* ftl/FTLCapabilities.cpp:
(JSC::FTL::canCompile):
* ftl/FTLIntrinsicRepository.h:
(FTL):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileArithAbs):
(LowerDFGToLLVM):
* ftl/FTLOutput.h:
(JSC::FTL::Output::doubleAbs):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (153197 => 153198)


--- trunk/Source/_javascript_Core/ChangeLog	2013-07-25 04:01:38 UTC (rev 153197)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-07-25 04:01:40 UTC (rev 153198)
@@ -1,3 +1,29 @@
+2013-05-28  Filip Pizlo  <[email protected]>
+
+        fourthTier: FTL should support ArithAbs
+        https://bugs.webkit.org/show_bug.cgi?id=116890
+
+        Reviewed by Oliver Hunt.
+        
+        Implements ArithAbs in the FTL, and cleans up the DFG implementation. The
+        DFG implementation was previously doing zero extensions manually when it
+        is probably better to just use StrictInt32Operand instead.
+
+        * dfg/DFGSpeculativeJIT32_64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * dfg/DFGSpeculativeJIT64.cpp:
+        (JSC::DFG::SpeculativeJIT::compile):
+        * ftl/FTLCapabilities.cpp:
+        (JSC::FTL::canCompile):
+        * ftl/FTLIntrinsicRepository.h:
+        (FTL):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compileNode):
+        (JSC::FTL::LowerDFGToLLVM::compileArithAbs):
+        (LowerDFGToLLVM):
+        * ftl/FTLOutput.h:
+        (JSC::FTL::Output::doubleAbs):
+
 2013-05-28  Mark Lam  <[email protected]>
 
         Misc JIT probe enhacements.

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp (153197 => 153198)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp	2013-07-25 04:01:38 UTC (rev 153197)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp	2013-07-25 04:01:40 UTC (rev 153198)
@@ -2263,11 +2263,11 @@
     case ArithAbs: {
         switch (node->child1().useKind()) {
         case Int32Use: {
-            SpeculateIntegerOperand op1(this, node->child1());
+            SpeculateStrictInt32Operand op1(this, node->child1());
             GPRTemporary result(this, op1);
             GPRTemporary scratch(this);
             
-            m_jit.zeroExtend32ToPtr(op1.gpr(), result.gpr());
+            m_jit.move(op1.gpr(), result.gpr());
             m_jit.rshift32(result.gpr(), MacroAssembler::TrustedImm32(31), scratch.gpr());
             m_jit.add32(scratch.gpr(), result.gpr());
             m_jit.xor32(scratch.gpr(), result.gpr());

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp (153197 => 153198)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp	2013-07-25 04:01:38 UTC (rev 153197)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp	2013-07-25 04:01:40 UTC (rev 153198)
@@ -2204,11 +2204,11 @@
     case ArithAbs: {
         switch (node->child1().useKind()) {
         case Int32Use: {
-            SpeculateIntegerOperand op1(this, node->child1());
+            SpeculateStrictInt32Operand op1(this, node->child1());
             GPRTemporary result(this);
             GPRTemporary scratch(this);
             
-            m_jit.zeroExtend32ToPtr(op1.gpr(), result.gpr());
+            m_jit.move(op1.gpr(), result.gpr());
             m_jit.rshift32(result.gpr(), MacroAssembler::TrustedImm32(31), scratch.gpr());
             m_jit.add32(scratch.gpr(), result.gpr());
             m_jit.xor32(scratch.gpr(), result.gpr());

Modified: trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp (153197 => 153198)


--- trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2013-07-25 04:01:38 UTC (rev 153197)
+++ trunk/Source/_javascript_Core/ftl/FTLCapabilities.cpp	2013-07-25 04:01:40 UTC (rev 153198)
@@ -70,6 +70,7 @@
     case ArithMod:
     case ArithMin:
     case ArithMax:
+    case ArithAbs:
     case ArithNegate:
     case UInt32ToNumber:
     case Int32ToDouble:

Modified: trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h (153197 => 153198)


--- trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h	2013-07-25 04:01:38 UTC (rev 153197)
+++ trunk/Source/_javascript_Core/ftl/FTLIntrinsicRepository.h	2013-07-25 04:01:40 UTC (rev 153198)
@@ -38,7 +38,8 @@
 #define FOR_EACH_FTL_INTRINSIC(macro) \
     macro(addWithOverflow32, "llvm.sadd.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \
     macro(subWithOverflow32, "llvm.ssub.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \
-    macro(mulWithOverflow32, "llvm.smul.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32))
+    macro(mulWithOverflow32, "llvm.smul.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \
+    macro(doubleAbs, "llvm.fabs.f64", functionType(doubleType, doubleType))
 
 class IntrinsicRepository : public CommonValues {
 public:

Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (153197 => 153198)


--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2013-07-25 04:01:38 UTC (rev 153197)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2013-07-25 04:01:40 UTC (rev 153198)
@@ -318,6 +318,9 @@
         case ArithMax:
             compileArithMinOrMax();
             break;
+        case ArithAbs:
+            compileArithAbs();
+            break;
         case ArithNegate:
             compileArithNegate();
             break;
@@ -935,6 +938,32 @@
         }
     }
     
+    void compileArithAbs()
+    {
+        switch (m_node->child1().useKind()) {
+        case Int32Use: {
+            LValue value = lowInt32(m_node->child1());
+            
+            LValue mask = m_out.aShr(value, m_out.constInt32(31));
+            LValue result = m_out.bitXor(mask, m_out.add(mask, value));
+            
+            speculate(Overflow, noValue(), 0, m_out.equal(result, m_out.constInt32(1 << 31)));
+            
+            m_int32Values.add(m_node, result);
+            break;
+        }
+            
+        case NumberUse: {
+            m_doubleValues.add(m_node, m_out.doubleAbs(lowDouble(m_node->child1())));
+            break;
+        }
+            
+        default:
+            RELEASE_ASSERT_NOT_REACHED();
+            break;
+        }
+    }
+    
     void compileArithNegate()
     {
         switch (m_node->child1().useKind()) {

Modified: trunk/Source/_javascript_Core/ftl/FTLOutput.h (153197 => 153198)


--- trunk/Source/_javascript_Core/ftl/FTLOutput.h	2013-07-25 04:01:38 UTC (rev 153197)
+++ trunk/Source/_javascript_Core/ftl/FTLOutput.h	2013-07-25 04:01:40 UTC (rev 153198)
@@ -164,6 +164,10 @@
     {
         return call(mulWithOverflow32Intrinsic(), left, right);
     }
+    LValue doubleAbs(LValue value)
+    {
+        return call(doubleAbsIntrinsic(), value);
+    }
     
     LValue zeroExt(LValue value, LType type) { return buildZExt(m_builder, value, type); }
     LValue intToFP(LValue value, LType type) { return buildSIToFP(m_builder, value, type); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to