| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests for heap profiler | 3 // Tests for heap profiler |
| 4 | 4 |
| 5 #include <ctype.h> | 5 #include <ctype.h> |
| 6 | 6 |
| 7 #include "v8.h" | 7 #include "v8.h" |
| 8 | 8 |
| 9 #include "cctest.h" | 9 #include "cctest.h" |
| 10 #include "hashmap.h" | 10 #include "hashmap.h" |
| (...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 CHECK_NE(NULL, global); | 1552 CHECK_NE(NULL, global); |
| 1553 const v8::HeapGraphNode* fun = | 1553 const v8::HeapGraphNode* fun = |
| 1554 GetProperty(global, v8::HeapGraphEdge::kProperty, "fun"); | 1554 GetProperty(global, v8::HeapGraphEdge::kProperty, "fun"); |
| 1555 CHECK(HasWeakEdge(fun)); | 1555 CHECK(HasWeakEdge(fun)); |
| 1556 const v8::HeapGraphNode* shared = | 1556 const v8::HeapGraphNode* shared = |
| 1557 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared"); | 1557 GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared"); |
| 1558 CHECK(HasWeakEdge(shared)); | 1558 CHECK(HasWeakEdge(shared)); |
| 1559 } | 1559 } |
| 1560 | 1560 |
| 1561 | 1561 |
| 1562 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1562 TEST(NoDebugObjectInSnapshot) { | 1563 TEST(NoDebugObjectInSnapshot) { |
| 1563 v8::HandleScope scope; | 1564 v8::HandleScope scope; |
| 1564 LocalContext env; | 1565 LocalContext env; |
| 1565 | 1566 |
| 1566 v8::internal::Isolate::Current()->debug()->Load(); | 1567 v8::internal::Isolate::Current()->debug()->Load(); |
| 1567 CompileRun("foo = {};"); | 1568 CompileRun("foo = {};"); |
| 1568 const v8::HeapSnapshot* snapshot = | 1569 const v8::HeapSnapshot* snapshot = |
| 1569 v8::HeapProfiler::TakeSnapshot(v8_str("snapshot")); | 1570 v8::HeapProfiler::TakeSnapshot(v8_str("snapshot")); |
| 1570 const v8::HeapGraphNode* root = snapshot->GetRoot(); | 1571 const v8::HeapGraphNode* root = snapshot->GetRoot(); |
| 1571 int globals_count = 0; | 1572 int globals_count = 0; |
| 1572 for (int i = 0; i < root->GetChildrenCount(); ++i) { | 1573 for (int i = 0; i < root->GetChildrenCount(); ++i) { |
| 1573 const v8::HeapGraphEdge* edge = root->GetChild(i); | 1574 const v8::HeapGraphEdge* edge = root->GetChild(i); |
| 1574 if (edge->GetType() == v8::HeapGraphEdge::kShortcut) { | 1575 if (edge->GetType() == v8::HeapGraphEdge::kShortcut) { |
| 1575 ++globals_count; | 1576 ++globals_count; |
| 1576 const v8::HeapGraphNode* global = edge->GetToNode(); | 1577 const v8::HeapGraphNode* global = edge->GetToNode(); |
| 1577 const v8::HeapGraphNode* foo = | 1578 const v8::HeapGraphNode* foo = |
| 1578 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); | 1579 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); |
| 1579 CHECK_NE(NULL, foo); | 1580 CHECK_NE(NULL, foo); |
| 1580 } | 1581 } |
| 1581 } | 1582 } |
| 1582 CHECK_EQ(1, globals_count); | 1583 CHECK_EQ(1, globals_count); |
| 1583 } | 1584 } |
| 1585 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1584 | 1586 |
| 1585 | 1587 |
| 1586 TEST(PersistentHandleCount) { | 1588 TEST(PersistentHandleCount) { |
| 1587 v8::HandleScope scope; | 1589 v8::HandleScope scope; |
| 1588 LocalContext env; | 1590 LocalContext env; |
| 1589 | 1591 |
| 1590 // V8 also uses global handles internally, so we can't test for an absolute | 1592 // V8 also uses global handles internally, so we can't test for an absolute |
| 1591 // number. | 1593 // number. |
| 1592 int global_handle_count = v8::HeapProfiler::GetPersistentHandleCount(); | 1594 int global_handle_count = v8::HeapProfiler::GetPersistentHandleCount(); |
| 1593 | 1595 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 const v8::HeapGraphNode* global_object = | 1651 const v8::HeapGraphNode* global_object = |
| 1650 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); | 1652 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); |
| 1651 CHECK_NE(NULL, global_object); | 1653 CHECK_NE(NULL, global_object); |
| 1652 const v8::HeapGraphNode* properties = | 1654 const v8::HeapGraphNode* properties = |
| 1653 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); | 1655 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); |
| 1654 CHECK_EQ(NULL, properties); | 1656 CHECK_EQ(NULL, properties); |
| 1655 const v8::HeapGraphNode* elements = | 1657 const v8::HeapGraphNode* elements = |
| 1656 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); | 1658 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); |
| 1657 CHECK_EQ(NULL, elements); | 1659 CHECK_EQ(NULL, elements); |
| 1658 } | 1660 } |
| OLD | NEW |