Commit 9ee6ca75 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Switch inlining tests to global scope.

This switches our inlining tests (i.e. cctest/test-run-inlining) to rely
on global object instead of function context specialization, which is
more in sync with what we are actually shipping. It will also allow us
to test inlining with the BytecodeGraphBuilder without having to add
support for function context specialization just for testing purposes.

R=bmeurer@chromium.org
TEST=cctest/test-run-inlining
BUG=v8:5251

Review-Url: https://codereview.chromium.org/2200673002
Cr-Commit-Position: refs/heads/master@{#38209}
parent 061d082d
......@@ -405,9 +405,7 @@
##############################################################################
['ignition_turbofan', {
# TODO(rmcilroy,4837): Inlining is currently disabled for the BytecodeGraphBuilder
# (see InliningPhase::Run). Also, we don't set a LoadContextSlot for a function as
# immutable in the BytecodeGraphBuilder, therefore no inlining happens.
# TODO(5251): Inlining is currently disabled for the BytecodeGraphBuilder.
'test-run-inlining/InlineLoopGuardedTwice': [FAIL],
'test-run-inlining/InlineSurplusArgumentsDeopt': [FAIL],
'test-run-inlining/InlineTwice': [FAIL],
......
......@@ -30,7 +30,7 @@ class FunctionTester : public InitializedHandleScope {
flags_(flags) {
Compile(function);
const uint32_t supported_flags =
CompilationInfo::kFunctionContextSpecializing |
CompilationInfo::kNativeContextSpecializing |
CompilationInfo::kInliningEnabled;
CHECK_EQ(0u, flags_ & ~supported_flags);
}
......@@ -212,8 +212,8 @@ class FunctionTester : public InitializedHandleScope {
CHECK(Parser::ParseStatic(info.parse_info()));
}
info.SetOptimizing();
if (flags_ & CompilationInfo::kFunctionContextSpecializing) {
info.MarkAsFunctionContextSpecializing();
if (flags_ & CompilationInfo::kNativeContextSpecializing) {
info.MarkAsNativeContextSpecializing();
}
if (flags_ & CompilationInfo::kInliningEnabled) {
info.MarkAsInliningEnabled();
......
......@@ -48,21 +48,19 @@ void InstallAssertInlineCountHelper(v8::Isolate* isolate) {
}
const uint32_t kRestrictedInliningFlags =
CompilationInfo::kFunctionContextSpecializing;
CompilationInfo::kNativeContextSpecializing;
const uint32_t kInlineFlags = CompilationInfo::kInliningEnabled |
CompilationInfo::kFunctionContextSpecializing;
CompilationInfo::kNativeContextSpecializing;
} // namespace
TEST(SimpleInlining) {
FunctionTester T(
"(function(){"
" function foo(s) { AssertInlineCount(2); return s; };"
" function bar(s, t) { return foo(s); };"
" return bar;"
"})();",
"function foo(s) { AssertInlineCount(2); return s; };"
"function bar(s, t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -72,11 +70,9 @@ TEST(SimpleInlining) {
TEST(SimpleInliningDeopt) {
FunctionTester T(
"(function(){"
" function foo(s) { %DeoptimizeFunction(bar); return s; };"
" function bar(s, t) { return foo(s); };"
" return bar;"
"})();",
"function foo(s) { %DeoptimizeFunction(bar); return s; };"
"function bar(s, t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -86,11 +82,9 @@ TEST(SimpleInliningDeopt) {
TEST(SimpleInliningDeoptSelf) {
FunctionTester T(
"(function(){"
" function foo(s) { %_DeoptimizeNow(); return s; };"
" function bar(s, t) { return foo(s); };"
" return bar;"
"})();",
"function foo(s) { %_DeoptimizeNow(); return s; };"
"function bar(s, t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -100,11 +94,9 @@ TEST(SimpleInliningDeoptSelf) {
TEST(SimpleInliningContext) {
FunctionTester T(
"(function () {"
" function foo(s) { AssertInlineCount(2); var x = 12; return s + x; };"
" function bar(s, t) { return foo(s); };"
" return bar;"
"})();",
"function foo(s) { AssertInlineCount(2); var x = 12; return s + x; };"
"function bar(s, t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -114,14 +106,12 @@ TEST(SimpleInliningContext) {
TEST(SimpleInliningContextDeopt) {
FunctionTester T(
"(function () {"
" function foo(s) {"
" AssertInlineCount(2); %DeoptimizeFunction(bar); var x = 12;"
" return s + x;"
" };"
" function bar(s, t) { return foo(s); };"
" return bar;"
"})();",
"function foo(s) {"
" AssertInlineCount(2); %DeoptimizeFunction(bar); var x = 12;"
" return s + x;"
"};"
"function bar(s, t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -149,10 +139,8 @@ TEST(CaptureContext) {
TEST(DontInlineEval) {
FunctionTester T(
"var x = 42;"
"(function () {"
" function bar(s, t) { return eval(\"AssertInlineCount(1); x\") };"
" return bar;"
"})();",
"function bar(s, t) { return eval(\"AssertInlineCount(1); x\") };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -162,12 +150,10 @@ TEST(DontInlineEval) {
TEST(InlineOmitArguments) {
FunctionTester T(
"(function () {"
" var x = 42;"
" function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };"
" function foo(s, t) { return bar(s); };"
" return foo;"
"})();",
"var x = 42;"
"function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };"
"function foo(s, t) { return bar(s); };"
"foo;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -177,13 +163,11 @@ TEST(InlineOmitArguments) {
TEST(InlineOmitArgumentsObject) {
FunctionTester T(
"(function () {"
" function bar(s, t, u, v) { AssertInlineCount(2); return arguments; };"
" function foo(s, t) { var args = bar(s);"
" return args.length == 1 &&"
" args[0] == 11; };"
" return foo;"
"})();",
"function bar(s, t, u, v) { AssertInlineCount(2); return arguments; };"
"function foo(s, t) { var args = bar(s);"
" return args.length == 1 &&"
" args[0] == 11; };"
"foo;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -193,14 +177,12 @@ TEST(InlineOmitArgumentsObject) {
TEST(InlineOmitArgumentsDeopt) {
FunctionTester T(
"(function () {"
" function foo(s,t,u,v) { AssertInlineCount(2);"
" %DeoptimizeFunction(bar); return baz(); };"
" function bar() { return foo(11); };"
" function baz() { return foo.arguments.length == 1 &&"
" foo.arguments[0] == 11; }"
" return bar;"
"})();",
"function foo(s,t,u,v) { AssertInlineCount(2);"
" %DeoptimizeFunction(bar); return baz(); };"
"function bar() { return foo(11); };"
"function baz() { return foo.arguments.length == 1 &&"
" foo.arguments[0] == 11; }"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -210,12 +192,10 @@ TEST(InlineOmitArgumentsDeopt) {
TEST(InlineSurplusArguments) {
FunctionTester T(
"(function () {"
" var x = 42;"
" function foo(s) { AssertInlineCount(2); return x + s; };"
" function bar(s, t) { return foo(s, t, 13); };"
" return bar;"
"})();",
"var x = 42;"
"function foo(s) { AssertInlineCount(2); return x + s; };"
"function bar(s, t) { return foo(s, t, 13); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -225,15 +205,13 @@ TEST(InlineSurplusArguments) {
TEST(InlineSurplusArgumentsObject) {
FunctionTester T(
"(function () {"
" function foo(s) { AssertInlineCount(2); return arguments; };"
" function bar(s, t) { var args = foo(s, t, 13);"
" return args.length == 3 &&"
" args[0] == 11 &&"
" args[1] == 12 &&"
" args[2] == 13; };"
" return bar;"
"})();",
"function foo(s) { AssertInlineCount(2); return arguments; };"
"function bar(s, t) { var args = foo(s, t, 13);"
" return args.length == 3 &&"
" args[0] == 11 &&"
" args[1] == 12 &&"
" args[2] == 13; };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -243,16 +221,14 @@ TEST(InlineSurplusArgumentsObject) {
TEST(InlineSurplusArgumentsDeopt) {
FunctionTester T(
"(function () {"
" function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar);"
" return baz(); };"
" function bar() { return foo(13, 14, 15); };"
" function baz() { return foo.arguments.length == 3 &&"
" foo.arguments[0] == 13 &&"
" foo.arguments[1] == 14 &&"
" foo.arguments[2] == 15; }"
" return bar;"
"})();",
"function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar);"
" return baz(); };"
"function bar() { return foo(13, 14, 15); };"
"function baz() { return foo.arguments.length == 3 &&"
" foo.arguments[0] == 13 &&"
" foo.arguments[1] == 14 &&"
" foo.arguments[2] == 15; }"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -262,12 +238,10 @@ TEST(InlineSurplusArgumentsDeopt) {
TEST(InlineTwice) {
FunctionTester T(
"(function () {"
" var x = 42;"
" function bar(s) { AssertInlineCount(2); return x + s; };"
" function foo(s, t) { return bar(s) + bar(t); };"
" return foo;"
"})();",
"var x = 42;"
"function bar(s) { AssertInlineCount(2); return x + s; };"
"function foo(s, t) { return bar(s) + bar(t); };"
"foo;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -277,12 +251,10 @@ TEST(InlineTwice) {
TEST(InlineTwiceDependent) {
FunctionTester T(
"(function () {"
" var x = 42;"
" function foo(s) { AssertInlineCount(2); return x + s; };"
" function bar(s,t) { return foo(foo(s)); };"
" return bar;"
"})();",
"var x = 42;"
"function foo(s) { AssertInlineCount(2); return x + s; };"
"function bar(s,t) { return foo(foo(s)); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -292,13 +264,11 @@ TEST(InlineTwiceDependent) {
TEST(InlineTwiceDependentDiamond) {
FunctionTester T(
"(function () {"
" var x = 41;"
" function foo(s) { AssertInlineCount(2); if (s % 2 == 0) {"
" return x - s } else { return x + s; } };"
" function bar(s,t) { return foo(foo(s)); };"
" return bar;"
"})();",
"var x = 41;"
"function foo(s) { AssertInlineCount(2); if (s % 2 == 0) {"
" return x - s } else { return x + s; } };"
"function bar(s,t) { return foo(foo(s)); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -308,13 +278,11 @@ TEST(InlineTwiceDependentDiamond) {
TEST(InlineTwiceDependentDiamondDifferent) {
FunctionTester T(
"(function () {"
" var x = 41;"
" function foo(s,t) { AssertInlineCount(2); if (s % 2 == 0) {"
" return x - s * t } else { return x + s * t; } };"
" function bar(s,t) { return foo(foo(s, 3), 5); };"
" return bar;"
"})();",
"var x = 41;"
"function foo(s,t) { AssertInlineCount(2); if (s % 2 == 0) {"
" return x - s * t } else { return x + s * t; } };"
"function bar(s,t) { return foo(foo(s, 3), 5); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -324,11 +292,9 @@ TEST(InlineTwiceDependentDiamondDifferent) {
TEST(InlineLoopGuardedEmpty) {
FunctionTester T(
"(function () {"
" function foo(s) { AssertInlineCount(2); if (s) while (s); return s; };"
" function bar(s,t) { return foo(s); };"
" return bar;"
"})();",
"function foo(s) { AssertInlineCount(2); if (s) while (s); return s; };"
"function bar(s,t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -338,12 +304,10 @@ TEST(InlineLoopGuardedEmpty) {
TEST(InlineLoopGuardedOnce) {
FunctionTester T(
"(function () {"
" function foo(s,t) { AssertInlineCount(2); if (t > 0) while (s > 0) {"
" s = s - 1; }; return s; };"
" function bar(s,t) { return foo(s,t); };"
" return bar;"
"})();",
"function foo(s,t) { AssertInlineCount(2); if (t > 0) while (s > 0) {"
" s = s - 1; }; return s; };"
"function bar(s,t) { return foo(s,t); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -353,12 +317,10 @@ TEST(InlineLoopGuardedOnce) {
TEST(InlineLoopGuardedTwice) {
FunctionTester T(
"(function () {"
" function foo(s,t) { AssertInlineCount(2); if (t > 0) while (s > 0) {"
" s = s - 1; }; return s; };"
" function bar(s,t) { return foo(foo(s,t),t); };"
" return bar;"
"})();",
"function foo(s,t) { AssertInlineCount(2); if (t > 0) while (s > 0) {"
" s = s - 1; }; return s; };"
"function bar(s,t) { return foo(foo(s,t),t); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -368,11 +330,9 @@ TEST(InlineLoopGuardedTwice) {
TEST(InlineLoopUnguardedEmpty) {
FunctionTester T(
"(function () {"
" function foo(s) { AssertInlineCount(2); while (s); return s; };"
" function bar(s, t) { return foo(s); };"
" return bar;"
"})();",
"function foo(s) { AssertInlineCount(2); while (s); return s; };"
"function bar(s, t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -382,12 +342,10 @@ TEST(InlineLoopUnguardedEmpty) {
TEST(InlineLoopUnguardedOnce) {
FunctionTester T(
"(function () {"
" function foo(s) { AssertInlineCount(2); while (s) {"
" s = s - 1; }; return s; };"
" function bar(s, t) { return foo(s); };"
" return bar;"
"})();",
"function foo(s) { AssertInlineCount(2); while (s) {"
" s = s - 1; }; return s; };"
"function bar(s, t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -397,12 +355,10 @@ TEST(InlineLoopUnguardedOnce) {
TEST(InlineLoopUnguardedTwice) {
FunctionTester T(
"(function () {"
" function foo(s) { AssertInlineCount(2); while (s > 0) {"
" s = s - 1; }; return s; };"
" function bar(s,t) { return foo(foo(s,t),t); };"
" return bar;"
"})();",
"function foo(s) { AssertInlineCount(2); while (s > 0) {"
" s = s - 1; }; return s; };"
"function bar(s,t) { return foo(foo(s,t),t); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -412,13 +368,11 @@ TEST(InlineLoopUnguardedTwice) {
TEST(InlineStrictIntoNonStrict) {
FunctionTester T(
"(function () {"
" var x = Object.create({}, { y: { value:42, writable:false } });"
" function foo(s) { 'use strict';"
" x.y = 9; };"
" function bar(s,t) { return foo(s); };"
" return bar;"
"})();",
"var x = Object.create({}, { y: { value:42, writable:false } });"
"function foo(s) { 'use strict';"
" x.y = 9; };"
"function bar(s,t) { return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -428,12 +382,10 @@ TEST(InlineStrictIntoNonStrict) {
TEST(InlineNonStrictIntoStrict) {
FunctionTester T(
"(function () {"
" var x = Object.create({}, { y: { value:42, writable:false } });"
" function foo(s) { x.y = 9; return x.y; };"
" function bar(s,t) { \'use strict\'; return foo(s); };"
" return bar;"
"})();",
"var x = Object.create({}, { y: { value:42, writable:false } });"
"function foo(s) { x.y = 9; return x.y; };"
"function bar(s,t) { \'use strict\'; return foo(s); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -441,66 +393,16 @@ TEST(InlineNonStrictIntoStrict) {
}
TEST(InlineIntrinsicIsSmi) {
FunctionTester T(
"(function () {"
" var x = 42;"
" function bar(s,t) { return %_IsSmi(x); };"
" return bar;"
"})();",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
T.CheckCall(T.true_value(), T.Val(12), T.Val(4));
}
TEST(InlineIntrinsicIsArray) {
FunctionTester T(
"(function () {"
" var x = [1,2,3];"
" function bar(s,t) { return %_IsArray(x); };"
" return bar;"
"})();",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
T.CheckCall(T.true_value(), T.Val(12), T.Val(4));
FunctionTester T2(
"(function () {"
" var x = 32;"
" function bar(s,t) { return %_IsArray(x); };"
" return bar;"
"})();",
kInlineFlags);
T2.CheckCall(T.false_value(), T.Val(12), T.Val(4));
FunctionTester T3(
"(function () {"
" var x = bar;"
" function bar(s,t) { return %_IsArray(x); };"
" return bar;"
"})();",
kInlineFlags);
T3.CheckCall(T.false_value(), T.Val(12), T.Val(4));
}
TEST(InlineWithArguments) {
FunctionTester T(
"(function () {"
" function foo(s,t,u) { AssertInlineCount(2);"
" return foo.arguments.length == 3 &&"
" foo.arguments[0] == 13 &&"
" foo.arguments[1] == 14 &&"
" foo.arguments[2] == 15;"
" }"
" function bar() { return foo(13, 14, 15); };"
" return bar;"
"})();",
"function foo(s,t,u) { AssertInlineCount(2);"
" return foo.arguments.length == 3 &&"
" foo.arguments[0] == 13 &&"
" foo.arguments[1] == 14 &&"
" foo.arguments[2] == 15;"
"}"
"function bar() { return foo(13, 14, 15); };"
"bar;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -510,12 +412,10 @@ TEST(InlineWithArguments) {
TEST(InlineBuiltin) {
FunctionTester T(
"(function () {"
" function foo(s,t,u) { AssertInlineCount(2); return true; }"
" function bar() { return foo(); };"
" %SetForceInlineFlag(foo);"
" return bar;"
"})();",
"function foo(s,t,u) { AssertInlineCount(2); return true; }"
"function bar() { return foo(); };"
"%SetForceInlineFlag(foo);"
"bar;",
kRestrictedInliningFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -525,14 +425,12 @@ TEST(InlineBuiltin) {
TEST(InlineNestedBuiltin) {
FunctionTester T(
"(function () {"
" function foo(s,t,u) { AssertInlineCount(3); return true; }"
" function baz(s,t,u) { return foo(s,t,u); }"
" function bar() { return baz(); };"
" %SetForceInlineFlag(foo);"
" %SetForceInlineFlag(baz);"
" return bar;"
"})();",
"function foo(s,t,u) { AssertInlineCount(3); return true; }"
"function baz(s,t,u) { return foo(s,t,u); }"
"function bar() { return baz(); };"
"%SetForceInlineFlag(foo);"
"%SetForceInlineFlag(baz);"
"bar;",
kRestrictedInliningFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -542,14 +440,12 @@ TEST(InlineNestedBuiltin) {
TEST(InlineSelfRecursive) {
FunctionTester T(
"(function () {"
" function foo(x) { "
" AssertInlineCount(1);"
" if (x == 1) return foo(12);"
" return x;"
" }"
" return foo;"
"})();",
"function foo(x) { "
" AssertInlineCount(1);"
" if (x == 1) return foo(12);"
" return x;"
"}"
"foo;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......@@ -559,14 +455,12 @@ TEST(InlineSelfRecursive) {
TEST(InlineMutuallyRecursive) {
FunctionTester T(
"(function () {"
" function bar(x) { AssertInlineCount(2); return foo(x); }"
" function foo(x) { "
" if (x == 1) return bar(42);"
" return x;"
" }"
" return foo;"
"})();",
"function bar(x) { AssertInlineCount(2); return foo(x); }"
"function foo(x) { "
" if (x == 1) return bar(42);"
" return x;"
"}"
"foo;",
kInlineFlags);
InstallAssertInlineCountHelper(CcTest::isolate());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment