| Index: test/cctest/test-profile-generator.cc | 
| diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc | 
| index 22b4e059a246993aa2bae921e16ed758377c23ee..c334c0a4af0c63705bd65f3aef699ee5cab73dcb 100644 | 
| --- a/test/cctest/test-profile-generator.cc | 
| +++ b/test/cctest/test-profile-generator.cc | 
| @@ -85,7 +85,8 @@ TEST(TokenEnumerator) { | 
|  | 
|  | 
| TEST(ProfileNodeFindOrAddChild) { | 
| -  ProfileNode node(NULL, NULL); | 
| +  ProfileTree tree; | 
| +  ProfileNode node(&tree, NULL); | 
| CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, | 
| TokenEnumerator::kNoSecurityToken); | 
| ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 
| @@ -113,7 +114,8 @@ TEST(ProfileNodeFindOrAddChild) { | 
| TEST(ProfileNodeFindOrAddChildForSameFunction) { | 
| const char* empty = ""; | 
| const char* aaa = "aaa"; | 
| -  ProfileNode node(NULL, NULL); | 
| +  ProfileTree tree; | 
| +  ProfileNode node(&tree, NULL); | 
| CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, | 
| TokenEnumerator::kNoSecurityToken); | 
| ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 
| @@ -607,7 +609,7 @@ class TestSetup { | 
| TEST(RecordTickSample) { | 
| TestSetup test_setup; | 
| CpuProfilesCollection profiles; | 
| -  profiles.StartProfiling("", 1); | 
| +  profiles.StartProfiling("", 1, false); | 
| ProfileGenerator generator(&profiles); | 
| CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 
| CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); | 
| @@ -713,6 +715,56 @@ TEST(SampleRateCalculator) { | 
| } | 
|  | 
|  | 
| +static void CheckNodeIds(ProfileNode* node, int* expectedId) { | 
| +  CHECK_EQ((*expectedId)++, node->id()); | 
| +  for (int i = 0; i < node->children()->length(); i++) { | 
| +      CheckNodeIds(node->children()->at(i), expectedId); | 
| +  } | 
| +} | 
| + | 
| +TEST(SampleIds) { | 
| +  TestSetup test_setup; | 
| +  CpuProfilesCollection profiles; | 
| +  profiles.StartProfiling("", 1, true); | 
| +  ProfileGenerator generator(&profiles); | 
| +  CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 
| +  CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); | 
| +  CodeEntry* entry3 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); | 
| +  generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 
| +  generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); | 
| +  generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); | 
| + | 
| +  // We are building the following calls tree: | 
| +  //                    -> aaa #3           - sample1 | 
| +  // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2 | 
| +  //                    -> ccc #6 -> aaa #7 - sample3 | 
| +  TickSample sample1; | 
| +  sample1.pc = ToAddress(0x1600); | 
| +  sample1.stack[0] = ToAddress(0x1510); | 
| +  sample1.frames_count = 1; | 
| +  generator.RecordTickSample(sample1); | 
| +  TickSample sample2; | 
| +  sample2.pc = ToAddress(0x1925); | 
| +  sample2.stack[0] = ToAddress(0x1780); | 
| +  sample2.stack[1] = ToAddress(0x10000);  // non-existent. | 
| +  sample2.stack[2] = ToAddress(0x1620); | 
| +  sample2.frames_count = 3; | 
| +  generator.RecordTickSample(sample2); | 
| +  TickSample sample3; | 
| +  sample3.pc = ToAddress(0x1510); | 
| +  sample3.stack[0] = ToAddress(0x1910); | 
| +  sample3.stack[1] = ToAddress(0x1610); | 
| +  sample3.frames_count = 2; | 
| +  generator.RecordTickSample(sample3); | 
| + | 
| +  CpuProfile* profile = | 
| +      profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); | 
| +  int nodeId = 1; | 
| +  CheckNodeIds(profile->top_down()->root(), &nodeId); | 
| +  CHECK_EQ(7, nodeId - 1); | 
| +} | 
| + | 
| + | 
| // --- P r o f i l e r   E x t e n s i o n --- | 
|  | 
| class ProfilerExtension : public v8::Extension { | 
| @@ -838,11 +890,12 @@ TEST(Issue51919) { | 
| for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) { | 
| i::Vector<char> title = i::Vector<char>::New(16); | 
| i::OS::SNPrintF(title, "%d", i); | 
| -    CHECK(collection.StartProfiling(title.start(), i + 1));  // UID must be > 0. | 
| +    // UID must be > 0. | 
| +    CHECK(collection.StartProfiling(title.start(), i + 1, false)); | 
| titles[i] = title.start(); | 
| } | 
| CHECK(!collection.StartProfiling( | 
| -      "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); | 
| +      "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); | 
| for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) | 
| i::DeleteArray(titles[i]); | 
| } | 
|  |