Author: [email protected]
Date: Mon Jul 13 14:24:54 2009
New Revision: 2449

Modified:
    branches/bleeding_edge/src/flag-definitions.h
    branches/bleeding_edge/src/heap.cc
    branches/bleeding_edge/src/heap.h
    branches/bleeding_edge/src/spaces.h

Log:
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.

Review URL: http://codereview.chromium.org/149568

Modified: branches/bleeding_edge/src/flag-definitions.h
==============================================================================
--- branches/bleeding_edge/src/flag-definitions.h       (original)
+++ branches/bleeding_edge/src/flag-definitions.h       Mon Jul 13 14:24:54 2009
@@ -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")


Modified: branches/bleeding_edge/src/heap.cc
==============================================================================
--- branches/bleeding_edge/src/heap.cc  (original)
+++ branches/bleeding_edge/src/heap.cc  Mon Jul 13 14:24:54 2009
@@ -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
  }



Modified: branches/bleeding_edge/src/heap.h
==============================================================================
--- branches/bleeding_edge/src/heap.h   (original)
+++ branches/bleeding_edge/src/heap.h   Mon Jul 13 14:24:54 2009
@@ -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.

Modified: branches/bleeding_edge/src/spaces.h
==============================================================================
--- branches/bleeding_edge/src/spaces.h (original)
+++ branches/bleeding_edge/src/spaces.h Mon Jul 13 14:24:54 2009
@@ -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;

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

Reply via email to