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

Unified Diff: src/heap/heap.cc

Issue 1410593005: Adds a scavenge GC pass to collect unmodified references (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Forgot a fix in the last 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
« no previous file with comments | « src/global-handles.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/global-handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698