| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests of profiles generator and utilities. | 3 // Tests of profiles generator and utilities. |
| 4 | 4 |
| 5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 6 | 6 |
| 7 #include "v8.h" | 7 #include "v8.h" |
| 8 #include "profile-generator-inl.h" | 8 #include "profile-generator-inl.h" |
| 9 #include "cctest.h" | 9 #include "cctest.h" |
| 10 #include "../include/v8-profiler.h" | 10 #include "../include/v8-profiler.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 public: | 32 public: |
| 33 static i::List<bool>* token_removed(TokenEnumerator* te) { | 33 static i::List<bool>* token_removed(TokenEnumerator* te) { |
| 34 return &te->token_removed_; | 34 return &te->token_removed_; |
| 35 } | 35 } |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 } } // namespace v8::internal | 38 } } // namespace v8::internal |
| 39 | 39 |
| 40 TEST(TokenEnumerator) { | 40 TEST(TokenEnumerator) { |
| 41 TokenEnumerator te; | 41 TokenEnumerator te; |
| 42 CHECK_EQ(CodeEntry::kNoSecurityToken, te.GetTokenId(NULL)); | 42 CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL)); |
| 43 v8::HandleScope hs; | 43 v8::HandleScope hs; |
| 44 v8::Local<v8::String> token1(v8::String::New("1")); | 44 v8::Local<v8::String> token1(v8::String::New("1")); |
| 45 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 45 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 46 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 46 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 47 v8::Local<v8::String> token2(v8::String::New("2")); | 47 v8::Local<v8::String> token2(v8::String::New("2")); |
| 48 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 48 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
| 49 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 49 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
| 50 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 50 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 51 { | 51 { |
| 52 v8::HandleScope hs; | 52 v8::HandleScope hs; |
| 53 v8::Local<v8::String> token3(v8::String::New("3")); | 53 v8::Local<v8::String> token3(v8::String::New("3")); |
| 54 CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); | 54 CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); |
| 55 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 55 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
| 56 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 56 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 57 } | 57 } |
| 58 CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); | 58 CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
| 59 i::Heap::CollectAllGarbage(false); | 59 i::Heap::CollectAllGarbage(false); |
| 60 CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); | 60 CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
| 61 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 61 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
| 62 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 62 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 TEST(ProfileNodeFindOrAddChild) { | 66 TEST(ProfileNodeFindOrAddChild) { |
| 67 ProfileNode node(NULL, NULL); | 67 ProfileNode node(NULL, NULL); |
| 68 CodeEntry entry1( | 68 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 69 i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken); | 69 TokenEnumerator::kNoSecurityToken); |
| 70 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 70 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); |
| 71 CHECK_NE(NULL, childNode1); | 71 CHECK_NE(NULL, childNode1); |
| 72 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 72 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
| 73 CodeEntry entry2( | 73 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 74 i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken); | 74 TokenEnumerator::kNoSecurityToken); |
| 75 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); | 75 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); |
| 76 CHECK_NE(NULL, childNode2); | 76 CHECK_NE(NULL, childNode2); |
| 77 CHECK_NE(childNode1, childNode2); | 77 CHECK_NE(childNode1, childNode2); |
| 78 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 78 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
| 79 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 79 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
| 80 CodeEntry entry3( | 80 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 81 i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken); | 81 TokenEnumerator::kNoSecurityToken); |
| 82 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); | 82 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); |
| 83 CHECK_NE(NULL, childNode3); | 83 CHECK_NE(NULL, childNode3); |
| 84 CHECK_NE(childNode1, childNode3); | 84 CHECK_NE(childNode1, childNode3); |
| 85 CHECK_NE(childNode2, childNode3); | 85 CHECK_NE(childNode2, childNode3); |
| 86 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 86 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
| 87 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 87 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
| 88 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); | 88 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 | 91 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 112 return node; | 112 return node; |
| 113 } | 113 } |
| 114 | 114 |
| 115 private: | 115 private: |
| 116 const ProfileTree* tree_; | 116 const ProfileTree* tree_; |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 } // namespace | 119 } // namespace |
| 120 | 120 |
| 121 TEST(ProfileTreeAddPathFromStart) { | 121 TEST(ProfileTreeAddPathFromStart) { |
| 122 CodeEntry entry1( | 122 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 123 i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken); | 123 TokenEnumerator::kNoSecurityToken); |
| 124 CodeEntry entry2( | 124 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 125 i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken); | 125 TokenEnumerator::kNoSecurityToken); |
| 126 CodeEntry entry3( | 126 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 127 i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken); | 127 TokenEnumerator::kNoSecurityToken); |
| 128 ProfileTree tree; | 128 ProfileTree tree; |
| 129 ProfileTreeTestHelper helper(&tree); | 129 ProfileTreeTestHelper helper(&tree); |
| 130 CHECK_EQ(NULL, helper.Walk(&entry1)); | 130 CHECK_EQ(NULL, helper.Walk(&entry1)); |
| 131 CHECK_EQ(NULL, helper.Walk(&entry2)); | 131 CHECK_EQ(NULL, helper.Walk(&entry2)); |
| 132 CHECK_EQ(NULL, helper.Walk(&entry3)); | 132 CHECK_EQ(NULL, helper.Walk(&entry3)); |
| 133 | 133 |
| 134 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; | 134 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; |
| 135 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 135 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
| 136 tree.AddPathFromStart(path_vec); | 136 tree.AddPathFromStart(path_vec); |
| 137 CHECK_EQ(NULL, helper.Walk(&entry2)); | 137 CHECK_EQ(NULL, helper.Walk(&entry2)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 CHECK_EQ(2, node3->self_ticks()); | 182 CHECK_EQ(2, node3->self_ticks()); |
| 183 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); | 183 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); |
| 184 CHECK_NE(NULL, node4); | 184 CHECK_NE(NULL, node4); |
| 185 CHECK_NE(node3, node4); | 185 CHECK_NE(node3, node4); |
| 186 CHECK_EQ(0, node4->total_ticks()); | 186 CHECK_EQ(0, node4->total_ticks()); |
| 187 CHECK_EQ(1, node4->self_ticks()); | 187 CHECK_EQ(1, node4->self_ticks()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 | 190 |
| 191 TEST(ProfileTreeAddPathFromEnd) { | 191 TEST(ProfileTreeAddPathFromEnd) { |
| 192 CodeEntry entry1( | 192 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 193 i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken); | 193 TokenEnumerator::kNoSecurityToken); |
| 194 CodeEntry entry2( | 194 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 195 i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken); | 195 TokenEnumerator::kNoSecurityToken); |
| 196 CodeEntry entry3( | 196 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 197 i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken); | 197 TokenEnumerator::kNoSecurityToken); |
| 198 ProfileTree tree; | 198 ProfileTree tree; |
| 199 ProfileTreeTestHelper helper(&tree); | 199 ProfileTreeTestHelper helper(&tree); |
| 200 CHECK_EQ(NULL, helper.Walk(&entry1)); | 200 CHECK_EQ(NULL, helper.Walk(&entry1)); |
| 201 CHECK_EQ(NULL, helper.Walk(&entry2)); | 201 CHECK_EQ(NULL, helper.Walk(&entry2)); |
| 202 CHECK_EQ(NULL, helper.Walk(&entry3)); | 202 CHECK_EQ(NULL, helper.Walk(&entry3)); |
| 203 | 203 |
| 204 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; | 204 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; |
| 205 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 205 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
| 206 tree.AddPathFromEnd(path_vec); | 206 tree.AddPathFromEnd(path_vec); |
| 207 CHECK_EQ(NULL, helper.Walk(&entry2)); | 207 CHECK_EQ(NULL, helper.Walk(&entry2)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 empty_tree.CalculateTotalTicks(); | 265 empty_tree.CalculateTotalTicks(); |
| 266 CHECK_EQ(0, empty_tree.root()->total_ticks()); | 266 CHECK_EQ(0, empty_tree.root()->total_ticks()); |
| 267 CHECK_EQ(0, empty_tree.root()->self_ticks()); | 267 CHECK_EQ(0, empty_tree.root()->self_ticks()); |
| 268 empty_tree.root()->IncrementSelfTicks(); | 268 empty_tree.root()->IncrementSelfTicks(); |
| 269 CHECK_EQ(0, empty_tree.root()->total_ticks()); | 269 CHECK_EQ(0, empty_tree.root()->total_ticks()); |
| 270 CHECK_EQ(1, empty_tree.root()->self_ticks()); | 270 CHECK_EQ(1, empty_tree.root()->self_ticks()); |
| 271 empty_tree.CalculateTotalTicks(); | 271 empty_tree.CalculateTotalTicks(); |
| 272 CHECK_EQ(1, empty_tree.root()->total_ticks()); | 272 CHECK_EQ(1, empty_tree.root()->total_ticks()); |
| 273 CHECK_EQ(1, empty_tree.root()->self_ticks()); | 273 CHECK_EQ(1, empty_tree.root()->self_ticks()); |
| 274 | 274 |
| 275 CodeEntry entry1( | 275 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 276 i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken); | 276 TokenEnumerator::kNoSecurityToken); |
| 277 CodeEntry* e1_path[] = {&entry1}; | 277 CodeEntry* e1_path[] = {&entry1}; |
| 278 Vector<CodeEntry*> e1_path_vec( | 278 Vector<CodeEntry*> e1_path_vec( |
| 279 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); | 279 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); |
| 280 | 280 |
| 281 ProfileTree single_child_tree; | 281 ProfileTree single_child_tree; |
| 282 single_child_tree.AddPathFromStart(e1_path_vec); | 282 single_child_tree.AddPathFromStart(e1_path_vec); |
| 283 single_child_tree.root()->IncrementSelfTicks(); | 283 single_child_tree.root()->IncrementSelfTicks(); |
| 284 CHECK_EQ(0, single_child_tree.root()->total_ticks()); | 284 CHECK_EQ(0, single_child_tree.root()->total_ticks()); |
| 285 CHECK_EQ(1, single_child_tree.root()->self_ticks()); | 285 CHECK_EQ(1, single_child_tree.root()->self_ticks()); |
| 286 ProfileTreeTestHelper single_child_helper(&single_child_tree); | 286 ProfileTreeTestHelper single_child_helper(&single_child_tree); |
| 287 ProfileNode* node1 = single_child_helper.Walk(&entry1); | 287 ProfileNode* node1 = single_child_helper.Walk(&entry1); |
| 288 CHECK_NE(NULL, node1); | 288 CHECK_NE(NULL, node1); |
| 289 CHECK_EQ(0, node1->total_ticks()); | 289 CHECK_EQ(0, node1->total_ticks()); |
| 290 CHECK_EQ(1, node1->self_ticks()); | 290 CHECK_EQ(1, node1->self_ticks()); |
| 291 single_child_tree.CalculateTotalTicks(); | 291 single_child_tree.CalculateTotalTicks(); |
| 292 CHECK_EQ(2, single_child_tree.root()->total_ticks()); | 292 CHECK_EQ(2, single_child_tree.root()->total_ticks()); |
| 293 CHECK_EQ(1, single_child_tree.root()->self_ticks()); | 293 CHECK_EQ(1, single_child_tree.root()->self_ticks()); |
| 294 CHECK_EQ(1, node1->total_ticks()); | 294 CHECK_EQ(1, node1->total_ticks()); |
| 295 CHECK_EQ(1, node1->self_ticks()); | 295 CHECK_EQ(1, node1->self_ticks()); |
| 296 | 296 |
| 297 CodeEntry entry2( | 297 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 298 i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken); | 298 TokenEnumerator::kNoSecurityToken); |
| 299 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; | 299 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |
| 300 Vector<CodeEntry*> e1_e2_path_vec( | 300 Vector<CodeEntry*> e1_e2_path_vec( |
| 301 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); | 301 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |
| 302 | 302 |
| 303 ProfileTree flat_tree; | 303 ProfileTree flat_tree; |
| 304 ProfileTreeTestHelper flat_helper(&flat_tree); | 304 ProfileTreeTestHelper flat_helper(&flat_tree); |
| 305 flat_tree.AddPathFromStart(e1_path_vec); | 305 flat_tree.AddPathFromStart(e1_path_vec); |
| 306 flat_tree.AddPathFromStart(e1_path_vec); | 306 flat_tree.AddPathFromStart(e1_path_vec); |
| 307 flat_tree.AddPathFromStart(e1_e2_path_vec); | 307 flat_tree.AddPathFromStart(e1_e2_path_vec); |
| 308 flat_tree.AddPathFromStart(e1_e2_path_vec); | 308 flat_tree.AddPathFromStart(e1_e2_path_vec); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 323 CHECK_EQ(5, flat_tree.root()->total_ticks()); | 323 CHECK_EQ(5, flat_tree.root()->total_ticks()); |
| 324 CHECK_EQ(0, flat_tree.root()->self_ticks()); | 324 CHECK_EQ(0, flat_tree.root()->self_ticks()); |
| 325 CHECK_EQ(5, node1->total_ticks()); | 325 CHECK_EQ(5, node1->total_ticks()); |
| 326 CHECK_EQ(2, node1->self_ticks()); | 326 CHECK_EQ(2, node1->self_ticks()); |
| 327 CHECK_EQ(3, node2->total_ticks()); | 327 CHECK_EQ(3, node2->total_ticks()); |
| 328 CHECK_EQ(3, node2->self_ticks()); | 328 CHECK_EQ(3, node2->self_ticks()); |
| 329 | 329 |
| 330 CodeEntry* e2_path[] = {&entry2}; | 330 CodeEntry* e2_path[] = {&entry2}; |
| 331 Vector<CodeEntry*> e2_path_vec( | 331 Vector<CodeEntry*> e2_path_vec( |
| 332 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); | 332 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); |
| 333 CodeEntry entry3( | 333 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 334 i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken); | 334 TokenEnumerator::kNoSecurityToken); |
| 335 CodeEntry* e3_path[] = {&entry3}; | 335 CodeEntry* e3_path[] = {&entry3}; |
| 336 Vector<CodeEntry*> e3_path_vec( | 336 Vector<CodeEntry*> e3_path_vec( |
| 337 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); | 337 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); |
| 338 | 338 |
| 339 ProfileTree wide_tree; | 339 ProfileTree wide_tree; |
| 340 ProfileTreeTestHelper wide_helper(&wide_tree); | 340 ProfileTreeTestHelper wide_helper(&wide_tree); |
| 341 wide_tree.AddPathFromStart(e1_path_vec); | 341 wide_tree.AddPathFromStart(e1_path_vec); |
| 342 wide_tree.AddPathFromStart(e1_path_vec); | 342 wide_tree.AddPathFromStart(e1_path_vec); |
| 343 wide_tree.AddPathFromStart(e1_e2_path_vec); | 343 wide_tree.AddPathFromStart(e1_e2_path_vec); |
| 344 wide_tree.AddPathFromStart(e2_path_vec); | 344 wide_tree.AddPathFromStart(e2_path_vec); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 387 |
| 388 | 388 |
| 389 TEST(ProfileTreeFilteredClone) { | 389 TEST(ProfileTreeFilteredClone) { |
| 390 ProfileTree source_tree; | 390 ProfileTree source_tree; |
| 391 const int token0 = 0, token1 = 1, token2 = 2; | 391 const int token0 = 0, token1 = 1, token2 = 2; |
| 392 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, token0); | 392 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, token0); |
| 393 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, token1); | 393 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, token1); |
| 394 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, token0); | 394 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, token0); |
| 395 CodeEntry entry4( | 395 CodeEntry entry4( |
| 396 i::Logger::FUNCTION_TAG, "", "ddd", "", 0, | 396 i::Logger::FUNCTION_TAG, "", "ddd", "", 0, |
| 397 CodeEntry::kInheritsSecurityToken); | 397 TokenEnumerator::kInheritsSecurityToken); |
| 398 | 398 |
| 399 { | 399 { |
| 400 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; | 400 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |
| 401 Vector<CodeEntry*> e1_e2_path_vec( | 401 Vector<CodeEntry*> e1_e2_path_vec( |
| 402 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); | 402 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |
| 403 source_tree.AddPathFromStart(e1_e2_path_vec); | 403 source_tree.AddPathFromStart(e1_e2_path_vec); |
| 404 CodeEntry* e2_e4_path[] = {&entry2, &entry4}; | 404 CodeEntry* e2_e4_path[] = {&entry2, &entry4}; |
| 405 Vector<CodeEntry*> e2_e4_path_vec( | 405 Vector<CodeEntry*> e2_e4_path_vec( |
| 406 e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0])); | 406 e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0])); |
| 407 source_tree.AddPathFromStart(e2_e4_path_vec); | 407 source_tree.AddPathFromStart(e2_e4_path_vec); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 | 486 |
| 487 | 487 |
| 488 static inline i::Address ToAddress(int n) { | 488 static inline i::Address ToAddress(int n) { |
| 489 return reinterpret_cast<i::Address>(n); | 489 return reinterpret_cast<i::Address>(n); |
| 490 } | 490 } |
| 491 | 491 |
| 492 TEST(CodeMapAddCode) { | 492 TEST(CodeMapAddCode) { |
| 493 CodeMap code_map; | 493 CodeMap code_map; |
| 494 CodeEntry entry1( | 494 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 495 i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken); | 495 TokenEnumerator::kNoSecurityToken); |
| 496 CodeEntry entry2( | 496 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 497 i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken); | 497 TokenEnumerator::kNoSecurityToken); |
| 498 CodeEntry entry3( | 498 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, |
| 499 i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken); | 499 TokenEnumerator::kNoSecurityToken); |
| 500 CodeEntry entry4( | 500 CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd", "", 0, |
| 501 i::Logger::FUNCTION_TAG, "", "ddd", "", 0, CodeEntry::kNoSecurityToken); | 501 TokenEnumerator::kNoSecurityToken); |
| 502 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 502 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
| 503 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 503 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
| 504 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); | 504 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); |
| 505 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); | 505 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); |
| 506 CHECK_EQ(NULL, code_map.FindEntry(0)); | 506 CHECK_EQ(NULL, code_map.FindEntry(0)); |
| 507 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); | 507 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); |
| 508 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 508 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
| 509 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); | 509 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); |
| 510 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); | 510 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); |
| 511 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 511 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
| 512 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); | 512 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); |
| 513 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); | 513 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); |
| 514 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); | 514 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); |
| 515 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); | 515 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); |
| 516 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); | 516 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); |
| 517 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); | 517 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); |
| 518 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); | 518 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); |
| 519 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); | 519 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); |
| 520 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); | 520 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); |
| 521 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); | 521 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); |
| 522 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); | 522 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); |
| 523 } | 523 } |
| 524 | 524 |
| 525 | 525 |
| 526 TEST(CodeMapMoveAndDeleteCode) { | 526 TEST(CodeMapMoveAndDeleteCode) { |
| 527 CodeMap code_map; | 527 CodeMap code_map; |
| 528 CodeEntry entry1( | 528 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, |
| 529 i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken); | 529 TokenEnumerator::kNoSecurityToken); |
| 530 CodeEntry entry2( | 530 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, |
| 531 i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken); | 531 TokenEnumerator::kNoSecurityToken); |
| 532 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 532 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
| 533 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 533 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
| 534 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 534 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
| 535 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 535 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
| 536 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1800)); | 536 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1800)); |
| 537 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); | 537 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); |
| 538 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 538 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
| 539 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1800))); | 539 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1800))); |
| 540 code_map.DeleteCode(ToAddress(0x1700)); | 540 code_map.DeleteCode(ToAddress(0x1700)); |
| 541 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); | 541 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 generator.RecordTickSample(sample2); | 594 generator.RecordTickSample(sample2); |
| 595 TickSample sample3; | 595 TickSample sample3; |
| 596 sample3.pc = ToAddress(0x1510); | 596 sample3.pc = ToAddress(0x1510); |
| 597 sample3.function = ToAddress(0x1500); | 597 sample3.function = ToAddress(0x1500); |
| 598 sample3.stack[0] = ToAddress(0x1910); | 598 sample3.stack[0] = ToAddress(0x1910); |
| 599 sample3.stack[1] = ToAddress(0x1610); | 599 sample3.stack[1] = ToAddress(0x1610); |
| 600 sample3.frames_count = 2; | 600 sample3.frames_count = 2; |
| 601 generator.RecordTickSample(sample3); | 601 generator.RecordTickSample(sample3); |
| 602 | 602 |
| 603 CpuProfile* profile = | 603 CpuProfile* profile = |
| 604 profiles.StopProfiling(CodeEntry::kNoSecurityToken, "", 1); | 604 profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |
| 605 CHECK_NE(NULL, profile); | 605 CHECK_NE(NULL, profile); |
| 606 ProfileTreeTestHelper top_down_test_helper(profile->top_down()); | 606 ProfileTreeTestHelper top_down_test_helper(profile->top_down()); |
| 607 CHECK_EQ(NULL, top_down_test_helper.Walk(entry2)); | 607 CHECK_EQ(NULL, top_down_test_helper.Walk(entry2)); |
| 608 CHECK_EQ(NULL, top_down_test_helper.Walk(entry3)); | 608 CHECK_EQ(NULL, top_down_test_helper.Walk(entry3)); |
| 609 ProfileNode* node1 = top_down_test_helper.Walk(entry1); | 609 ProfileNode* node1 = top_down_test_helper.Walk(entry1); |
| 610 CHECK_NE(NULL, node1); | 610 CHECK_NE(NULL, node1); |
| 611 CHECK_EQ(entry1, node1->entry()); | 611 CHECK_EQ(entry1, node1->entry()); |
| 612 ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); | 612 ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); |
| 613 CHECK_NE(NULL, node2); | 613 CHECK_NE(NULL, node2); |
| 614 CHECK_EQ(entry1, node2->entry()); | 614 CHECK_EQ(entry1, node2->entry()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 current = PickChild(current, "a"); | 769 current = PickChild(current, "a"); |
| 770 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 770 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
| 771 current = PickChild(current, "b"); | 771 current = PickChild(current, "b"); |
| 772 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 772 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
| 773 current = PickChild(current, "c"); | 773 current = PickChild(current, "c"); |
| 774 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 774 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
| 775 CHECK_EQ(0, current->children()->length()); | 775 CHECK_EQ(0, current->children()->length()); |
| 776 } | 776 } |
| 777 | 777 |
| 778 #endif // ENABLE_LOGGING_AND_PROFILING | 778 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |