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(WeakGlobalContextRefs) { | 1524 TEST(WeakNativeContextRefs) { |
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* global_context = GetNode( | 1536 const v8::HeapGraphNode* native_context = GetNode( |
1537 global_handles, v8::HeapGraphNode::kHidden, "system / GlobalContext"); | 1537 global_handles, v8::HeapGraphNode::kHidden, "system / NativeContext"); |
1538 CHECK_NE(NULL, global_context); | 1538 CHECK_NE(NULL, native_context); |
1539 CHECK(HasWeakEdge(global_context)); | 1539 CHECK(HasWeakEdge(native_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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 const v8::HeapGraphNode* global_object = | 1651 const v8::HeapGraphNode* global_object = |
1652 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); | 1652 GetProperty(global, v8::HeapGraphEdge::kProperty, "global_object"); |
1653 CHECK_NE(NULL, global_object); | 1653 CHECK_NE(NULL, global_object); |
1654 const v8::HeapGraphNode* properties = | 1654 const v8::HeapGraphNode* properties = |
1655 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); | 1655 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "properties"); |
1656 CHECK_EQ(NULL, properties); | 1656 CHECK_EQ(NULL, properties); |
1657 const v8::HeapGraphNode* elements = | 1657 const v8::HeapGraphNode* elements = |
1658 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); | 1658 GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements"); |
1659 CHECK_EQ(NULL, elements); | 1659 CHECK_EQ(NULL, elements); |
1660 } | 1660 } |
OLD | NEW |