Title: [183310] trunk/Source/_javascript_Core
- Revision
- 183310
- Author
- [email protected]
- Date
- 2015-04-25 08:43:45 -0700 (Sat, 25 Apr 2015)
Log Message
mayExit() is wrong about Branch nodes with ObjectOrOtherUse: they can exit.
https://bugs.webkit.org/show_bug.cgi?id=144152
Reviewed by Filip Pizlo.
Changed the EdgeMayExit functor to recognize ObjectUse, ObjectOrOtherUse,
StringObjectUse, and StringOrStringObjectUse kinds as potentially triggering
OSR exits. This was overlooked in the original code.
While only the ObjectOrOtherUse kind is relevant for manifesting this bug with
the Branch node, the other 3 may also trigger the same bug for other nodes.
To prevent this bug from manifesting with other nodes (and future ones that
are yet to be added to mayExits()'s "potential won't exit" set), we fix the
EdgeMayExit functor to handle all 4 use kinds (instead of just ObjectOrOtherUse).
Also added a test to exercise a code path that will trigger this bug with
the Branch node before the fix is applied.
* dfg/DFGMayExit.cpp:
* tests/stress/branch-may-exit-due-to-object-or-other-use-kind.js: Added.
(inlinedFunction):
(foo):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (183309 => 183310)
--- trunk/Source/_javascript_Core/ChangeLog 2015-04-25 08:13:03 UTC (rev 183309)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-04-25 15:43:45 UTC (rev 183310)
@@ -1,3 +1,28 @@
+2015-04-25 Mark Lam <[email protected]>
+
+ mayExit() is wrong about Branch nodes with ObjectOrOtherUse: they can exit.
+ https://bugs.webkit.org/show_bug.cgi?id=144152
+
+ Reviewed by Filip Pizlo.
+
+ Changed the EdgeMayExit functor to recognize ObjectUse, ObjectOrOtherUse,
+ StringObjectUse, and StringOrStringObjectUse kinds as potentially triggering
+ OSR exits. This was overlooked in the original code.
+
+ While only the ObjectOrOtherUse kind is relevant for manifesting this bug with
+ the Branch node, the other 3 may also trigger the same bug for other nodes.
+ To prevent this bug from manifesting with other nodes (and future ones that
+ are yet to be added to mayExits()'s "potential won't exit" set), we fix the
+ EdgeMayExit functor to handle all 4 use kinds (instead of just ObjectOrOtherUse).
+
+ Also added a test to exercise a code path that will trigger this bug with
+ the Branch node before the fix is applied.
+
+ * dfg/DFGMayExit.cpp:
+ * tests/stress/branch-may-exit-due-to-object-or-other-use-kind.js: Added.
+ (inlinedFunction):
+ (foo):
+
2015-04-24 Commit Queue <[email protected]>
Unreviewed, rolling out r183288.
Modified: trunk/Source/_javascript_Core/dfg/DFGMayExit.cpp (183309 => 183310)
--- trunk/Source/_javascript_Core/dfg/DFGMayExit.cpp 2015-04-25 08:13:03 UTC (rev 183309)
+++ trunk/Source/_javascript_Core/dfg/DFGMayExit.cpp 2015-04-25 15:43:45 UTC (rev 183310)
@@ -45,7 +45,21 @@
void operator()(Node*, Edge edge)
{
- m_result |= edge.willHaveCheck();
+ if (edge.willHaveCheck()) {
+ m_result = true;
+ return;
+ }
+
+ switch (edge.useKind()) {
+ case ObjectUse:
+ case ObjectOrOtherUse:
+ case StringObjectUse:
+ case StringOrStringObjectUse:
+ m_result = true;
+ break;
+ default:
+ break;
+ }
}
bool result() const { return m_result; }
Added: trunk/Source/_javascript_Core/tests/stress/branch-may-exit-due-to-object-or-other-use-kind.js (0 => 183310)
--- trunk/Source/_javascript_Core/tests/stress/branch-may-exit-due-to-object-or-other-use-kind.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/branch-may-exit-due-to-object-or-other-use-kind.js 2015-04-25 15:43:45 UTC (rev 183310)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// Regression test for https://bugs.webkit.org/show_bug.cgi?id=144152
+
+// The bug in 144152 needs 3 conditions to manifest:
+// 1. The branch test value in the inlined function is of useKind ObjectOrOtherUse.
+// 2. The branch test value is proven to be a known useKind.
+// 3. The masqueradesAsUndefined watchpoint is no longer valid.
+// With the bug fixed, this test should not crash on debug builds.
+
+function inlinedFunction(x) {
+ if (x) // Conditional branch that will assert on a debug build if the bug is present.
+ new Object;
+}
+
+function foo(x) {
+ if (x) // Testing x before calling the inlined function sets up condition 2.
+ inlinedFunction(x);
+}
+
+makeMasquerader(); // Invalidates the masqueradesAsUndefined watchpoint for condition 3.
+for (var i = 0; i < 10000; i++)
+ foo({}); // Pass an object argument to set up condition 1.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes