| OLD | NEW | 
|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 36 using i::CodeEntry; | 36 using i::CodeEntry; | 
| 37 using i::CodeMap; | 37 using i::CodeMap; | 
| 38 using i::CpuProfile; | 38 using i::CpuProfile; | 
| 39 using i::CpuProfiler; | 39 using i::CpuProfiler; | 
| 40 using i::CpuProfilesCollection; | 40 using i::CpuProfilesCollection; | 
| 41 using i::ProfileNode; | 41 using i::ProfileNode; | 
| 42 using i::ProfileTree; | 42 using i::ProfileTree; | 
| 43 using i::ProfileGenerator; | 43 using i::ProfileGenerator; | 
| 44 using i::SampleRateCalculator; | 44 using i::SampleRateCalculator; | 
| 45 using i::TickSample; | 45 using i::TickSample; | 
| 46 using i::TokenEnumerator; |  | 
| 47 using i::Vector; | 46 using i::Vector; | 
| 48 | 47 | 
| 49 | 48 | 
| 50 namespace v8 { |  | 
| 51 namespace internal { |  | 
| 52 |  | 
| 53 class TokenEnumeratorTester { |  | 
| 54  public: |  | 
| 55   static i::List<bool>* token_removed(TokenEnumerator* te) { |  | 
| 56     return &te->token_removed_; |  | 
| 57   } |  | 
| 58 }; |  | 
| 59 |  | 
| 60 } }  // namespace v8::internal |  | 
| 61 |  | 
| 62 TEST(TokenEnumerator) { |  | 
| 63   TokenEnumerator te; |  | 
| 64   CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL)); |  | 
| 65   v8::HandleScope hs(v8::Isolate::GetCurrent()); |  | 
| 66   v8::Local<v8::String> token1(v8::String::New("1x")); |  | 
| 67   CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |  | 
| 68   CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |  | 
| 69   v8::Local<v8::String> token2(v8::String::New("2x")); |  | 
| 70   CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |  | 
| 71   CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |  | 
| 72   CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |  | 
| 73   { |  | 
| 74     v8::HandleScope hs(v8::Isolate::GetCurrent()); |  | 
| 75     v8::Local<v8::String> token3(v8::String::New("3x")); |  | 
| 76     CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); |  | 
| 77     CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |  | 
| 78     CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |  | 
| 79   } |  | 
| 80   CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); |  | 
| 81   HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |  | 
| 82   CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); |  | 
| 83   CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |  | 
| 84   CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |  | 
| 85 } |  | 
| 86 |  | 
| 87 |  | 
| 88 TEST(ProfileNodeFindOrAddChild) { | 49 TEST(ProfileNodeFindOrAddChild) { | 
| 89   ProfileTree tree; | 50   ProfileTree tree; | 
| 90   ProfileNode node(&tree, NULL); | 51   ProfileNode node(&tree, NULL); | 
| 91   CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 52   CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 
| 92   ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 53   ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 
| 93   CHECK_NE(NULL, childNode1); | 54   CHECK_NE(NULL, childNode1); | 
| 94   CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 55   CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 
| 95   CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 56   CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 
| 96   ProfileNode* childNode2 = node.FindOrAddChild(&entry2); | 57   ProfileNode* childNode2 = node.FindOrAddChild(&entry2); | 
| 97   CHECK_NE(NULL, childNode2); | 58   CHECK_NE(NULL, childNode2); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 114   ProfileTree tree; | 75   ProfileTree tree; | 
| 115   ProfileNode node(&tree, NULL); | 76   ProfileNode node(&tree, NULL); | 
| 116   CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa); | 77   CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa); | 
| 117   ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 78   ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 
| 118   CHECK_NE(NULL, childNode1); | 79   CHECK_NE(NULL, childNode1); | 
| 119   CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 80   CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 
| 120   // The same function again. | 81   // The same function again. | 
| 121   CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa); | 82   CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa); | 
| 122   CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); | 83   CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); | 
| 123   // Now with a different security token. | 84   // Now with a different security token. | 
| 124   CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa, | 85   CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa); | 
| 125                    TokenEnumerator::kNoSecurityToken + 1); |  | 
| 126   CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); | 86   CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); | 
| 127 } | 87 } | 
| 128 | 88 | 
| 129 | 89 | 
| 130 namespace { | 90 namespace { | 
| 131 | 91 | 
| 132 class ProfileTreeTestHelper { | 92 class ProfileTreeTestHelper { | 
| 133  public: | 93  public: | 
| 134   explicit ProfileTreeTestHelper(const ProfileTree* tree) | 94   explicit ProfileTreeTestHelper(const ProfileTree* tree) | 
| 135       : tree_(tree) { } | 95       : tree_(tree) { } | 
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 408   CHECK_EQ(2, node1->self_ticks()); | 368   CHECK_EQ(2, node1->self_ticks()); | 
| 409   CHECK_EQ(1, node1_2->total_ticks()); | 369   CHECK_EQ(1, node1_2->total_ticks()); | 
| 410   CHECK_EQ(1, node1_2->self_ticks()); | 370   CHECK_EQ(1, node1_2->self_ticks()); | 
| 411   CHECK_EQ(3, node2->total_ticks()); | 371   CHECK_EQ(3, node2->total_ticks()); | 
| 412   CHECK_EQ(3, node2->self_ticks()); | 372   CHECK_EQ(3, node2->self_ticks()); | 
| 413   CHECK_EQ(4, node3->total_ticks()); | 373   CHECK_EQ(4, node3->total_ticks()); | 
| 414   CHECK_EQ(4, node3->self_ticks()); | 374   CHECK_EQ(4, node3->self_ticks()); | 
| 415 } | 375 } | 
| 416 | 376 | 
| 417 | 377 | 
| 418 TEST(ProfileTreeFilteredClone) { |  | 
| 419   ProfileTree source_tree; |  | 
| 420   const int token0 = 0, token1 = 1, token2 = 2; |  | 
| 421   CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", token0); |  | 
| 422   CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", token1); |  | 
| 423   CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc", token0); |  | 
| 424   CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd", |  | 
| 425                    TokenEnumerator::kInheritsSecurityToken); |  | 
| 426 |  | 
| 427   { |  | 
| 428     CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |  | 
| 429     Vector<CodeEntry*> e1_e2_path_vec( |  | 
| 430         e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |  | 
| 431     source_tree.AddPathFromStart(e1_e2_path_vec); |  | 
| 432     CodeEntry* e2_e4_path[] = {&entry2, &entry4}; |  | 
| 433     Vector<CodeEntry*> e2_e4_path_vec( |  | 
| 434         e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0])); |  | 
| 435     source_tree.AddPathFromStart(e2_e4_path_vec); |  | 
| 436     CodeEntry* e3_e1_path[] = {&entry3, &entry1}; |  | 
| 437     Vector<CodeEntry*> e3_e1_path_vec( |  | 
| 438         e3_e1_path, sizeof(e3_e1_path) / sizeof(e3_e1_path[0])); |  | 
| 439     source_tree.AddPathFromStart(e3_e1_path_vec); |  | 
| 440     CodeEntry* e3_e2_path[] = {&entry3, &entry2}; |  | 
| 441     Vector<CodeEntry*> e3_e2_path_vec( |  | 
| 442         e3_e2_path, sizeof(e3_e2_path) / sizeof(e3_e2_path[0])); |  | 
| 443     source_tree.AddPathFromStart(e3_e2_path_vec); |  | 
| 444     source_tree.CalculateTotalTicks(); |  | 
| 445     // Results in               -> {entry1,0,1,0} -> {entry2,1,1,1} |  | 
| 446     //            {root,0,4,-1} -> {entry2,0,1,1} -> {entry4,1,1,inherits} |  | 
| 447     //                          -> {entry3,0,2,0} -> {entry1,1,1,0} |  | 
| 448     //                                            -> {entry2,1,1,1} |  | 
| 449     CHECK_EQ(4, source_tree.root()->total_ticks()); |  | 
| 450     CHECK_EQ(0, source_tree.root()->self_ticks()); |  | 
| 451   } |  | 
| 452 |  | 
| 453   { |  | 
| 454     ProfileTree token0_tree; |  | 
| 455     token0_tree.FilteredClone(&source_tree, token0); |  | 
| 456     // Should be                -> {entry1,1,1,0} |  | 
| 457     //            {root,1,4,-1} -> {entry3,1,2,0} -> {entry1,1,1,0} |  | 
| 458     // [self ticks from filtered nodes are attributed to their parents] |  | 
| 459     CHECK_EQ(4, token0_tree.root()->total_ticks()); |  | 
| 460     CHECK_EQ(1, token0_tree.root()->self_ticks()); |  | 
| 461     ProfileTreeTestHelper token0_helper(&token0_tree); |  | 
| 462     ProfileNode* node1 = token0_helper.Walk(&entry1); |  | 
| 463     CHECK_NE(NULL, node1); |  | 
| 464     CHECK_EQ(1, node1->total_ticks()); |  | 
| 465     CHECK_EQ(1, node1->self_ticks()); |  | 
| 466     CHECK_EQ(NULL, token0_helper.Walk(&entry2)); |  | 
| 467     ProfileNode* node3 = token0_helper.Walk(&entry3); |  | 
| 468     CHECK_NE(NULL, node3); |  | 
| 469     CHECK_EQ(2, node3->total_ticks()); |  | 
| 470     CHECK_EQ(1, node3->self_ticks()); |  | 
| 471     ProfileNode* node3_1 = token0_helper.Walk(&entry3, &entry1); |  | 
| 472     CHECK_NE(NULL, node3_1); |  | 
| 473     CHECK_EQ(1, node3_1->total_ticks()); |  | 
| 474     CHECK_EQ(1, node3_1->self_ticks()); |  | 
| 475     CHECK_EQ(NULL, token0_helper.Walk(&entry3, &entry2)); |  | 
| 476   } |  | 
| 477 |  | 
| 478   { |  | 
| 479     ProfileTree token1_tree; |  | 
| 480     token1_tree.FilteredClone(&source_tree, token1); |  | 
| 481     // Should be |  | 
| 482     //            {root,1,4,-1} -> {entry2,2,3,1} -> {entry4,1,1,inherits} |  | 
| 483     // [child nodes referring to the same entry get merged and |  | 
| 484     //  their self times summed up] |  | 
| 485     CHECK_EQ(4, token1_tree.root()->total_ticks()); |  | 
| 486     CHECK_EQ(1, token1_tree.root()->self_ticks()); |  | 
| 487     ProfileTreeTestHelper token1_helper(&token1_tree); |  | 
| 488     CHECK_EQ(NULL, token1_helper.Walk(&entry1)); |  | 
| 489     CHECK_EQ(NULL, token1_helper.Walk(&entry3)); |  | 
| 490     ProfileNode* node2 = token1_helper.Walk(&entry2); |  | 
| 491     CHECK_NE(NULL, node2); |  | 
| 492     CHECK_EQ(3, node2->total_ticks()); |  | 
| 493     CHECK_EQ(2, node2->self_ticks()); |  | 
| 494     ProfileNode* node2_4 = token1_helper.Walk(&entry2, &entry4); |  | 
| 495     CHECK_NE(NULL, node2_4); |  | 
| 496     CHECK_EQ(1, node2_4->total_ticks()); |  | 
| 497     CHECK_EQ(1, node2_4->self_ticks()); |  | 
| 498   } |  | 
| 499 |  | 
| 500   { |  | 
| 501     ProfileTree token2_tree; |  | 
| 502     token2_tree.FilteredClone(&source_tree, token2); |  | 
| 503     // Should be |  | 
| 504     //            {root,4,4,-1} |  | 
| 505     // [no nodes, all ticks get migrated into root node] |  | 
| 506     CHECK_EQ(4, token2_tree.root()->total_ticks()); |  | 
| 507     CHECK_EQ(4, token2_tree.root()->self_ticks()); |  | 
| 508     ProfileTreeTestHelper token2_helper(&token2_tree); |  | 
| 509     CHECK_EQ(NULL, token2_helper.Walk(&entry1)); |  | 
| 510     CHECK_EQ(NULL, token2_helper.Walk(&entry2)); |  | 
| 511     CHECK_EQ(NULL, token2_helper.Walk(&entry3)); |  | 
| 512   } |  | 
| 513 } |  | 
| 514 |  | 
| 515 |  | 
| 516 static inline i::Address ToAddress(int n) { | 378 static inline i::Address ToAddress(int n) { | 
| 517   return reinterpret_cast<i::Address>(n); | 379   return reinterpret_cast<i::Address>(n); | 
| 518 } | 380 } | 
| 519 | 381 | 
| 520 TEST(CodeMapAddCode) { | 382 TEST(CodeMapAddCode) { | 
| 521   CodeMap code_map; | 383   CodeMap code_map; | 
| 522   CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 384   CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 
| 523   CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 385   CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 
| 524   CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 386   CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 
| 525   CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); | 387   CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 615   sample2.frames_count = 3; | 477   sample2.frames_count = 3; | 
| 616   generator.RecordTickSample(sample2); | 478   generator.RecordTickSample(sample2); | 
| 617   TickSample sample3; | 479   TickSample sample3; | 
| 618   sample3.pc = ToAddress(0x1510); | 480   sample3.pc = ToAddress(0x1510); | 
| 619   sample3.tos = ToAddress(0x1500); | 481   sample3.tos = ToAddress(0x1500); | 
| 620   sample3.stack[0] = ToAddress(0x1910); | 482   sample3.stack[0] = ToAddress(0x1910); | 
| 621   sample3.stack[1] = ToAddress(0x1610); | 483   sample3.stack[1] = ToAddress(0x1610); | 
| 622   sample3.frames_count = 2; | 484   sample3.frames_count = 2; | 
| 623   generator.RecordTickSample(sample3); | 485   generator.RecordTickSample(sample3); | 
| 624 | 486 | 
| 625   CpuProfile* profile = | 487   CpuProfile* profile = profiles.StopProfiling("", 1); | 
| 626       profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |  | 
| 627   CHECK_NE(NULL, profile); | 488   CHECK_NE(NULL, profile); | 
| 628   ProfileTreeTestHelper top_down_test_helper(profile->top_down()); | 489   ProfileTreeTestHelper top_down_test_helper(profile->top_down()); | 
| 629   CHECK_EQ(NULL, top_down_test_helper.Walk(entry2)); | 490   CHECK_EQ(NULL, top_down_test_helper.Walk(entry2)); | 
| 630   CHECK_EQ(NULL, top_down_test_helper.Walk(entry3)); | 491   CHECK_EQ(NULL, top_down_test_helper.Walk(entry3)); | 
| 631   ProfileNode* node1 = top_down_test_helper.Walk(entry1); | 492   ProfileNode* node1 = top_down_test_helper.Walk(entry1); | 
| 632   CHECK_NE(NULL, node1); | 493   CHECK_NE(NULL, node1); | 
| 633   CHECK_EQ(entry1, node1->entry()); | 494   CHECK_EQ(entry1, node1->entry()); | 
| 634   ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); | 495   ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); | 
| 635   CHECK_NE(NULL, node2); | 496   CHECK_NE(NULL, node2); | 
| 636   CHECK_EQ(entry1, node2->entry()); | 497   CHECK_EQ(entry1, node2->entry()); | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 728   sample2.stack[2] = ToAddress(0x1620); | 589   sample2.stack[2] = ToAddress(0x1620); | 
| 729   sample2.frames_count = 3; | 590   sample2.frames_count = 3; | 
| 730   generator.RecordTickSample(sample2); | 591   generator.RecordTickSample(sample2); | 
| 731   TickSample sample3; | 592   TickSample sample3; | 
| 732   sample3.pc = ToAddress(0x1510); | 593   sample3.pc = ToAddress(0x1510); | 
| 733   sample3.stack[0] = ToAddress(0x1910); | 594   sample3.stack[0] = ToAddress(0x1910); | 
| 734   sample3.stack[1] = ToAddress(0x1610); | 595   sample3.stack[1] = ToAddress(0x1610); | 
| 735   sample3.frames_count = 2; | 596   sample3.frames_count = 2; | 
| 736   generator.RecordTickSample(sample3); | 597   generator.RecordTickSample(sample3); | 
| 737 | 598 | 
| 738   CpuProfile* profile = | 599   CpuProfile* profile = profiles.StopProfiling("", 1); | 
| 739       profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |  | 
| 740   int nodeId = 1; | 600   int nodeId = 1; | 
| 741   CheckNodeIds(profile->top_down()->root(), &nodeId); | 601   CheckNodeIds(profile->top_down()->root(), &nodeId); | 
| 742   CHECK_EQ(7, nodeId - 1); | 602   CHECK_EQ(7, nodeId - 1); | 
| 743 | 603 | 
| 744   CHECK_EQ(3, profile->samples_count()); | 604   CHECK_EQ(3, profile->samples_count()); | 
| 745   int expected_id[] = {3, 5, 7}; | 605   int expected_id[] = {3, 5, 7}; | 
| 746   for (int i = 0; i < 3; i++) { | 606   for (int i = 0; i < 3; i++) { | 
| 747     CHECK_EQ(expected_id[i], profile->sample(i)->id()); | 607     CHECK_EQ(expected_id[i], profile->sample(i)->id()); | 
| 748   } | 608   } | 
| 749 } | 609 } | 
| 750 | 610 | 
| 751 | 611 | 
| 752 TEST(NoSamples) { | 612 TEST(NoSamples) { | 
| 753   TestSetup test_setup; | 613   TestSetup test_setup; | 
| 754   CpuProfilesCollection profiles; | 614   CpuProfilesCollection profiles; | 
| 755   profiles.StartProfiling("", 1, false); | 615   profiles.StartProfiling("", 1, false); | 
| 756   ProfileGenerator generator(&profiles); | 616   ProfileGenerator generator(&profiles); | 
| 757   CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 617   CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 
| 758   generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 618   generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 
| 759 | 619 | 
| 760   // We are building the following calls tree: | 620   // We are building the following calls tree: | 
| 761   // (root)#1 -> aaa #2 -> aaa #3 - sample1 | 621   // (root)#1 -> aaa #2 -> aaa #3 - sample1 | 
| 762   TickSample sample1; | 622   TickSample sample1; | 
| 763   sample1.pc = ToAddress(0x1600); | 623   sample1.pc = ToAddress(0x1600); | 
| 764   sample1.stack[0] = ToAddress(0x1510); | 624   sample1.stack[0] = ToAddress(0x1510); | 
| 765   sample1.frames_count = 1; | 625   sample1.frames_count = 1; | 
| 766   generator.RecordTickSample(sample1); | 626   generator.RecordTickSample(sample1); | 
| 767 | 627 | 
| 768   CpuProfile* profile = | 628   CpuProfile* profile = profiles.StopProfiling("", 1); | 
| 769       profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |  | 
| 770   int nodeId = 1; | 629   int nodeId = 1; | 
| 771   CheckNodeIds(profile->top_down()->root(), &nodeId); | 630   CheckNodeIds(profile->top_down()->root(), &nodeId); | 
| 772   CHECK_EQ(3, nodeId - 1); | 631   CHECK_EQ(3, nodeId - 1); | 
| 773 | 632 | 
| 774   CHECK_EQ(0, profile->samples_count()); | 633   CHECK_EQ(0, profile->samples_count()); | 
| 775 } | 634 } | 
| 776 | 635 | 
| 777 | 636 | 
| 778 // --- P r o f i l e r   E x t e n s i o n --- | 637 // --- P r o f i l e r   E x t e n s i o n --- | 
| 779 | 638 | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 853 | 712 | 
| 854   CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); | 713   CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); | 
| 855   CHECK_EQ(0, profiler->GetProfilesCount()); | 714   CHECK_EQ(0, profiler->GetProfilesCount()); | 
| 856   CompileRun( | 715   CompileRun( | 
| 857       "function c() { startProfiling(); }\n" | 716       "function c() { startProfiling(); }\n" | 
| 858       "function b() { c(); }\n" | 717       "function b() { c(); }\n" | 
| 859       "function a() { b(); }\n" | 718       "function a() { b(); }\n" | 
| 860       "a();\n" | 719       "a();\n" | 
| 861       "stopProfiling();"); | 720       "stopProfiling();"); | 
| 862   CHECK_EQ(1, profiler->GetProfilesCount()); | 721   CHECK_EQ(1, profiler->GetProfilesCount()); | 
| 863   CpuProfile* profile = profiler->GetProfile(NULL, 0); | 722   CpuProfile* profile = profiler->GetProfile(0); | 
| 864   const ProfileTree* topDown = profile->top_down(); | 723   const ProfileTree* topDown = profile->top_down(); | 
| 865   const ProfileNode* current = topDown->root(); | 724   const ProfileNode* current = topDown->root(); | 
| 866   const_cast<ProfileNode*>(current)->Print(0); | 725   const_cast<ProfileNode*>(current)->Print(0); | 
| 867   // The tree should look like this: | 726   // The tree should look like this: | 
| 868   //  (root) | 727   //  (root) | 
| 869   //   (anonymous function) | 728   //   (anonymous function) | 
| 870   //     a | 729   //     a | 
| 871   //       b | 730   //       b | 
| 872   //         c | 731   //         c | 
| 873   // There can also be: | 732   // There can also be: | 
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 958   current = PickChild(current, "b"); | 817   current = PickChild(current, "b"); | 
| 959   CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 818   CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 
| 960   CHECK_EQ(script_b->GetId(), current->GetScriptId()); | 819   CHECK_EQ(script_b->GetId(), current->GetScriptId()); | 
| 961 | 820 | 
| 962   current = PickChild(current, "a"); | 821   current = PickChild(current, "a"); | 
| 963   CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 822   CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 
| 964   CHECK_EQ(script_a->GetId(), current->GetScriptId()); | 823   CHECK_EQ(script_a->GetId(), current->GetScriptId()); | 
| 965 } | 824 } | 
| 966 | 825 | 
| 967 | 826 | 
| OLD | NEW | 
|---|