From 45a52b624a820194497770ebce31750fa74c39ec Mon Sep 17 00:00:00 2001 From: hpayer Date: Thu, 19 Nov 2015 02:52:37 -0800 Subject: [PATCH] [heap] Move slot recording of weak fields in native context to native context list retainer. BUG= Review URL: https://codereview.chromium.org/1463483002 Cr-Commit-Position: refs/heads/master@{#32109} --- src/heap/objects-visiting-inl.h | 7 ------- src/heap/objects-visiting.cc | 12 ++++++++++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/heap/objects-visiting-inl.h b/src/heap/objects-visiting-inl.h index 08e9092cb8..cc75234ae8 100644 --- a/src/heap/objects-visiting-inl.h +++ b/src/heap/objects-visiting-inl.h @@ -304,13 +304,6 @@ void StaticMarkingVisitor::VisitNativeContext( Map* map, HeapObject* object) { FixedBodyVisitor::Visit(map, object); - - MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector(); - for (int idx = Context::FIRST_WEAK_SLOT; idx < Context::NATIVE_CONTEXT_SLOTS; - ++idx) { - Object** slot = Context::cast(object)->RawFieldOfElementAt(idx); - collector->RecordSlot(object, slot, *slot); - } } diff --git a/src/heap/objects-visiting.cc b/src/heap/objects-visiting.cc index 22d3aba7ec..c56db57c23 100644 --- a/src/heap/objects-visiting.cc +++ b/src/heap/objects-visiting.cc @@ -307,9 +307,17 @@ struct WeakListVisitor { DoWeakList(heap, context, retainer, Context::OPTIMIZED_FUNCTIONS_LIST); - // Code objects are always allocated in Code space, we do not have to visit - // them during scavenges. if (heap->gc_state() == Heap::MARK_COMPACT) { + // Record the slots of the weak entries in the native context. + MarkCompactCollector* collector = heap->mark_compact_collector(); + for (int idx = Context::FIRST_WEAK_SLOT; + idx < Context::NATIVE_CONTEXT_SLOTS; ++idx) { + Object** slot = Context::cast(context)->RawFieldOfElementAt(idx); + collector->RecordSlot(context, slot, *slot); + } + // Code objects are always allocated in Code space, we do not have to + // visit + // them during scavenges. DoWeakList(heap, context, retainer, Context::OPTIMIZED_CODE_LIST); DoWeakList(heap, context, retainer, Context::DEOPTIMIZED_CODE_LIST); }