Reviewers: Hannes Payer, Igor Sheludko,

Message:
Igor: Could you please check against your repro?
Hannes: PTAL.

Description:
Visit encountered JSWeakCollection list during scavenging.

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

Please review this at https://codereview.chromium.org/310783003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+21, -15 lines):
  M src/heap.h
  M src/heap.cc
  M src/mark-compact.h
  M src/mark-compact.cc
  M src/objects-visiting-inl.h


Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index ff7a9ff12f20d6f7e37751f7d2bd91fb26939684..a530c396bedda23beec01b349f57c62f3760c944 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -145,6 +145,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);
@@ -1508,6 +1509,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()) {
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index 8956e3c56b50f31af04c57a3caf9669d4c58f3f2..9e5b6a55253552b979e2315a365189034615b02e 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -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_; }

@@ -1605,6 +1612,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 {
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index fcaad0def2dee36ce5e03c3994e77137ed7a053d..53f884c6af5a86d8de9d643bd02a1e2e067c21bb 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -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));
 }


Index: src/mark-compact.h
diff --git a/src/mark-compact.h b/src/mark-compact.h
index bd34d56c5dd9fbcc153b4e7c72e11069abab58ec..18c8fa1ddf6ba8f1dbcfed63a55049ff1b7fa8b0 100644
--- a/src/mark-compact.h
+++ b/src/mark-compact.h
@@ -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_;
Index: src/objects-visiting-inl.h
diff --git a/src/objects-visiting-inl.h b/src/objects-visiting-inl.h
index 057b8ae99ffc3651e80b729c6f96f9335cb342a3..ec7fd79a8d37d9db3dda2645c51c0e896c50cd6f 100644
--- a/src/objects-visiting-inl.h
+++ b/src/objects-visiting-inl.h
@@ -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


--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to