Index: src/heap/objects-visiting.cc |
diff --git a/src/heap/objects-visiting.cc b/src/heap/objects-visiting.cc |
index 22d3aba7ec6cc0a1aeac9db70a3fc31705e739fc..c56db57c2331ca53f761b18acb2daafc5118a742 100644 |
--- a/src/heap/objects-visiting.cc |
+++ b/src/heap/objects-visiting.cc |
@@ -307,9 +307,17 @@ struct WeakListVisitor<Context> { |
DoWeakList<JSFunction>(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<Code>(heap, context, retainer, Context::OPTIMIZED_CODE_LIST); |
DoWeakList<Code>(heap, context, retainer, Context::DEOPTIMIZED_CODE_LIST); |
} |