From 86bfd87fa6edd26a2cd8d03b8be0d72e7bc83b27 Mon Sep 17 00:00:00 2001 From: "alph@chromium.org" Date: Wed, 17 Jul 2013 18:23:16 +0000 Subject: [PATCH] Do not report unessential weak references in heap snapshot. R=verwaest@chromium.org, yurys@chromium.org Review URL: https://codereview.chromium.org/19267023 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15731 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap-snapshot-generator.cc | 5 +++-- test/cctest/test-heap-profiler.cc | 25 ++----------------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc index 15e0a7ccef..feced9f2bf 100644 --- a/src/heap-snapshot-generator.cc +++ b/src/heap-snapshot-generator.cc @@ -1681,13 +1681,14 @@ void V8HeapExplorer::SetWeakReference(HeapObject* parent_obj, int field_offset) { ASSERT(parent_entry == GetEntry(parent_obj)->index()); HeapEntry* child_entry = GetEntry(child_obj); - if (child_entry != NULL) { + if (child_entry == NULL) return; + if (IsEssentialObject(child_obj)) { filler_->SetIndexedReference(HeapGraphEdge::kWeak, parent_entry, index, child_entry); - IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); } + IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset); } diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index 2351790e6c..e30fcc00c9 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -1728,27 +1728,6 @@ TEST(WeakGlobalHandle) { } -TEST(WeakNativeContextRefs) { - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); - - const v8::HeapSnapshot* snapshot = - heap_profiler->TakeHeapSnapshot(v8_str("weaks")); - CHECK(ValidateSnapshot(snapshot)); - const v8::HeapGraphNode* gc_roots = GetNode( - snapshot->GetRoot(), v8::HeapGraphNode::kSynthetic, "(GC roots)"); - CHECK_NE(NULL, gc_roots); - const v8::HeapGraphNode* global_handles = GetNode( - gc_roots, v8::HeapGraphNode::kSynthetic, "(Global handles)"); - CHECK_NE(NULL, global_handles); - const v8::HeapGraphNode* native_context = GetNode( - global_handles, v8::HeapGraphNode::kHidden, "system / NativeContext"); - CHECK_NE(NULL, native_context); - CHECK(HasWeakEdge(native_context)); -} - - TEST(SfiAndJsFunctionWeakRefs) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -1763,10 +1742,10 @@ TEST(SfiAndJsFunctionWeakRefs) { CHECK_NE(NULL, global); const v8::HeapGraphNode* fun = GetProperty(global, v8::HeapGraphEdge::kProperty, "fun"); - CHECK(HasWeakEdge(fun)); + CHECK(!HasWeakEdge(fun)); const v8::HeapGraphNode* shared = GetProperty(fun, v8::HeapGraphEdge::kInternal, "shared"); - CHECK(HasWeakEdge(shared)); + CHECK(!HasWeakEdge(shared)); }