| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1656 const v8::HeapGraphNode* foo = | 1656 const v8::HeapGraphNode* foo = |
| 1657 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); | 1657 GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); |
| 1658 CHECK_NE(NULL, foo); | 1658 CHECK_NE(NULL, foo); |
| 1659 } | 1659 } |
| 1660 } | 1660 } |
| 1661 CHECK_EQ(1, globals_count); | 1661 CHECK_EQ(1, globals_count); |
| 1662 } | 1662 } |
| 1663 #endif // ENABLE_DEBUGGER_SUPPORT | 1663 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1664 | 1664 |
| 1665 | 1665 |
| 1666 TEST(PersistentHandleCount) { | |
| 1667 LocalContext env; | |
| 1668 v8::Isolate* isolate = env->GetIsolate(); | |
| 1669 v8::HandleScope scope(isolate); | |
| 1670 | |
| 1671 // V8 also uses global handles internally, so we can't test for an absolute | |
| 1672 // number. | |
| 1673 int global_handle_count = v8::HeapProfiler::GetPersistentHandleCount(); | |
| 1674 | |
| 1675 // Create some persistent handles. | |
| 1676 v8::Persistent<v8::String> p_AAA = | |
| 1677 v8::Persistent<v8::String>::New(isolate, v8_str("AAA")); | |
| 1678 CHECK_EQ(global_handle_count + 1, | |
| 1679 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1680 v8::Persistent<v8::String> p_BBB = | |
| 1681 v8::Persistent<v8::String>::New(isolate, v8_str("BBB")); | |
| 1682 CHECK_EQ(global_handle_count + 2, | |
| 1683 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1684 v8::Persistent<v8::String> p_CCC = | |
| 1685 v8::Persistent<v8::String>::New(isolate, v8_str("CCC")); | |
| 1686 CHECK_EQ(global_handle_count + 3, | |
| 1687 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1688 | |
| 1689 // Dipose the persistent handles in a different order. | |
| 1690 p_AAA.Dispose(env->GetIsolate()); | |
| 1691 CHECK_EQ(global_handle_count + 2, | |
| 1692 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1693 p_CCC.Dispose(env->GetIsolate()); | |
| 1694 CHECK_EQ(global_handle_count + 1, | |
| 1695 v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1696 p_BBB.Dispose(env->GetIsolate()); | |
| 1697 CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount()); | |
| 1698 } | |
| 1699 | |
| 1700 | |
| 1701 TEST(AllStrongGcRootsHaveNames) { | 1666 TEST(AllStrongGcRootsHaveNames) { |
| 1702 LocalContext env; | 1667 LocalContext env; |
| 1703 v8::HandleScope scope(env->GetIsolate()); | 1668 v8::HandleScope scope(env->GetIsolate()); |
| 1704 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1669 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 1705 | 1670 |
| 1706 CompileRun("foo = {};"); | 1671 CompileRun("foo = {};"); |
| 1707 const v8::HeapSnapshot* snapshot = | 1672 const v8::HeapSnapshot* snapshot = |
| 1708 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); | 1673 heap_profiler->TakeHeapSnapshot(v8_str("snapshot")); |
| 1709 const v8::HeapGraphNode* gc_roots = GetNode( | 1674 const v8::HeapGraphNode* gc_roots = GetNode( |
| 1710 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); | 1675 snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(GC roots)"); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1800 // Check all the objects have got their names. | 1765 // Check all the objects have got their names. |
| 1801 // ... well check just every 8th because otherwise it's too slow in debug. | 1766 // ... well check just every 8th because otherwise it's too slow in debug. |
| 1802 for (int i = 0; i < num_objects - 1; i += 8) { | 1767 for (int i = 0; i < num_objects - 1; i += 8) { |
| 1803 i::EmbeddedVector<char, 100> var_name; | 1768 i::EmbeddedVector<char, 100> var_name; |
| 1804 i::OS::SNPrintF(var_name, "f_%d", i); | 1769 i::OS::SNPrintF(var_name, "f_%d", i); |
| 1805 const v8::HeapGraphNode* f_object = GetProperty( | 1770 const v8::HeapGraphNode* f_object = GetProperty( |
| 1806 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); | 1771 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); |
| 1807 CHECK_NE(NULL, f_object); | 1772 CHECK_NE(NULL, f_object); |
| 1808 } | 1773 } |
| 1809 } | 1774 } |
| OLD | NEW |