Revision: 13159
Author:   [email protected]
Date:     Fri Dec  7 01:44:10 2012
Log:      Add GCTracer metrics for a scavenger GC for DOM wrappers

This patch adds the following three metrics for the --trace_gc_nvp option.

nodes_died_in_new_space_; // Number of died nodes in the new space.
nodes_copied_in_new_space_; // Number of copied nodes to the new space.
nodes_promoted; // Number of promoted nodes to the old space.

BUG=
TEST=Manually confirmed that the "--trace_gc --trace_gc_nvp" option prints the metrics

Review URL: https://codereview.chromium.org/11365146
Patch from Kentaro Hara <[email protected]>.
http://code.google.com/p/v8/source/detail?r=13159

Modified:
 /branches/bleeding_edge/src/global-handles.cc
 /branches/bleeding_edge/src/global-handles.h
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h

=======================================
--- /branches/bleeding_edge/src/global-handles.cc       Tue Dec  4 02:23:43 2012
+++ /branches/bleeding_edge/src/global-handles.cc       Fri Dec  7 01:44:10 2012
@@ -597,7 +597,7 @@


 bool GlobalHandles::PostGarbageCollectionProcessing(
-    GarbageCollector collector) {
+    GarbageCollector collector, GCTracer* tracer) {
   // Process weak global handle callbacks. This must be done after the
   // GC is completely done, because the callbacks may invoke arbitrary
   // API functions.
@@ -647,10 +647,17 @@
   for (int i = 0; i < new_space_nodes_.length(); ++i) {
     Node* node = new_space_nodes_[i];
     ASSERT(node->is_in_new_space_list());
- if (node->IsRetainer() && isolate_->heap()->InNewSpace(node->object())) {
-      new_space_nodes_[last++] = node;
+    if (node->IsRetainer()) {
+      if (isolate_->heap()->InNewSpace(node->object())) {
+        new_space_nodes_[last++] = node;
+        tracer->increment_nodes_copied_in_new_space();
+      } else {
+        node->set_in_new_space_list(false);
+        tracer->increment_nodes_promoted();
+      }
     } else {
       node->set_in_new_space_list(false);
+      tracer->increment_nodes_died_in_new_space();
     }
   }
   new_space_nodes_.Rewind(last);
=======================================
--- /branches/bleeding_edge/src/global-handles.h        Tue Dec  4 02:23:43 2012
+++ /branches/bleeding_edge/src/global-handles.h        Fri Dec  7 01:44:10 2012
@@ -168,7 +168,8 @@

   // Process pending weak handles.
   // Returns true if next major GC is likely to collect more garbage.
-  bool PostGarbageCollectionProcessing(GarbageCollector collector);
+  bool PostGarbageCollectionProcessing(GarbageCollector collector,
+                                       GCTracer* tracer);

   // Iterates over all strong handles.
   void IterateStrongRoots(ObjectVisitor* v);
=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Dec  4 02:23:43 2012
+++ /branches/bleeding_edge/src/heap.cc Fri Dec  7 01:44:10 2012
@@ -965,7 +965,8 @@
   { DisableAssertNoAllocation allow_allocation;
     GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
     next_gc_likely_to_collect_more =
- isolate_->global_handles()->PostGarbageCollectionProcessing(collector);
+        isolate_->global_handles()->PostGarbageCollectionProcessing(
+            collector, tracer);
   }
   gc_post_processing_depth_--;

@@ -6864,6 +6865,9 @@
       allocated_since_last_gc_(0),
       spent_in_mutator_(0),
       promoted_objects_size_(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) {
@@ -7004,6 +7008,9 @@

     PrintF("allocated=%" V8_PTR_PREFIX "d ", allocated_since_last_gc_);
     PrintF("promoted=%" V8_PTR_PREFIX "d ", promoted_objects_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_);

     if (collector_ == SCAVENGER) {
       PrintF("stepscount=%d ", steps_count_since_last_gc_);
=======================================
--- /branches/bleeding_edge/src/heap.h  Tue Dec  4 02:23:43 2012
+++ /branches/bleeding_edge/src/heap.h  Fri Dec  7 01:44:10 2012
@@ -2548,6 +2548,18 @@
   void increment_promoted_objects_size(int object_size) {
     promoted_objects_size_ += object_size;
   }
+
+  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.
@@ -2593,6 +2605,15 @@
   // Size of objects promoted during the current collection.
   intptr_t promoted_objects_size_;

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

Reply via email to