Changeset 193795 in webkit


Ignore:
Timestamp:
Dec 8, 2015, 4:30:18 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

Factoring out common DFG code for bitwise and shift operators.
https://bugs.webkit.org/show_bug.cgi?id=152019

Reviewed by Michael Saboff.

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileBitwiseOp):
(JSC::DFG::SpeculativeJIT::compileShiftOp):

  • dfg/DFGSpeculativeJIT.h:
  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/JavaScriptCore/ChangeLog

    r193793 r193795  
     12015-12-08  Mark Lam  <mark.lam@apple.com>
     2
     3        Factoring out common DFG code for bitwise and shift operators.
     4        https://bugs.webkit.org/show_bug.cgi?id=152019
     5
     6        Reviewed by Michael Saboff.
     7
     8        * dfg/DFGSpeculativeJIT.cpp:
     9        (JSC::DFG::SpeculativeJIT::compileBitwiseOp):
     10        (JSC::DFG::SpeculativeJIT::compileShiftOp):
     11        * dfg/DFGSpeculativeJIT.h:
     12        * dfg/DFGSpeculativeJIT32_64.cpp:
     13        (JSC::DFG::SpeculativeJIT::compile):
     14        * dfg/DFGSpeculativeJIT64.cpp:
     15        (JSC::DFG::SpeculativeJIT::compile):
     16
    1172015-12-08  Mark Lam  <mark.lam@apple.com>
    218
  • TabularUnified trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r193793 r193795  
    27852785
    27862786    blessedBooleanResult(scratchReg, node);
     2787}
     2788
     2789void SpeculativeJIT::compileBitwiseOp(Node* node)
     2790{
     2791    NodeType op = node->op();
     2792    Edge& leftChild = node->child1();
     2793    Edge& rightChild = node->child2();
     2794
     2795    if (leftChild->isInt32Constant()) {
     2796        SpeculateInt32Operand op2(this, rightChild);
     2797        GPRTemporary result(this, Reuse, op2);
     2798
     2799        bitOp(op, leftChild->asInt32(), op2.gpr(), result.gpr());
     2800
     2801        int32Result(result.gpr(), node);
     2802
     2803    } else if (rightChild->isInt32Constant()) {
     2804        SpeculateInt32Operand op1(this, leftChild);
     2805        GPRTemporary result(this, Reuse, op1);
     2806
     2807        bitOp(op, rightChild->asInt32(), op1.gpr(), result.gpr());
     2808
     2809        int32Result(result.gpr(), node);
     2810
     2811    } else {
     2812        SpeculateInt32Operand op1(this, leftChild);
     2813        SpeculateInt32Operand op2(this, rightChild);
     2814        GPRTemporary result(this, Reuse, op1, op2);
     2815       
     2816        GPRReg reg1 = op1.gpr();
     2817        GPRReg reg2 = op2.gpr();
     2818        bitOp(op, reg1, reg2, result.gpr());
     2819       
     2820        int32Result(result.gpr(), node);
     2821    }
     2822}
     2823
     2824void SpeculativeJIT::compileShiftOp(Node* node)
     2825{
     2826    NodeType op = node->op();
     2827    Edge& leftChild = node->child1();
     2828    Edge& rightChild = node->child2();
     2829
     2830    if (rightChild->isInt32Constant()) {
     2831        SpeculateInt32Operand op1(this, leftChild);
     2832        GPRTemporary result(this, Reuse, op1);
     2833
     2834        shiftOp(op, op1.gpr(), rightChild->asInt32() & 0x1f, result.gpr());
     2835
     2836        int32Result(result.gpr(), node);
     2837    } else {
     2838        // Do not allow shift amount to be used as the result, MacroAssembler does not permit this.
     2839        SpeculateInt32Operand op1(this, leftChild);
     2840        SpeculateInt32Operand op2(this, rightChild);
     2841        GPRTemporary result(this, Reuse, op1);
     2842
     2843        GPRReg reg1 = op1.gpr();
     2844        GPRReg reg2 = op2.gpr();
     2845        shiftOp(op, reg1, reg2, result.gpr());
     2846
     2847        int32Result(result.gpr(), node);
     2848    }
    27872849}
    27882850
  • TabularUnified trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r193766 r193795  
    22132213    void compileUInt32ToNumber(Node*);
    22142214    void compileDoubleAsInt32(Node*);
     2215    void compileBitwiseOp(Node*);
     2216    void compileShiftOp(Node*);
    22152217    void compileValueAdd(Node*);
    22162218    void compileArithAdd(Node*);
  • TabularUnified trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r193766 r193795  
    20602060    case BitOr:
    20612061    case BitXor:
    2062         if (node->child1()->isInt32Constant()) {
    2063             SpeculateInt32Operand op2(this, node->child2());
    2064             GPRTemporary result(this, Reuse, op2);
    2065 
    2066             bitOp(op, node->child1()->asInt32(), op2.gpr(), result.gpr());
    2067 
    2068             int32Result(result.gpr(), node);
    2069         } else if (node->child2()->isInt32Constant()) {
    2070             SpeculateInt32Operand op1(this, node->child1());
    2071             GPRTemporary result(this, Reuse, op1);
    2072 
    2073             bitOp(op, node->child2()->asInt32(), op1.gpr(), result.gpr());
    2074 
    2075             int32Result(result.gpr(), node);
    2076         } else {
    2077             SpeculateInt32Operand op1(this, node->child1());
    2078             SpeculateInt32Operand op2(this, node->child2());
    2079             GPRTemporary result(this, Reuse, op1, op2);
    2080 
    2081             GPRReg reg1 = op1.gpr();
    2082             GPRReg reg2 = op2.gpr();
    2083             bitOp(op, reg1, reg2, result.gpr());
    2084 
    2085             int32Result(result.gpr(), node);
    2086         }
     2062        compileBitwiseOp(node);
    20872063        break;
    20882064
     
    20902066    case BitLShift:
    20912067    case BitURShift:
    2092         if (node->child2()->isInt32Constant()) {
    2093             SpeculateInt32Operand op1(this, node->child1());
    2094             GPRTemporary result(this, Reuse, op1);
    2095 
    2096             shiftOp(op, op1.gpr(), node->child2()->asInt32() & 0x1f, result.gpr());
    2097 
    2098             int32Result(result.gpr(), node);
    2099         } else {
    2100             // Do not allow shift amount to be used as the result, MacroAssembler does not permit this.
    2101             SpeculateInt32Operand op1(this, node->child1());
    2102             SpeculateInt32Operand op2(this, node->child2());
    2103             GPRTemporary result(this, Reuse, op1);
    2104 
    2105             GPRReg reg1 = op1.gpr();
    2106             GPRReg reg2 = op2.gpr();
    2107             shiftOp(op, reg1, reg2, result.gpr());
    2108 
    2109             int32Result(result.gpr(), node);
    2110         }
     2068        compileShiftOp(node);
    21112069        break;
    21122070
  • TabularUnified trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r193766 r193795  
    21452145    case BitOr:
    21462146    case BitXor:
    2147         if (node->child1()->isInt32Constant()) {
    2148             SpeculateInt32Operand op2(this, node->child2());
    2149             GPRTemporary result(this, Reuse, op2);
    2150 
    2151             bitOp(op, node->child1()->asInt32(), op2.gpr(), result.gpr());
    2152 
    2153             int32Result(result.gpr(), node);
    2154         } else if (node->child2()->isInt32Constant()) {
    2155             SpeculateInt32Operand op1(this, node->child1());
    2156             GPRTemporary result(this, Reuse, op1);
    2157 
    2158             bitOp(op, node->child2()->asInt32(), op1.gpr(), result.gpr());
    2159 
    2160             int32Result(result.gpr(), node);
    2161         } else {
    2162             SpeculateInt32Operand op1(this, node->child1());
    2163             SpeculateInt32Operand op2(this, node->child2());
    2164             GPRTemporary result(this, Reuse, op1, op2);
    2165 
    2166             GPRReg reg1 = op1.gpr();
    2167             GPRReg reg2 = op2.gpr();
    2168             bitOp(op, reg1, reg2, result.gpr());
    2169 
    2170             int32Result(result.gpr(), node);
    2171         }
     2147        compileBitwiseOp(node);
    21722148        break;
    21732149
     
    21752151    case BitLShift:
    21762152    case BitURShift:
    2177         if (node->child2()->isInt32Constant()) {
    2178             SpeculateInt32Operand op1(this, node->child1());
    2179             GPRTemporary result(this, Reuse, op1);
    2180 
    2181             shiftOp(op, op1.gpr(), node->child2()->asInt32() & 0x1f, result.gpr());
    2182 
    2183             int32Result(result.gpr(), node);
    2184         } else {
    2185             // Do not allow shift amount to be used as the result, MacroAssembler does not permit this.
    2186             SpeculateInt32Operand op1(this, node->child1());
    2187             SpeculateInt32Operand op2(this, node->child2());
    2188             GPRTemporary result(this, Reuse, op1);
    2189 
    2190             GPRReg reg1 = op1.gpr();
    2191             GPRReg reg2 = op2.gpr();
    2192             shiftOp(op, reg1, reg2, result.gpr());
    2193 
    2194             int32Result(result.gpr(), node);
    2195         }
     2153        compileShiftOp(node);
    21962154        break;
    21972155
Note: See TracChangeset for help on using the changeset viewer.