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() ...@@ -146,6 +146,7 @@ Heap::Heap()
set_native_contexts_list(NULL); set_native_contexts_list(NULL);
set_array_buffers_list(Smi::FromInt(0)); set_array_buffers_list(Smi::FromInt(0));
set_allocation_sites_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 // Put a dummy entry in the remembered pages so we can find the list the
// minidump even if there are no real unmapped pages. // minidump even if there are no real unmapped pages.
RememberUnmappedPage(NULL, false); RememberUnmappedPage(NULL, false);
...@@ -1529,6 +1530,9 @@ void Heap::Scavenge() { ...@@ -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. // Copy objects reachable from the code flushing candidates list.
MarkCompactCollector* collector = mark_compact_collector(); MarkCompactCollector* collector = mark_compact_collector();
if (collector->is_code_flushing_enabled()) { if (collector->is_code_flushing_enabled()) {
......
...@@ -849,6 +849,13 @@ class Heap { ...@@ -849,6 +849,13 @@ class Heap {
Object* weak_object_to_code_table() { return weak_object_to_code_table_; } 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. // Number of mark-sweeps.
unsigned int ms_count() { return ms_count_; } unsigned int ms_count() { return ms_count_; }
...@@ -1613,6 +1620,11 @@ class Heap { ...@@ -1613,6 +1620,11 @@ class Heap {
// start. // start.
Object* weak_object_to_code_table_; 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_; StoreBufferRebuilder store_buffer_rebuilder_;
struct StringTypeTable { struct StringTypeTable {
......
...@@ -51,7 +51,6 @@ MarkCompactCollector::MarkCompactCollector(Heap* heap) : // NOLINT ...@@ -51,7 +51,6 @@ MarkCompactCollector::MarkCompactCollector(Heap* heap) : // NOLINT
migration_slots_buffer_(NULL), migration_slots_buffer_(NULL),
heap_(heap), heap_(heap),
code_flusher_(NULL), code_flusher_(NULL),
encountered_weak_collections_(NULL),
have_code_to_deoptimize_(false) { } have_code_to_deoptimize_(false) { }
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
...@@ -2738,7 +2737,7 @@ void MarkCompactCollector::ClearNonLiveDependentCode(DependentCode* entries) { ...@@ -2738,7 +2737,7 @@ void MarkCompactCollector::ClearNonLiveDependentCode(DependentCode* entries) {
void MarkCompactCollector::ProcessWeakCollections() { void MarkCompactCollector::ProcessWeakCollections() {
GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_PROCESS); 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)) { while (weak_collection_obj != Smi::FromInt(0)) {
JSWeakCollection* weak_collection = JSWeakCollection* weak_collection =
reinterpret_cast<JSWeakCollection*>(weak_collection_obj); reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
...@@ -2765,7 +2764,7 @@ void MarkCompactCollector::ProcessWeakCollections() { ...@@ -2765,7 +2764,7 @@ void MarkCompactCollector::ProcessWeakCollections() {
void MarkCompactCollector::ClearWeakCollections() { void MarkCompactCollector::ClearWeakCollections() {
GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKCOLLECTION_CLEAR); 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)) { while (weak_collection_obj != Smi::FromInt(0)) {
JSWeakCollection* weak_collection = JSWeakCollection* weak_collection =
reinterpret_cast<JSWeakCollection*>(weak_collection_obj); reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
...@@ -2782,7 +2781,7 @@ void MarkCompactCollector::ClearWeakCollections() { ...@@ -2782,7 +2781,7 @@ void MarkCompactCollector::ClearWeakCollections() {
weak_collection_obj = weak_collection->next(); weak_collection_obj = weak_collection->next();
weak_collection->set_next(heap()->undefined_value()); 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 { ...@@ -649,13 +649,6 @@ class MarkCompactCollector {
bool TryPromoteObject(HeapObject* object, int object_size); 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 InvalidateCode(Code* code);
void ClearMarkbits(); void ClearMarkbits();
...@@ -913,7 +906,6 @@ class MarkCompactCollector { ...@@ -913,7 +906,6 @@ class MarkCompactCollector {
Heap* heap_; Heap* heap_;
MarkingDeque marking_deque_; MarkingDeque marking_deque_;
CodeFlusher* code_flusher_; CodeFlusher* code_flusher_;
Object* encountered_weak_collections_;
bool have_code_to_deoptimize_; bool have_code_to_deoptimize_;
List<Page*> evacuation_candidates_; List<Page*> evacuation_candidates_;
......
...@@ -402,12 +402,11 @@ void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection( ...@@ -402,12 +402,11 @@ void StaticMarkingVisitor<StaticVisitor>::VisitWeakCollection(
Heap* heap = map->GetHeap(); Heap* heap = map->GetHeap();
JSWeakCollection* weak_collection = JSWeakCollection* weak_collection =
reinterpret_cast<JSWeakCollection*>(object); reinterpret_cast<JSWeakCollection*>(object);
MarkCompactCollector* collector = heap->mark_compact_collector();
// Enqueue weak collection in linked list of encountered weak collections. // Enqueue weak collection in linked list of encountered weak collections.
if (weak_collection->next() == heap->undefined_value()) { if (weak_collection->next() == heap->undefined_value()) {
weak_collection->set_next(collector->encountered_weak_collections()); weak_collection->set_next(heap->encountered_weak_collections());
collector->set_encountered_weak_collections(weak_collection); heap->set_encountered_weak_collections(weak_collection);
} }
// Skip visiting the backing hash table containing the mappings and the // 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