Title: [247724] trunk
Revision
247724
Author
[email protected]
Date
2019-07-23 10:24:13 -0700 (Tue, 23 Jul 2019)

Log Message

Sometimes we miss removable CheckInBounds
https://bugs.webkit.org/show_bug.cgi?id=200018

Reviewed by Saam Barati.

JSTests:

* microbenchmarks/typed-array-sum.js: Added.
(doTest):

Source/_javascript_Core:

We failed to remove the CheckInBounds bounds because we did not see that the index was nonnegative. This is because we do not see the relationship between the two
separate zero constants that appear in the IR for the given test case. This patch re-adds the hack to de-duplicate m_zero that was removed in
<https://trac.webkit.org/changeset/241228/webkit>.

* dfg/DFGIntegerRangeOptimizationPhase.cpp:

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (247723 => 247724)


--- trunk/JSTests/ChangeLog	2019-07-23 14:51:29 UTC (rev 247723)
+++ trunk/JSTests/ChangeLog	2019-07-23 17:24:13 UTC (rev 247724)
@@ -1,3 +1,13 @@
+2019-07-23  Justin Michaud  <[email protected]>
+
+        Sometimes we miss removable CheckInBounds
+        https://bugs.webkit.org/show_bug.cgi?id=200018
+
+        Reviewed by Saam Barati.
+
+        * microbenchmarks/typed-array-sum.js: Added.
+        (doTest):
+
 2019-07-16  Mark Lam  <[email protected]>
 
         ArgumentsEliminationPhase should insert KillStack nodes before PutStack nodes that it adds.

Added: trunk/JSTests/microbenchmarks/typed-array-sum.js (0 => 247724)


--- trunk/JSTests/microbenchmarks/typed-array-sum.js	                        (rev 0)
+++ trunk/JSTests/microbenchmarks/typed-array-sum.js	2019-07-23 17:24:13 UTC (rev 247724)
@@ -0,0 +1,12 @@
+function doTest(arr1) {
+    let sum = 0
+    for (let i=0; i<arr1.length; ++i) {
+        sum += arr1[i]
+    }
+    return sum
+}
+noInline(doTest);
+
+let arr1 = new Int32Array(1000)
+
+for (let i=0; i<1000; ++i) doTest(arr1)

Modified: trunk/Source/_javascript_Core/ChangeLog (247723 => 247724)


--- trunk/Source/_javascript_Core/ChangeLog	2019-07-23 14:51:29 UTC (rev 247723)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-07-23 17:24:13 UTC (rev 247724)
@@ -1,3 +1,16 @@
+2019-07-23  Justin Michaud  <[email protected]>
+
+        Sometimes we miss removable CheckInBounds
+        https://bugs.webkit.org/show_bug.cgi?id=200018
+
+        Reviewed by Saam Barati.
+
+        We failed to remove the CheckInBounds bounds because we did not see that the index was nonnegative. This is because we do not see the relationship between the two
+        separate zero constants that appear in the IR for the given test case. This patch re-adds the hack to de-duplicate m_zero that was removed in 
+        <https://trac.webkit.org/changeset/241228/webkit>.
+
+        * dfg/DFGIntegerRangeOptimizationPhase.cpp:
+
 2019-07-22  Yusuke Suzuki  <[email protected]>
 
         [bmalloc] Each IsoPage gets 1MB VA because VMHeap::tryAllocateLargeChunk rounds up

Modified: trunk/Source/_javascript_Core/dfg/DFGIntegerRangeOptimizationPhase.cpp (247723 => 247724)


--- trunk/Source/_javascript_Core/dfg/DFGIntegerRangeOptimizationPhase.cpp	2019-07-23 14:51:29 UTC (rev 247723)
+++ trunk/Source/_javascript_Core/dfg/DFGIntegerRangeOptimizationPhase.cpp	2019-07-23 17:24:13 UTC (rev 247724)
@@ -1010,8 +1010,16 @@
         ASSERT(m_graph.m_form == SSA);
         
         // Before we do anything, make sure that we have a zero constant at the top.
-        m_zero = m_insertionSet.insertConstant(0, m_graph.block(0)->at(0)->origin, jsNumber(0));
-        m_insertionSet.execute(m_graph.block(0));
+        for (Node* node : *m_graph.block(0)) {
+            if (node->isInt32Constant() && !node->asInt32()) {
+                m_zero = node;
+                break;
+            }
+        }
+        if (!m_zero) {
+            m_zero = m_insertionSet.insertConstant(0, m_graph.block(0)->at(0)->origin, jsNumber(0));
+            m_insertionSet.execute(m_graph.block(0));
+        }
         
         if (DFGIntegerRangeOptimizationPhaseInternal::verbose) {
             dataLog("Graph before integer range optimization:\n");
@@ -1321,7 +1329,8 @@
                     
                     if (nonNegative && lessThanLength) {
                         executeNode(block->at(nodeIndex));
-                        node->convertToIdentityOn(m_zero);
+                        // We just need to make sure we are a value-producing node.
+                        node->convertToIdentityOn(node->child1().node());
                         changed = true;
                     }
                     break;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to