Title: [242568] trunk
Revision
242568
Author
[email protected]
Date
2019-03-06 14:34:30 -0800 (Wed, 06 Mar 2019)

Log Message

[JSC] AI should not propagate AbstractValue relying on constant folding phase
https://bugs.webkit.org/show_bug.cgi?id=195375

Reviewed by Saam Barati.

JSTests:

* stress/make-rope-should-not-propagate-constant-folded-value-in-ai.js: Added.
(let.array):

Source/_javascript_Core:

MakeRope rule in AI attempts to propagate the node, which will be produced after constant folding phase runs.
This is wrong since we do not guarantee that constant folding phase runs after AI runs (e.g. DFGSpeculativeJIT
and FTLLowerDFGToB3 run AI). This results in the bug that the value produced at runtime is different from the
proven constant value in AI. In the attached test, AI says the value is SpecStringIdent while the resulted value
at runtime is SpecStringVar, resulting in wrong MakeRope code. This patch removes the path propagating the node
relying on constant folding phase.

* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (242567 => 242568)


--- trunk/JSTests/ChangeLog	2019-03-06 22:28:30 UTC (rev 242567)
+++ trunk/JSTests/ChangeLog	2019-03-06 22:34:30 UTC (rev 242568)
@@ -1,3 +1,13 @@
+2019-03-06  Yusuke Suzuki  <[email protected]>
+
+        [JSC] AI should not propagate AbstractValue relying on constant folding phase
+        https://bugs.webkit.org/show_bug.cgi?id=195375
+
+        Reviewed by Saam Barati.
+
+        * stress/make-rope-should-not-propagate-constant-folded-value-in-ai.js: Added.
+        (let.array):
+
 2019-03-05  Saam barati  <[email protected]>
 
         op_switch_char broken for rope strings after JSRopeString layout rewrite

Added: trunk/JSTests/stress/make-rope-should-not-propagate-constant-folded-value-in-ai.js (0 => 242568)


--- trunk/JSTests/stress/make-rope-should-not-propagate-constant-folded-value-in-ai.js	                        (rev 0)
+++ trunk/JSTests/stress/make-rope-should-not-propagate-constant-folded-value-in-ai.js	2019-03-06 22:34:30 UTC (rev 242568)
@@ -0,0 +1,14 @@
+//@ runDefault("--forceEagerCompilation=1")
+let string = 'a';
+let array = []
+
+function test() {
+    let x = [][array.length];
+    let y = x ? x + '' : '';
+    let z = string + y;
+    let za = z + 'a';
+    [].join(za);
+}
+
+for (let i=0; i< 1e4; i++)
+    test();

Modified: trunk/Source/_javascript_Core/ChangeLog (242567 => 242568)


--- trunk/Source/_javascript_Core/ChangeLog	2019-03-06 22:28:30 UTC (rev 242567)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-03-06 22:34:30 UTC (rev 242568)
@@ -1,3 +1,20 @@
+2019-03-06  Yusuke Suzuki  <[email protected]>
+
+        [JSC] AI should not propagate AbstractValue relying on constant folding phase
+        https://bugs.webkit.org/show_bug.cgi?id=195375
+
+        Reviewed by Saam Barati.
+
+        MakeRope rule in AI attempts to propagate the node, which will be produced after constant folding phase runs.
+        This is wrong since we do not guarantee that constant folding phase runs after AI runs (e.g. DFGSpeculativeJIT
+        and FTLLowerDFGToB3 run AI). This results in the bug that the value produced at runtime is different from the
+        proven constant value in AI. In the attached test, AI says the value is SpecStringIdent while the resulted value
+        at runtime is SpecStringVar, resulting in wrong MakeRope code. This patch removes the path propagating the node
+        relying on constant folding phase.
+
+        * dfg/DFGAbstractInterpreterInlines.h:
+        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
+
 2019-03-05  Saam barati  <[email protected]>
 
         op_switch_char broken for rope strings after JSRopeString layout rewrite

Modified: trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h (242567 => 242568)


--- trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h	2019-03-06 22:28:30 UTC (rev 242567)
+++ trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h	2019-03-06 22:34:30 UTC (rev 242568)
@@ -733,19 +733,8 @@
             ++numberOfRemovedChildren;
         }
 
-        if (numberOfRemovedChildren) {
+        if (numberOfRemovedChildren)
             m_state.setFoundConstants(true);
-            if (numberOfRemovedChildren == numberOfChildren) {
-                // Propagate the last child. This is the way taken in the constant folding phase.
-                setForNode(node, forNode(node->children.child(numberOfChildren - 1)));
-                break;
-            }
-            if ((numberOfRemovedChildren + 1) == numberOfChildren) {
-                ASSERT(nonEmptyIndex);
-                setForNode(node, forNode(node->children.child(nonEmptyIndex.value())));
-                break;
-            }
-        }
         setForNode(node, m_vm.stringStructure.get());
         break;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to