Refactor the op_add, op_sub, and op_mul snippets to use the SnippetOperand class.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Dec 2015 00:07:39 +0000 (00:07 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Dec 2015 00:07:39 +0000 (00:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151678

Reviewed by Geoffrey Garen.

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileValueAdd):
(JSC::DFG::SpeculativeJIT::compileArithSub):
* ftl/FTLCompile.cpp:
* jit/JITAddGenerator.cpp:
(JSC::JITAddGenerator::generateFastPath):
* jit/JITAddGenerator.h:
(JSC::JITAddGenerator::JITAddGenerator):
* jit/JITArithmetic.cpp:
(JSC::JIT::emit_op_add):
(JSC::JIT::emit_op_mul):
(JSC::JIT::emit_op_sub):
* jit/JITMulGenerator.cpp:
(JSC::JITMulGenerator::generateFastPath):
* jit/JITMulGenerator.h:
(JSC::JITMulGenerator::JITMulGenerator):
* jit/JITSubGenerator.cpp:
(JSC::JITSubGenerator::generateFastPath):
* jit/JITSubGenerator.h:
(JSC::JITSubGenerator::JITSubGenerator):
* jit/SnippetOperand.h:
(JSC::SnippetOperand::isPositiveConstInt32):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Source/JavaScriptCore/ftl/FTLCompile.cpp
Source/JavaScriptCore/jit/JITAddGenerator.cpp
Source/JavaScriptCore/jit/JITAddGenerator.h
Source/JavaScriptCore/jit/JITArithmetic.cpp
Source/JavaScriptCore/jit/JITMulGenerator.cpp
Source/JavaScriptCore/jit/JITMulGenerator.h
Source/JavaScriptCore/jit/JITSubGenerator.cpp
Source/JavaScriptCore/jit/JITSubGenerator.h
Source/JavaScriptCore/jit/SnippetOperand.h

index 49c0add..3029aa0 100644 (file)
@@ -1,3 +1,33 @@
+2015-11-30  Mark Lam  <mark.lam@apple.com>
+
+        Refactor the op_add, op_sub, and op_mul snippets to use the SnippetOperand class.
+        https://bugs.webkit.org/show_bug.cgi?id=151678
+
+        Reviewed by Geoffrey Garen.
+
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileValueAdd):
+        (JSC::DFG::SpeculativeJIT::compileArithSub):
+        * ftl/FTLCompile.cpp:
+        * jit/JITAddGenerator.cpp:
+        (JSC::JITAddGenerator::generateFastPath):
+        * jit/JITAddGenerator.h:
+        (JSC::JITAddGenerator::JITAddGenerator):
+        * jit/JITArithmetic.cpp:
+        (JSC::JIT::emit_op_add):
+        (JSC::JIT::emit_op_mul):
+        (JSC::JIT::emit_op_sub):
+        * jit/JITMulGenerator.cpp:
+        (JSC::JITMulGenerator::generateFastPath):
+        * jit/JITMulGenerator.h:
+        (JSC::JITMulGenerator::JITMulGenerator):
+        * jit/JITSubGenerator.cpp:
+        (JSC::JITSubGenerator::generateFastPath):
+        * jit/JITSubGenerator.h:
+        (JSC::JITSubGenerator::JITSubGenerator):
+        * jit/SnippetOperand.h:
+        (JSC::SnippetOperand::isPositiveConstInt32):
+
 2015-11-30  Filip Pizlo  <fpizlo@apple.com>
 
         B3 stackmaps should support early clobber
index 77a14b4..800613c 100755 (executable)
@@ -2853,30 +2853,26 @@ void SpeculativeJIT::compileValueAdd(Node* node)
     FPRReg scratchFPR = fprScratch.fpr();
 #endif
 
