[JSC] Use 3 operands Add in more places
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Mar 2016 02:42:43 +0000 (02:42 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Mar 2016 02:42:43 +0000 (02:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155082

Reviewed by Filip Pizlo.

* assembler/MacroAssembler.h:
(JSC::MacroAssembler::addPtr):
(JSC::MacroAssembler::add32):
* assembler/MacroAssemblerARMv7.h:
(JSC::MacroAssemblerARMv7::add32):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileArithAdd):
The case with child1 constant is useless.
The canonical form will have the constant as child2.

Also add register reuse for the fast-add.
Registers are a scarce resource on x86.

* jit/CCallHelpers.h:
(JSC::CCallHelpers::prepareForTailCallSlow):
* yarr/YarrJIT.cpp:
(JSC::Yarr::YarrGenerator::generate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197653 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/MacroAssembler.h
Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Source/JavaScriptCore/jit/CCallHelpers.h
Source/JavaScriptCore/yarr/YarrJIT.cpp

index 0cc90cf..085b387 100644 (file)
@@ -1,3 +1,28 @@
+2016-03-06  Benjamin Poulain  <benjamin@webkit.org>
+
+        [JSC] Use 3 operands Add in more places
+        https://bugs.webkit.org/show_bug.cgi?id=155082
+
+        Reviewed by Filip Pizlo.
+
+        * assembler/MacroAssembler.h:
+        (JSC::MacroAssembler::addPtr):
+        (JSC::MacroAssembler::add32):
+        * assembler/MacroAssemblerARMv7.h:
+        (JSC::MacroAssemblerARMv7::add32):
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileArithAdd):
+        The case with child1 constant is useless.
+        The canonical form will have the constant as child2.
+
+        Also add register reuse for the fast-add.
+        Registers are a scarce resource on x86.
+
+        * jit/CCallHelpers.h:
+        (JSC::CCallHelpers::prepareForTailCallSlow):
+        * yarr/YarrJIT.cpp:
+        (JSC::Yarr::YarrGenerator::generate):
+
 2016-03-06  Benjamin Poulain  <bpoulain@apple.com>
 
         [JSC] Improve codegen of Compare and Test
index ef8b71f..f16cb31 100644 (file)
@@ -521,6 +521,11 @@ public:
         add32(src, dest);
     }
 
+    void addPtr(RegisterID left, RegisterID right, RegisterID dest)
+    {
+        add32(left, right, dest);
+    }
+
     void addPtr(TrustedImm32 imm, RegisterID srcDest)
     {
         add32(imm, srcDest);
@@ -793,6 +798,11 @@ public:
     {
         add64(src, dest);
     }
+
+    void addPtr(RegisterID left, RegisterID right, RegisterID dest)
+    {
+        add64(left, right, dest);
+    }
     
     void addPtr(Address src, RegisterID dest)
     {
@@ -1457,6 +1467,16 @@ public:
         } else
             add32(imm.asTrustedImm32(), dest);
     }
+
+    void add32(Imm32 imm, RegisterID src, RegisterID dest)
+    {
+        if (shouldBlind(imm)) {
+            BlindedImm32 key = additionBlindedConstant(imm);
+            add32(key.value1, src, dest);
+            add32(key.value2, dest);
+        } else
+            add32(imm.asTrustedImm32(), src, dest);
+    }
     
     void addPtr(Imm32 imm, RegisterID dest)
     {
index 2bb6634..0941bf1 100644 (file)
@@ -155,6 +155,11 @@ public:
         m_assembler.add(dest, dest, src);
     }
 
