Revision: 21655
Author:   [email protected]
Date:     Tue Jun  3 17:37:33 2014 UTC
Log:      Visit encountered JSWeakCollection list during scavenging.

[email protected]
BUG=chromium:380068
LOG=N

Review URL: https://codereview.chromium.org/310783003
http://code.google.com/p/v8/source/detail?r=21655

Modified:
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h
 /branches/bleeding_edge/src/mark-compact.cc
 /branches/bleeding_edge/src/mark-compact.h
 /branches/bleeding_edge/src/objects-visiting-inl.h

=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Jun  3 16:22:10 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Tue Jun  3 17:37:33 2014 UTC
@@ -146,6 +146,7 @@
   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);
@@ -1528,6 +1529,9 @@
scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(type_address));
     }
   }
+
+  // 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();
=======================================
--- /branches/bleeding_edge/src/heap.h  Tue Jun  3 16:22:10 2014 UTC
+++ /branches/bleeding_edge/src/heap.h  Tue Jun  3 17:37:33 2014 UTC
@@ -848,6 +848,13 @@
Object** allocation_sites_list_address() { return &allocation_sites_list_; }

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 @@
   // 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 {
=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Tue Jun  3 16:22:10 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.cc Tue Jun  3 17:37:33 2014 UTC
@@ -51,7 +51,6 @@
       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::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::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 @@
     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));
 }


=======================================
--- /branches/bleeding_edge/src/mark-compact.h  Tue Jun  3 08:12:43 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.h  Tue Jun  3 17:37:33 2014 UTC
@@ -649,13 +649,6 @@

   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 @@
   Heap* heap_;
   MarkingDeque marking_deque_;
   CodeFlusher* code_flusher_;
-  Object* encountered_weak_collections_;
   bool have_code_to_deoptimize_;

   List<Page*> evacuation_candidates_;
=======================================
--- /branches/bleeding_edge/src/objects-visiting-inl.h Tue Jun 3 16:22:10 2014 UTC +++ /branches/bleeding_edge/src/objects-visiting-inl.h Tue Jun 3 17:37:33 2014 UTC
@@ -402,12 +402,11 @@
   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
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to