OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests for heap profiler | 3 // Tests for heap profiler |
4 | 4 |
5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
6 | 6 |
7 #include "v8.h" | 7 #include "v8.h" |
8 #include "heap-profiler.h" | 8 #include "heap-profiler.h" |
9 #include "snapshot.h" | 9 #include "snapshot.h" |
10 #include "string-stream.h" | 10 #include "string-stream.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 bool has_A2; | 424 bool has_A2; |
425 bool has_B2; | 425 bool has_B2; |
426 bool has_C2; | 426 bool has_C2; |
427 }; | 427 }; |
428 | 428 |
429 } // namespace | 429 } // namespace |
430 | 430 |
431 | 431 |
432 static const v8::HeapGraphNode* GetGlobalObject( | 432 static const v8::HeapGraphNode* GetGlobalObject( |
433 const v8::HeapSnapshot* snapshot) { | 433 const v8::HeapSnapshot* snapshot) { |
434 if (i::Snapshot::IsEnabled()) { | 434 CHECK_EQ(1, snapshot->GetHead()->GetChildrenCount()); |
435 // In case if snapshots are enabled, there will present a | 435 return snapshot->GetHead()->GetChild(0)->GetToNode(); |
436 // vanilla deserealized global object, without properties | |
437 // added by the test code. | |
438 CHECK_EQ(2, snapshot->GetHead()->GetChildrenCount()); | |
439 // Choose the global object of a bigger size. | |
440 const v8::HeapGraphNode* node0 = | |
441 snapshot->GetHead()->GetChild(0)->GetToNode(); | |
442 const v8::HeapGraphNode* node1 = | |
443 snapshot->GetHead()->GetChild(1)->GetToNode(); | |
444 return node0->GetTotalSize() > node1->GetTotalSize() ? node0 : node1; | |
445 } else { | |
446 CHECK_EQ(1, snapshot->GetHead()->GetChildrenCount()); | |
447 return snapshot->GetHead()->GetChild(0)->GetToNode(); | |
448 } | |
449 } | 436 } |
450 | 437 |
451 | 438 |
452 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node, | 439 static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node, |
453 v8::HeapGraphEdge::Type type, | 440 v8::HeapGraphEdge::Type type, |
454 const char* name) { | 441 const char* name) { |
455 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { | 442 for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { |
456 const v8::HeapGraphEdge* prop = node->GetChild(i); | 443 const v8::HeapGraphEdge* prop = node->GetChild(i); |
457 v8::String::AsciiValue prop_name(prop->GetName()); | 444 v8::String::AsciiValue prop_name(prop->GetName()); |
458 if (prop->GetType() == type && strcmp(name, *prop_name) == 0) | 445 if (prop->GetType() == type && strcmp(name, *prop_name) == 0) |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 lazy_references_x = true; | 618 lazy_references_x = true; |
632 break; | 619 break; |
633 } | 620 } |
634 } | 621 } |
635 } | 622 } |
636 CHECK(compiled_references_x); | 623 CHECK(compiled_references_x); |
637 CHECK(!lazy_references_x); | 624 CHECK(!lazy_references_x); |
638 } | 625 } |
639 | 626 |
640 #endif // ENABLE_LOGGING_AND_PROFILING | 627 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |