Reviewers: Mads Ager,

Description:
Add a trace_gc_verbose flag.

The flag is only turned on when --trace_gc is one. It prints out used
and available bytes in each space. To enable it,
ENABLE_LOGGING_AND_PROFILING must be defined.

This is a mini version of --heap_stats, but don't need DEBUG macro to be
turned on.


Please review this at http://codereview.chromium.org/149568

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

Affected files:
   M     src/flag-definitions.h
   M     src/heap.h
   M     src/heap.cc
   M     src/spaces.h


Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 2446)
+++ src/heap.cc (working copy)
@@ -207,6 +207,27 @@
  }


+#if defined(ENABLE_LOGGING_AND_PROFILING)
+void Heap::PrintShortHeapStatistics() {
+  if (!FLAG_trace_gc_verbose) return;
+  PrintF("Memory allocator,   used: %8d, available: %8d\n",
+         MemoryAllocator::Size(), MemoryAllocator::Available());
+  PrintF("New space,          used: %8d, available: %8d\n",
+         Heap::new_space_.Size(), new_space_.Available());
+  PrintF("Old pointers,       used: %8d, available: %8d\n",
+         old_pointer_space_->Size(), old_pointer_space_->Available());
+  PrintF("Old data space,     used: %8d, available: %8d\n",
+         old_data_space_->Size(), old_data_space_->Available());
+  PrintF("Code space,         used: %8d, available: %8d\n",
+         code_space_->Size(), code_space_->Available());
+  PrintF("Map space,          used: %8d, available: %8d\n",
+         map_space_->Size(), map_space_->Available());
+  PrintF("Large object space, used: %8d, avaialble: %8d\n",
+         map_space_->Size(), map_space_->Available());
+}
+#endif
+
+
  // TODO(1238405): Combine the infrastructure for --heap-stats and
  // --log-gc to avoid the complicated preprocessor and flag testing.
  void Heap::ReportStatisticsAfterGC() {
@@ -3620,6 +3641,10 @@
           CollectorString(),
           start_size_, SizeOfHeapObjects(),
           static_cast<int>(OS::TimeCurrentMillis() - start_time_));
+
+#if defined(ENABLE_LOGGING_AND_PROFILING)
+  Heap::PrintShortHeapStatistics();
+#endif
  }


Index: src/spaces.h
===================================================================
--- src/spaces.h        (revision 2446)
+++ src/spaces.h        (working copy)
@@ -393,6 +393,9 @@
    // Returns the maximum available bytes of heaps.
    static int Available() { return capacity_ < size_ ? 0 : capacity_ -  
size_; }

+  // Returns allocated spaces in bytes.
+  static int Size() { return size_; }
+
    // Returns maximum available bytes that the old space can have.
    static int MaxAvailable() {
      return (Available() / Page::kPageSize) * Page::kObjectAreaSize;
Index: src/flag-definitions.h
===================================================================
--- src/flag-definitions.h      (revision 2446)
+++ src/flag-definitions.h      (working copy)
@@ -158,6 +158,8 @@
  DEFINE_int(gc_interval, -1, "garbage collect after <n> allocations")
  DEFINE_bool(trace_gc, false,
              "print one trace line following each garbage collection")
+DEFINE_bool(trace_gc_verbose, false,
+            "print more details following each garbage collection")
  DEFINE_bool(collect_maps, true,
              "garbage collect maps from which no objects can be reached")

Index: src/heap.h
===================================================================
--- src/heap.h  (revision 2446)
+++ src/heap.h  (working copy)
@@ -733,6 +733,11 @@
    static void ZapFromSpace();
  #endif

+#if defined(ENABLE_LOGGING_AND_PROFILING)
+  // Print short heap statistics.
+  static void PrintShortHeapStatistics();
+#endif
+
    // Makes a new symbol object
    // Returns Failure::RetryAfterGC(requested_bytes, space) if the  
allocation
    // failed.



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to