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

Unified Diff: src/heap/heap.cc

Issue 904633003: Just visit young array buffers during scavenge. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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.h ('k') | src/heap/mark-compact.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 0742aafc83913c1c3e4a46792ca6da2e415c2ebe..67d033cd13c3b1b5d810a0be4147bece61e2045e 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -144,7 +144,8 @@ Heap::Heap()
external_string_table_(this),
chunks_queued_for_free_(NULL),
gc_callbacks_depth_(0),
- deserialization_complete_(false) {
+ deserialization_complete_(false),
+ promotion_failure_(false) {
// Allow build-time customization of the max semispace size. Building
// V8 with snapshots and a non-default max semispace size is much
// easier if you can define it as part of the build environment.
@@ -731,6 +732,7 @@ void Heap::GarbageCollectionEpilogue() {
// Remember the last top pointer so that we can later find out
// whether we allocated in new space since the last GC.
new_space_top_after_last_gc_ = new_space()->top();
+ set_promotion_failure(false);
}
@@ -1689,32 +1691,70 @@ void Heap::UpdateReferencesInExternalStringTable(
void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) {
- ProcessArrayBuffers(retainer);
+ ProcessArrayBuffers(retainer, false);
+ ProcessNewArrayBufferViews(retainer);
ProcessNativeContexts(retainer);
ProcessAllocationSites(retainer);
}
void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) {
- ProcessArrayBuffers(retainer);
+ ProcessArrayBuffers(retainer, true);
+ ProcessNewArrayBufferViews(retainer);
ProcessNativeContexts(retainer);
}
void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) {
- Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer);
+ Object* head =
+ VisitWeakList<Context>(this, native_contexts_list(), retainer, false);
// Update the head of the list of contexts.
set_native_contexts_list(head);
}
-void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer) {
- Object* array_buffer_obj =
- VisitWeakList<JSArrayBuffer>(this, array_buffers_list(), retainer);
+void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer,
+ bool stop_after_young) {
+ Object* array_buffer_obj = VisitWeakList<JSArrayBuffer>(
+ this, array_buffers_list(), retainer, stop_after_young);
set_array_buffers_list(array_buffer_obj);
}
+void Heap::ProcessNewArrayBufferViews(WeakObjectRetainer* retainer) {
+ // Retain the list of new space views.
+ Object* typed_array_obj = VisitWeakList<JSArrayBufferView>(
+ this, new_array_buffer_views_list_, retainer, false);
+ set_new_array_buffer_views_list(typed_array_obj);
+
+ // Some objects in the list may be in old space now. Find them
+ // and move them to the corresponding array buffer.
Hannes Payer (out of office) 2015/02/06 12:21:10 We could do this in one pass with a specialized Vi
+ Object* undefined = undefined_value();
+ Object* previous = undefined;
+ Object* next;
+ for (Object* o = new_array_buffer_views_list(); o != undefined;) {
+ JSArrayBufferView* view = JSArrayBufferView::cast(o);
+ next = view->weak_next();
+ if (!InNewSpace(view)) {
+ if (previous == undefined) {
+ // We are at the list head.
+ set_new_array_buffer_views_list(next);
+ } else {
+ // We are in the middle of the list, skip the old space element.
+ JSArrayBufferView::cast(previous)->set_weak_next(next);
+ }
+ JSArrayBuffer* buffer = JSArrayBuffer::cast(view->buffer());
+ view->set_weak_next(buffer->weak_first_view());
+ buffer->set_weak_first_view(view);
+ } else {
+ // We found a valid new space view, remember it.
+ previous = view;
+ }
+ o = next;
+ }
+}
+
+
void Heap::TearDownArrayBuffers() {
Object* undefined = undefined_value();
for (Object* o = array_buffers_list(); o != undefined;) {
@@ -1727,8 +1767,8 @@ void Heap::TearDownArrayBuffers() {
void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) {
- Object* allocation_site_obj =
- VisitWeakList<AllocationSite>(this, allocation_sites_list(), retainer);
+ Object* allocation_site_obj = VisitWeakList<AllocationSite>(
+ this, allocation_sites_list(), retainer, false);
set_allocation_sites_list(allocation_site_obj);
}
@@ -2161,6 +2201,7 @@ class ScavengingVisitor : public StaticVisitorBase {
return;
}
+ heap->set_promotion_failure(true);
// If promotion failed, we try to copy the object to the other semi-space
if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return;
@@ -5500,6 +5541,7 @@ bool Heap::CreateHeapObjects() {
set_native_contexts_list(undefined_value());
set_array_buffers_list(undefined_value());
+ set_new_array_buffer_views_list(undefined_value());
set_allocation_sites_list(undefined_value());
weak_object_to_code_table_ = undefined_value();
return true;
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698