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

Unified Diff: src/heap/objects-visiting.cc

Issue 990423004: Reland Just visit young array buffers during scavenge. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/heap/objects-visiting.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/objects-visiting.cc
diff --git a/src/heap/objects-visiting.cc b/src/heap/objects-visiting.cc
index 7b2e2d9a388939440e0aac0bb5c3263fedc4676f..9d6d99ccae22bdaca59d02d04838498c6c4c482c 100644
--- a/src/heap/objects-visiting.cc
+++ b/src/heap/objects-visiting.cc
@@ -191,15 +191,19 @@ struct WeakListVisitor;
template <class T>
-Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) {
+Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer,
+ bool stop_after_young) {
Object* undefined = heap->undefined_value();
Object* head = undefined;
T* tail = NULL;
MarkCompactCollector* collector = heap->mark_compact_collector();
bool record_slots = MustRecordSlots(heap);
+
while (list != undefined) {
// Check whether to keep the candidate in the list.
T* candidate = reinterpret_cast<T*>(list);
+ T* original_candidate = candidate;
+
Object* retained = retainer->RetainAs(list);
if (retained != NULL) {
if (head == undefined) {
@@ -220,9 +224,21 @@ Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) {
candidate = reinterpret_cast<T*>(retained);
tail = candidate;
-
// tail is a live object, visit it.
WeakListVisitor<T>::VisitLiveObject(heap, tail, retainer);
+
+ // The list of weak objects is usually order. It starts with objects
+ // recently allocated in the young generation followed by objects
+ // allocated in the old generation. When a migration failure happened,
+ // the list is not ordered until the next GC that has no migration
+ // failure.
+ // For young generation collections we just have to visit until the last
+ // young generation objects.
+ if (stop_after_young && !heap->migration_failure() &&
+ !heap->previous_migration_failure() &&
+ !heap->InNewSpace(original_candidate)) {
+ return head;
+ }
} else {
WeakListVisitor<T>::VisitPhantomObject(heap, candidate);
}
@@ -239,6 +255,56 @@ Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) {
}
+Object* VisitNewArrayBufferViewsWeakList(Heap* heap, Object* list,
+ WeakObjectRetainer* retainer) {
+ Object* undefined = heap->undefined_value();
+ Object* previous = undefined;
+ Object* head = undefined;
+ Object* next;
+ MarkCompactCollector* collector = heap->mark_compact_collector();
+ bool record_slots = MustRecordSlots(heap);
+
+ for (Object* o = list; o != undefined;) {
+ JSArrayBufferView* view = JSArrayBufferView::cast(o);
+ next = view->weak_next();
+ if (!heap->InNewSpace(view)) {
+ if (previous != undefined) {
+ // We are in the middle of the list, skip the old space element.
+ JSArrayBufferView* previous_view = JSArrayBufferView::cast(previous);
+ previous_view->set_weak_next(next);
+ if (record_slots) {
+ Object** next_slot = HeapObject::RawField(
+ previous_view, JSArrayBufferView::kWeakNextOffset);
+ collector->RecordSlot(next_slot, next_slot, next);
+ }
+ }
+ JSArrayBuffer* buffer = JSArrayBuffer::cast(view->buffer());
+ view->set_weak_next(buffer->weak_first_view());
+ if (record_slots) {
+ Object** next_slot =
+ HeapObject::RawField(view, JSArrayBufferView::kWeakNextOffset);
+ collector->RecordSlot(next_slot, next_slot, buffer->weak_first_view());
+ }
+ buffer->set_weak_first_view(view);
+ if (record_slots) {
+ Object** slot =
+ HeapObject::RawField(buffer, JSArrayBuffer::kWeakFirstViewOffset);
+ heap->mark_compact_collector()->RecordSlot(slot, slot, view);
+ }
+ } else {
+ // We found a valid new space view, remember it.
+ previous = view;
+ if (head == undefined) {
+ // We are at the list head.
+ head = view;
+ }
+ }
+ o = next;
+ }
+ return head;
+}
+
+
template <class T>
static void ClearWeakList(Heap* heap, Object* list) {
Object* undefined = heap->undefined_value();
@@ -316,7 +382,8 @@ struct WeakListVisitor<Context> {
static void DoWeakList(Heap* heap, Context* context,
WeakObjectRetainer* retainer, int index) {
// Visit the weak list, removing dead intermediate elements.
- Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer);
+ Object* list_head =
+ VisitWeakList<T>(heap, context->get(index), retainer, false);
// Update the list head.
context->set(index, list_head, UPDATE_WRITE_BARRIER);
@@ -368,7 +435,7 @@ struct WeakListVisitor<JSArrayBuffer> {
static void VisitLiveObject(Heap* heap, JSArrayBuffer* array_buffer,
WeakObjectRetainer* retainer) {
Object* typed_array_obj = VisitWeakList<JSArrayBufferView>(
- heap, array_buffer->weak_first_view(), retainer);
+ heap, array_buffer->weak_first_view(), retainer, false);
array_buffer->set_weak_first_view(typed_array_obj);
if (typed_array_obj != heap->undefined_value() && MustRecordSlots(heap)) {
Object** slot = HeapObject::RawField(array_buffer,
@@ -399,23 +466,21 @@ struct WeakListVisitor<AllocationSite> {
};
-template Object* VisitWeakList<Code>(Heap* heap, Object* list,
- WeakObjectRetainer* retainer);
-
-
-template Object* VisitWeakList<JSFunction>(Heap* heap, Object* list,
- WeakObjectRetainer* retainer);
-
-
template Object* VisitWeakList<Context>(Heap* heap, Object* list,
- WeakObjectRetainer* retainer);
+ WeakObjectRetainer* retainer,
+ bool stop_after_young);
template Object* VisitWeakList<JSArrayBuffer>(Heap* heap, Object* list,
- WeakObjectRetainer* retainer);
+ WeakObjectRetainer* retainer,
+ bool stop_after_young);
+template Object* VisitWeakList<JSArrayBufferView>(Heap* heap, Object* list,
+ WeakObjectRetainer* retainer,
+ bool stop_after_young);
template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list,
- WeakObjectRetainer* retainer);
+ WeakObjectRetainer* retainer,
+ bool stop_after_young);
}
} // namespace v8::internal
« no previous file with comments | « src/heap/objects-visiting.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698