Modified: trunk/Source/_javascript_Core/ChangeLog (182744 => 182745)
--- trunk/Source/_javascript_Core/ChangeLog 2015-04-13 18:04:55 UTC (rev 182744)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-04-13 18:08:33 UTC (rev 182745)
@@ -1,3 +1,32 @@
+2015-04-13 Mark Lam <[email protected]>
+
+ DFG inlining of op_call_varargs should keep the callee alive in case of OSR exit.
+ https://bugs.webkit.org/show_bug.cgi?id=143407
+
+ Reviewed by Filip Pizlo.
+
+ DFG inlining of a varargs call / construct needs to keep the local
+ containing the callee alive with a Phantom node because the LoadVarargs
+ node may OSR exit. After the OSR exit, the baseline JIT executes the
+ op_call_varargs with that callee in the local.
+
+ Previously, because that callee local was not explicitly kept alive,
+ the op_call_varargs case can OSR exit a DFG function and leave an
+ undefined value in that local. As a result, the baseline observes the
+ side effect of an op_call_varargs on an undefined value instead of the
+ function it expected.
+
+ Note: this issue does not manifest with op_construct_varargs because
+ the inlined constructor will have an op_create_this which operates on
+ the incoming callee value, thereby keeping it alive.
+
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::handleInlining):
+ * tests/stress/call-varargs-with-different-arguments-length-after-warmup.js: Added.
+ (foo):
+ (Foo):
+ (doTest):
+
2015-04-12 Yusuke Suzuki <[email protected]>
[ES6] Implement Array.prototype.values
Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (182744 => 182745)
--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2015-04-13 18:04:55 UTC (rev 182744)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2015-04-13 18:08:33 UTC (rev 182745)
@@ -1570,7 +1570,12 @@
data->mandatoryMinimum = mandatoryMinimum;
addToGraph(LoadVarargs, OpInfo(data), get(argumentsArgument));
-
+
+ // LoadVarargs may OSR exit. Hence, we need to keep alive callTargetNode, thisArgument
+ // and argumentsArgument for the baseline JIT. However, we only need a Phantom for
+ // callTargetNode because the other 2 are still in use and alive at this point.
+ addToGraph(Phantom, callTargetNode);
+
// In DFG IR before SSA, we cannot insert control flow between after the
// LoadVarargs and the last SetArgument. This isn't a problem once we get to DFG
// SSA. Fortunately, we also have other reasons for not inserting control flow
Added: trunk/Source/_javascript_Core/tests/stress/call-varargs-with-different-arguments-length-after-warmup.js (0 => 182745)
--- trunk/Source/_javascript_Core/tests/stress/call-varargs-with-different-arguments-length-after-warmup.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/call-varargs-with-different-arguments-length-after-warmup.js 2015-04-13 18:08:33 UTC (rev 182745)
@@ -0,0 +1,91 @@
+/*
+ * 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=143407.
+
+var verbose = false;
+
+function foo() {
+ return arguments.length;
+}
+
+function Foo() {
+ this.length = arguments.length;
+}
+
+var callTestBodyStr =
+" var result = this.method.apply(this, arguments);" + "\n" +
+" return result + 1;";
+
+var constructTestBodyStr =
+" return new this.constructor(...arguments);";
+
+var tiers = [
+ { name: "LLint", iterations: 10 },
+ { name: "BaselineJIT", iterations: 50 },
+ { name: "DFG", iterations: 500 },
+ { name: "FTL", iterations: 10000 },
+];
+
+function doTest(testCategory, testBodyStr, tier) {
+ try {
+ var iterations = tiers[tier].iterations;
+ if (verbose)
+ print("Testing " + testCategory + " tier " + tiers[tier].name + " by iterating " + iterations + " times");
+
+ var o = {}
+ o.method = foo;
+ o.constructor = Foo;
+ o.trigger = new Function(testBodyStr);
+
+ for (var i = 0; i < iterations; i++)
+ o.trigger(o, 1);
+ o.trigger(o, 1, 2);
+
+ } catch (e) {
+ print("FAILED " + testCategory + " in tier " + tiers[tier].name + ": " + e);
+ return false;
+ }
+ return true;
+}
+
+var failureFound = 0;
+
+for (var tier = 0; tier < tiers.length; tier++) {
+ if (!doTest("op_call_varargs", callTestBodyStr, tier))
+ failureFound++;
+}
+
+for (var tier = 0; tier < tiers.length; tier++) {
+ if (!doTest("op_construct_varargs", constructTestBodyStr, tier))
+ failureFound++;
+}
+
+if (failureFound == 1)
+ throw "ERROR: test has 1 failure";
+else if (failureFound > 1)
+ throw "ERROR: test has " + failureFound + " failures";
+else if (verbose)
+ print("No failures");