| Index: src/heap/heap.cc
|
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc
|
| index 75b7ec1fa698f824e2e82c57da0cb9947132b08f..56dabf62e77a933b04971beb7860b46d0c71e495 100644
|
| --- a/src/heap/heap.cc
|
| +++ b/src/heap/heap.cc
|
| @@ -1256,7 +1256,10 @@ bool Heap::PerformGarbageCollection(
|
| GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL);
|
| VMState<EXTERNAL> state(isolate_);
|
| HandleScope handle_scope(isolate_);
|
| + // if (!(FLAG_scavenge_reclaim_unmodified_objects &&
|
| + // (gc_type == kGCTypeScavenge))) {
|
| CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags);
|
| + //}
|
| }
|
| }
|
|
|
| @@ -1341,7 +1344,10 @@ bool Heap::PerformGarbageCollection(
|
| GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL);
|
| VMState<EXTERNAL> state(isolate_);
|
| HandleScope handle_scope(isolate_);
|
| + // if (!(FLAG_scavenge_reclaim_unmodified_objects &&
|
| + // (gc_type == kGCTypeScavenge))) {
|
| CallGCEpilogueCallbacks(gc_type, gc_callback_flags);
|
| + // }
|
| }
|
| }
|
|
|
| @@ -1501,6 +1507,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 +1641,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 +1685,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 +1701,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);
|
|
|