+    void add32(RegisterID left, RegisterID right, RegisterID dest)
+    {
+        m_assembler.add(dest, left, right);
+    }
+
     void add32(TrustedImm32 imm, RegisterID dest)
     {
         add32(imm, dest, dest);
index c3d33b0..838cb56 100644 (file)
@@ -3256,32 +3256,20 @@ void SpeculativeJIT::compileArithAdd(Node* node)
     switch (node->binaryUseKind()) {
     case Int32Use: {
         ASSERT(!shouldCheckNegativeZero(node->arithMode()));
-        
-        if (node->child1()->isInt32Constant()) {
-            int32_t imm1 = node->child1()->asInt32();
-            SpeculateInt32Operand op2(this, node->child2());
-            GPRTemporary result(this);
-
-            if (!shouldCheckOverflow(node->arithMode())) {
-                m_jit.move(op2.gpr(), result.gpr());
-                m_jit.add32(Imm32(imm1), result.gpr());
-            } else
-                speculationCheck(Overflow, JSValueRegs(), 0, m_jit.branchAdd32(MacroAssembler::Overflow, op2.gpr(), Imm32(imm1), result.gpr()));
 
-            int32Result(result.gpr(), node);
-            return;
-        }
-        
         if (node->child2()->isInt32Constant()) {
             SpeculateInt32Operand op1(this, node->child1());
             int32_t imm2 = node->child2()->asInt32();
-            GPRTemporary result(this);
-                
+
             if (!shouldCheckOverflow(node->arithMode())) {
-                m_jit.move(op1.gpr(), result.gpr());
-                m_jit.add32(Imm32(imm2), result.gpr());
-            } else
-                speculationCheck(Overflow, JSValueRegs(), 0, m_jit.branchAdd32(MacroAssembler::Overflow, op1.gpr(), Imm32(imm2), result.gpr()));
+                GPRTemporary result(this, Reuse, op1);
+                m_jit.add32(Imm32(imm2), op1.gpr(), result.gpr());
+                int32Result(result.gpr(), node);
+                return;
+            }
+
+            GPRTemporary result(this);
+            speculationCheck(Overflow, JSValueRegs(), 0, m_jit.branchAdd32(MacroAssembler::Overflow, op1.gpr(), Imm32(imm2), result.gpr()));
 
             int32Result(result.gpr(), node);
             return;
@@ -3295,14 +3283,9 @@ void SpeculativeJIT::compileArithAdd(Node* node)
         GPRReg gpr2 = op2.gpr();
         GPRReg gprResult = result.gpr();
 
-        if (!shouldCheckOverflow(node->arithMode())) {
-            if (gpr1 == gprResult)
-                m_jit.add32(gpr2, gprResult);
-            else {
-                m_jit.move(gpr2, gprResult);
-                m_jit.add32(gpr1, gprResult);
-            }
-        } else {
+        if (!shouldCheckOverflow(node->arithMode()))
+            m_jit.add32(gpr1, gpr2, gprResult);
+        else {
             MacroAssembler::Jump check = m_jit.branchAdd32(MacroAssembler::Overflow, gpr1, gpr2, gprResult);
                 
             if (gpr1 == gprResult)
@@ -3329,8 +3312,7 @@ void SpeculativeJIT::compileArithAdd(Node* node)
             SpeculateWhicheverInt52Operand op1(this, node->child1());
             SpeculateWhicheverInt52Operand op2(this, node->child2(), op1);
             GPRTemporary result(this, Reuse, op1);
-            m_jit.move(op1.gpr(), result.gpr());
-            m_jit.add64(op2.gpr(), result.gpr());
+            m_jit.add64(op1.gpr(), op2.gpr(), result.gpr());
             int52Result(result.gpr(), node, op1.format());
             return;
         }
index 13e67b0..e649d39 100644 (file)
@@ -2157,8 +2157,7 @@ public:
 
             // The new frame pointer is at framePointer + oldFrameSize - newFrameSize
             ASSERT(newFramePointer != oldFrameSizeGPR);
-            move(framePointerRegister, newFramePointer);
-            addPtr(oldFrameSizeGPR, newFramePointer);
+            addPtr(framePointerRegister, oldFrameSizeGPR, newFramePointer);
 
             // The new frame size is just the number of arguments plus the
             // frame header size, aligned
index 92f6d7c..e6fed6d 100644 (file)
@@ -1626,8 +1626,7 @@ class YarrGenerator : private MacroAssembler {
                     if (term->quantityType == QuantifierFixedCount)
                         inputOffset -= term->parentheses.disjunction->m_minimumSize;
                     if (inputOffset) {
-                        move(index, indexTemporary);
-                        add32(Imm32(inputOffset), indexTemporary);
+                        add32(Imm32(inputOffset), index, indexTemporary);
                         setSubpatternStart(indexTemporary, term->parentheses.subpatternId);
                     } else
                         setSubpatternStart(index, term->parentheses.subpatternId);
@@ -1657,8 +1656,7 @@ class YarrGenerator : private MacroAssembler {
                 if (term->capture() && compileMode == IncludeSubpatterns) {
                     int inputOffset = term->inputPosition - m_checked;
                     if (inputOffset) {
-                        move(index, indexTemporary);
-                        add32(Imm32(inputOffset), indexTemporary);
+                        add32(Imm32(inputOffset), index, indexTemporary);
                         setSubpatternEnd(indexTemporary, term->parentheses.subpatternId);
                     } else
                         setSubpatternEnd(index, term->parentheses.subpatternId);