| 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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 CHECK(!HasWeakGlobalHandle()); | 1514 CHECK(!HasWeakGlobalHandle()); |
| 1515 | 1515 |
| 1516 v8::Persistent<v8::Object> handle = | 1516 v8::Persistent<v8::Object> handle = |
| 1517 v8::Persistent<v8::Object>::New(v8::Object::New()); | 1517 v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 1518 handle.MakeWeak(NULL, PersistentHandleCallback); | 1518 handle.MakeWeak(NULL, PersistentHandleCallback); |
| 1519 | 1519 |
| 1520 CHECK(HasWeakGlobalHandle()); | 1520 CHECK(HasWeakGlobalHandle()); |
| 1521 } | 1521 } |
| 1522 | 1522 |
| 1523 | 1523 |
| 1524 TEST(WeakNativeContextRefs) { | 1524 TEST(WeakGlobalContextRefs) { |
| 1525 v8::HandleScope scope; | 1525 v8::HandleScope scope; |
| 1526 LocalContext env; | 1526 LocalContext env; |
| 1527 | 1527 |
| 1528 const v8::HeapSnapshot* snapshot = | 1528 const v8::HeapSnapshot* snapshot = |
| 1529 v8::HeapProfiler::TakeSnapshot(v8_str("weaks")); | 1529 v8::HeapProfiler::TakeSnapshot(v8_str("weaks")); |
| 1530 const v8::HeapGraphNode* gc_roots = GetNode( | 1530 const v8::HeapGraphNode* gc_roots = GetNode( |
| 1531 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); | 1531 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); |
| 1532 CHECK_NE(NULL, gc_roots); | 1532 CHECK_NE(NULL, gc_roots); |
| 1533 const v8::HeapGraphNode* global_handles = GetNode( | 1533 const v8::HeapGraphNode* global_handles = GetNode( |
| 1534 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)"); | 1534 gc_roots, v8::HeapGraphNode::kObject, "(Global handles)"); |
| 1535 CHECK_NE(NULL, global_handles); | 1535 CHECK_NE(NULL, global_handles); |
| 1536 const v8::HeapGraphNode* native_context = GetNode( | 1536 const v8::HeapGraphNode* global_context = GetNode( |
| 1537 global_handles, v8::HeapGraphNode::kHidden, "system / NativeContext"); | 1537 global_handles, v8::HeapGraphNode::kHidden, "system / GlobalContext"); |
| 1538 CHECK_NE(NULL, native_context); | 1538 CHECK_NE(NULL, global_context); |
| 1539 CHECK(HasWeakEdge(native_context)); | 1539 CHECK(HasWeakEdge(global_context)); |
| 1540 } | 1540 } |
| 1541 | 1541 |
| 1542 | 1542 |
| 1543 TEST(SfiAndJsFunctionWeakRefs) { | 1543 TEST(SfiAndJsFunctionWeakRefs) { |
| 1544 v8::HandleScope scope; | 1544 v8::HandleScope scope; |
| 1545 LocalContext env; | 1545 LocalContext env; |
| 1546 | 1546 |
| 1547 CompileRun( | 1547 CompileRun( |
| 1548 "fun = (function (x) { return function () { return x + 1; } })(1);"); | 1548 "fun = (function (x) { return function () { return x + 1; } })(1);"); |
| 1549 const v8::HeapSnapshot* snapshot = | 1549 const v8::HeapSnapshot* snapshot = |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 const v8::HeapGraphNode* map = | 1673 const v8::HeapGraphNode* map = |
| 1674 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map"); | 1674 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map"); |
| 1675 CHECK_NE(NULL, map); | 1675 CHECK_NE(NULL, map); |
| 1676 const v8::HeapGraphNode* descriptors = | 1676 const v8::HeapGraphNode* descriptors = |
| 1677 GetProperty(map, v8::HeapGraphEdge::kInternal, "descriptors"); | 1677 GetProperty(map, v8::HeapGraphEdge::kInternal, "descriptors"); |
| 1678 CHECK_NE(NULL, descriptors); | 1678 CHECK_NE(NULL, descriptors); |
| 1679 const v8::HeapGraphNode* transitions = | 1679 const v8::HeapGraphNode* transitions = |
| 1680 GetProperty(map, v8::HeapGraphEdge::kInternal, "transitions"); | 1680 GetProperty(map, v8::HeapGraphEdge::kInternal, "transitions"); |
| 1681 CHECK_NE(NULL, transitions); | 1681 CHECK_NE(NULL, transitions); |
| 1682 } | 1682 } |
| OLD | NEW |