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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 80 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
81 CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); | 81 CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
82 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 82 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
83 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 83 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 TEST(ProfileNodeFindOrAddChild) { | 87 TEST(ProfileNodeFindOrAddChild) { |
88 ProfileTree tree; | 88 ProfileTree tree; |
89 ProfileNode node(&tree, NULL); | 89 ProfileNode node(&tree, NULL); |
90 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, | 90 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); |
91 TokenEnumerator::kNoSecurityToken); | |
92 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 91 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); |
93 CHECK_NE(NULL, childNode1); | 92 CHECK_NE(NULL, childNode1); |
94 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 93 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
95 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, | 94 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); |
96 TokenEnumerator::kNoSecurityToken); | |
97 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); | 95 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); |
98 CHECK_NE(NULL, childNode2); | 96 CHECK_NE(NULL, childNode2); |
99 CHECK_NE(childNode1, childNode2); | 97 CHECK_NE(childNode1, childNode2); |
100 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 98 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
101 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 99 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
102 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, | 100 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); |
103 TokenEnumerator::kNoSecurityToken); | |
104 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); | 101 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); |
105 CHECK_NE(NULL, childNode3); | 102 CHECK_NE(NULL, childNode3); |
106 CHECK_NE(childNode1, childNode3); | 103 CHECK_NE(childNode1, childNode3); |
107 CHECK_NE(childNode2, childNode3); | 104 CHECK_NE(childNode2, childNode3); |
108 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 105 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
109 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 106 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); |
110 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); | 107 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); |
111 } | 108 } |
112 | 109 |
113 | 110 |
114 TEST(ProfileNodeFindOrAddChildForSameFunction) { | 111 TEST(ProfileNodeFindOrAddChildForSameFunction) { |
115 const char* empty = ""; | 112 const char* empty = ""; |
116 const char* aaa = "aaa"; | 113 const char* aaa = "aaa"; |
117 ProfileTree tree; | 114 ProfileTree tree; |
118 ProfileNode node(&tree, NULL); | 115 ProfileNode node(&tree, NULL); |
119 CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, | 116 CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa); |
120 TokenEnumerator::kNoSecurityToken); | |
121 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 117 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); |
122 CHECK_NE(NULL, childNode1); | 118 CHECK_NE(NULL, childNode1); |
123 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 119 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); |
124 // The same function again. | 120 // The same function again. |
125 CodeEntry entry2(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, | 121 CodeEntry entry2(i::Logger::FUNCTION_TAG, empty, aaa); |
126 TokenEnumerator::kNoSecurityToken); | |
127 CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); | 122 CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); |
128 // Now with a different security token. | 123 // Now with a different security token. |
129 CodeEntry entry3(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, | 124 CodeEntry entry3(i::Logger::FUNCTION_TAG, empty, aaa, |
130 TokenEnumerator::kNoSecurityToken + 1); | 125 TokenEnumerator::kNoSecurityToken + 1); |
131 CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); | 126 CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); |
132 } | 127 } |
133 | 128 |
134 | 129 |
135 namespace { | 130 namespace { |
136 | 131 |
137 class ProfileTreeTestHelper { | 132 class ProfileTreeTestHelper { |
138 public: | 133 public: |
139 explicit ProfileTreeTestHelper(const ProfileTree* tree) | 134 explicit ProfileTreeTestHelper(const ProfileTree* tree) |
(...skipping 15 matching lines...) Expand all Loading... |
155 return node; | 150 return node; |
156 } | 151 } |
157 | 152 |
158 private: | 153 private: |
159 const ProfileTree* tree_; | 154 const ProfileTree* tree_; |
160 }; | 155 }; |
161 | 156 |
162 } // namespace | 157 } // namespace |
163 | 158 |
164 TEST(ProfileTreeAddPathFromStart) { | 159 TEST(ProfileTreeAddPathFromStart) { |
165 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, | 160 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); |
166 TokenEnumerator::kNoSecurityToken); | 161 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); |
167 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, | 162 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); |
168 TokenEnumerator::kNoSecurityToken); | |
169 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, | |
170 TokenEnumerator::kNoSecurityToken); | |
171 ProfileTree tree; | 163 ProfileTree tree; |
172 ProfileTreeTestHelper helper(&tree); | 164 ProfileTreeTestHelper helper(&tree); |
173 CHECK_EQ(NULL, helper.Walk(&entry1)); | 165 CHECK_EQ(NULL, helper.Walk(&entry1)); |
174 CHECK_EQ(NULL, helper.Walk(&entry2)); | 166 CHECK_EQ(NULL, helper.Walk(&entry2)); |
175 CHECK_EQ(NULL, helper.Walk(&entry3)); | 167 CHECK_EQ(NULL, helper.Walk(&entry3)); |
176 | 168 |
177 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; | 169 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; |
178 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 170 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
179 tree.AddPathFromStart(path_vec); | 171 tree.AddPathFromStart(path_vec); |
180 CHECK_EQ(NULL, helper.Walk(&entry2)); | 172 CHECK_EQ(NULL, helper.Walk(&entry2)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 CHECK_EQ(2, node3->self_ticks()); | 217 CHECK_EQ(2, node3->self_ticks()); |
226 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); | 218 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); |
227 CHECK_NE(NULL, node4); | 219 CHECK_NE(NULL, node4); |
228 CHECK_NE(node3, node4); | 220 CHECK_NE(node3, node4); |
229 CHECK_EQ(0, node4->total_ticks()); | 221 CHECK_EQ(0, node4->total_ticks()); |
230 CHECK_EQ(1, node4->self_ticks()); | 222 CHECK_EQ(1, node4->self_ticks()); |
231 } | 223 } |
232 | 224 |
233 | 225 |
234 TEST(ProfileTreeAddPathFromEnd) { | 226 TEST(ProfileTreeAddPathFromEnd) { |
235 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, | 227 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); |
236 TokenEnumerator::kNoSecurityToken); | 228 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); |
237 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, | 229 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); |
238 TokenEnumerator::kNoSecurityToken); | |
239 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, | |
240 TokenEnumerator::kNoSecurityToken); | |
241 ProfileTree tree; | 230 ProfileTree tree; |
242 ProfileTreeTestHelper helper(&tree); | 231 ProfileTreeTestHelper helper(&tree); |
243 CHECK_EQ(NULL, helper.Walk(&entry1)); | 232 CHECK_EQ(NULL, helper.Walk(&entry1)); |
244 CHECK_EQ(NULL, helper.Walk(&entry2)); | 233 CHECK_EQ(NULL, helper.Walk(&entry2)); |
245 CHECK_EQ(NULL, helper.Walk(&entry3)); | 234 CHECK_EQ(NULL, helper.Walk(&entry3)); |
246 | 235 |
247 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; | 236 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; |
248 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 237 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
249 tree.AddPathFromEnd(path_vec); | 238 tree.AddPathFromEnd(path_vec); |
250 CHECK_EQ(NULL, helper.Walk(&entry2)); | 239 CHECK_EQ(NULL, helper.Walk(&entry2)); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 empty_tree.CalculateTotalTicks(); | 297 empty_tree.CalculateTotalTicks(); |
309 CHECK_EQ(0, empty_tree.root()->total_ticks()); | 298 CHECK_EQ(0, empty_tree.root()->total_ticks()); |
310 CHECK_EQ(0, empty_tree.root()->self_ticks()); | 299 CHECK_EQ(0, empty_tree.root()->self_ticks()); |
311 empty_tree.root()->IncrementSelfTicks(); | 300 empty_tree.root()->IncrementSelfTicks(); |
312 CHECK_EQ(0, empty_tree.root()->total_ticks()); | 301 CHECK_EQ(0, empty_tree.root()->total_ticks()); |
313 CHECK_EQ(1, empty_tree.root()->self_ticks()); | 302 CHECK_EQ(1, empty_tree.root()->self_ticks()); |
314 empty_tree.CalculateTotalTicks(); | 303 empty_tree.CalculateTotalTicks(); |
315 CHECK_EQ(1, empty_tree.root()->total_ticks()); | 304 CHECK_EQ(1, empty_tree.root()->total_ticks()); |
316 CHECK_EQ(1, empty_tree.root()->self_ticks()); | 305 CHECK_EQ(1, empty_tree.root()->self_ticks()); |
317 | 306 |
318 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, | 307 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); |
319 TokenEnumerator::kNoSecurityToken); | |
320 CodeEntry* e1_path[] = {&entry1}; | 308 CodeEntry* e1_path[] = {&entry1}; |
321 Vector<CodeEntry*> e1_path_vec( | 309 Vector<CodeEntry*> e1_path_vec( |
322 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); | 310 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); |
323 | 311 |
324 ProfileTree single_child_tree; | 312 ProfileTree single_child_tree; |
325 single_child_tree.AddPathFromStart(e1_path_vec); | 313 single_child_tree.AddPathFromStart(e1_path_vec); |
326 single_child_tree.root()->IncrementSelfTicks(); | 314 single_child_tree.root()->IncrementSelfTicks(); |
327 CHECK_EQ(0, single_child_tree.root()->total_ticks()); | 315 CHECK_EQ(0, single_child_tree.root()->total_ticks()); |
328 CHECK_EQ(1, single_child_tree.root()->self_ticks()); | 316 CHECK_EQ(1, single_child_tree.root()->self_ticks()); |
329 ProfileTreeTestHelper single_child_helper(&single_child_tree); | 317 ProfileTreeTestHelper single_child_helper(&single_child_tree); |
330 ProfileNode* node1 = single_child_helper.Walk(&entry1); | 318 ProfileNode* node1 = single_child_helper.Walk(&entry1); |
331 CHECK_NE(NULL, node1); | 319 CHECK_NE(NULL, node1); |
332 CHECK_EQ(0, node1->total_ticks()); | 320 CHECK_EQ(0, node1->total_ticks()); |
333 CHECK_EQ(1, node1->self_ticks()); | 321 CHECK_EQ(1, node1->self_ticks()); |
334 single_child_tree.CalculateTotalTicks(); | 322 single_child_tree.CalculateTotalTicks(); |
335 CHECK_EQ(2, single_child_tree.root()->total_ticks()); | 323 CHECK_EQ(2, single_child_tree.root()->total_ticks()); |
336 CHECK_EQ(1, single_child_tree.root()->self_ticks()); | 324 CHECK_EQ(1, single_child_tree.root()->self_ticks()); |
337 CHECK_EQ(1, node1->total_ticks()); | 325 CHECK_EQ(1, node1->total_ticks()); |
338 CHECK_EQ(1, node1->self_ticks()); | 326 CHECK_EQ(1, node1->self_ticks()); |
339 | 327 |
340 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, | 328 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); |
341 TokenEnumerator::kNoSecurityToken); | |
342 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; | 329 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |
343 Vector<CodeEntry*> e1_e2_path_vec( | 330 Vector<CodeEntry*> e1_e2_path_vec( |
344 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); | 331 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |
345 | 332 |
346 ProfileTree flat_tree; | 333 ProfileTree flat_tree; |
347 ProfileTreeTestHelper flat_helper(&flat_tree); | 334 ProfileTreeTestHelper flat_helper(&flat_tree); |
348 flat_tree.AddPathFromStart(e1_path_vec); | 335 flat_tree.AddPathFromStart(e1_path_vec); |
349 flat_tree.AddPathFromStart(e1_path_vec); | 336 flat_tree.AddPathFromStart(e1_path_vec); |
350 flat_tree.AddPathFromStart(e1_e2_path_vec); | 337 flat_tree.AddPathFromStart(e1_e2_path_vec); |
351 flat_tree.AddPathFromStart(e1_e2_path_vec); | 338 flat_tree.AddPathFromStart(e1_e2_path_vec); |
(...skipping 14 matching lines...) Expand all Loading... |
366 CHECK_EQ(5, flat_tree.root()->total_ticks()); | 353 CHECK_EQ(5, flat_tree.root()->total_ticks()); |
367 CHECK_EQ(0, flat_tree.root()->self_ticks()); | 354 CHECK_EQ(0, flat_tree.root()->self_ticks()); |
368 CHECK_EQ(5, node1->total_ticks()); | 355 CHECK_EQ(5, node1->total_ticks()); |
369 CHECK_EQ(2, node1->self_ticks()); | 356 CHECK_EQ(2, node1->self_ticks()); |
370 CHECK_EQ(3, node2->total_ticks()); | 357 CHECK_EQ(3, node2->total_ticks()); |
371 CHECK_EQ(3, node2->self_ticks()); | 358 CHECK_EQ(3, node2->self_ticks()); |
372 | 359 |
373 CodeEntry* e2_path[] = {&entry2}; | 360 CodeEntry* e2_path[] = {&entry2}; |
374 Vector<CodeEntry*> e2_path_vec( | 361 Vector<CodeEntry*> e2_path_vec( |
375 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); | 362 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); |
376 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, | 363 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); |
377 TokenEnumerator::kNoSecurityToken); | |
378 CodeEntry* e3_path[] = {&entry3}; | 364 CodeEntry* e3_path[] = {&entry3}; |
379 Vector<CodeEntry*> e3_path_vec( | 365 Vector<CodeEntry*> e3_path_vec( |
380 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); | 366 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); |
381 | 367 |
382 ProfileTree wide_tree; | 368 ProfileTree wide_tree; |
383 ProfileTreeTestHelper wide_helper(&wide_tree); | 369 ProfileTreeTestHelper wide_helper(&wide_tree); |
384 wide_tree.AddPathFromStart(e1_path_vec); | 370 wide_tree.AddPathFromStart(e1_path_vec); |
385 wide_tree.AddPathFromStart(e1_path_vec); | 371 wide_tree.AddPathFromStart(e1_path_vec); |
386 wide_tree.AddPathFromStart(e1_e2_path_vec); | 372 wide_tree.AddPathFromStart(e1_e2_path_vec); |
387 wide_tree.AddPathFromStart(e2_path_vec); | 373 wide_tree.AddPathFromStart(e2_path_vec); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 CHECK_EQ(3, node2->total_ticks()); | 411 CHECK_EQ(3, node2->total_ticks()); |
426 CHECK_EQ(3, node2->self_ticks()); | 412 CHECK_EQ(3, node2->self_ticks()); |
427 CHECK_EQ(4, node3->total_ticks()); | 413 CHECK_EQ(4, node3->total_ticks()); |
428 CHECK_EQ(4, node3->self_ticks()); | 414 CHECK_EQ(4, node3->self_ticks()); |
429 } | 415 } |
430 | 416 |
431 | 417 |
432 TEST(ProfileTreeFilteredClone) { | 418 TEST(ProfileTreeFilteredClone) { |
433 ProfileTree source_tree; | 419 ProfileTree source_tree; |
434 const int token0 = 0, token1 = 1, token2 = 2; | 420 const int token0 = 0, token1 = 1, token2 = 2; |
435 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, token0); | 421 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", token0); |
436 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, token1); | 422 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", token1); |
437 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, token0); | 423 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", token0); |
438 CodeEntry entry4( | 424 CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd", |
439 i::Logger::FUNCTION_TAG, "", "ddd", "", 0, | 425 TokenEnumerator::kInheritsSecurityToken); |
440 TokenEnumerator::kInheritsSecurityToken); | |
441 | 426 |
442 { | 427 { |
443 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; | 428 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |
444 Vector<CodeEntry*> e1_e2_path_vec( | 429 Vector<CodeEntry*> e1_e2_path_vec( |
445 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); | 430 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |
446 source_tree.AddPathFromStart(e1_e2_path_vec); | 431 source_tree.AddPathFromStart(e1_e2_path_vec); |
447 CodeEntry* e2_e4_path[] = {&entry2, &entry4}; | 432 CodeEntry* e2_e4_path[] = {&entry2, &entry4}; |
448 Vector<CodeEntry*> e2_e4_path_vec( | 433 Vector<CodeEntry*> e2_e4_path_vec( |
449 e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0])); | 434 e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0])); |
450 source_tree.AddPathFromStart(e2_e4_path_vec); | 435 source_tree.AddPathFromStart(e2_e4_path_vec); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 } | 512 } |
528 } | 513 } |
529 | 514 |
530 | 515 |
531 static inline i::Address ToAddress(int n) { | 516 static inline i::Address ToAddress(int n) { |
532 return reinterpret_cast<i::Address>(n); | 517 return reinterpret_cast<i::Address>(n); |
533 } | 518 } |
534 | 519 |
535 TEST(CodeMapAddCode) { | 520 TEST(CodeMapAddCode) { |
536 CodeMap code_map; | 521 CodeMap code_map; |
537 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, | 522 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); |
538 TokenEnumerator::kNoSecurityToken); | 523 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); |
539 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, | 524 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); |
540 TokenEnumerator::kNoSecurityToken); | 525 CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd"); |
541 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, | |
542 TokenEnumerator::kNoSecurityToken); | |
543 CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd", "", 0, | |
544 TokenEnumerator::kNoSecurityToken); | |
545 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 526 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
546 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 527 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
547 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); | 528 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); |
548 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); | 529 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); |
549 CHECK_EQ(NULL, code_map.FindEntry(0)); | 530 CHECK_EQ(NULL, code_map.FindEntry(0)); |
550 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); | 531 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); |
551 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 532 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
552 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); | 533 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); |
553 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); | 534 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); |
554 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 535 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
555 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); | 536 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); |
556 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); | 537 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); |
557 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); | 538 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); |
558 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); | 539 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); |
559 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); | 540 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); |
560 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); | 541 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); |
561 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); | 542 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); |
562 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); | 543 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); |
563 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); | 544 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); |
564 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); | 545 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); |
565 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); | 546 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); |
566 } | 547 } |
567 | 548 |
568 | 549 |
569 TEST(CodeMapMoveAndDeleteCode) { | 550 TEST(CodeMapMoveAndDeleteCode) { |
570 CodeMap code_map; | 551 CodeMap code_map; |
571 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, | 552 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); |
572 TokenEnumerator::kNoSecurityToken); | 553 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); |
573 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, | |
574 TokenEnumerator::kNoSecurityToken); | |
575 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 554 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
576 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 555 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
577 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 556 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
578 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 557 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
579 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. | 558 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. |
580 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); | 559 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); |
581 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); | 560 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); |
582 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, | 561 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); |
583 TokenEnumerator::kNoSecurityToken); | |
584 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); | 562 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); |
585 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); | 563 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); |
586 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); | 564 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); |
587 } | 565 } |
588 | 566 |
589 | 567 |
590 namespace { | 568 namespace { |
591 | 569 |
592 class TestSetup { | 570 class TestSetup { |
593 public: | 571 public: |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 i::OS::SNPrintF(title, "%d", i); | 899 i::OS::SNPrintF(title, "%d", i); |
922 // UID must be > 0. | 900 // UID must be > 0. |
923 CHECK(collection.StartProfiling(title.start(), i + 1, false)); | 901 CHECK(collection.StartProfiling(title.start(), i + 1, false)); |
924 titles[i] = title.start(); | 902 titles[i] = title.start(); |
925 } | 903 } |
926 CHECK(!collection.StartProfiling( | 904 CHECK(!collection.StartProfiling( |
927 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); | 905 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); |
928 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) | 906 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) |
929 i::DeleteArray(titles[i]); | 907 i::DeleteArray(titles[i]); |
930 } | 908 } |
OLD | NEW |