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

Unified Diff: test/cctest/test-cpu-profiler.cc

Issue 2451853002: Uniform and precise source positions for inlining (Closed)
Patch Set: fixed gcmole issue Created 4 years, 1 month 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
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 90a8d5d0c6476c170dbfe001ee6d5dc86c92f220..f286b9d0502d29cd651043cdff926da251ef1c2e 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -1905,10 +1905,8 @@ TEST(SourceLocation) {
.ToLocalChecked();
}
-
static const char* inlined_source =
- "function opt_function(left, right) { var k = left / 10; var r = 10 / "
- "right; return k + r; }\n";
+ "function opt_function(f) { return f()*f(); }\n";
// 0.........1.........2.........3.........4....*....5.........6......*..7
@@ -1925,17 +1923,16 @@ TEST(DeoptAtFirstLevelInlinedSource) {
// 0.........1.........2.........3.........4.........5.........6.........7
const char* source =
- "function test(left, right) { return opt_function(left, right); }\n"
+ "function test(f) { return opt_function(f); }\n"
"\n"
"startProfiling();\n"
"\n"
- "test(10, 10);\n"
+ "test(function(){return 10});test(function(){return 12});\n"
"\n"
+ "%SetForceInlineFlag(opt_function);\n"
"%OptimizeFunctionOnNextCall(test)\n"
"\n"
- "test(10, 10);\n"
- "\n"
- "test(undefined, 10);\n"
+ "test(function(){return 100000000000});\n"
"\n"
"stopProfiling();\n"
"\n";
@@ -1970,12 +1967,13 @@ TEST(DeoptAtFirstLevelInlinedSource) {
CHECK_EQ(1U, deopt_infos.size());
const v8::CpuProfileDeoptInfo& info = deopt_infos[0];
- CHECK_EQ(reason(i::DeoptimizeReason::kNotAHeapNumber), info.deopt_reason);
+ CHECK_EQ(reason(i::DeoptimizeReason::kNotASmi), info.deopt_reason);
CHECK_EQ(2U, info.stack.size());
CHECK_EQ(inlined_script_id, info.stack[0].script_id);
- CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position);
+ CHECK(abs(static_cast<int>(offset(inlined_source, "*f()")) -
+ static_cast<int>(info.stack[0].position)) <= 1);
CHECK_EQ(script_id, info.stack[1].script_id);
- CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position);
+ CHECK_EQ(offset(source, "opt_function(f)"), info.stack[1].position);
iprofiler->DeleteProfile(iprofile);
}
@@ -1994,18 +1992,21 @@ TEST(DeoptAtSecondLevelInlinedSource) {
// 0.........1.........2.........3.........4.........5.........6.........7
const char* source =
- "function test2(left, right) { return opt_function(left, right); }\n"
- "function test1(left, right) { return test2(left, right); }\n"
+ "function test2(f) { return opt_function(f); }\n"
+ "function test1(f) { return test2(f); }\n"
"\n"
"startProfiling();\n"
"\n"
- "test1(10, 10);\n"
+ "test1(function(){return 10});\n"
+ "test1(function(){return 11});\n"
"\n"
+ "%SetForceInlineFlag(test2);\n"
+ "%SetForceInlineFlag(opt_function);\n"
"%OptimizeFunctionOnNextCall(test1)\n"
"\n"
- "test1(10, 10);\n"
+ "test1(function(){return 12});\n"
"\n"
- "test1(undefined, 10);\n"
+ "test1(function(){return 100000000000});\n"
"\n"
"stopProfiling();\n"
"\n";
@@ -2043,13 +2044,14 @@ TEST(DeoptAtSecondLevelInlinedSource) {
CHECK_EQ(1U, deopt_infos.size());
const v8::CpuProfileDeoptInfo info = deopt_infos[0];
- CHECK_EQ(reason(i::DeoptimizeReason::kNotAHeapNumber), info.deopt_reason);
+ CHECK_EQ(reason(i::DeoptimizeReason::kNotASmi), info.deopt_reason);
CHECK_EQ(3U, info.stack.size());
CHECK_EQ(inlined_script_id, info.stack[0].script_id);
- CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position);
+ CHECK(abs(static_cast<int>(offset(inlined_source, "*f()")) -
+ static_cast<int>(info.stack[0].position)) <= 1);
CHECK_EQ(script_id, info.stack[1].script_id);
- CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position);
- CHECK_EQ(offset(source, "test2(left, right);"), info.stack[2].position);
+ CHECK_EQ(offset(source, "opt_function(f)"), info.stack[1].position);
+ CHECK_EQ(offset(source, "test2(f);"), info.stack[2].position);
iprofiler->DeleteProfile(iprofile);
}
@@ -2070,15 +2072,17 @@ TEST(DeoptUntrackedFunction) {
const char* source =
"function test(left, right) { return opt_function(left, right); }\n"
"\n"
- "test(10, 10);\n"
+ "test(function(){return 10});\n"
+ "test(function(){return 11});\n"
"\n"
+ "%SetForceInlineFlag(opt_function);\n"
"%OptimizeFunctionOnNextCall(test)\n"
"\n"
- "test(10, 10);\n"
+ "test(function(){return 10});\n"
"\n"
"startProfiling();\n" // profiler started after compilation.
"\n"
- "test(undefined, 10);\n"
+ "test(function(){return 100000000000});\n"
"\n"
"stopProfiling();\n"
"\n";

Powered by Google App Engine
This is Rietveld 408576698