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

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

Issue 1740073002: Make CPU profiler unwind the inlined functions stack. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/cctest.status ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 361c879af39935f40b845e57d6cc3d3ab0948f18..3f5f987387397c21ad215beeb4dabdb0af46e77e 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -1510,6 +1510,70 @@ TEST(JsNativeJsRuntimeJsSampleMultiple) {
profile->Delete();
}
+void CheckChildIsRare(const v8::Local<v8::Context>& context,
+ const v8::CpuProfileNode* node, const char* name) {
+ const v8::CpuProfileNode* child = FindChild(context, node, name);
+ CHECK(!child || child->GetHitCount() < 10u);
+}
+
+static const char* inlining_test_source =
+ "%NeverOptimizeFunction(action);\n"
+ "%NeverOptimizeFunction(start);\n"
+ "%OptimizeFunctionOnNextCall(level1);\n"
+ "%OptimizeFunctionOnNextCall(level2);\n"
+ "%OptimizeFunctionOnNextCall(level3);\n"
+ "function action(n) {\n"
+ " var s = 0;\n"
+ " for (var i = 0; i < n; ++i) s += i*i*i;\n"
+ " return s;\n"
+ "}\n"
+ "function level3() { return action(1000); }\n"
+ "function level2() { return level3() * 2; }\n"
+ "function level1() { return level2(); }\n"
+ "function start() {\n"
+ " startProfiling('my_profile');\n"
+ " var startTime = Date.now();\n"
+ " do {\n"
+ " level1();\n"
+ " } while (Date.now() - startTime < 200);\n"
+ "}";
+
+// The test check multiple entrances/exits between JS and native code.
+//
+// [Top down]:
+// (root) #0 1
+// start #16 3
+// level1 #0 4
+// level2 #16 5
+// level3 #16 6
+// action #16 7
+// (program) #0 2
+TEST(Inlining) {
titzer 2016/02/26 21:24:01 Is there a way to make this test non-flaky? It cur
alph 2016/02/26 22:12:10 It does not. It was supposed to check that there's
titzer 2016/02/26 23:46:52 It's still inherently flaky. Why can't you test th
alph 2016/02/27 08:24:02 looks like I managed to make the test deterministi
+ i::FLAG_allow_natives_syntax = true;
+ v8::HandleScope scope(CcTest::isolate());
+ v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
+ v8::Context::Scope context_scope(env);
+
+ CompileRun(inlining_test_source);
+ v8::Local<v8::Function> function = GetFunction(env, "start");
+ v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 1000);
+
+ const v8::CpuProfileNode* root = profile->GetTopDownRoot();
+ const v8::CpuProfileNode* start_node = GetChild(env, root, "start");
+ const v8::CpuProfileNode* level1_node = GetChild(env, start_node, "level1");
+ const v8::CpuProfileNode* level2_node = GetChild(env, level1_node, "level2");
+ const v8::CpuProfileNode* level3_node = GetChild(env, level2_node, "level3");
+ GetChild(env, level3_node, "action");
+ CheckChildIsRare(env, start_node, "level2");
+ CheckChildIsRare(env, start_node, "level3");
+ CheckChildIsRare(env, start_node, "action");
+ CheckChildIsRare(env, level1_node, "level3");
+ CheckChildIsRare(env, level1_node, "action");
+ CheckChildIsRare(env, level2_node, "action");
+
+ profile->Delete();
+}
+
// [Top down]:
// 0 (root) #0 1
// 2 (program) #0 2
« no previous file with comments | « test/cctest/cctest.status ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698