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

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: Checks if the object is not active inaddition to unmodified before reclaiming it. The browser test … 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') | test/cctest/test-api.cc » ('j') | 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..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);
« no previous file with comments | « 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