Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index 75b7ec1fa698f824e2e82c57da0cb9947132b08f..7da044de460688c1deb8b29feb2a2312ec88a5ec 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -1501,6 +1501,22 @@ static bool IsUnscavengedHeapObject(Heap* heap, Object** p) { |
} |
+static bool IsUnmodifiedHeapObject(Object** p) { |
+ Object* object = *p; |
+ DCHECK(object->IsHeapObject()); |
+ HeapObject* heap_object = HeapObject::cast(object); |
+ if (!object->IsJSObject()) return false; |
+ Object* obj_constructor = (JSObject::cast(object))->map()->GetConstructor(); |
+ if (!obj_constructor->IsJSFunction()) return false; |
+ JSFunction* constructor = JSFunction::cast(obj_constructor); |
+ if (constructor != nullptr && |
+ constructor->initial_map() == heap_object->map()) { |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+ |
void Heap::ScavengeStoreBufferCallback(Heap* heap, MemoryChunk* page, |
StoreBufferEvent event) { |
heap->store_buffer_rebuilder_.Callback(page, event); |
@@ -1619,6 +1635,12 @@ void Heap::Scavenge() { |
promotion_queue_.Initialize(); |
ScavengeVisitor scavenge_visitor(this); |
+ |
+ if (FLAG_scavenge_reclaim_unmodified_objects) { |
+ isolate()->global_handles()->IdentifyWeakUnmodifiedObjects( |
+ &IsUnmodifiedHeapObject); |
+ } |
+ |
{ |
// Copy roots. |
GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_ROOTS); |
@@ -1657,7 +1679,14 @@ void Heap::Scavenge() { |
new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
} |
- { |
+ if (FLAG_scavenge_reclaim_unmodified_objects) { |
+ isolate()->global_handles()->MarkNewSpaceWeakUnmodifiedObjectsPending( |
+ &IsUnscavengedHeapObject); |
+ |
+ isolate()->global_handles()->IterateNewSpaceWeakUnmodifiedRoots( |
+ &scavenge_visitor); |
+ new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
+ } else { |
GCTracer::Scope gc_scope(tracer(), |
GCTracer::Scope::SCAVENGER_OBJECT_GROUPS); |
while (isolate()->global_handles()->IterateObjectGroups( |
@@ -1666,14 +1695,14 @@ void Heap::Scavenge() { |
} |
isolate()->global_handles()->RemoveObjectGroups(); |
isolate()->global_handles()->RemoveImplicitRefGroups(); |
- } |
- isolate()->global_handles()->IdentifyNewSpaceWeakIndependentHandles( |
- &IsUnscavengedHeapObject); |
+ isolate()->global_handles()->IdentifyNewSpaceWeakIndependentHandles( |
+ &IsUnscavengedHeapObject); |
- isolate()->global_handles()->IterateNewSpaceWeakIndependentRoots( |
- &scavenge_visitor); |
- new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
+ isolate()->global_handles()->IterateNewSpaceWeakIndependentRoots( |
+ &scavenge_visitor); |
+ new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
+ } |
UpdateNewSpaceReferencesInExternalStringTable( |
&UpdateNewSpaceReferenceInExternalStringTableEntry); |