Index: src/mark-compact.cc |
diff --git a/src/mark-compact.cc b/src/mark-compact.cc |
index 26f88cfe611ca1bc95cbda7e995489aaf45ab89a..c8172519d333efd91e2d10333a7b6b55d96f2a2f 100644 |
--- a/src/mark-compact.cc |
+++ b/src/mark-compact.cc |
@@ -282,6 +282,11 @@ class StaticMarkingVisitor : public StaticVisitorBase { |
FixedArray::BodyDescriptor, |
void>::Visit); |
+ table_.Register(kVisitGlobalContext, |
+ &FixedBodyVisitor<StaticMarkingVisitor, |
+ Context::MarkCompactBodyDescriptor, |
+ void>::Visit); |
+ |
table_.Register(kVisitSharedFunctionInfo, &VisitSharedFunctionInfo); |
table_.Register(kVisitByteArray, &DataObjectVisitor::Visit); |
@@ -578,6 +583,7 @@ class StaticMarkingVisitor : public StaticVisitorBase { |
VisitPointers(SLOT_ADDR(object, |
JSFunction::kCodeEntryOffset + kPointerSize), |
SLOT_ADDR(object, JSFunction::kSize)); |
+ |
#undef SLOT_ADDR |
} |
@@ -738,6 +744,21 @@ class SymbolTableCleaner : public ObjectVisitor { |
}; |
+// Implementation of WeakObjectRetainer for mark compact GCs. All marked objects |
+// are retained. |
+class MarkCompactWeakObjectRetainer : public WeakObjectRetainer { |
+ public: |
+ virtual Object* RetainAs(Object* object) { |
+ MapWord first_word = HeapObject::cast(object)->map_word(); |
+ if (first_word.IsMarked()) { |
+ return object; |
+ } else { |
+ return NULL; |
+ } |
+ } |
+}; |
+ |
+ |
void MarkCompactCollector::MarkUnmarkedObject(HeapObject* object) { |
ASSERT(!object->IsMarked()); |
ASSERT(Heap::Contains(object)); |
@@ -1069,6 +1090,10 @@ void MarkCompactCollector::MarkLiveObjects() { |
ExternalStringTable::Iterate(&v); |
ExternalStringTable::CleanUp(); |
+ // Process the weak references. |
+ MarkCompactWeakObjectRetainer mark_compact_object_retainer; |
+ Heap::ProcessWeakReferences(&mark_compact_object_retainer); |
+ |
// Remove object groups after marking phase. |
GlobalHandles::RemoveObjectGroups(); |
} |
@@ -1639,6 +1664,9 @@ static void SweepNewSpace(NewSpace* space) { |
} |
} |
+ // Update pointer from the global contexts list. |
+ updating_visitor.VisitPointer(Heap::global_contexts_list_address()); |
+ |
// Update pointers from external string table. |
Heap::UpdateNewSpaceReferencesInExternalStringTable( |
&UpdateNewSpaceReferenceInExternalStringTableEntry); |
@@ -2245,6 +2273,9 @@ void MarkCompactCollector::UpdatePointers() { |
Heap::IterateRoots(&updating_visitor, VISIT_ONLY_STRONG); |
GlobalHandles::IterateWeakRoots(&updating_visitor); |
+ // Update the pointer to the head of the weak list of global contexts. |
+ updating_visitor.VisitPointer(&Heap::global_contexts_list_); |
marklam
2010/10/19 00:57:19
For consistency, shouldn't this be made to call He
|
+ |
int live_maps_size = IterateLiveObjects(Heap::map_space(), |
&UpdatePointersInOldObject); |
int live_pointer_olds_size = IterateLiveObjects(Heap::old_pointer_space(), |