Title: [161467] branches/jsCStack/Source/_javascript_Core

Diff

Modified: branches/jsCStack/Source/_javascript_Core/ChangeLog (161466 => 161467)


--- branches/jsCStack/Source/_javascript_Core/ChangeLog	2014-01-08 00:30:07 UTC (rev 161466)
+++ branches/jsCStack/Source/_javascript_Core/ChangeLog	2014-01-08 00:35:15 UTC (rev 161467)
@@ -1,5 +1,9 @@
 2014-01-07  Filip Pizlo  <[email protected]>
 
+        Merge trunk r161465.
+
+2014-01-07  Filip Pizlo  <[email protected]>
+
         Add a test that got lost in some merge.
 
         * tests/stress/phantom-arguments-set-local-then-exit-in-same-block.js: Added.

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGBackwardsPropagationPhase.cpp (161466 => 161467)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGBackwardsPropagationPhase.cpp	2014-01-08 00:30:07 UTC (rev 161466)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGBackwardsPropagationPhase.cpp	2014-01-08 00:35:15 UTC (rev 161467)
@@ -114,8 +114,7 @@
             
         case BitOr:
         case BitXor:
-        case BitLShift:
-        case ValueToInt32: {
+        case BitLShift: {
             return power > 31;
         }
             
@@ -205,13 +204,6 @@
             break;
         }
             
-        case ValueToInt32: {
-            flags |= NodeBytecodeUsesAsInt;
-            flags &= ~(NodeBytecodeUsesAsNumber | NodeBytecodeNeedsNegZero | NodeBytecodeUsesAsOther);
-            node->child1()->mergeFlags(flags);
-            break;
-        }
-            
         case StringCharCodeAt: {
             node->child1()->mergeFlags(NodeBytecodeUsesAsValue);
             node->child2()->mergeFlags(NodeBytecodeUsesAsValue | NodeBytecodeUsesAsInt);

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (161466 => 161467)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2014-01-08 00:30:07 UTC (rev 161466)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2014-01-08 00:35:15 UTC (rev 161467)
@@ -505,30 +505,6 @@
         flush(m_inlineStackTop);
     }
 
-    // Get an operand, and perform a ToInt32/ToNumber conversion on it.
-    Node* getToInt32(int operand)
-    {
-        return toInt32(get(VirtualRegister(operand)));
-    }
-
-    // Perform an ES5 ToInt32 operation - returns a node of type NodeResultInt32.
-    Node* toInt32(Node* node)
-    {
-        if (node->hasInt32Result())
-            return node;
-
-        // Check for numeric constants boxed as JSValues.
-        if (canFold(node)) {
-            JSValue v = valueOfJSConstant(node);
-            if (v.isInt32())
-                return getJSConstant(node->constantNumber());
-            if (v.isNumber())
-                return getJSConstantForValue(JSValue(JSC::toInt32(v.asNumber())));
-        }
-
-        return addToGraph(ValueToInt32, node);
-    }
-
     // NOTE: Only use this to construct constants that arise from non-speculative
     // constant folding. I.e. creating constants using this if we had constant
     // field inference would be a bad idea, since the bytecode parser's folding
@@ -1579,9 +1555,9 @@
         if (argumentCountIncludingThis != 2)
             return false;
 
-        int thisOperand = virtualRegisterForArgument(0, registerOffset).offset();
-        int indexOperand = virtualRegisterForArgument(1, registerOffset).offset();
-        Node* charCode = addToGraph(StringCharCodeAt, OpInfo(ArrayMode(Array::String).asWord()), get(VirtualRegister(thisOperand)), getToInt32(indexOperand));
+        VirtualRegister thisOperand = virtualRegisterForArgument(0, registerOffset);
+        VirtualRegister indexOperand = virtualRegisterForArgument(1, registerOffset);
+        Node* charCode = addToGraph(StringCharCodeAt, OpInfo(ArrayMode(Array::String).asWord()), get(thisOperand), get(indexOperand));
 
         set(VirtualRegister(resultOperand), charCode);
         return true;
@@ -1591,9 +1567,9 @@
         if (argumentCountIncludingThis != 2)
             return false;
 
