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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 591 |
592 // Find references to code. | 592 // Find references to code. |
593 const v8::HeapGraphNode* compiled_code = | 593 const v8::HeapGraphNode* compiled_code = |
594 GetProperty(compiled, v8::HeapGraphEdge::INTERNAL, "code"); | 594 GetProperty(compiled, v8::HeapGraphEdge::INTERNAL, "code"); |
595 CHECK_NE(NULL, compiled_code); | 595 CHECK_NE(NULL, compiled_code); |
596 const v8::HeapGraphNode* lazy_code = | 596 const v8::HeapGraphNode* lazy_code = |
597 GetProperty(lazy, v8::HeapGraphEdge::INTERNAL, "code"); | 597 GetProperty(lazy, v8::HeapGraphEdge::INTERNAL, "code"); |
598 CHECK_NE(NULL, lazy_code); | 598 CHECK_NE(NULL, lazy_code); |
599 | 599 |
600 // Verify that non-compiled code doesn't contain references to "x" | 600 // Verify that non-compiled code doesn't contain references to "x" |
601 // literal, while compiled code does. | 601 // literal, while compiled code does. The scope info is stored in FixedArray |
| 602 // objects attached to the SharedFunctionInfo. |
602 bool compiled_references_x = false, lazy_references_x = false; | 603 bool compiled_references_x = false, lazy_references_x = false; |
603 for (int i = 0, count = compiled_code->GetChildrenCount(); i < count; ++i) { | 604 for (int i = 0, count = compiled_code->GetChildrenCount(); i < count; ++i) { |
604 const v8::HeapGraphEdge* prop = compiled_code->GetChild(i); | 605 const v8::HeapGraphEdge* prop = compiled_code->GetChild(i); |
605 const v8::HeapGraphNode* node = prop->GetToNode(); | 606 const v8::HeapGraphNode* node = prop->GetToNode(); |
606 if (node->GetType() == v8::HeapGraphNode::CODE) { | 607 if (node->GetType() == v8::HeapGraphNode::ARRAY) { |
607 if (HasString(node, "x")) { | 608 if (HasString(node, "x")) { |
608 compiled_references_x = true; | 609 compiled_references_x = true; |
609 break; | 610 break; |
610 } | 611 } |
611 } | 612 } |
612 } | 613 } |
613 for (int i = 0, count = lazy_code->GetChildrenCount(); i < count; ++i) { | 614 for (int i = 0, count = lazy_code->GetChildrenCount(); i < count; ++i) { |
614 const v8::HeapGraphEdge* prop = lazy_code->GetChild(i); | 615 const v8::HeapGraphEdge* prop = lazy_code->GetChild(i); |
615 const v8::HeapGraphNode* node = prop->GetToNode(); | 616 const v8::HeapGraphNode* node = prop->GetToNode(); |
616 if (node->GetType() == v8::HeapGraphNode::CODE) { | 617 if (node->GetType() == v8::HeapGraphNode::ARRAY) { |
617 if (HasString(node, "x")) { | 618 if (HasString(node, "x")) { |
618 lazy_references_x = true; | 619 lazy_references_x = true; |
619 break; | 620 break; |
620 } | 621 } |
621 } | 622 } |
622 } | 623 } |
623 CHECK(compiled_references_x); | 624 CHECK(compiled_references_x); |
624 CHECK(!lazy_references_x); | 625 CHECK(!lazy_references_x); |
625 } | 626 } |
626 | 627 |
627 #endif // ENABLE_LOGGING_AND_PROFILING | 628 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |