| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 using i::ProfileTree; | 44 using i::ProfileTree; |
| 45 using i::ProfileGenerator; | 45 using i::ProfileGenerator; |
| 46 using i::TickSample; | 46 using i::TickSample; |
| 47 using i::Vector; | 47 using i::Vector; |
| 48 | 48 |
| 49 | 49 |
| 50 TEST(ProfileNodeFindOrAddChild) { | 50 TEST(ProfileNodeFindOrAddChild) { |
| 51 CcTest::InitializeVM(); | 51 CcTest::InitializeVM(); |
| 52 ProfileTree tree(CcTest::i_isolate()); | 52 ProfileTree tree(CcTest::i_isolate()); |
| 53 ProfileNode* node = tree.root(); | 53 ProfileNode* node = tree.root(); |
| 54 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 54 CodeEntry entry1(i::CodeEventListener::FUNCTION_TAG, "aaa"); |
| 55 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); | 55 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); |
| 56 CHECK(childNode1); | 56 CHECK(childNode1); |
| 57 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); | 57 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
| 58 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 58 CodeEntry entry2(i::CodeEventListener::FUNCTION_TAG, "bbb"); |
| 59 ProfileNode* childNode2 = node->FindOrAddChild(&entry2); | 59 ProfileNode* childNode2 = node->FindOrAddChild(&entry2); |
| 60 CHECK(childNode2); | 60 CHECK(childNode2); |
| 61 CHECK_NE(childNode1, childNode2); | 61 CHECK_NE(childNode1, childNode2); |
| 62 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); | 62 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
| 63 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); | 63 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); |
| 64 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 64 CodeEntry entry3(i::CodeEventListener::FUNCTION_TAG, "ccc"); |
| 65 ProfileNode* childNode3 = node->FindOrAddChild(&entry3); | 65 ProfileNode* childNode3 = node->FindOrAddChild(&entry3); |
| 66 CHECK(childNode3); | 66 CHECK(childNode3); |
| 67 CHECK_NE(childNode1, childNode3); | 67 CHECK_NE(childNode1, childNode3); |
| 68 CHECK_NE(childNode2, childNode3); | 68 CHECK_NE(childNode2, childNode3); |
| 69 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); | 69 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
| 70 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); | 70 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); |
| 71 CHECK_EQ(childNode3, node->FindOrAddChild(&entry3)); | 71 CHECK_EQ(childNode3, node->FindOrAddChild(&entry3)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 TEST(ProfileNodeFindOrAddChildForSameFunction) { | 75 TEST(ProfileNodeFindOrAddChildForSameFunction) { |
| 76 CcTest::InitializeVM(); | 76 CcTest::InitializeVM(); |
| 77 const char* aaa = "aaa"; | 77 const char* aaa = "aaa"; |
| 78 ProfileTree tree(CcTest::i_isolate()); | 78 ProfileTree tree(CcTest::i_isolate()); |
| 79 ProfileNode* node = tree.root(); | 79 ProfileNode* node = tree.root(); |
| 80 CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa); | 80 CodeEntry entry1(i::CodeEventListener::FUNCTION_TAG, aaa); |
| 81 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); | 81 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); |
| 82 CHECK(childNode1); | 82 CHECK(childNode1); |
| 83 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); | 83 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
| 84 // The same function again. | 84 // The same function again. |
| 85 CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa); | 85 CodeEntry entry2(i::CodeEventListener::FUNCTION_TAG, aaa); |
| 86 CHECK_EQ(childNode1, node->FindOrAddChild(&entry2)); | 86 CHECK_EQ(childNode1, node->FindOrAddChild(&entry2)); |
| 87 // Now with a different security token. | 87 // Now with a different security token. |
| 88 CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa); | 88 CodeEntry entry3(i::CodeEventListener::FUNCTION_TAG, aaa); |
| 89 CHECK_EQ(childNode1, node->FindOrAddChild(&entry3)); | 89 CHECK_EQ(childNode1, node->FindOrAddChild(&entry3)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 namespace { | 93 namespace { |
| 94 | 94 |
| 95 class ProfileTreeTestHelper { | 95 class ProfileTreeTestHelper { |
| 96 public: | 96 public: |
| 97 explicit ProfileTreeTestHelper(const ProfileTree* tree) | 97 explicit ProfileTreeTestHelper(const ProfileTree* tree) |
| 98 : tree_(tree) { } | 98 : tree_(tree) { } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 const ProfileTree* tree_; | 117 const ProfileTree* tree_; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace | 120 } // namespace |
| 121 | 121 |
| 122 | 122 |
| 123 TEST(ProfileTreeAddPathFromEnd) { | 123 TEST(ProfileTreeAddPathFromEnd) { |
| 124 CcTest::InitializeVM(); | 124 CcTest::InitializeVM(); |
| 125 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 125 CodeEntry entry1(i::CodeEventListener::FUNCTION_TAG, "aaa"); |
| 126 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 126 CodeEntry entry2(i::CodeEventListener::FUNCTION_TAG, "bbb"); |
| 127 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 127 CodeEntry entry3(i::CodeEventListener::FUNCTION_TAG, "ccc"); |
| 128 ProfileTree tree(CcTest::i_isolate()); | 128 ProfileTree tree(CcTest::i_isolate()); |
| 129 ProfileTreeTestHelper helper(&tree); | 129 ProfileTreeTestHelper helper(&tree); |
| 130 CHECK(!helper.Walk(&entry1)); | 130 CHECK(!helper.Walk(&entry1)); |
| 131 CHECK(!helper.Walk(&entry2)); | 131 CHECK(!helper.Walk(&entry2)); |
| 132 CHECK(!helper.Walk(&entry3)); | 132 CHECK(!helper.Walk(&entry3)); |
| 133 | 133 |
| 134 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; | 134 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; |
| 135 std::vector<CodeEntry*> path_vec(path, path + arraysize(path)); | 135 std::vector<CodeEntry*> path_vec(path, path + arraysize(path)); |
| 136 tree.AddPathFromEnd(path_vec); | 136 tree.AddPathFromEnd(path_vec); |
| 137 CHECK(!helper.Walk(&entry2)); | 137 CHECK(!helper.Walk(&entry2)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 TEST(ProfileTreeCalculateTotalTicks) { | 183 TEST(ProfileTreeCalculateTotalTicks) { |
| 184 CcTest::InitializeVM(); | 184 CcTest::InitializeVM(); |
| 185 ProfileTree empty_tree(CcTest::i_isolate()); | 185 ProfileTree empty_tree(CcTest::i_isolate()); |
| 186 CHECK_EQ(0u, empty_tree.root()->self_ticks()); | 186 CHECK_EQ(0u, empty_tree.root()->self_ticks()); |
| 187 empty_tree.root()->IncrementSelfTicks(); | 187 empty_tree.root()->IncrementSelfTicks(); |
| 188 CHECK_EQ(1u, empty_tree.root()->self_ticks()); | 188 CHECK_EQ(1u, empty_tree.root()->self_ticks()); |
| 189 | 189 |
| 190 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 190 CodeEntry entry1(i::CodeEventListener::FUNCTION_TAG, "aaa"); |
| 191 CodeEntry* e1_path[] = {&entry1}; | 191 CodeEntry* e1_path[] = {&entry1}; |
| 192 std::vector<CodeEntry*> e1_path_vec(e1_path, e1_path + arraysize(e1_path)); | 192 std::vector<CodeEntry*> e1_path_vec(e1_path, e1_path + arraysize(e1_path)); |
| 193 | 193 |
| 194 ProfileTree single_child_tree(CcTest::i_isolate()); | 194 ProfileTree single_child_tree(CcTest::i_isolate()); |
| 195 single_child_tree.AddPathFromEnd(e1_path_vec); | 195 single_child_tree.AddPathFromEnd(e1_path_vec); |
| 196 single_child_tree.root()->IncrementSelfTicks(); | 196 single_child_tree.root()->IncrementSelfTicks(); |
| 197 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); | 197 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); |
| 198 ProfileTreeTestHelper single_child_helper(&single_child_tree); | 198 ProfileTreeTestHelper single_child_helper(&single_child_tree); |
| 199 ProfileNode* node1 = single_child_helper.Walk(&entry1); | 199 ProfileNode* node1 = single_child_helper.Walk(&entry1); |
| 200 CHECK(node1); | 200 CHECK(node1); |
| 201 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); | 201 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); |
| 202 CHECK_EQ(1u, node1->self_ticks()); | 202 CHECK_EQ(1u, node1->self_ticks()); |
| 203 | 203 |
| 204 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 204 CodeEntry entry2(i::CodeEventListener::FUNCTION_TAG, "bbb"); |
| 205 CodeEntry* e2_e1_path[] = {&entry2, &entry1}; | 205 CodeEntry* e2_e1_path[] = {&entry2, &entry1}; |
| 206 std::vector<CodeEntry*> e2_e1_path_vec(e2_e1_path, | 206 std::vector<CodeEntry*> e2_e1_path_vec(e2_e1_path, |
| 207 e2_e1_path + arraysize(e2_e1_path)); | 207 e2_e1_path + arraysize(e2_e1_path)); |
| 208 | 208 |
| 209 ProfileTree flat_tree(CcTest::i_isolate()); | 209 ProfileTree flat_tree(CcTest::i_isolate()); |
| 210 ProfileTreeTestHelper flat_helper(&flat_tree); | 210 ProfileTreeTestHelper flat_helper(&flat_tree); |
| 211 flat_tree.AddPathFromEnd(e1_path_vec); | 211 flat_tree.AddPathFromEnd(e1_path_vec); |
| 212 flat_tree.AddPathFromEnd(e1_path_vec); | 212 flat_tree.AddPathFromEnd(e1_path_vec); |
| 213 flat_tree.AddPathFromEnd(e2_e1_path_vec); | 213 flat_tree.AddPathFromEnd(e2_e1_path_vec); |
| 214 flat_tree.AddPathFromEnd(e2_e1_path_vec); | 214 flat_tree.AddPathFromEnd(e2_e1_path_vec); |
| 215 flat_tree.AddPathFromEnd(e2_e1_path_vec); | 215 flat_tree.AddPathFromEnd(e2_e1_path_vec); |
| 216 // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3} | 216 // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3} |
| 217 CHECK_EQ(0u, flat_tree.root()->self_ticks()); | 217 CHECK_EQ(0u, flat_tree.root()->self_ticks()); |
| 218 node1 = flat_helper.Walk(&entry1); | 218 node1 = flat_helper.Walk(&entry1); |
| 219 CHECK(node1); | 219 CHECK(node1); |
| 220 CHECK_EQ(2u, node1->self_ticks()); | 220 CHECK_EQ(2u, node1->self_ticks()); |
| 221 ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2); | 221 ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2); |
| 222 CHECK(node2); | 222 CHECK(node2); |
| 223 CHECK_EQ(3u, node2->self_ticks()); | 223 CHECK_EQ(3u, node2->self_ticks()); |
| 224 // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3} | 224 // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3} |
| 225 CHECK_EQ(0u, flat_tree.root()->self_ticks()); | 225 CHECK_EQ(0u, flat_tree.root()->self_ticks()); |
| 226 CHECK_EQ(2u, node1->self_ticks()); | 226 CHECK_EQ(2u, node1->self_ticks()); |
| 227 | 227 |
| 228 CodeEntry* e2_path[] = {&entry2}; | 228 CodeEntry* e2_path[] = {&entry2}; |
| 229 std::vector<CodeEntry*> e2_path_vec(e2_path, e2_path + arraysize(e2_path)); | 229 std::vector<CodeEntry*> e2_path_vec(e2_path, e2_path + arraysize(e2_path)); |
| 230 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 230 CodeEntry entry3(i::CodeEventListener::FUNCTION_TAG, "ccc"); |
| 231 CodeEntry* e3_path[] = {&entry3}; | 231 CodeEntry* e3_path[] = {&entry3}; |
| 232 std::vector<CodeEntry*> e3_path_vec(e3_path, e3_path + arraysize(e3_path)); | 232 std::vector<CodeEntry*> e3_path_vec(e3_path, e3_path + arraysize(e3_path)); |
| 233 | 233 |
| 234 ProfileTree wide_tree(CcTest::i_isolate()); | 234 ProfileTree wide_tree(CcTest::i_isolate()); |
| 235 ProfileTreeTestHelper wide_helper(&wide_tree); | 235 ProfileTreeTestHelper wide_helper(&wide_tree); |
| 236 wide_tree.AddPathFromEnd(e1_path_vec); | 236 wide_tree.AddPathFromEnd(e1_path_vec); |
| 237 wide_tree.AddPathFromEnd(e1_path_vec); | 237 wide_tree.AddPathFromEnd(e1_path_vec); |
| 238 wide_tree.AddPathFromEnd(e2_e1_path_vec); | 238 wide_tree.AddPathFromEnd(e2_e1_path_vec); |
| 239 wide_tree.AddPathFromEnd(e2_path_vec); | 239 wide_tree.AddPathFromEnd(e2_path_vec); |
| 240 wide_tree.AddPathFromEnd(e2_path_vec); | 240 wide_tree.AddPathFromEnd(e2_path_vec); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 270 } | 270 } |
| 271 | 271 |
| 272 | 272 |
| 273 static inline i::Address ToAddress(int n) { | 273 static inline i::Address ToAddress(int n) { |
| 274 return reinterpret_cast<i::Address>(n); | 274 return reinterpret_cast<i::Address>(n); |
| 275 } | 275 } |
| 276 | 276 |
| 277 | 277 |
| 278 TEST(CodeMapAddCode) { | 278 TEST(CodeMapAddCode) { |
| 279 CodeMap code_map; | 279 CodeMap code_map; |
| 280 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 280 CodeEntry entry1(i::CodeEventListener::FUNCTION_TAG, "aaa"); |
| 281 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 281 CodeEntry entry2(i::CodeEventListener::FUNCTION_TAG, "bbb"); |
| 282 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 282 CodeEntry entry3(i::CodeEventListener::FUNCTION_TAG, "ccc"); |
| 283 CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); | 283 CodeEntry entry4(i::CodeEventListener::FUNCTION_TAG, "ddd"); |
| 284 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 284 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
| 285 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 285 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
| 286 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); | 286 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); |
| 287 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); | 287 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); |
| 288 CHECK(!code_map.FindEntry(0)); | 288 CHECK(!code_map.FindEntry(0)); |
| 289 CHECK(!code_map.FindEntry(ToAddress(0x1500 - 1))); | 289 CHECK(!code_map.FindEntry(ToAddress(0x1500 - 1))); |
| 290 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 290 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
| 291 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); | 291 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); |
| 292 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); | 292 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); |
| 293 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 293 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
| 294 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); | 294 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); |
| 295 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); | 295 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); |
| 296 CHECK(!code_map.FindEntry(ToAddress(0x1700 + 0x100))); | 296 CHECK(!code_map.FindEntry(ToAddress(0x1700 + 0x100))); |
| 297 CHECK(!code_map.FindEntry(ToAddress(0x1900 - 1))); | 297 CHECK(!code_map.FindEntry(ToAddress(0x1900 - 1))); |
| 298 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); | 298 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); |
| 299 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); | 299 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); |
| 300 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); | 300 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); |
| 301 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); | 301 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); |
| 302 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); | 302 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); |
| 303 CHECK(!code_map.FindEntry(ToAddress(0x1950 + 0x10))); | 303 CHECK(!code_map.FindEntry(ToAddress(0x1950 + 0x10))); |
| 304 CHECK(!code_map.FindEntry(ToAddress(0xFFFFFFFF))); | 304 CHECK(!code_map.FindEntry(ToAddress(0xFFFFFFFF))); |
| 305 } | 305 } |
| 306 | 306 |
| 307 | 307 |
| 308 TEST(CodeMapMoveAndDeleteCode) { | 308 TEST(CodeMapMoveAndDeleteCode) { |
| 309 CodeMap code_map; | 309 CodeMap code_map; |
| 310 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 310 CodeEntry entry1(i::CodeEventListener::FUNCTION_TAG, "aaa"); |
| 311 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 311 CodeEntry entry2(i::CodeEventListener::FUNCTION_TAG, "bbb"); |
| 312 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 312 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
| 313 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 313 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
| 314 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 314 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
| 315 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 315 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
| 316 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. | 316 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. |
| 317 CHECK(!code_map.FindEntry(ToAddress(0x1500))); | 317 CHECK(!code_map.FindEntry(ToAddress(0x1500))); |
| 318 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); | 318 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); |
| 319 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 319 CodeEntry entry3(i::CodeEventListener::FUNCTION_TAG, "ccc"); |
| 320 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); | 320 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); |
| 321 CHECK(!code_map.FindEntry(ToAddress(0x1700))); | 321 CHECK(!code_map.FindEntry(ToAddress(0x1700))); |
| 322 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); | 322 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); |
| 323 } | 323 } |
| 324 | 324 |
| 325 | 325 |
| 326 namespace { | 326 namespace { |
| 327 | 327 |
| 328 class TestSetup { | 328 class TestSetup { |
| 329 public: | 329 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 340 bool old_flag_prof_browser_mode_; | 340 bool old_flag_prof_browser_mode_; |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 } // namespace | 343 } // namespace |
| 344 | 344 |
| 345 TEST(RecordTickSample) { | 345 TEST(RecordTickSample) { |
| 346 TestSetup test_setup; | 346 TestSetup test_setup; |
| 347 CpuProfilesCollection profiles(CcTest::heap()); | 347 CpuProfilesCollection profiles(CcTest::heap()); |
| 348 profiles.StartProfiling("", false); | 348 profiles.StartProfiling("", false); |
| 349 ProfileGenerator generator(&profiles); | 349 ProfileGenerator generator(&profiles); |
| 350 CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 350 CodeEntry* entry1 = |
| 351 CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); | 351 profiles.NewCodeEntry(i::CodeEventListener::FUNCTION_TAG, "aaa"); |
| 352 CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); | 352 CodeEntry* entry2 = |
| 353 profiles.NewCodeEntry(i::CodeEventListener::FUNCTION_TAG, "bbb"); |
| 354 CodeEntry* entry3 = |
| 355 profiles.NewCodeEntry(i::CodeEventListener::FUNCTION_TAG, "ccc"); |
| 353 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 356 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 354 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); | 357 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); |
| 355 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); | 358 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); |
| 356 | 359 |
| 357 // We are building the following calls tree: | 360 // We are building the following calls tree: |
| 358 // -> aaa - sample1 | 361 // -> aaa - sample1 |
| 359 // aaa -> bbb -> ccc - sample2 | 362 // aaa -> bbb -> ccc - sample2 |
| 360 // -> ccc -> aaa - sample3 | 363 // -> ccc -> aaa - sample3 |
| 361 TickSample sample1; | 364 TickSample sample1; |
| 362 sample1.pc = ToAddress(0x1600); | 365 sample1.pc = ToAddress(0x1600); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 CheckNodeIds(node->children()->at(i), expectedId); | 409 CheckNodeIds(node->children()->at(i), expectedId); |
| 407 } | 410 } |
| 408 } | 411 } |
| 409 | 412 |
| 410 | 413 |
| 411 TEST(SampleIds) { | 414 TEST(SampleIds) { |
| 412 TestSetup test_setup; | 415 TestSetup test_setup; |
| 413 CpuProfilesCollection profiles(CcTest::heap()); | 416 CpuProfilesCollection profiles(CcTest::heap()); |
| 414 profiles.StartProfiling("", true); | 417 profiles.StartProfiling("", true); |
| 415 ProfileGenerator generator(&profiles); | 418 ProfileGenerator generator(&profiles); |
| 416 CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 419 CodeEntry* entry1 = |
| 417 CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); | 420 profiles.NewCodeEntry(i::CodeEventListener::FUNCTION_TAG, "aaa"); |
| 418 CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); | 421 CodeEntry* entry2 = |
| 422 profiles.NewCodeEntry(i::CodeEventListener::FUNCTION_TAG, "bbb"); |
| 423 CodeEntry* entry3 = |
| 424 profiles.NewCodeEntry(i::CodeEventListener::FUNCTION_TAG, "ccc"); |
| 419 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 425 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 420 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); | 426 generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); |
| 421 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); | 427 generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); |
| 422 | 428 |
| 423 // We are building the following calls tree: | 429 // We are building the following calls tree: |
| 424 // -> aaa #3 - sample1 | 430 // -> aaa #3 - sample1 |
| 425 // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2 | 431 // (root)#1 -> aaa #2 -> bbb #4 -> ccc #5 - sample2 |
| 426 // -> ccc #6 -> aaa #7 - sample3 | 432 // -> ccc #6 -> aaa #7 - sample3 |
| 427 TickSample sample1; | 433 TickSample sample1; |
| 428 sample1.timestamp = v8::base::TimeTicks::HighResolutionNow(); | 434 sample1.timestamp = v8::base::TimeTicks::HighResolutionNow(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 457 CHECK_EQ(expected_id[i], profile->sample(i)->id()); | 463 CHECK_EQ(expected_id[i], profile->sample(i)->id()); |
| 458 } | 464 } |
| 459 } | 465 } |
| 460 | 466 |
| 461 | 467 |
| 462 TEST(NoSamples) { | 468 TEST(NoSamples) { |
| 463 TestSetup test_setup; | 469 TestSetup test_setup; |
| 464 CpuProfilesCollection profiles(CcTest::heap()); | 470 CpuProfilesCollection profiles(CcTest::heap()); |
| 465 profiles.StartProfiling("", false); | 471 profiles.StartProfiling("", false); |
| 466 ProfileGenerator generator(&profiles); | 472 ProfileGenerator generator(&profiles); |
| 467 CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 473 CodeEntry* entry1 = |
| 474 profiles.NewCodeEntry(i::CodeEventListener::FUNCTION_TAG, "aaa"); |
| 468 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 475 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
| 469 | 476 |
| 470 // We are building the following calls tree: | 477 // We are building the following calls tree: |
| 471 // (root)#1 -> aaa #2 -> aaa #3 - sample1 | 478 // (root)#1 -> aaa #2 -> aaa #3 - sample1 |
| 472 TickSample sample1; | 479 TickSample sample1; |
| 473 sample1.pc = ToAddress(0x1600); | 480 sample1.pc = ToAddress(0x1600); |
| 474 sample1.stack[0] = ToAddress(0x1510); | 481 sample1.stack[0] = ToAddress(0x1510); |
| 475 sample1.frames_count = 1; | 482 sample1.frames_count = 1; |
| 476 generator.RecordTickSample(sample1); | 483 generator.RecordTickSample(sample1); |
| 477 | 484 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 // (root) | 718 // (root) |
| 712 // "" | 719 // "" |
| 713 // kDebuggerStatement | 720 // kDebuggerStatement |
| 714 current = PickChild(current, ""); | 721 current = PickChild(current, ""); |
| 715 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 722 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 716 | 723 |
| 717 current = PickChild(current, "Debugger"); | 724 current = PickChild(current, "Debugger"); |
| 718 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 725 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 719 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); | 726 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); |
| 720 } | 727 } |
| OLD | NEW |