-        int thisOperand = virtualRegisterForArgument(0, registerOffset).offset();
-        int indexOperand = virtualRegisterForArgument(1, registerOffset).offset();
-        Node* charCode = addToGraph(StringCharAt, OpInfo(ArrayMode(Array::String).asWord()), get(VirtualRegister(thisOperand)), getToInt32(indexOperand));
+        VirtualRegister thisOperand = virtualRegisterForArgument(0, registerOffset);
+        VirtualRegister indexOperand = virtualRegisterForArgument(1, registerOffset);
+        Node* charCode = addToGraph(StringCharAt, OpInfo(ArrayMode(Array::String).asWord()), get(thisOperand), get(indexOperand));
 
         set(VirtualRegister(resultOperand), charCode);
         return true;
@@ -1602,8 +1578,8 @@
         if (argumentCountIncludingThis != 2)
             return false;
 
-        int indexOperand = virtualRegisterForArgument(1, registerOffset).offset();
-        Node* charCode = addToGraph(StringFromCharCode, getToInt32(indexOperand));
+        VirtualRegister indexOperand = virtualRegisterForArgument(1, registerOffset);
+        Node* charCode = addToGraph(StringFromCharCode, get(indexOperand));
 
         set(VirtualRegister(resultOperand), charCode);
 
@@ -1633,10 +1609,10 @@
     case IMulIntrinsic: {
         if (argumentCountIncludingThis != 3)
             return false;
-        int leftOperand = virtualRegisterForArgument(1, registerOffset).offset();
-        int rightOperand = virtualRegisterForArgument(2, registerOffset).offset();
-        Node* left = getToInt32(leftOperand);
-        Node* right = getToInt32(rightOperand);
+        VirtualRegister leftOperand = virtualRegisterForArgument(1, registerOffset);
+        VirtualRegister rightOperand = virtualRegisterForArgument(2, registerOffset);
+        Node* left = get(leftOperand);
+        Node* right = get(rightOperand);
         set(VirtualRegister(resultOperand), addToGraph(ArithIMul, left, right));
         return true;
     }
@@ -2055,45 +2031,45 @@
         // === Bitwise operations ===
 
         case op_bitand: {
-            Node* op1 = getToInt32(currentInstruction[2].u.operand);
-            Node* op2 = getToInt32(currentInstruction[3].u.operand);
+            Node* op1 = get(VirtualRegister(currentInstruction[2].u.operand));
+            Node* op2 = get(VirtualRegister(currentInstruction[3].u.operand));
             set(VirtualRegister(currentInstruction[1].u.operand), addToGraph(BitAnd, op1, op2));
             NEXT_OPCODE(op_bitand);
         }
 
         case op_bitor: {
-            Node* op1 = getToInt32(currentInstruction[2].u.operand);
-            Node* op2 = getToInt32(currentInstruction[3].u.operand);
+            Node* op1 = get(VirtualRegister(currentInstruction[2].u.operand));
+            Node* op2 = get(VirtualRegister(currentInstruction[3].u.operand));
             set(VirtualRegister(currentInstruction[1].u.operand), addToGraph(BitOr, op1, op2));
             NEXT_OPCODE(op_bitor);
         }
 
         case op_bitxor: {
-            Node* op1 = getToInt32(currentInstruction[2].u.operand);
-            Node* op2 = getToInt32(currentInstruction[3].u.operand);
+            Node* op1 = get(VirtualRegister(currentInstruction[2].u.operand));
+            Node* op2 = get(VirtualRegister(currentInstruction[3].u.operand));
             set(VirtualRegister(currentInstruction[1].u.operand), addToGraph(BitXor, op1, op2));
             NEXT_OPCODE(op_bitxor);
         }
 
         case op_rshift: {
-            Node* op1 = getToInt32(currentInstruction[2].u.operand);
-            Node* op2 = getToInt32(currentInstruction[3].u.operand);
+            Node* op1 = get(VirtualRegister(currentInstruction[2].u.operand));
+            Node* op2 = get(VirtualRegister(currentInstruction[3].u.operand));
             set(VirtualRegister(currentInstruction[1].u.operand),
                 addToGraph(BitRShift, op1, op2));
             NEXT_OPCODE(op_rshift);
         }
 
         case op_lshift: {
-            Node* op1 = getToInt32(currentInstruction[2].u.operand);
-            Node* op2 = getToInt32(currentInstruction[3].u.operand);
+            Node* op1 = get(VirtualRegister(currentInstruction[2].u.operand));
+            Node* op2 = get(VirtualRegister(currentInstruction[3].u.operand));
             set(VirtualRegister(currentInstruction[1].u.operand),
                 addToGraph(BitLShift, op1, op2));
             NEXT_OPCODE(op_lshift);
         }
 
         case op_urshift: {
-            Node* op1 = getToInt32(currentInstruction[2].u.operand);
-            Node* op2 = getToInt32(currentInstruction[3].u.operand);
+            Node* op1 = get(VirtualRegister(currentInstruction[2].u.operand));
+            Node* op2 = get(VirtualRegister(currentInstruction[3].u.operand));
             set(VirtualRegister(currentInstruction[1].u.operand),
                 addToGraph(BitURShift, op1, op2));
             NEXT_OPCODE(op_urshift);
@@ -2101,7 +2077,7 @@
             
         case op_unsigned: {
             set(VirtualRegister(currentInstruction[1].u.operand),
-                makeSafe(addToGraph(UInt32ToNumber, getToInt32(currentInstruction[2].u.operand))));
+                makeSafe(addToGraph(UInt32ToNumber, get(VirtualRegister(currentInstruction[2].u.operand)))));
             NEXT_OPCODE(op_unsigned);
         }
 

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGFixupPhase.cpp (161466 => 161467)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2014-01-08 00:30:07 UTC (rev 161466)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2014-01-08 00:35:15 UTC (rev 161467)
@@ -94,24 +94,18 @@
             return;
         }
             