-    ResultType leftType = m_state.forNode(node->child1()).resultType();
-    ResultType rightType = m_state.forNode(node->child2()).resultType();
-    int32_t leftConstInt32 = 0;
-    int32_t rightConstInt32 = 0;
+    SnippetOperand leftOperand(m_state.forNode(node->child1()).resultType());
+    SnippetOperand rightOperand(m_state.forNode(node->child2()).resultType());
 
-    ASSERT(!leftIsConstInt32 || !rightIsConstInt32);
+    if (leftIsConstInt32)
+        leftOperand.setConstInt32(node->child1()->asInt32());
+    if (rightIsConstInt32)
+        rightOperand.setConstInt32(node->child2()->asInt32());
 
-    if (leftIsConstInt32) {
-        leftConstInt32 = node->child1()->asInt32();
-        right = JSValueOperand(this, node->child2());
-        rightRegs = right->jsValueRegs();
-    } else if (rightIsConstInt32) {
-        left = JSValueOperand(this, node->child1());
-        leftRegs = left->jsValueRegs();
-        rightConstInt32 = node->child2()->asInt32();
-    } else {
+    ASSERT(!leftOperand.isConst() || !rightOperand.isConst());
+
+    if (!leftOperand.isConst()) {
         left = JSValueOperand(this, node->child1());
         leftRegs = left->jsValueRegs();
+    }
+    if (!rightOperand.isConst()) {
         right = JSValueOperand(this, node->child2());
         rightRegs = right->jsValueRegs();
     }
 
-    JITAddGenerator gen(resultRegs, leftRegs, rightRegs, leftType, rightType,
-        leftIsConstInt32, rightIsConstInt32, leftConstInt32, rightConstInt32,
+    JITAddGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
         leftFPR, rightFPR, scratchGPR, scratchFPR);
     gen.generateFastPath(m_jit);
 
@@ -3216,9 +3212,6 @@ void SpeculativeJIT::compileArithSub(Node* node)
         JSValueRegs leftRegs = left.jsValueRegs();
         JSValueRegs rightRegs = right.jsValueRegs();
 
-        ResultType leftType = m_state.forNode(node->child1()).resultType();
-        ResultType rightType = m_state.forNode(node->child2()).resultType();
-
         FPRTemporary leftNumber(this);
         FPRTemporary rightNumber(this);
         FPRReg leftFPR = leftNumber.fpr();
@@ -3239,7 +3232,10 @@ void SpeculativeJIT::compileArithSub(Node* node)
         FPRReg scratchFPR = fprScratch.fpr();
 #endif
 
-        JITSubGenerator gen(resultRegs, leftRegs, rightRegs, leftType, rightType,
+        SnippetOperand leftOperand(m_state.forNode(node->child1()).resultType());
+        SnippetOperand rightOperand(m_state.forNode(node->child2()).resultType());
+
+        JITSubGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
             leftFPR, rightFPR, scratchGPR, scratchFPR);
         gen.generateFastPath(m_jit);
 
index 2c065c0..9da5a3c 100644 (file)
@@ -440,6 +440,9 @@ static void generateArithSubICFastPath(
 
         CCallHelpers fastPathJIT(&vm, codeBlock);
 
+        SnippetOperand leftOperand(ic.leftType());
+        SnippetOperand rightOperand(ic.rightType());
+
         GPRReg result = record.locations[0].directGPR();
         GPRReg left = record.locations[1].directGPR();
         GPRReg right = record.locations[2].directGPR();
@@ -454,7 +457,7 @@ static void generateArithSubICFastPath(
         FPRReg rightFPR = allocator.allocateScratchFPR();
         FPRReg scratchFPR = InvalidFPRReg;
 
-        JITSubGenerator gen(JSValueRegs(result), JSValueRegs(left), JSValueRegs(right), ic.leftType(), ic.rightType(), leftFPR, rightFPR, scratchGPR, scratchFPR);
+        JITSubGenerator gen(leftOperand, rightOperand, JSValueRegs(result), JSValueRegs(left), JSValueRegs(right), leftFPR, rightFPR, scratchGPR, scratchFPR);
 
         auto numberOfBytesUsedToPreserveReusedRegisters =
             allocator.preserveReusedRegistersByPushing(fastPathJIT, ScratchRegisterAllocator::ExtraStackSpace::NoExtraSpace);
index 20e0250..5d91a51 100644 (file)
@@ -24,9 +24,9 @@
  */
 
 #include "config.h"
+#include "JITAddGenerator.h"
 
 #if ENABLE(JIT)
-#include "JITAddGenerator.h"
 
 namespace JSC {
 
@@ -41,34 +41,24 @@ void JITAddGenerator::generateFastPath(CCallHelpers& jit)
     ASSERT(m_scratchFPR != InvalidFPRReg);
 #endif
 
-    ASSERT(!m_leftIsConstInt32 || !m_rightIsConstInt32);
+    ASSERT(!m_leftOperand.isConstInt32() || !m_rightOperand.isConstInt32());
     
-    if (!m_leftType.mightBeNumber() || !m_rightType.mightBeNumber()) {
+    if (!m_leftOperand.mightBeNumber() || !m_rightOperand.mightBeNumber()) {
         ASSERT(!m_didEmitFastPath);
         return;
     }
 
     m_didEmitFastPath = true;
 
-    if (m_leftIsConstInt32 || m_rightIsConstInt32) {
-        JSValueRegs var;
-        ResultType varType = ResultType::unknownType();
-        int32_t constInt32;
-
-        if (m_leftIsConstInt32) {
-            var = m_right;
-            varType = m_rightType;
-            constInt32 = m_leftConstInt32;
-        } else {
-            var = m_left;
-            varType = m_leftType;
-            constInt32 = m_rightConstInt32;
-        }
+    if (m_leftOperand.isConstInt32() || m_rightOperand.isConstInt32()) {
+        JSValueRegs var = m_leftOperand.isConstInt32() ? m_right : m_left;
+        SnippetOperand& varOpr = m_leftOperand.isConstInt32() ? m_rightOperand : m_leftOperand;
+        SnippetOperand& constOpr = m_leftOperand.isConstInt32() ? m_leftOperand : m_rightOperand;
 
         // Try to do intVar + intConstant.
         CCallHelpers::Jump notInt32 = jit.branchIfNotInt32(var);
 
-        m_slowPathJumpList.append(jit.branchAdd32(CCallHelpers::Overflow, var.payloadGPR(), CCallHelpers::Imm32(constInt32), m_scratchGPR));
+        m_slowPathJumpList.append(jit.branchAdd32(CCallHelpers::Overflow, var.payloadGPR(), CCallHelpers::Imm32(constOpr.asConstInt32()), m_scratchGPR));
 
         jit.boxInt32(m_scratchGPR, m_result);
         m_endJumpList.append(jit.jump());
@@ -80,18 +70,18 @@ void JITAddGenerator::generateFastPath(CCallHelpers& jit)
 
         // Try to do doubleVar + double(intConstant).
         notInt32.link(&jit);
-        if (!varType.definitelyIsNumber())
+        if (!varOpr.definitelyIsNumber())
             m_slowPathJumpList.append(jit.branchIfNotNumber(var, m_scratchGPR));
 
         jit.unboxDoubleNonDestructive(var, m_leftFPR, m_scratchGPR, m_scratchFPR);
 
-        jit.move(CCallHelpers::Imm32(constInt32), m_scratchGPR);
+        jit.move(CCallHelpers::Imm32(constOpr.asConstInt32()), m_scratchGPR);
         jit.convertInt32ToDouble(m_scratchGPR, m_rightFPR);
 
         // Fall thru to doubleVar + doubleVar.
 
     } else {
-        ASSERT(!m_leftIsConstInt32 && !m_rightIsConstInt32);
+        ASSERT(!m_leftOperand.isConstInt32() && !m_rightOperand.isConstInt32());
         CCallHelpers::Jump leftNotInt;
         CCallHelpers::Jump rightNotInt;
 
@@ -111,9 +101,9 @@ void JITAddGenerator::generateFastPath(CCallHelpers& jit)
         }
 
         leftNotInt.link(&jit);
-        if (!m_leftType.definitelyIsNumber())
+        if (!m_leftOperand.definitelyIsNumber())
             m_slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR));
-        if (!m_rightType.definitelyIsNumber())
+        if (!m_rightOperand.definitelyIsNumber())
             m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
 
         jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR);
@@ -123,7 +113,7 @@ void JITAddGenerator::generateFastPath(CCallHelpers& jit)
         CCallHelpers::Jump rightWasInteger = jit.jump();
 
         rightNotInt.link(&jit);
-        if (!m_rightType.definitelyIsNumber())
+        if (!m_rightOperand.definitelyIsNumber())
             m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
 
         jit.convertInt32ToDouble(m_left.payloadGPR(), m_leftFPR);
index 1f32c11..c28db72 100644 (file)
 #if ENABLE(JIT)
 
 #include "CCallHelpers.h"
-#include "ResultType.h"
+#include "SnippetOperand.h"
 
 namespace JSC {
 
 class JITAddGenerator {
 public:
-    JITAddGenerator(JSValueRegs result, JSValueRegs left, JSValueRegs right,
-        ResultType leftType, ResultType rightType, bool leftIsConstInt32, bool rightIsConstInt32,
-        int32_t leftConstInt32, int32_t rightConstInt32, FPRReg leftFPR, FPRReg rightFPR,
-        GPRReg scratchGPR, FPRReg scratchFPR)
-        : m_result(result)
+    JITAddGenerator(SnippetOperand leftOperand, SnippetOperand rightOperand,
+        JSValueRegs result, JSValueRegs left, JSValueRegs right,
+        FPRReg leftFPR, FPRReg rightFPR, GPRReg scratchGPR, FPRReg scratchFPR)
+        : m_leftOperand(leftOperand)
+        , m_rightOperand(rightOperand)
+        , m_result(result)
         , m_left(left)
         , m_right(right)
-        , m_leftType(leftType)
-        , m_rightType(rightType)
-        , m_leftIsConstInt32(leftIsConstInt32)
-        , m_rightIsConstInt32(rightIsConstInt32)
-        , m_leftConstInt32(leftConstInt32)
-        , m_rightConstInt32(rightConstInt32)
         , m_leftFPR(leftFPR)
         , m_rightFPR(rightFPR)
         , m_scratchGPR(scratchGPR)
         , m_scratchFPR(scratchFPR)
     {
-        ASSERT(!leftIsConstInt32 || !rightIsConstInt32);
+        ASSERT(!m_leftOperand.isConstInt32() || !m_rightOperand.isConstInt32());
     }
 
     void generateFastPath(CCallHelpers&);
@@ -63,15 +58,11 @@ public:
     CCallHelpers::JumpList& slowPathJumpList() { return m_slowPathJumpList; }
 
 private:
+    SnippetOperand m_leftOperand;
+    SnippetOperand m_rightOperand;
     JSValueRegs m_result;
     JSValueRegs m_left;
     JSValueRegs m_right;
-    ResultType m_leftType;
-    ResultType m_rightType;
-    bool m_leftIsConstInt32;
-    bool m_rightIsConstInt32;
-    int32_t m_leftConstInt32;
-    int32_t m_rightConstInt32;
     FPRReg m_leftFPR;
     FPRReg m_rightFPR;
     GPRReg m_scratchGPR;
index edf83a1..3c34951 100644 (file)
@@ -685,28 +685,22 @@ void JIT::emit_op_add(Instruction* currentInstruction)
     FPRReg scratchFPR = fpRegT2;
 #endif
 
-    bool leftIsConstInt32 = isOperandConstantInt(op1);
-    bool rightIsConstInt32 = isOperandConstantInt(op2);
-    ResultType leftType = types.first();
-    ResultType rightType = types.second();
-    int32_t leftConstInt32 = 0;
-    int32_t rightConstInt32 = 0;
+    SnippetOperand leftOperand(types.first());
+    SnippetOperand rightOperand(types.second());
 
-    ASSERT(!leftIsConstInt32 || !rightIsConstInt32);
+    if (isOperandConstantInt(op1))
+        leftOperand.setConstInt32(getOperandConstantInt(op1));
+    if (isOperandConstantInt(op2))
+        rightOperand.setConstInt32(getOperandConstantInt(op2));
 
-    if (leftIsConstInt32) {
-        leftConstInt32 = getOperandConstantInt(op1);
-        emitGetVirtualRegister(op2, rightRegs);
-    } else if (rightIsConstInt32) {
-        emitGetVirtualRegister(op1, leftRegs);
-        rightConstInt32 = getOperandConstantInt(op2);
-    } else {
+    ASSERT(!leftOperand.isConst() || !rightOperand.isConst());
+
+    if (!leftOperand.isConst())
         emitGetVirtualRegister(op1, leftRegs);
+    if (!rightOperand.isConst())
         emitGetVirtualRegister(op2, rightRegs);
-    }
 
-    JITAddGenerator gen(resultRegs, leftRegs, rightRegs, leftType, rightType,
-        leftIsConstInt32, rightIsConstInt32, leftConstInt32, rightConstInt32,
+    JITAddGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
         fpRegT0, fpRegT1, scratchGPR, scratchFPR);
 
     gen.generateFastPath(*this);
@@ -826,38 +820,26 @@ void JIT::emit_op_mul(Instruction* currentInstruction)
     FPRReg scratchFPR = fpRegT2;
 #endif
 
-    bool leftIsConstInt32 = isOperandConstantInt(op1);
-    bool rightIsConstInt32 = isOperandConstantInt(op2);
-    ResultType leftType = types.first();
-    ResultType rightType = types.second();
-    int32_t leftConstInt32 = 0;
-    int32_t rightConstInt32 = 0;
-
     uint32_t* profilingCounter = nullptr;
     if (shouldEmitProfiling())
         profilingCounter = &m_codeBlock->addSpecialFastCaseProfile(m_bytecodeOffset)->m_counter;
 
-    ASSERT(!leftIsConstInt32 || !rightIsConstInt32);
+    SnippetOperand leftOperand(types.first());
+    SnippetOperand rightOperand(types.second());
 
-    if (leftIsConstInt32)
-        leftConstInt32 = getOperandConstantInt(op1);
-    if (rightIsConstInt32)
-        rightConstInt32 = getOperandConstantInt(op2);
+    if (isOperandConstantInt(op1))
+        leftOperand.setConstInt32(getOperandConstantInt(op1));
+    if (isOperandConstantInt(op2))
+        rightOperand.setConstInt32(getOperandConstantInt(op2));
 
-    bool leftIsPositiveConstInt32 = leftIsConstInt32 && (leftConstInt32 > 0);
-    bool rightIsPositiveConstInt32 = rightIsConstInt32 && (rightConstInt32 > 0);
+    ASSERT(!leftOperand.isConst() || !rightOperand.isConst());
 
-    if (leftIsPositiveConstInt32)
-        emitGetVirtualRegister(op2, rightRegs);
-    else if (rightIsPositiveConstInt32)
-        emitGetVirtualRegister(op1, leftRegs);
-    else {
+    if (!leftOperand.isPositiveConstInt32())
         emitGetVirtualRegister(op1, leftRegs);
+    if (!rightOperand.isPositiveConstInt32())
         emitGetVirtualRegister(op2, rightRegs);
-    }
 
-    JITMulGenerator gen(resultRegs, leftRegs, rightRegs, leftType, rightType,
-        leftIsPositiveConstInt32, rightIsPositiveConstInt32, leftConstInt32, rightConstInt32,
+    JITMulGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
         fpRegT0, fpRegT1, scratchGPR, scratchFPR, profilingCounter);
 
     gen.generateFastPath(*this);
@@ -904,10 +886,13 @@ void JIT::emit_op_sub(Instruction* currentInstruction)
     FPRReg scratchFPR = fpRegT2;
 #endif
 
+    SnippetOperand leftOperand(types.first());
+    SnippetOperand rightOperand(types.second());
+    
     emitGetVirtualRegister(op1, leftRegs);
     emitGetVirtualRegister(op2, rightRegs);
 
-    JITSubGenerator gen(resultRegs, leftRegs, rightRegs, types.first(), types.second(),
+    JITSubGenerator gen(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs,
         fpRegT0, fpRegT1, scratchGPR, scratchFPR);
 
     gen.generateFastPath(*this);
index c23fb47..aa2b6f2 100644 (file)
@@ -24,9 +24,9 @@
  */
 
 #include "config.h"
+#include "JITMulGenerator.h"
 
 #if ENABLE(JIT)
-#include "JITMulGenerator.h"
 
 namespace JSC {
 
@@ -41,34 +41,24 @@ void JITMulGenerator::generateFastPath(CCallHelpers& jit)
     ASSERT(m_scratchFPR != InvalidFPRReg);
 #endif
 
-    ASSERT(!m_leftIsPositiveConstInt32 || !m_rightIsPositiveConstInt32);
-    
-    if (!m_leftType.mightBeNumber() || !m_rightType.mightBeNumber()) {
+    ASSERT(!m_leftOperand.isPositiveConstInt32() || !m_rightOperand.isPositiveConstInt32());
+
+    if (!m_leftOperand.mightBeNumber() || !m_rightOperand.mightBeNumber()) {
         ASSERT(!m_didEmitFastPath);
         return;
     }
 
     m_didEmitFastPath = true;
 
-    if (m_leftIsPositiveConstInt32 || m_rightIsPositiveConstInt32) {
-        JSValueRegs var;
-        ResultType varType = ResultType::unknownType();
-        int32_t constInt32;
-
-        if (m_leftIsPositiveConstInt32) {
-            var = m_right;
-            varType = m_rightType;
-            constInt32 = m_leftConstInt32;
-        } else {
-            var = m_left;
-            varType = m_leftType;
-            constInt32 = m_rightConstInt32;
-        }
+    if (m_leftOperand.isPositiveConstInt32() || m_rightOperand.isPositiveConstInt32()) {
+        JSValueRegs var = m_leftOperand.isPositiveConstInt32() ? m_right : m_left;
+        SnippetOperand& varOpr = m_leftOperand.isPositiveConstInt32() ? m_rightOperand : m_leftOperand;
+        SnippetOperand& constOpr = m_leftOperand.isPositiveConstInt32() ? m_leftOperand : m_rightOperand;
 
         // Try to do intVar * intConstant.
         CCallHelpers::Jump notInt32 = jit.branchIfNotInt32(var);
 
-        m_slowPathJumpList.append(jit.branchMul32(CCallHelpers::Overflow, var.payloadGPR(), CCallHelpers::Imm32(constInt32), m_scratchGPR));
+        m_slowPathJumpList.append(jit.branchMul32(CCallHelpers::Overflow, var.payloadGPR(), CCallHelpers::Imm32(constOpr.asConstInt32()), m_scratchGPR));
 
         jit.boxInt32(m_scratchGPR, m_result);
         m_endJumpList.append(jit.jump());
@@ -80,18 +70,18 @@ void JITMulGenerator::generateFastPath(CCallHelpers& jit)
 
         // Try to do doubleVar * double(intConstant).
         notInt32.link(&jit);
-        if (!varType.definitelyIsNumber())
+        if (!varOpr.definitelyIsNumber())
             m_slowPathJumpList.append(jit.branchIfNotNumber(var, m_scratchGPR));
 
         jit.unboxDoubleNonDestructive(var, m_leftFPR, m_scratchGPR, m_scratchFPR);
 
-        jit.move(CCallHelpers::Imm32(constInt32), m_scratchGPR);
+        jit.move(CCallHelpers::Imm32(constOpr.asConstInt32()), m_scratchGPR);
         jit.convertInt32ToDouble(m_scratchGPR, m_rightFPR);
 
         // Fall thru to doubleVar * doubleVar.
 
     } else {
-        ASSERT(!m_leftIsPositiveConstInt32 && !m_rightIsPositiveConstInt32);
+        ASSERT(!m_leftOperand.isPositiveConstInt32() && !m_rightOperand.isPositiveConstInt32());
 
         CCallHelpers::Jump leftNotInt;
         CCallHelpers::Jump rightNotInt;
@@ -130,9 +120,9 @@ void JITMulGenerator::generateFastPath(CCallHelpers& jit)
         }
 
         leftNotInt.link(&jit);
-        if (!m_leftType.definitelyIsNumber())
+        if (!m_leftOperand.definitelyIsNumber())
             m_slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR));
-        if (!m_rightType.definitelyIsNumber())
+        if (!m_rightOperand.definitelyIsNumber())
             m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
 
         jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR);
@@ -142,7 +132,7 @@ void JITMulGenerator::generateFastPath(CCallHelpers& jit)
         CCallHelpers::Jump rightWasInteger = jit.jump();
 
         rightNotInt.link(&jit);
-        if (!m_rightType.definitelyIsNumber())
+        if (!m_rightOperand.definitelyIsNumber())
             m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
 
         jit.convertInt32ToDouble(m_left.payloadGPR(), m_leftFPR);
index 5d28f80..a6993b0 100644 (file)
 #if ENABLE(JIT)
 
 #include "CCallHelpers.h"
-#include "ResultType.h"
+#include "SnippetOperand.h"
 
 namespace JSC {
 
 class JITMulGenerator {
 public:
-    JITMulGenerator(JSValueRegs result, JSValueRegs left, JSValueRegs right,
-        ResultType leftType, ResultType rightType, bool leftIsPositiveConstInt32, bool rightIsPositiveConstInt32,
-        int32_t leftConstInt32, int32_t rightConstInt32, FPRReg leftFPR, FPRReg rightFPR,
-        GPRReg scratchGPR, FPRReg scratchFPR, uint32_t* profilingCounter)
-        : m_result(result)
+    JITMulGenerator(SnippetOperand leftOperand, SnippetOperand rightOperand,
+        JSValueRegs result, JSValueRegs left, JSValueRegs right,
+        FPRReg leftFPR, FPRReg rightFPR, GPRReg scratchGPR, FPRReg scratchFPR, uint32_t* profilingCounter)
+        : m_leftOperand(leftOperand)
+        , m_rightOperand(rightOperand)
+        , m_result(result)
         , m_left(left)
         , m_right(right)
-        , m_leftType(leftType)
-        , m_rightType(rightType)
-        , m_leftIsPositiveConstInt32(leftIsPositiveConstInt32)
-        , m_rightIsPositiveConstInt32(rightIsPositiveConstInt32)
-        , m_leftConstInt32(leftConstInt32)
-        , m_rightConstInt32(rightConstInt32)
         , m_leftFPR(leftFPR)
         , m_rightFPR(rightFPR)
         , m_scratchGPR(scratchGPR)
         , m_scratchFPR(scratchFPR)
         , m_profilingCounter(profilingCounter)
     {
-        ASSERT(!leftIsPositiveConstInt32 || !rightIsPositiveConstInt32);
+        ASSERT(!m_leftOperand.isPositiveConstInt32() || !m_rightOperand.isPositiveConstInt32());
     }
 
     void generateFastPath(CCallHelpers&);
@@ -64,15 +59,11 @@ public:
     CCallHelpers::JumpList& slowPathJumpList() { return m_slowPathJumpList; }
 
 private:
+    SnippetOperand m_leftOperand;
+    SnippetOperand m_rightOperand;
     JSValueRegs m_result;
     JSValueRegs m_left;
     JSValueRegs m_right;
-    ResultType m_leftType;
-    ResultType m_rightType;
-    bool m_leftIsPositiveConstInt32;
-    bool m_rightIsPositiveConstInt32;
-    int32_t m_leftConstInt32;
-    int32_t m_rightConstInt32;
     FPRReg m_leftFPR;
     FPRReg m_rightFPR;
     GPRReg m_scratchGPR;
index ae9bde6..3ebaaa3 100644 (file)
@@ -24,9 +24,9 @@
  */
 
 #include "config.h"
+#include "JITSubGenerator.h"
 
 #if ENABLE(JIT)
-#include "JITSubGenerator.h"
 
 namespace JSC {
 
@@ -60,9 +60,9 @@ void JITSubGenerator::generateFastPath(CCallHelpers& jit)
     }
 
     leftNotInt.link(&jit);
-    if (!m_leftType.definitelyIsNumber())
+    if (!m_leftOperand.definitelyIsNumber())
         m_slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR));
-    if (!m_rightType.definitelyIsNumber())
+    if (!m_rightOperand.definitelyIsNumber())
         m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
 
     jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR);
@@ -72,7 +72,7 @@ void JITSubGenerator::generateFastPath(CCallHelpers& jit)
     CCallHelpers::Jump rightWasInteger = jit.jump();
 
     rightNotInt.link(&jit);
-    if (!m_rightType.definitelyIsNumber())
+    if (!m_rightOperand.definitelyIsNumber())
         m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR));
 
     jit.convertInt32ToDouble(m_left.payloadGPR(), m_leftFPR);
index 603aa2e..f677e08 100644 (file)
 #if ENABLE(JIT)
 
 #include "CCallHelpers.h"
-#include "ResultType.h"
+#include "SnippetOperand.h"
 
 namespace JSC {
 
 class JITSubGenerator {
 public:
-    JITSubGenerator(JSValueRegs result, JSValueRegs left, JSValueRegs right,
-        ResultType leftType, ResultType rightType, FPRReg leftFPR, FPRReg rightFPR,
-        GPRReg scratchGPR, FPRReg scratchFPR)
-        : m_result(result)
+    JITSubGenerator(SnippetOperand leftOperand, SnippetOperand rightOperand,
+        JSValueRegs result, JSValueRegs left, JSValueRegs right,
+        FPRReg leftFPR, FPRReg rightFPR, GPRReg scratchGPR, FPRReg scratchFPR)
+        : m_leftOperand(leftOperand)
+        , m_rightOperand(rightOperand)
+        , m_result(result)
         , m_left(left)
         , m_right(right)
-        , m_leftType(leftType)
-        , m_rightType(rightType)
         , m_leftFPR(leftFPR)
         , m_rightFPR(rightFPR)
         , m_scratchGPR(scratchGPR)
@@ -56,11 +56,11 @@ public:
     CCallHelpers::JumpList& slowPathJumpList() { return m_slowPathJumpList; }
 
 private:
+    SnippetOperand m_leftOperand;
+    SnippetOperand m_rightOperand;
     JSValueRegs m_result;
     JSValueRegs m_left;
     JSValueRegs m_right;
-    ResultType m_leftType;
-    ResultType m_rightType;
     FPRReg m_leftFPR;
     FPRReg m_rightFPR;
     GPRReg m_scratchGPR;
index c763403..957cfe4 100644 (file)
@@ -50,6 +50,7 @@ public:
     bool isConst() const { return m_type != Variable; }
     bool isConstInt32() const { return m_type == ConstInt32; }
     bool isConstDouble() const { return m_type == ConstDouble; }
+    bool isPositiveConstInt32() const { return isConstInt32() && asConstInt32() > 0; }
 
     int64_t asRawBits() const { return m_val.rawBits; }