| 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 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 const v8::HeapGraphNode* gc_roots = GetNode( | 1756 const v8::HeapGraphNode* gc_roots = GetNode( |
| 1757 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); | 1757 snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); |
| 1758 CHECK_NE(NULL, gc_roots); | 1758 CHECK_NE(NULL, gc_roots); |
| 1759 const v8::HeapGraphNode* global_handles = GetNode( | 1759 const v8::HeapGraphNode* global_handles = GetNode( |
| 1760 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)"); | 1760 gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)"); |
| 1761 CHECK_NE(NULL, global_handles); | 1761 CHECK_NE(NULL, global_handles); |
| 1762 return HasWeakEdge(global_handles); | 1762 return HasWeakEdge(global_handles); |
| 1763 } | 1763 } |
| 1764 | 1764 |
| 1765 | 1765 |
| 1766 static void PersistentHandleCallback(v8::Isolate* isolate, | 1766 static void PersistentHandleCallback( |
| 1767 v8::Persistent<v8::Value>* handle, | 1767 const v8::WeakCallbackData<v8::Value, void>& data) { |
| 1768 void*) { | |
| 1769 handle->Reset(); | |
| 1770 } | 1768 } |
| 1771 | 1769 |
| 1772 | 1770 |
| 1773 TEST(WeakGlobalHandle) { | 1771 TEST(WeakGlobalHandle) { |
| 1774 LocalContext env; | 1772 LocalContext env; |
| 1775 v8::HandleScope scope(env->GetIsolate()); | 1773 v8::HandleScope scope(env->GetIsolate()); |
| 1776 | 1774 |
| 1777 CHECK(!HasWeakGlobalHandle()); | 1775 CHECK(!HasWeakGlobalHandle()); |
| 1778 | 1776 |
| 1779 v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New()); | 1777 v8::Persistent<v8::Object> handle(env->GetIsolate(), v8::Object::New()); |
| 1780 handle.MakeWeak<v8::Value, void>(NULL, PersistentHandleCallback); | 1778 handle.SetWeak<v8::Value, void>(NULL, PersistentHandleCallback); |
| 1781 | 1779 |
| 1782 CHECK(HasWeakGlobalHandle()); | 1780 CHECK(HasWeakGlobalHandle()); |
| 1783 } | 1781 } |
| 1784 | 1782 |
| 1785 | 1783 |
| 1786 TEST(SfiAndJsFunctionWeakRefs) { | 1784 TEST(SfiAndJsFunctionWeakRefs) { |
| 1787 LocalContext env; | 1785 LocalContext env; |
| 1788 v8::HandleScope scope(env->GetIsolate()); | 1786 v8::HandleScope scope(env->GetIsolate()); |
| 1789 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1787 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); |
| 1790 | 1788 |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2322 | 2320 |
| 2323 AllocationTraceNode* node = | 2321 AllocationTraceNode* node = |
| 2324 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); | 2322 FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); |
| 2325 CHECK_NE(NULL, node); | 2323 CHECK_NE(NULL, node); |
| 2326 CHECK_LT(node->allocation_count(), 100); | 2324 CHECK_LT(node->allocation_count(), 100); |
| 2327 | 2325 |
| 2328 CcTest::heap()->DisableInlineAllocation(); | 2326 CcTest::heap()->DisableInlineAllocation(); |
| 2329 heap_profiler->StopRecordingHeapAllocations(); | 2327 heap_profiler->StopRecordingHeapAllocations(); |
| 2330 } | 2328 } |
| 2331 } | 2329 } |
| OLD | NEW |