Visit encountered JSWeakCollection list during scavenging.

R=hpayer@chromium.org
BUG=chromium:380068
LOG=N

Review URL: https://codereview.chromium.org/310783003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21655 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 083419a3
......@@ -146,6 +146,7 @@ Heap::Heap()
set_native_contexts_list(NULL);
set_array_buffers_list(Smi::FromInt(0));
set_allocation_sites_list(Smi::FromInt(0));
set_encountered_weak_collections(Smi::FromInt(0));
// Put a dummy entry in the remembered pages so we can find the list the
// minidump even if there are no real unmapped pages.
RememberUnmappedPage(NULL, false);
......@@ -1529,6 +1530,9 @@ void Heap::Scavenge() {
}
}
// Copy objects reachable from the encountered weak collections list.
scavenge_visitor.VisitPointer(&encountered_weak_collections_);
// Copy objects reachable from the code flushing candidates list.
MarkCompactCollector* collector = mark_compact_collector();
if (collector->is_code_flushing_enabled()) {
......
......@@ -849,6 +849,13 @@ class Heap {
Object* weak_object_to_code_table() { return weak_object_to_code_table_; }
void set_encountered_weak_collections(Object* weak_collection) {
encountered_weak_collections_ = weak_collection;
}
Object* encountered_weak_collections() const {
return encountered_weak_collections_;
}
// Number of mark-sweeps.
unsigned int ms_count() { return ms_count_; }
......@@ -1613,6 +1620,11 @@ class Heap {
// start.
Object* weak_object_to_code_table_;
// List of encountered weak collections (JSWeakMap and JSWeakSet) during
// marking. It is initialized during marking, destroyed after marking and
// contains Smi(0) while marking is not active.
Object* encountered_weak_collections_;
StoreBufferRebuilder store_buffer_rebuilder_;
struct StringTypeTable {
......
......@@ -51,7 +51,6 @@ MarkCompactCollector::MarkCompactCollector(Heap* heap) : // NOLINT
migration_slots_buffer_(NULL),
heap_(heap),
code_flusher_(NULL),
encountered_weak_collections_(NULL),
have_code_to_deoptimize_(false) { }
#ifdef VERIFY_HEAP
......@@ -2738,7 +2737,7 @@ void MarkCompactCollector::ClearNonLiveDependentCode(DependentCode* entries) {
void MarkCompactCollector::ProcessWeakCollections() {
GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS);
Object* weak_collection_obj = encountered_weak_collections();
Object* weak_collection_obj = heap()->encountered_weak_collections();
while (weak_collection_obj != Smi::FromInt(0)) {
JSWeakCollection* weak_collection =
reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
......@@ -2765,7 +2764,7 @@ void MarkCompactCollector::ProcessWeakCollections() {
void MarkCompactCollector::ClearWeakCollections() {
GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_CLEAR);
Object* weak_collection_obj = encountered_weak_collections();
Object* weak_collection_obj = heap()->encountered_weak_collections();
while (weak_collection_obj != Smi::FromInt(0)) {
JSWeakCollection* weak_collection =
reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
......@@ -2782,7 +2781,7 @@ void MarkCompactCollector::ClearWeakCollections() {
weak_collection_obj = weak_collection->next();
weak_collection->set_next(heap()->undefined_value());
}
set_encountered_weak_collections(Smi::FromInt(0));
heap()->set_encountered_weak_collections(Smi::FromInt(0));
}
......
......@@ -649,13 +649,6 @@ class MarkCompactCollector {
bool TryPromoteObject(HeapObject* object, int object_size);
inline Object* encountered_weak_collections() {
return encountered_weak_collections_;
}
inline void set_encountered_weak_collections(Object* weak_collection) {
encountered_weak_collections_ = weak_collection;
}
void InvalidateCode(Code* code);
void ClearMarkbits();
......@@ -913,7 +906,6 @@ class MarkCompactCollector {
Heap* heap_;
MarkingDeque marking_deque_;
CodeFlusher* code_flusher_;
Object* encountered_weak_collections_;
bool have_code_to_deoptimize_;
List<Page*> evacuation_candidates_;
......
......@@ -402,12 +402,11 @@ void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection(
Heap* heap = map->GetHeap();
JSWeakCollection* weak_collection =
reinterpret_cast<JSWeakCollection*>(object);
MarkCompactCollector* collector = heap->mark_compact_collector();
// Enqueue weak collection in linked list of encountered weak collections.
if (weak_collection->next() == heap->undefined_value()) {
weak_collection->set_next(collector->encountered_weak_collections());
collector->set_encountered_weak_collections(weak_collection);
weak_collection->set_next(heap->encountered_weak_collections());
heap->set_encountered_weak_collections(weak_collection);
}
// Skip visiting the backing hash table containing the mappings and the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment