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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 CHECK_EQ(NULL, token2_helper.Walk(&entry2)); | 510 CHECK_EQ(NULL, token2_helper.Walk(&entry2)); |
511 CHECK_EQ(NULL, token2_helper.Walk(&entry3)); | 511 CHECK_EQ(NULL, token2_helper.Walk(&entry3)); |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 | 515 |
516 static inline i::Address ToAddress(int n) { | 516 static inline i::Address ToAddress(int n) { |
517 return reinterpret_cast<i::Address>(n); | 517 return reinterpret_cast<i::Address>(n); |
518 } | 518 } |
519 | 519 |
| 520 |
520 TEST(CodeMapAddCode) { | 521 TEST(CodeMapAddCode) { |
521 CodeMap code_map; | 522 CodeMap code_map; |
522 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 523 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
523 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 524 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
524 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 525 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
525 CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); | 526 CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); |
526 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 527 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
527 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 528 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
528 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); | 529 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); |
529 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); | 530 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 } | 694 } |
694 | 695 |
695 | 696 |
696 static void CheckNodeIds(ProfileNode* node, int* expectedId) { | 697 static void CheckNodeIds(ProfileNode* node, int* expectedId) { |
697 CHECK_EQ((*expectedId)++, node->id()); | 698 CHECK_EQ((*expectedId)++, node->id()); |
698 for (int i = 0; i < node->children()->length(); i++) { | 699 for (int i = 0; i < node->children()->length(); i++) { |
699 CheckNodeIds(node->children()->at(i), expectedId); | 700 CheckNodeIds(node->children()->at(i), expectedId); |
700 } | 701 } |
701 } | 702 } |
702 | 703 |
| 704 |
703 TEST(SampleIds) { | 705 TEST(SampleIds) { |
704 TestSetup test_setup; | 706 TestSetup test_setup; |
705 CpuProfilesCollection profiles; | 707 CpuProfilesCollection profiles; |
706 profiles.StartProfiling("", 1, true); | 708 profiles.StartProfiling("", 1, true); |
707 ProfileGenerator generator(&profiles); | 709 ProfileGenerator generator(&profiles); |
708 CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 710 CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
709 CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); | 711 CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); |
710 CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); | 712 CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); |
711 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 713 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
712 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); | 714 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 current = PickChild(current, "b"); | 960 current = PickChild(current, "b"); |
959 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 961 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
960 CHECK_EQ(script_b->GetId(), current->GetScriptId()); | 962 CHECK_EQ(script_b->GetId(), current->GetScriptId()); |
961 | 963 |
962 current = PickChild(current, "a"); | 964 current = PickChild(current, "a"); |
963 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 965 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
964 CHECK_EQ(script_a->GetId(), current->GetScriptId()); | 966 CHECK_EQ(script_a->GetId(), current->GetScriptId()); |
965 } | 967 } |
966 | 968 |
967 | 969 |
OLD | NEW |