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..c84003f0393a1dbcbbd753fde1234656c1cf70c9 100644 |
--- a/test/cctest/test-profile-generator.cc |
+++ b/test/cctest/test-profile-generator.cc |
@@ -782,3 +782,49 @@ 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 TryCatch() {\n" |
+ " try {\n" |
+ " startProfiling();\n" |
+ " } catch (e) { };\n" |
+ "}\n" |
+ "function TryFinally() {\n" |
+ " try {\n" |
+ " TryCatch();\n" |
+ " } finally { };\n" |
+ "}\n" |
+ "TryFinally();\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 |
+ current = PickChild(current, i::ProfileGenerator::kAnonymousFunctionName); |
+ CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
+ |
+ current = PickChild(current, "TryFinally"); |
+ CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
+ CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); |
+ |
+ current = PickChild(current, "TryCatch"); |
+ CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
+ CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); |
+} |