Chromium Code Reviews| 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()); |
| +} |