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

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

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