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 e9197896734da11548615e2424bafff2608e494f..97d63a75be719149d87982a54ff797e30607de8a 100644 | 
| --- a/test/cctest/test-profile-generator.cc | 
| +++ b/test/cctest/test-profile-generator.cc | 
| @@ -905,3 +905,53 @@ TEST(Issue51919) { | 
| for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) | 
| i::DeleteArray(titles[i]); | 
| } | 
| + | 
| + | 
| +TEST(ProfileNodeScriptId) { | 
| + // This test does not pass with inlining enabled since inlined functions | 
| + // don't appear in the stack trace. | 
| 
 
yurys
2013/07/01 14:50:00
I think we should be testing with inlining on as w
 
 | 
| + i::FLAG_use_inlining = false; | 
| + | 
| + v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 
| + v8::HandleScope scope(isolate); | 
| + const char* extensions[] = { "v8/profiler" }; | 
| + v8::ExtensionConfiguration config(1, extensions); | 
| + v8::Local<v8::Context> context = v8::Context::New(isolate, &config); | 
| + context->Enter(); | 
| 
 
yurys
2013/07/01 14:50:00
Please use LocalContext env(config); instead, it w
 
 | 
| + | 
| + CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); | 
| + CHECK_EQ(0, profiler->GetProfilesCount()); | 
| + v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::New( | 
| + "function a() { startProfiling(); }\n")); | 
| + script_a->Run(); | 
| + v8::Handle<v8::Script> script_b = v8::Script::Compile(v8::String::New( | 
| + "function b() { a(); }\n" | 
| + "b();\n" | 
| + "stopProfiling();\n")); | 
| + script_b->Run(); | 
| + CHECK_EQ(1, profiler->GetProfilesCount()); | 
| + CpuProfile* profile = profiler->GetProfile(NULL, 0); | 
| 
 
yurys
2013/07/01 14:50:00
Why don't we use public API here?
 
 | 
| + const ProfileTree* topDown = profile->top_down(); | 
| + const ProfileNode* current = topDown->root(); | 
| + const_cast<ProfileNode*>(current)->Print(0); | 
| + // The tree should look like this: | 
| + // (root) | 
| + // (anonymous function) | 
| + // b | 
| + // a | 
| + // There can also be: | 
| + // startProfiling | 
| + // if the sampler managed to get a tick. | 
| + current = PickChild(current, "(anonymous function)"); | 
| 
 
yurys
2013/07/01 14:50:00
Please use i::ProfilerGenerator::kAnonymousFunctio
 
 | 
| + CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 
| + | 
| + current = PickChild(current, "b"); | 
| + CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 
| + CHECK_EQ(script_b->GetId(), current->entry()->script_id()); | 
| + | 
| + current = PickChild(current, "a"); | 
| + CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 
| + CHECK_EQ(script_a->GetId(), current->entry()->script_id()); | 
| +} | 
| + | 
| + |