Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Unified Diff: src/mark-compact.cc

Issue 3764011: Link all global contexts into a weak list. (Closed)
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/contexts.h ('K') | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(),
« src/contexts.h ('K') | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698