Reviewers: Hannes Payer,

Message:
PTAL

Description:
Move node statistics from GCTracer to Heap.

[email protected]
BUG=

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

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

Affected files (+30, -36 lines):
  M src/global-handles.h
  M src/global-handles.cc
  M src/heap.h
  M src/heap.cc


Index: src/global-handles.cc
diff --git a/src/global-handles.cc b/src/global-handles.cc
index a5ae2d5626f3701f8c953676ebc2a3e1932736fb..2c9fada1e82d97bc14bd9197549d08bf210835ea 100644
--- a/src/global-handles.cc
+++ b/src/global-handles.cc
@@ -612,7 +612,7 @@ bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v,


 int GlobalHandles::PostGarbageCollectionProcessing(
-    GarbageCollector collector, GCTracer* tracer) {
+    GarbageCollector collector) {
   // Process weak global handle callbacks. This must be done after the
   // GC is completely done, because the callbacks may invoke arbitrary
   // API functions.
@@ -675,14 +675,14 @@ int GlobalHandles::PostGarbageCollectionProcessing(
     if (node->IsRetainer()) {
       if (isolate_->heap()->InNewSpace(node->object())) {
         new_space_nodes_[last++] = node;
-        tracer->increment_nodes_copied_in_new_space();
+        isolate_->heap()->IncrementNodesCopiedInNewSpace();
       } else {
         node->set_in_new_space_list(false);
-        tracer->increment_nodes_promoted();
+        isolate_->heap()->IncrementNodesPromoted();
       }
     } else {
       node->set_in_new_space_list(false);
-      tracer->increment_nodes_died_in_new_space();
+      isolate_->heap()->IncrementNodesDiedInNewSpace();
     }
   }
   new_space_nodes_.Rewind(last);
Index: src/global-handles.h
diff --git a/src/global-handles.h b/src/global-handles.h
index 2f5afc9345d729559fbbb16b7232f6b9b1911950..f469f3bbbcd0e82faec04a1b57e8ff9c02cef55b 100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -15,7 +15,6 @@
 namespace v8 {
 namespace internal {

-class GCTracer;
 class HeapStats;
 class ObjectVisitor;

@@ -156,8 +155,7 @@ class GlobalHandles {

   // Process pending weak handles.
   // Returns the number of freed nodes.
-  int PostGarbageCollectionProcessing(GarbageCollector collector,
-                                      GCTracer* tracer);
+  int PostGarbageCollectionProcessing(GarbageCollector collector);

   // Iterates over all strong handles.
   void IterateStrongRoots(ObjectVisitor* v);
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 75a48f15f551add4e7b53145735d65f4a4e52da0..16d7a8040bd4bdc1307363521e0d3f1128cc04ad 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -105,6 +105,9 @@ Heap::Heap()
       promotion_rate_(0),
       semi_space_copied_object_size_(0),
       semi_space_copied_rate_(0),
+      nodes_died_in_new_space_(0),
+      nodes_copied_in_new_space_(0),
+      nodes_promoted_(0),
       maximum_size_scavenges_(0),
       max_gc_pause_(0.0),
       total_gc_time_ms_(0.0),
@@ -428,6 +431,9 @@ void Heap::GarbageCollectionPrologue() {
   // Reset GC statistics.
   promoted_objects_size_ = 0;
   semi_space_copied_object_size_ = 0;
+  nodes_died_in_new_space_ = 0;
+  nodes_copied_in_new_space_ = 0;
+  nodes_promoted_ = 0;

   UpdateMaximumCommitted();

@@ -1115,8 +1121,7 @@ bool Heap::PerformGarbageCollection(
   { AllowHeapAllocation allow_allocation;
     GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
     freed_global_handles =
-        isolate_->global_handles()->PostGarbageCollectionProcessing(
-            collector, tracer);
+ isolate_->global_handles()->PostGarbageCollectionProcessing(collector);
   }
   gc_post_processing_depth_--;

@@ -5985,9 +5990,6 @@ GCTracer::GCTracer(Heap* heap,
       collector_(collector),
       allocated_since_last_gc_(0),
       spent_in_mutator_(0),
-      nodes_died_in_new_space_(0),
-      nodes_copied_in_new_space_(0),
-      nodes_promoted_(0),
       heap_(heap),
       gc_reason_(gc_reason),
       collector_reason_(collector_reason) {
@@ -6135,9 +6137,9 @@ void GCTracer::PrintNVP() const {
   PrintF("promoted=%" V8_PTR_PREFIX "d ", heap_->promoted_objects_size_);
   PrintF("semi_space_copied=%" V8_PTR_PREFIX "d ",
          heap_->semi_space_copied_object_size_);
-  PrintF("nodes_died_in_new=%d ", nodes_died_in_new_space_);
-  PrintF("nodes_copied_in_new=%d ", nodes_copied_in_new_space_);
-  PrintF("nodes_promoted=%d ", nodes_promoted_);
+  PrintF("nodes_died_in_new=%d ", heap_->nodes_died_in_new_space_);
+  PrintF("nodes_copied_in_new=%d ", heap_->nodes_copied_in_new_space_);
+  PrintF("nodes_promoted=%d ", heap_->nodes_promoted_);
   PrintF("promotion_rate=%.1f%% ", heap_->promotion_rate_);
   PrintF("semi_space_copy_rate=%.1f%% ", heap_->semi_space_copied_rate_);

Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index 9eaa6ab399e7a215539f12e1d579e7d390a255dc..6569c198309947d5c21ef01724e5f90e155ba5b8 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1182,6 +1182,18 @@ class Heap {
     semi_space_copied_object_size_ += object_size;
   }

+  inline void IncrementNodesDiedInNewSpace() {
+    nodes_died_in_new_space_++;
+  }
+
+  inline void IncrementNodesCopiedInNewSpace() {
+    nodes_copied_in_new_space_++;
+  }
+
+  inline void IncrementNodesPromoted() {
+    nodes_promoted_++;
+  }
+
   inline void IncrementYoungSurvivorsCounter(int survived) {
     ASSERT(survived >= 0);
     survived_since_last_expansion_ += survived;
@@ -2026,6 +2038,9 @@ class Heap {
   double promotion_rate_;
   intptr_t semi_space_copied_object_size_;
   double semi_space_copied_rate_;
+  int nodes_died_in_new_space_;
+  int nodes_copied_in_new_space_;
+  int nodes_promoted_;

   // This is the pretenuring trigger for allocation sites that are in maybe
// tenure state. When we switched to the maximum new space size we deoptimize
@@ -2569,18 +2584,6 @@ class GCTracer BASE_EMBEDDED {
                     const char* collector_reason);
   ~GCTracer();

-  void increment_nodes_died_in_new_space() {
-    nodes_died_in_new_space_++;
-  }
-
-  void increment_nodes_copied_in_new_space() {
-    nodes_copied_in_new_space_++;
-  }
-
-  void increment_nodes_promoted() {
-    nodes_promoted_++;
-  }
-
  private:
   // Returns a string matching the collector.
   const char* CollectorString() const;
@@ -2627,15 +2630,6 @@ class GCTracer BASE_EMBEDDED {
   // previous collection and the beginning of the current one.
   double spent_in_mutator_;

-  // Number of died nodes in the new space.
-  int nodes_died_in_new_space_;
-
-  // Number of copied nodes to the new space.
-  int nodes_copied_in_new_space_;
-
-  // Number of promoted nodes to the old space.
-  int nodes_promoted_;
-
   // Incremental marking steps counters.
   int steps_count_;
   double steps_took_;


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