Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Unified Diff: test/cctest/compiler/test-run-inlining.cc

Issue 2200673002: [turbofan] Switch inlining tests to global scope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-inlining.cc
diff --git a/test/cctest/compiler/test-run-inlining.cc b/test/cctest/compiler/test-run-inlining.cc
index fcd5fbaea1c8f1b6bfbe3e1ab190abd134acbde9..b715214c0d6b8e507d09251dda25a15d594d343a 100644
--- a/test/cctest/compiler/test-run-inlining.cc
+++ b/test/cctest/compiler/test-run-inlining.cc
@@ -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());
« no previous file with comments | « test/cctest/compiler/function-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698