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

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

Issue 17642009: CPUProfiler: propagate scriptId to the front-end (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: unnecessary line was removed Created 7 years, 6 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
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", "", 0, 90 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", 0, "", 0,
91 TokenEnumerator::kNoSecurityToken); 91 TokenEnumerator::kNoSecurityToken);
92 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); 92 ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
93 CHECK_NE(NULL, childNode1); 93 CHECK_NE(NULL, childNode1);
94 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); 94 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
95 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, 95 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", 0, "", 0,
96 TokenEnumerator::kNoSecurityToken); 96 TokenEnumerator::kNoSecurityToken);
97 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); 97 ProfileNode* childNode2 = node.FindOrAddChild(&entry2);
98 CHECK_NE(NULL, childNode2); 98 CHECK_NE(NULL, childNode2);
99 CHECK_NE(childNode1, childNode2); 99 CHECK_NE(childNode1, childNode2);
100 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); 100 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
101 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); 101 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2));
102 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, 102 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", 0, "", 0,
103 TokenEnumerator::kNoSecurityToken); 103 TokenEnumerator::kNoSecurityToken);
104 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); 104 ProfileNode* childNode3 = node.FindOrAddChild(&entry3);
105 CHECK_NE(NULL, childNode3); 105 CHECK_NE(NULL, childNode3);
106 CHECK_NE(childNode1, childNode3); 106 CHECK_NE(childNode1, childNode3);
107 CHECK_NE(childNode2, childNode3); 107 CHECK_NE(childNode2, childNode3);
108 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); 108 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
109 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); 109 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2));
110 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); 110 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3));
111 } 111 }
112 112
113 113
114 TEST(ProfileNodeFindOrAddChildForSameFunction) { 114 TEST(ProfileNodeFindOrAddChildForSameFunction) {
115 const char* empty = ""; 115 const char* empty = "";
116 const char* aaa = "aaa"; 116 const char* aaa = "aaa";
117 ProfileTree tree; 117 ProfileTree tree;
118 ProfileNode node(&tree, NULL); 118 ProfileNode node(&tree, NULL);
119 CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, 119 CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa, 0, empty, 0,
120 TokenEnumerator::kNoSecurityToken); 120 TokenEnumerator::kNoSecurityToken);
121 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); 121 ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
122 CHECK_NE(NULL, childNode1); 122 CHECK_NE(NULL, childNode1);
123 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); 123 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
124 // The same function again. 124 // The same function again.
125 CodeEntry entry2(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, 125 CodeEntry entry2(i::Logger::FUNCTION_TAG, empty, aaa, 0, empty, 0,
126 TokenEnumerator::kNoSecurityToken); 126 TokenEnumerator::kNoSecurityToken);
127 CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); 127 CHECK_EQ(childNode1, node.FindOrAddChild(&entry2));
128 // Now with a different security token. 128 // Now with a different security token.
129 CodeEntry entry3(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, 129 CodeEntry entry3(i::Logger::FUNCTION_TAG, empty, aaa, 0, empty, 0,
130 TokenEnumerator::kNoSecurityToken + 1); 130 TokenEnumerator::kNoSecurityToken + 1);
131 CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); 131 CHECK_EQ(childNode1, node.FindOrAddChild(&entry3));
132 } 132 }
133 133
134 134
135 namespace { 135 namespace {
136 136
137 class ProfileTreeTestHelper { 137 class ProfileTreeTestHelper {
138 public: 138 public:
139 explicit ProfileTreeTestHelper(const ProfileTree* tree) 139 explicit ProfileTreeTestHelper(const ProfileTree* tree)
(...skipping 15 matching lines...) Expand all
155 return node; 155 return node;
156 } 156 }
157 157
158 private: 158 private:
159 const ProfileTree* tree_; 159 const ProfileTree* tree_;
160 }; 160 };
161 161
162 } // namespace 162 } // namespace
163 163
164 TEST(ProfileTreeAddPathFromStart) { 164 TEST(ProfileTreeAddPathFromStart) {
165 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, 165 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", 0, "", 0,
166 TokenEnumerator::kNoSecurityToken); 166 TokenEnumerator::kNoSecurityToken);
167 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, 167 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", 0, "", 0,
168 TokenEnumerator::kNoSecurityToken); 168 TokenEnumerator::kNoSecurityToken);
169 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, 169 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", 0, "", 0,
170 TokenEnumerator::kNoSecurityToken); 170 TokenEnumerator::kNoSecurityToken);
171 ProfileTree tree; 171 ProfileTree tree;
172 ProfileTreeTestHelper helper(&tree); 172 ProfileTreeTestHelper helper(&tree);
173 CHECK_EQ(NULL, helper.Walk(&entry1)); 173 CHECK_EQ(NULL, helper.Walk(&entry1));
174 CHECK_EQ(NULL, helper.Walk(&entry2)); 174 CHECK_EQ(NULL, helper.Walk(&entry2));
175 CHECK_EQ(NULL, helper.Walk(&entry3)); 175 CHECK_EQ(NULL, helper.Walk(&entry3));
176 176
177 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; 177 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL};
178 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); 178 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0]));
179 tree.AddPathFromStart(path_vec); 179 tree.AddPathFromStart(path_vec);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 CHECK_EQ(2, node3->self_ticks()); 225 CHECK_EQ(2, node3->self_ticks());
226 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); 226 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2);
227 CHECK_NE(NULL, node4); 227 CHECK_NE(NULL, node4);
228 CHECK_NE(node3, node4); 228 CHECK_NE(node3, node4);
229 CHECK_EQ(0, node4->total_ticks()); 229 CHECK_EQ(0, node4->total_ticks());
230 CHECK_EQ(1, node4->self_ticks()); 230 CHECK_EQ(1, node4->self_ticks());
231 } 231 }
232 232
233 233
234 TEST(ProfileTreeAddPathFromEnd) { 234 TEST(ProfileTreeAddPathFromEnd) {
235 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, 235 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", 0, "", 0,
236 TokenEnumerator::kNoSecurityToken); 236 TokenEnumerator::kNoSecurityToken);
237 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, 237 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", 0, "", 0,
238 TokenEnumerator::kNoSecurityToken); 238 TokenEnumerator::kNoSecurityToken);
239 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, 239 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", 0, "", 0,
240 TokenEnumerator::kNoSecurityToken); 240 TokenEnumerator::kNoSecurityToken);
241 ProfileTree tree; 241 ProfileTree tree;
242 ProfileTreeTestHelper helper(&tree); 242 ProfileTreeTestHelper helper(&tree);
243 CHECK_EQ(NULL, helper.Walk(&entry1)); 243 CHECK_EQ(NULL, helper.Walk(&entry1));
244 CHECK_EQ(NULL, helper.Walk(&entry2)); 244 CHECK_EQ(NULL, helper.Walk(&entry2));
245 CHECK_EQ(NULL, helper.Walk(&entry3)); 245 CHECK_EQ(NULL, helper.Walk(&entry3));
246 246
247 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; 247 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL};
248 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); 248 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0]));
249 tree.AddPathFromEnd(path_vec); 249 tree.AddPathFromEnd(path_vec);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 empty_tree.CalculateTotalTicks(); 308 empty_tree.CalculateTotalTicks();
309 CHECK_EQ(0, empty_tree.root()->total_ticks()); 309 CHECK_EQ(0, empty_tree.root()->total_ticks());
310 CHECK_EQ(0, empty_tree.root()->self_ticks()); 310 CHECK_EQ(0, empty_tree.root()->self_ticks());
311 empty_tree.root()->IncrementSelfTicks(); 311 empty_tree.root()->IncrementSelfTicks();
312 CHECK_EQ(0, empty_tree.root()->total_ticks()); 312 CHECK_EQ(0, empty_tree.root()->total_ticks());
313 CHECK_EQ(1, empty_tree.root()->self_ticks()); 313 CHECK_EQ(1, empty_tree.root()->self_ticks());
314 empty_tree.CalculateTotalTicks(); 314 empty_tree.CalculateTotalTicks();
315 CHECK_EQ(1, empty_tree.root()->total_ticks()); 315 CHECK_EQ(1, empty_tree.root()->total_ticks());
316 CHECK_EQ(1, empty_tree.root()->self_ticks()); 316 CHECK_EQ(1, empty_tree.root()->self_ticks());
317 317
318 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, 318 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", 0, "", 0,
319 TokenEnumerator::kNoSecurityToken); 319 TokenEnumerator::kNoSecurityToken);
320 CodeEntry* e1_path[] = {&entry1}; 320 CodeEntry* e1_path[] = {&entry1};
321 Vector<CodeEntry*> e1_path_vec( 321 Vector<CodeEntry*> e1_path_vec(
322 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); 322 e1_path, sizeof(e1_path) / sizeof(e1_path[0]));
323 323
324 ProfileTree single_child_tree; 324 ProfileTree single_child_tree;
325 single_child_tree.AddPathFromStart(e1_path_vec); 325 single_child_tree.AddPathFromStart(e1_path_vec);
326 single_child_tree.root()->IncrementSelfTicks(); 326 single_child_tree.root()->IncrementSelfTicks();
327 CHECK_EQ(0, single_child_tree.root()->total_ticks()); 327 CHECK_EQ(0, single_child_tree.root()->total_ticks());
328 CHECK_EQ(1, single_child_tree.root()->self_ticks()); 328 CHECK_EQ(1, single_child_tree.root()->self_ticks());
329 ProfileTreeTestHelper single_child_helper(&single_child_tree); 329 ProfileTreeTestHelper single_child_helper(&single_child_tree);
330 ProfileNode* node1 = single_child_helper.Walk(&entry1); 330 ProfileNode* node1 = single_child_helper.Walk(&entry1);
331 CHECK_NE(NULL, node1); 331 CHECK_NE(NULL, node1);
332 CHECK_EQ(0, node1->total_ticks()); 332 CHECK_EQ(0, node1->total_ticks());
333 CHECK_EQ(1, node1->self_ticks()); 333 CHECK_EQ(1, node1->self_ticks());
334 single_child_tree.CalculateTotalTicks(); 334 single_child_tree.CalculateTotalTicks();
335 CHECK_EQ(2, single_child_tree.root()->total_ticks()); 335 CHECK_EQ(2, single_child_tree.root()->total_ticks());
336 CHECK_EQ(1, single_child_tree.root()->self_ticks()); 336 CHECK_EQ(1, single_child_tree.root()->self_ticks());
337 CHECK_EQ(1, node1->total_ticks()); 337 CHECK_EQ(1, node1->total_ticks());
338 CHECK_EQ(1, node1->self_ticks()); 338 CHECK_EQ(1, node1->self_ticks());
339 339
340 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, 340 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", 0, "", 0,
341 TokenEnumerator::kNoSecurityToken); 341 TokenEnumerator::kNoSecurityToken);
342 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; 342 CodeEntry* e1_e2_path[] = {&entry1, &entry2};
343 Vector<CodeEntry*> e1_e2_path_vec( 343 Vector<CodeEntry*> e1_e2_path_vec(
344 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); 344 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0]));
345 345
346 ProfileTree flat_tree; 346 ProfileTree flat_tree;
347 ProfileTreeTestHelper flat_helper(&flat_tree); 347 ProfileTreeTestHelper flat_helper(&flat_tree);
348 flat_tree.AddPathFromStart(e1_path_vec); 348 flat_tree.AddPathFromStart(e1_path_vec);
349 flat_tree.AddPathFromStart(e1_path_vec); 349 flat_tree.AddPathFromStart(e1_path_vec);
350 flat_tree.AddPathFromStart(e1_e2_path_vec); 350 flat_tree.AddPathFromStart(e1_e2_path_vec);
(...skipping 15 matching lines...) Expand all
366 CHECK_EQ(5, flat_tree.root()->total_ticks()); 366 CHECK_EQ(5, flat_tree.root()->total_ticks());
367 CHECK_EQ(0, flat_tree.root()->self_ticks()); 367 CHECK_EQ(0, flat_tree.root()->self_ticks());
368 CHECK_EQ(5, node1->total_ticks()); 368 CHECK_EQ(5, node1->total_ticks());
369 CHECK_EQ(2, node1->self_ticks()); 369 CHECK_EQ(2, node1->self_ticks());
370 CHECK_EQ(3, node2->total_ticks()); 370 CHECK_EQ(3, node2->total_ticks());
371 CHECK_EQ(3, node2->self_ticks()); 371 CHECK_EQ(3, node2->self_ticks());
372 372
373 CodeEntry* e2_path[] = {&entry2}; 373 CodeEntry* e2_path[] = {&entry2};
374 Vector<CodeEntry*> e2_path_vec( 374 Vector<CodeEntry*> e2_path_vec(
375 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); 375 e2_path, sizeof(e2_path) / sizeof(e2_path[0]));
376 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, 376 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", 0, "", 0,
377 TokenEnumerator::kNoSecurityToken); 377 TokenEnumerator::kNoSecurityToken);
378 CodeEntry* e3_path[] = {&entry3}; 378 CodeEntry* e3_path[] = {&entry3};
379 Vector<CodeEntry*> e3_path_vec( 379 Vector<CodeEntry*> e3_path_vec(
380 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); 380 e3_path, sizeof(e3_path) / sizeof(e3_path[0]));
381 381
382 ProfileTree wide_tree; 382 ProfileTree wide_tree;
383 ProfileTreeTestHelper wide_helper(&wide_tree); 383 ProfileTreeTestHelper wide_helper(&wide_tree);
384 wide_tree.AddPathFromStart(e1_path_vec); 384 wide_tree.AddPathFromStart(e1_path_vec);
385 wide_tree.AddPathFromStart(e1_path_vec); 385 wide_tree.AddPathFromStart(e1_path_vec);
386 wide_tree.AddPathFromStart(e1_e2_path_vec); 386 wide_tree.AddPathFromStart(e1_e2_path_vec);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 CHECK_EQ(3, node2->total_ticks()); 425 CHECK_EQ(3, node2->total_ticks());
426 CHECK_EQ(3, node2->self_ticks()); 426 CHECK_EQ(3, node2->self_ticks());
427 CHECK_EQ(4, node3->total_ticks()); 427 CHECK_EQ(4, node3->total_ticks());
428 CHECK_EQ(4, node3->self_ticks()); 428 CHECK_EQ(4, node3->self_ticks());
429 } 429 }
430 430
431 431
432 TEST(ProfileTreeFilteredClone) { 432 TEST(ProfileTreeFilteredClone) {
433 ProfileTree source_tree; 433 ProfileTree source_tree;
434 const int token0 = 0, token1 = 1, token2 = 2; 434 const int token0 = 0, token1 = 1, token2 = 2;
435 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, token0); 435 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", 0, "", 0, token0);
436 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, token1); 436 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", 0, "", 0, token1);
437 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, token0); 437 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", 0, "", 0, token0);
438 CodeEntry entry4( 438 CodeEntry entry4(
439 i::Logger::FUNCTION_TAG, "", "ddd", "", 0, 439 i::Logger::FUNCTION_TAG, "", "ddd", 0, "", 0,
440 TokenEnumerator::kInheritsSecurityToken); 440 TokenEnumerator::kInheritsSecurityToken);
441 441
442 { 442 {
443 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; 443 CodeEntry* e1_e2_path[] = {&entry1, &entry2};
444 Vector<CodeEntry*> e1_e2_path_vec( 444 Vector<CodeEntry*> e1_e2_path_vec(
445 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); 445 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0]));
446 source_tree.AddPathFromStart(e1_e2_path_vec); 446 source_tree.AddPathFromStart(e1_e2_path_vec);
447 CodeEntry* e2_e4_path[] = {&entry2, &entry4}; 447 CodeEntry* e2_e4_path[] = {&entry2, &entry4};
448 Vector<CodeEntry*> e2_e4_path_vec( 448 Vector<CodeEntry*> e2_e4_path_vec(
449 e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0])); 449 e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0]));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 } 527 }
528 } 528 }
529 529
530 530
531 static inline i::Address ToAddress(int n) { 531 static inline i::Address ToAddress(int n) {
532 return reinterpret_cast<i::Address>(n); 532 return reinterpret_cast<i::Address>(n);
533 } 533 }
534 534
535 TEST(CodeMapAddCode) { 535 TEST(CodeMapAddCode) {
536 CodeMap code_map; 536 CodeMap code_map;
537 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, 537 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", 0, "", 0,
538 TokenEnumerator::kNoSecurityToken); 538 TokenEnumerator::kNoSecurityToken);
539 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, 539 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", 0, "", 0,
540 TokenEnumerator::kNoSecurityToken); 540 TokenEnumerator::kNoSecurityToken);
541 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, 541 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", 0, "", 0,
542 TokenEnumerator::kNoSecurityToken); 542 TokenEnumerator::kNoSecurityToken);
543 CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd", "", 0, 543 CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd", 0, "", 0,
544 TokenEnumerator::kNoSecurityToken); 544 TokenEnumerator::kNoSecurityToken);
545 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); 545 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200);
546 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); 546 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100);
547 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); 547 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50);
548 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); 548 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10);
549 CHECK_EQ(NULL, code_map.FindEntry(0)); 549 CHECK_EQ(NULL, code_map.FindEntry(0));
550 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); 550 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1)));
551 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); 551 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500)));
552 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); 552 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100)));
553 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); 553 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1)));
554 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); 554 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700)));
555 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); 555 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50)));
556 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); 556 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1)));
557 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); 557 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100)));
558 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); 558 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1)));
559 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); 559 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900)));
560 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); 560 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28)));
561 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); 561 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950)));
562 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); 562 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7)));
563 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); 563 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1)));
564 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); 564 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10)));
565 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); 565 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF)));
566 } 566 }
567 567
568 568
569 TEST(CodeMapMoveAndDeleteCode) { 569 TEST(CodeMapMoveAndDeleteCode) {
570 CodeMap code_map; 570 CodeMap code_map;
571 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, 571 CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", 0, "", 0,
572 TokenEnumerator::kNoSecurityToken); 572 TokenEnumerator::kNoSecurityToken);
573 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, 573 CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", 0, "", 0,
574 TokenEnumerator::kNoSecurityToken); 574 TokenEnumerator::kNoSecurityToken);
575 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); 575 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200);
576 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); 576 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100);
577 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); 577 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500)));
578 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); 578 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700)));
579 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. 579 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb.
580 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); 580 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500)));
581 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); 581 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700)));
582 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, 582 CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", 0, "", 0,
583 TokenEnumerator::kNoSecurityToken); 583 TokenEnumerator::kNoSecurityToken);
584 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); 584 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100);
585 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); 585 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700)));
586 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); 586 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750)));
587 } 587 }
588 588
589 589
590 namespace { 590 namespace {
591 591
592 class TestSetup { 592 class TestSetup {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 i::OS::SNPrintF(title, "%d", i); 921 i::OS::SNPrintF(title, "%d", i);
922 // UID must be > 0. 922 // UID must be > 0.
923 CHECK(collection.StartProfiling(title.start(), i + 1, false)); 923 CHECK(collection.StartProfiling(title.start(), i + 1, false));
924 titles[i] = title.start(); 924 titles[i] = title.start();
925 } 925 }
926 CHECK(!collection.StartProfiling( 926 CHECK(!collection.StartProfiling(
927 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); 927 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
928 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) 928 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
929 i::DeleteArray(titles[i]); 929 i::DeleteArray(titles[i]);
930 } 930 }
OLDNEW
« test/cctest/test-cpu-profiler.cc ('K') | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698