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

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

Issue 1061753008: Revert of Remove the weak list of views from array buffers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/heap.cc ('k') | src/heap/objects-visiting-inl.h » ('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 8c2f198754525390688fe114b61c3daebb229f1d..cf71fb2bdaf540423a3ec3c8f46c03771d1a888b 100644
--- a/src/heap/objects-visiting.cc
+++ b/src/heap/objects-visiting.cc
@@ -243,6 +243,56 @@
}
+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();
@@ -345,6 +395,22 @@
template <>
+struct WeakListVisitor<JSArrayBufferView> {
+ static void SetWeakNext(JSArrayBufferView* obj, Object* next) {
+ obj->set_weak_next(next);
+ }
+
+ static Object* WeakNext(JSArrayBufferView* obj) { return obj->weak_next(); }
+
+ static int WeakNextOffset() { return JSArrayBufferView::kWeakNextOffset; }
+
+ static void VisitLiveObject(Heap*, JSArrayBufferView*, WeakObjectRetainer*) {}
+
+ static void VisitPhantomObject(Heap*, JSArrayBufferView*) {}
+};
+
+
+template <>
struct WeakListVisitor<JSArrayBuffer> {
static void SetWeakNext(JSArrayBuffer* obj, Object* next) {
obj->set_weak_next(next);
@@ -356,6 +422,14 @@
static void VisitLiveObject(Heap* heap, JSArrayBuffer* array_buffer,
WeakObjectRetainer* retainer) {
+ Object* typed_array_obj = VisitWeakList<JSArrayBufferView>(
+ heap, array_buffer->weak_first_view(), retainer, false, NULL);
+ array_buffer->set_weak_first_view(typed_array_obj);
+ if (typed_array_obj != heap->undefined_value() && MustRecordSlots(heap)) {
+ Object** slot = HeapObject::RawField(array_buffer,
+ JSArrayBuffer::kWeakFirstViewOffset);
+ heap->mark_compact_collector()->RecordSlot(slot, slot, typed_array_obj);
+ }
}
static void VisitPhantomObject(Heap* heap, JSArrayBuffer* phantom) {
@@ -391,6 +465,11 @@
bool stop_after_young,
Object** list_tail);
+template Object* VisitWeakList<JSArrayBufferView>(Heap* heap, Object* list,
+ WeakObjectRetainer* retainer,
+ bool stop_after_young,
+ Object** list_tail);
+
template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list,
WeakObjectRetainer* retainer,
bool stop_after_young,
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/objects-visiting-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698