-        case BitOr: {
-            fixIntEdge(node->child1());
-            fixIntEdge(node->child2());
-            break;
-        }
         case BitAnd:
+        case BitOr:
         case BitXor:
         case BitRShift:
         case BitLShift:
         case BitURShift: {
-            fixIntEdge(node->child1());
-            fixIntEdge(node->child2());
+            fixBinaryIntEdges();
             break;
         }
-            
+
         case ArithIMul: {
-            fixIntEdge(node->child1());
-            fixIntEdge(node->child2());
+            fixBinaryIntEdges();
             node->setOp(ArithMul);
             node->setArithMode(Arith::Unchecked);
             node->child1().setUseKind(Int32Use);
@@ -120,7 +114,7 @@
         }
             
         case UInt32ToNumber: {
-            fixEdge<KnownInt32Use>(node->child1());
+            fixIntEdge(node->child1());
             if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
                 node->convertToIdentity();
             else if (nodeCanSpeculateInt32(node->arithNodeFlags()))
@@ -130,42 +124,6 @@
             break;
         }
             
-        case DoubleAsInt32: {
-            RELEASE_ASSERT_NOT_REACHED();
-            break;
-        }
-            
-        case ValueToInt32: {
-            if (node->child1()->shouldSpeculateInt32()) {
-                fixEdge<Int32Use>(node->child1());
-                node->setOpAndDefaultFlags(Identity);
-                break;
-            }
-            
-            if (node->child1()->shouldSpeculateMachineInt()) {
-                fixEdge<MachineIntUse>(node->child1());
-                break;
-            }
-            
-            if (node->child1()->shouldSpeculateNumber()) {
-                fixEdge<NumberUse>(node->child1());
-                break;
-            }
-            
-            if (node->child1()->shouldSpeculateBoolean()) {
-                fixEdge<BooleanUse>(node->child1());
-                break;
-            }
-            
-            fixEdge<NotCellUse>(node->child1());
-            break;
-        }
-            
-        case Int32ToDouble: {
-            RELEASE_ASSERT_NOT_REACHED();
-            break;
-        }
-            
         case ValueAdd: {
             if (attemptToMakeIntegerAdd(node)) {
                 node->setOp(ArithAdd);
@@ -941,6 +899,9 @@
         case CheckArray:
         case CheckInBounds:
         case ConstantStoragePointer:
+        case DoubleAsInt32:
+        case Int32ToDouble:
+        case ValueToInt32:
             // These are just nodes that we don't currently expect to see during fixup.
             // If we ever wanted to insert them prior to fixup, then we just have to create
             // fixup rules for them.
@@ -1559,25 +1520,45 @@
         edge.setUseKind(useKind);
     }
     
-    void fixIntEdge(Edge& edge)
+    bool fixIntEdge(Edge& edge)
     {
         Node* node = edge.node();
-        if (node->op() != ValueToInt32) {
-            fixEdge<KnownInt32Use>(edge);
-            return;
+        if (node->shouldSpeculateInt32()) {
+            fixEdge<Int32Use>(edge);
+            return false;
         }
         
-        Edge newEdge = node->child1();
+        UseKind useKind;
+        if (node->shouldSpeculateMachineInt())
+            useKind = MachineIntUse;
+        else if (node->shouldSpeculateNumber())
+            useKind = NumberUse;
+        else if (node->shouldSpeculateBoolean())
+            useKind = BooleanUse;
+        else
+            useKind = NotCellUse;
+        Node* newNode = m_insertionSet.insertNode(
+            m_indexInBlock, SpecInt32, ValueToInt32, m_currentNode->codeOrigin,
+            Edge(node, useKind));
+        observeUseKindOnNode(node, useKind);
         
-        if (newEdge.useKind() != Int32Use) {
-            edge.setUseKind(KnownInt32Use);
-            return;
-        }
-        
-        ASSERT(newEdge->shouldSpeculateInt32());
-        edge = newEdge;
+        edge = Edge(newNode, KnownInt32Use);
+        return true;
     }
     
+    void fixBinaryIntEdges()
+    {
+        AdjacencyList children = m_currentNode->children;
+        
+        // Call fixIntEdge() on both edges.
+        bool needPhantom =
+            fixIntEdge(m_currentNode->child1()) | fixIntEdge(m_currentNode->child2());
+        
+        if (!needPhantom)
+            return;
+        m_insertionSet.insertNode(m_indexInBlock + 1, SpecNone, Phantom, m_currentNode->codeOrigin, children);
+    }
+      
     void injectInt32ToDoubleNode(Edge& edge, UseKind useKind = NumberUse)
     {
         Node* result = m_insertionSet.insertNode(

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp (161466 => 161467)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp	2014-01-08 00:30:07 UTC (rev 161466)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGPredictionPropagationPhase.cpp	2014-01-08 00:35:15 UTC (rev 161467)
@@ -168,11 +168,6 @@
             break;
         }
             
-        case ValueToInt32: {
-            changed |= setPrediction(SpecInt32);
-            break;
-        }
-            
         case ArrayPop:
         case ArrayPush:
         case RegExpExec:
@@ -510,7 +505,8 @@
         case InvalidationPoint:
         case Int52ToValue:
         case Int52ToDouble:
-        case CheckInBounds: {
+        case CheckInBounds:
+        case ValueToInt32: {
             // This node should never be visible at this stage of compilation. It is
             // inserted by fixup(), which follows this phase.
             RELEASE_ASSERT_NOT_REACHED();

Added: branches/jsCStack/Source/_javascript_Core/tests/stress/bit-op-value-to-int32-input-liveness.js (0 => 161467)


--- branches/jsCStack/Source/_javascript_Core/tests/stress/bit-op-value-to-int32-input-liveness.js	                        (rev 0)
+++ branches/jsCStack/Source/_javascript_Core/tests/stress/bit-op-value-to-int32-input-liveness.js	2014-01-08 00:35:15 UTC (rev 161467)
@@ -0,0 +1,20 @@
+function foo(a, b) {
+    return a.f ^ b.f;
+}
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+    var result = foo({f:5.5}, {f:6.5});
+    if (result != 3)
+        throw "Error: bad result: " + result;
+}
+
+var result = foo({f:"5.5"}, {f:6.5});
+if (result != 3)
+    throw "Error: bad result: " + result;
+
+var result = foo({f:5.5}, {f:"6.5"});
+if (result != 3)
+    throw "Error: bad result: " + result;
+
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to