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

Unified Diff: src/heap/heap.cc

Issue 1358703003: Changed scavenge GC to collect unmodified references (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased the patch Created 5 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
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 0144262863b161ae31557b183370a13d0eca1ce1..335a3a755b47f331ae52b220f73b8ba7aa9465e2 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1240,7 +1240,9 @@ bool Heap::PerformGarbageCollection(
GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL);
VMState<EXTERNAL> state(isolate_);
HandleScope handle_scope(isolate_);
- CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags);
+ if (!(gc_type == kGCTypeScavenge &&
+ FLAG_scavenge_reclaim_unmodified_objects))
rmcilroy 2015/10/02 18:09:46 Nit - swap flag and GC_type check order.
mythria 2015/10/05 10:55:34 Done.
+ CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags);
}
}
@@ -1325,7 +1327,9 @@ bool Heap::PerformGarbageCollection(
GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL);
VMState<EXTERNAL> state(isolate_);
HandleScope handle_scope(isolate_);
- CallGCEpilogueCallbacks(gc_type, gc_callback_flags);
+ if (!(gc_type == kGCTypeScavenge &&
+ FLAG_scavenge_reclaim_unmodified_objects))
rmcilroy 2015/10/02 18:09:46 Ditto
mythria 2015/10/05 10:55:34 Done.
+ CallGCEpilogueCallbacks(gc_type, gc_callback_flags);
}
}
@@ -1485,6 +1489,22 @@ static bool IsUnscavengedHeapObject(Heap* heap, Object** p) {
}
+static bool IsUnModifiedNewSpaceObject(Object** p) {
rmcilroy 2015/10/02 18:09:46 This function doesn't seem to check if the object
mythria 2015/10/05 10:55:34 Done.
+ 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 == NULL) return false;
+ if (constructor->initial_map() == heap_object->map()) return true;
+ return false;
rmcilroy 2015/10/02 18:09:46 Nit - just: return constructor != nullptr && cons
mythria 2015/10/05 10:55:34 Done.
+}
+
+
void Heap::ScavengeStoreBufferCallback(Heap* heap, MemoryChunk* page,
StoreBufferEvent event) {
heap->store_buffer_rebuilder_.Callback(page, event);
@@ -1603,6 +1623,12 @@ void Heap::Scavenge() {
promotion_queue_.Initialize();
ScavengeVisitor scavenge_visitor(this);
+
+ if (FLAG_scavenge_reclaim_unmodified_objects) {
+ isolate()->global_handles()->IdentifyWeakUnmodifiedObjects(
+ &IsUnModifiedNewSpaceObject);
+ }
+
{
// Copy roots.
GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_ROOTS);
@@ -1641,7 +1667,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(
@@ -1650,14 +1683,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);
« src/global-handles.cc ('K') | « src/global-handles.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698