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

Unified Diff: test/cctest/test-profile-generator.cc

Issue 23817003: Propagate bailout and dont_optimize reasons to cpu-profiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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
« src/objects.h ('K') | « src/profile-generator-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-profile-generator.cc
diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc
index 5dd92b60fd6f819221ee4a25ab4b9cb5680eeb8e..cfb4c27b1143131a9ab105801c6fd40e14c692b4 100644
--- a/test/cctest/test-profile-generator.cc
+++ b/test/cctest/test-profile-generator.cc
@@ -782,3 +782,54 @@ TEST(LineNumber) {
profiler->StopProfiling("LineNumber");
}
+
+
+
+TEST(BailoutReason) {
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ LocalContext env(&config);
+ v8::HandleScope hs(env->GetIsolate());
+
+ v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
+ CHECK_EQ(0, profiler->GetProfileCount());
+ v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(
+ "function kTryCatch() {\n"
+ " try {\n"
+ " startProfiling();\n"
+ " } catch (e) { };\n"
+ "}\n"
+ "function kTryFinally() {\n"
yurys 2013/09/02 14:40:05 Why this "k" prefix?
loislo 2013/09/02 16:03:45 Done.
+ " try {\n"
+ " kTryCatch();\n"
+ " } finally { };\n"
+ "}\n"
+ "kTryFinally();\n"
+ "stopProfiling();"));
+ script->Run();
+ CHECK_EQ(1, profiler->GetProfileCount());
+ const v8::CpuProfile* profile = profiler->GetCpuProfile(0);
+ const v8::CpuProfileNode* current = profile->GetTopDownRoot();
+ reinterpret_cast<ProfileNode*>(
+ const_cast<v8::CpuProfileNode*>(current))->Print(0);
+ // The tree should look like this:
+ // (root)
+ // (anonymous function)
+ // kTryFinally
+ // kTryCatch
+ // There can also be:
+ // startProfiling
yurys 2013/09/02 14:40:05 There should always be that tick as we generate it
loislo 2013/09/02 16:03:45 Done.
+ // if the sampler managed to get a tick.
+ current = PickChild(current, i::ProfileGenerator::kAnonymousFunctionName);
+ CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
+
+ current = PickChild(current, "kTryFinally");
+ CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
+ CHECK_EQ(v8::String::New("TryFinallyStatement"),
+ current->GetBailoutReason());
+
+ current = PickChild(current, "kTryCatch");
+ CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
+ CHECK_EQ(v8::String::New("TryCatchStatement"),
+ current->GetBailoutReason());
+}
« src/objects.h ('K') | « src/profile-generator-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698