Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Side by Side Diff: test/cctest/test-profile-generator.cc

Issue 18344002: Revert "CpuProfiler: eliminate 2 layers of 4 for CodeCreateEvent calls." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"); 90 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa");
91 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); 91 ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
92 CHECK_NE(NULL, childNode1); 92 CHECK_NE(NULL, childNode1);
93 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); 93 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
94 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); 94 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb");
95 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); 95 ProfileNode* childNode2 = node.FindOrAddChild(&entry2);
96 CHECK_NE(NULL, childNode2); 96 CHECK_NE(NULL, childNode2);
97 CHECK_NE(childNode1, childNode2); 97 CHECK_NE(childNode1, childNode2);
98 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); 98 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
99 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); 99 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2));
100 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); 100 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc");
101 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); 101 ProfileNode* childNode3 = node.FindOrAddChild(&entry3);
102 CHECK_NE(NULL, childNode3); 102 CHECK_NE(NULL, childNode3);
103 CHECK_NE(childNode1, childNode3); 103 CHECK_NE(childNode1, childNode3);
104 CHECK_NE(childNode2, childNode3); 104 CHECK_NE(childNode2, childNode3);
105 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); 105 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
106 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); 106 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2));
107 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); 107 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3));
108 } 108 }
109 109
110 110
111 TEST(ProfileNodeFindOrAddChildForSameFunction) { 111 TEST(ProfileNodeFindOrAddChildForSameFunction) {
112 const char* empty = "";
112 const char* aaa = "aaa"; 113 const char* aaa = "aaa";
113 ProfileTree tree; 114 ProfileTree tree;
114 ProfileNode node(&tree, NULL); 115 ProfileNode node(&tree, NULL);
115 CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa); 116 CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa);
116 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); 117 ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
117 CHECK_NE(NULL, childNode1); 118 CHECK_NE(NULL, childNode1);
118 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); 119 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
119 // The same function again. 120 // The same function again.
120 CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa); 121 CodeEntry entry2(i::Logger::FUNCTION_TAG, empty, aaa);
121 CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); 122 CHECK_EQ(childNode1, node.FindOrAddChild(&entry2));
122 // Now with a different security token. 123 // Now with a different security token.
123 CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa, 124 CodeEntry entry3(i::Logger::FUNCTION_TAG, empty, aaa,
124 TokenEnumerator::kNoSecurityToken + 1); 125 TokenEnumerator::kNoSecurityToken + 1);
125 CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); 126 CHECK_EQ(childNode1, node.FindOrAddChild(&entry3));
126 } 127 }
127 128
128 129
129 namespace { 130 namespace {
130 131
131 class ProfileTreeTestHelper { 132 class ProfileTreeTestHelper {
132 public: 133 public:
133 explicit ProfileTreeTestHelper(const ProfileTree* tree) 134 explicit ProfileTreeTestHelper(const ProfileTree* tree)
(...skipping 15 matching lines...) Expand all
149 return node; 150 return node;
150 } 151 }
151 152
152 private: 153 private:
153 const ProfileTree* tree_; 154 const ProfileTree* tree_;
154 }; 155 };
155 156
156 } // namespace 157 } // namespace
157 158
158 TEST(ProfileTreeAddPathFromStart) { 159 TEST(ProfileTreeAddPathFromStart) {
159 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); 160 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa");
160 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); 161 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb");
161 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); 162 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc");
162 ProfileTree tree; 163 ProfileTree tree;
163 ProfileTreeTestHelper helper(&tree); 164 ProfileTreeTestHelper helper(&tree);
164 CHECK_EQ(NULL, helper.Walk(&entry1)); 165 CHECK_EQ(NULL, helper.Walk(&entry1));
165 CHECK_EQ(NULL, helper.Walk(&entry2)); 166 CHECK_EQ(NULL, helper.Walk(&entry2));
166 CHECK_EQ(NULL, helper.Walk(&entry3)); 167 CHECK_EQ(NULL, helper.Walk(&entry3));
167 168
168 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; 169 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL};
169 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); 170 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0]));
170 tree.AddPathFromStart(path_vec); 171 tree.AddPathFromStart(path_vec);
171 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
216 CHECK_EQ(2, node3->self_ticks()); 217 CHECK_EQ(2, node3->self_ticks());
217 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); 218 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2);
218 CHECK_NE(NULL, node4); 219 CHECK_NE(NULL, node4);
219 CHECK_NE(node3, node4); 220 CHECK_NE(node3, node4);
220 CHECK_EQ(0, node4->total_ticks()); 221 CHECK_EQ(0, node4->total_ticks());
221 CHECK_EQ(1, node4->self_ticks()); 222 CHECK_EQ(1, node4->self_ticks());
222 } 223 }
223 224
224 225
225 TEST(ProfileTreeAddPathFromEnd) { 226 TEST(ProfileTreeAddPathFromEnd) {
226 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); 227 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa");
227 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); 228 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb");
228 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); 229 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc");
229 ProfileTree tree; 230 ProfileTree tree;
230 ProfileTreeTestHelper helper(&tree); 231 ProfileTreeTestHelper helper(&tree);
231 CHECK_EQ(NULL, helper.Walk(&entry1)); 232 CHECK_EQ(NULL, helper.Walk(&entry1));
232 CHECK_EQ(NULL, helper.Walk(&entry2)); 233 CHECK_EQ(NULL, helper.Walk(&entry2));
233 CHECK_EQ(NULL, helper.Walk(&entry3)); 234 CHECK_EQ(NULL, helper.Walk(&entry3));
234 235
235 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; 236 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL};
236 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); 237 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0]));
237 tree.AddPathFromEnd(path_vec); 238 tree.AddPathFromEnd(path_vec);
238 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
296 empty_tree.CalculateTotalTicks(); 297 empty_tree.CalculateTotalTicks();
297 CHECK_EQ(0, empty_tree.root()->total_ticks()); 298 CHECK_EQ(0, empty_tree.root()->total_ticks());
298 CHECK_EQ(0, empty_tree.root()->self_ticks()); 299 CHECK_EQ(0, empty_tree.root()->self_ticks());
299 empty_tree.root()->IncrementSelfTicks(); 300 empty_tree.root()->IncrementSelfTicks();
300 CHECK_EQ(0, empty_tree.root()->total_ticks()); 301 CHECK_EQ(0, empty_tree.root()->total_ticks());
301 CHECK_EQ(1, empty_tree.root()->self_ticks()); 302 CHECK_EQ(1, empty_tree.root()->self_ticks());
302 empty_tree.CalculateTotalTicks(); 303 empty_tree.CalculateTotalTicks();
303 CHECK_EQ(1, empty_tree.root()->total_ticks()); 304 CHECK_EQ(1, empty_tree.root()->total_ticks());
304 CHECK_EQ(1, empty_tree.root()->self_ticks()); 305 CHECK_EQ(1, empty_tree.root()->self_ticks());
305 306
306 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); 307 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa");
307 CodeEntry* e1_path[] = {&entry1}; 308 CodeEntry* e1_path[] = {&entry1};
308 Vector<CodeEntry*> e1_path_vec( 309 Vector<CodeEntry*> e1_path_vec(
309 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); 310 e1_path, sizeof(e1_path) / sizeof(e1_path[0]));
310 311
311 ProfileTree single_child_tree; 312 ProfileTree single_child_tree;
312 single_child_tree.AddPathFromStart(e1_path_vec); 313 single_child_tree.AddPathFromStart(e1_path_vec);
313 single_child_tree.root()->IncrementSelfTicks(); 314 single_child_tree.root()->IncrementSelfTicks();
314 CHECK_EQ(0, single_child_tree.root()->total_ticks()); 315 CHECK_EQ(0, single_child_tree.root()->total_ticks());
315 CHECK_EQ(1, single_child_tree.root()->self_ticks()); 316 CHECK_EQ(1, single_child_tree.root()->self_ticks());
316 ProfileTreeTestHelper single_child_helper(&single_child_tree); 317 ProfileTreeTestHelper single_child_helper(&single_child_tree);
317 ProfileNode* node1 = single_child_helper.Walk(&entry1); 318 ProfileNode* node1 = single_child_helper.Walk(&entry1);
318 CHECK_NE(NULL, node1); 319 CHECK_NE(NULL, node1);
319 CHECK_EQ(0, node1->total_ticks()); 320 CHECK_EQ(0, node1->total_ticks());
320 CHECK_EQ(1, node1->self_ticks()); 321 CHECK_EQ(1, node1->self_ticks());
321 single_child_tree.CalculateTotalTicks(); 322 single_child_tree.CalculateTotalTicks();
322 CHECK_EQ(2, single_child_tree.root()->total_ticks()); 323 CHECK_EQ(2, single_child_tree.root()->total_ticks());
323 CHECK_EQ(1, single_child_tree.root()->self_ticks()); 324 CHECK_EQ(1, single_child_tree.root()->self_ticks());
324 CHECK_EQ(1, node1->total_ticks()); 325 CHECK_EQ(1, node1->total_ticks());
325 CHECK_EQ(1, node1->self_ticks()); 326 CHECK_EQ(1, node1->self_ticks());
326 327
327 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); 328 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb");
328 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; 329 CodeEntry* e1_e2_path[] = {&entry1, &entry2};
329 Vector<CodeEntry*> e1_e2_path_vec( 330 Vector<CodeEntry*> e1_e2_path_vec(
330 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]));
331 332
332 ProfileTree flat_tree; 333 ProfileTree flat_tree;
333 ProfileTreeTestHelper flat_helper(&flat_tree); 334 ProfileTreeTestHelper flat_helper(&flat_tree);
334 flat_tree.AddPathFromStart(e1_path_vec); 335 flat_tree.AddPathFromStart(e1_path_vec);
335 flat_tree.AddPathFromStart(e1_path_vec); 336 flat_tree.AddPathFromStart(e1_path_vec);
336 flat_tree.AddPathFromStart(e1_e2_path_vec); 337 flat_tree.AddPathFromStart(e1_e2_path_vec);
337 flat_tree.AddPathFromStart(e1_e2_path_vec); 338 flat_tree.AddPathFromStart(e1_e2_path_vec);
(...skipping 14 matching lines...) Expand all
352 CHECK_EQ(5, flat_tree.root()->total_ticks()); 353 CHECK_EQ(5, flat_tree.root()->total_ticks());
353 CHECK_EQ(0, flat_tree.root()->self_ticks()); 354 CHECK_EQ(0, flat_tree.root()->self_ticks());
354 CHECK_EQ(5, node1->total_ticks()); 355 CHECK_EQ(5, node1->total_ticks());
355 CHECK_EQ(2, node1->self_ticks()); 356 CHECK_EQ(2, node1->self_ticks());
356 CHECK_EQ(3, node2->total_ticks()); 357 CHECK_EQ(3, node2->total_ticks());
357 CHECK_EQ(3, node2->self_ticks()); 358 CHECK_EQ(3, node2->self_ticks());
358 359
359 CodeEntry* e2_path[] = {&entry2}; 360 CodeEntry* e2_path[] = {&entry2};
360 Vector<CodeEntry*> e2_path_vec( 361 Vector<CodeEntry*> e2_path_vec(
361 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); 362 e2_path, sizeof(e2_path) / sizeof(e2_path[0]));
362 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); 363 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc");
363 CodeEntry* e3_path[] = {&entry3}; 364 CodeEntry* e3_path[] = {&entry3};
364 Vector<CodeEntry*> e3_path_vec( 365 Vector<CodeEntry*> e3_path_vec(
365 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); 366 e3_path, sizeof(e3_path) / sizeof(e3_path[0]));
366 367
367 ProfileTree wide_tree; 368 ProfileTree wide_tree;
368 ProfileTreeTestHelper wide_helper(&wide_tree); 369 ProfileTreeTestHelper wide_helper(&wide_tree);
369 wide_tree.AddPathFromStart(e1_path_vec); 370 wide_tree.AddPathFromStart(e1_path_vec);
370 wide_tree.AddPathFromStart(e1_path_vec); 371 wide_tree.AddPathFromStart(e1_path_vec);
371 wide_tree.AddPathFromStart(e1_e2_path_vec); 372 wide_tree.AddPathFromStart(e1_e2_path_vec);
372 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
410 CHECK_EQ(3, node2->total_ticks()); 411 CHECK_EQ(3, node2->total_ticks());
411 CHECK_EQ(3, node2->self_ticks()); 412 CHECK_EQ(3, node2->self_ticks());
412 CHECK_EQ(4, node3->total_ticks()); 413 CHECK_EQ(4, node3->total_ticks());
413 CHECK_EQ(4, node3->self_ticks()); 414 CHECK_EQ(4, node3->self_ticks());
414 } 415 }
415 416
416 417
417 TEST(ProfileTreeFilteredClone) { 418 TEST(ProfileTreeFilteredClone) {
418 ProfileTree source_tree; 419 ProfileTree source_tree;
419 const int token0 = 0, token1 = 1, token2 = 2; 420 const int token0 = 0, token1 = 1, token2 = 2;
420 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", token0); 421 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", token0);
421 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", token1); 422 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", token1);
422 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc", token0); 423 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", token0);
423 CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd", 424 CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd",
424 TokenEnumerator::kInheritsSecurityToken); 425 TokenEnumerator::kInheritsSecurityToken);
425 426
426 { 427 {
427 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; 428 CodeEntry* e1_e2_path[] = {&entry1, &entry2};
428 Vector<CodeEntry*> e1_e2_path_vec( 429 Vector<CodeEntry*> e1_e2_path_vec(
429 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]));
430 source_tree.AddPathFromStart(e1_e2_path_vec); 431 source_tree.AddPathFromStart(e1_e2_path_vec);
431 CodeEntry* e2_e4_path[] = {&entry2, &entry4}; 432 CodeEntry* e2_e4_path[] = {&entry2, &entry4};
432 Vector<CodeEntry*> e2_e4_path_vec( 433 Vector<CodeEntry*> e2_e4_path_vec(
433 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]));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 512 }
512 } 513 }
513 514
514 515
515 static inline i::Address ToAddress(int n) { 516 static inline i::Address ToAddress(int n) {
516 return reinterpret_cast<i::Address>(n); 517 return reinterpret_cast<i::Address>(n);
517 } 518 }
518 519
519 TEST(CodeMapAddCode) { 520 TEST(CodeMapAddCode) {
520 CodeMap code_map; 521 CodeMap code_map;
521 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); 522 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa");
522 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); 523 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb");
523 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); 524 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc");
524 CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); 525 CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd");
525 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); 526 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200);
526 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); 527 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100);
527 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); 528 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50);
528 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); 529 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10);
529 CHECK_EQ(NULL, code_map.FindEntry(0)); 530 CHECK_EQ(NULL, code_map.FindEntry(0));
530 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); 531 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1)));
531 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); 532 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500)));
532 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); 533 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100)));
533 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); 534 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1)));
534 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); 535 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700)));
535 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); 536 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50)));
536 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); 537 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1)));
537 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); 538 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100)));
538 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); 539 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1)));
539 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); 540 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900)));
540 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); 541 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28)));
541 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); 542 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950)));
542 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); 543 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7)));
543 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); 544 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1)));
544 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); 545 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10)));
545 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); 546 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF)));
546 } 547 }
547 548
548 549
549 TEST(CodeMapMoveAndDeleteCode) { 550 TEST(CodeMapMoveAndDeleteCode) {
550 CodeMap code_map; 551 CodeMap code_map;
551 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); 552 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa");
552 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); 553 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb");
553 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); 554 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200);
554 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); 555 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100);
555 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); 556 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500)));
556 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); 557 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700)));
557 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. 558 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb.
558 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); 559 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500)));
559 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); 560 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700)));
560 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); 561 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc");
561 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); 562 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100);
562 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); 563 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700)));
563 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); 564 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750)));
564 } 565 }
565 566
566 567
567 namespace { 568 namespace {
568 569
569 class TestSetup { 570 class TestSetup {
570 public: 571 public:
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 i::OS::SNPrintF(title, "%d", i); 899 i::OS::SNPrintF(title, "%d", i);
899 // UID must be > 0. 900 // UID must be > 0.
900 CHECK(collection.StartProfiling(title.start(), i + 1, false)); 901 CHECK(collection.StartProfiling(title.start(), i + 1, false));
901 titles[i] = title.start(); 902 titles[i] = title.start();
902 } 903 }
903 CHECK(!collection.StartProfiling( 904 CHECK(!collection.StartProfiling(
904 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); 905 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
905 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) 906 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
906 i::DeleteArray(titles[i]); 907 i::DeleteArray(titles[i]);
907 } 908 }
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698