Revision: 21207
Author:   [email protected]
Date:     Fri May  9 09:02:40 2014 UTC
Log:      Cleaned up the weak lists hanging off the heap a bit.

 * Route all access to the 3 weak lists through getters/setters.

 * Removed superfluous visiting already done by ProcessWeakReferences.

[email protected]

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

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

=======================================
--- /branches/bleeding_edge/src/heap.cc Fri May  9 08:38:27 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Fri May  9 09:02:40 2014 UTC
@@ -144,9 +144,9 @@
   ASSERT(MB >= Page::kPageSize);

   memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
-  native_contexts_list_ = NULL;
-  array_buffers_list_ = Smi::FromInt(0);
-  allocation_sites_list_ = Smi::FromInt(0);
+  set_native_contexts_list(NULL);
+  set_array_buffers_list(Smi::FromInt(0));
+  set_allocation_sites_list(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);
@@ -962,7 +962,7 @@
 void Heap::ClearJSFunctionResultCaches() {
   if (isolate_->bootstrapper()->IsActive()) return;

-  Object* context = native_contexts_list_;
+  Object* context = native_contexts_list();
   while (!context->IsUndefined()) {
     // Get the caches for this context. GC can happen when the context
     // is not fully initialized, so the caches can be undefined.
@@ -988,7 +988,7 @@
     return;
   }

-  Object* context = native_contexts_list_;
+  Object* context = native_contexts_list();
   while (!context->IsUndefined()) {
     // GC can happen when the context is not fully initialized,
     // so the cache can be undefined.
@@ -1568,9 +1568,6 @@
   if (collector->is_code_flushing_enabled()) {
collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor);
   }
-
-  // Scavenge object reachable from the native contexts list directly.
-  scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_));

   new_space_front = DoScavenge(&scavenge_visitor, new_space_front);

@@ -1704,7 +1701,7 @@
       VisitWeakList<Context>(
           this, native_contexts_list(), retainer, record_slots);
   // Update the head of the list of contexts.
-  native_contexts_list_ = head;
+  set_native_contexts_list(head);
 }


@@ -1725,7 +1722,7 @@
     Runtime::FreeArrayBuffer(isolate(), buffer);
     o = buffer->weak_next();
   }
-  array_buffers_list_ = undefined;
+  set_array_buffers_list(undefined);
 }


@@ -5283,9 +5280,9 @@
   CreateInitialObjects();
   CHECK_EQ(0, gc_count_);

-  native_contexts_list_ = undefined_value();
-  array_buffers_list_ = undefined_value();
-  allocation_sites_list_ = undefined_value();
+  set_native_contexts_list(undefined_value());
+  set_array_buffers_list(undefined_value());
+  set_allocation_sites_list(undefined_value());
   weak_object_to_code_table_ = undefined_value();
   return true;
 }
=======================================
--- /branches/bleeding_edge/src/heap.h  Fri May  9 08:38:27 2014 UTC
+++ /branches/bleeding_edge/src/heap.h  Fri May  9 09:02:40 2014 UTC
@@ -833,17 +833,19 @@
   void set_native_contexts_list(Object* object) {
     native_contexts_list_ = object;
   }
-  Object* native_contexts_list() { return native_contexts_list_; }
+  Object* native_contexts_list() const { return native_contexts_list_; }

   void set_array_buffers_list(Object* object) {
     array_buffers_list_ = object;
   }
-  Object* array_buffers_list() { return array_buffers_list_; }
+  Object* array_buffers_list() const { return array_buffers_list_; }

   void set_allocation_sites_list(Object* object) {
     allocation_sites_list_ = object;
   }
   Object* allocation_sites_list() { return allocation_sites_list_; }
+
+  // Used in CreateAllocationSiteStub and the (de)serializer.
Object** allocation_sites_list_address() { return &allocation_sites_list_; }

Object* weak_object_to_code_table() { return weak_object_to_code_table_; }
@@ -935,11 +937,6 @@
   Address* store_buffer_top_address() {
     return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]);
   }
-
-  // Get address of native contexts list for serialization support.
-  Object** native_contexts_list_address() {
-    return &native_contexts_list_;
-  }

 #ifdef VERIFY_HEAP
   // Verify the heap is in its normal state before or after a GC.
=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Wed Apr 30 12:25:18 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.cc Fri May  9 09:02:40 2014 UTC
@@ -2483,7 +2483,7 @@


 void MarkCompactCollector::ProcessMapCaches() {
-  Object* raw_context = heap()->native_contexts_list_;
+  Object* raw_context = heap()->native_contexts_list();
   while (raw_context != heap()->undefined_value()) {
     Context* context = reinterpret_cast<Context*>(raw_context);
     if (IsMarked(context)) {
@@ -3641,9 +3641,6 @@
       PropertyCell::BodyDescriptor::IterateBody(cell, &updating_visitor);
     }
   }
-
-  // Update the head of the native contexts list in the heap.
-  updating_visitor.VisitPointer(heap_->native_contexts_list_address());

   heap_->string_table()->Iterate(&updating_visitor);
updating_visitor.VisitPointer(heap_->weak_object_to_code_table_address());

--
--
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