Revision: 3413
Author: [email protected]
Date: Thu Dec  3 06:18:11 2009
Log: Merge bleeding_edge revision 3406 and 3410 to 1.3 branch.

This change puts a structure with heap statistics on the stack in case
of OOM situations.  This will allow us to see heap statistics in OOM
crash reports.

Review URL: http://codereview.chromium.org/460042
http://code.google.com/p/v8/source/detail?r=3413

Modified:
  /branches/1.3/src/api.cc
  /branches/1.3/src/global-handles.cc
  /branches/1.3/src/global-handles.h
  /branches/1.3/src/heap.cc
  /branches/1.3/src/heap.h
  /branches/1.3/src/version.cc

=======================================
--- /branches/1.3/src/api.cc    Mon Nov 30 03:23:58 2009
+++ /branches/1.3/src/api.cc    Thu Dec  3 06:18:11 2009
@@ -124,7 +124,8 @@

  // When V8 cannot allocated memory FatalProcessOutOfMemory is called.
  // The default fatal error handler is called and execution is stopped.
-void i::V8::FatalProcessOutOfMemory(const char* location) {
+static void ExecuteFatalProcessOutOfMemory(const char* location,
+                                           i::HeapStats* heap_stats) {
    i::V8::SetFatalError();
    FatalErrorCallback callback = GetFatalErrorHandler();
    {
@@ -134,6 +135,13 @@
    // If the callback returns, we stop execution.
    UNREACHABLE();
  }
+
+
+void i::V8::FatalProcessOutOfMemory(const char* location) {
+  i::HeapStats heap_stats;
+  i::Heap::RecordStats(&heap_stats);
+  ExecuteFatalProcessOutOfMemory(location, &heap_stats);
+}


  void V8::SetFatalErrorHandler(FatalErrorCallback that) {
=======================================
--- /branches/1.3/src/global-handles.cc Tue Nov 17 13:43:00 2009
+++ /branches/1.3/src/global-handles.cc Thu Dec  3 06:18:11 2009
@@ -419,6 +419,26 @@
  GlobalHandles::Node* GlobalHandles::first_free_ = NULL;
  GlobalHandles::Node* GlobalHandles::first_deallocated_ = NULL;

+void GlobalHandles::RecordStats(HeapStats* stats) {
+  stats->global_handle_count = 0;
+  stats->weak_global_handle_count = 0;
+  stats->pending_global_handle_count = 0;
+  stats->near_death_global_handle_count = 0;
+  stats->destroyed_global_handle_count = 0;
+  for (Node* current = head_; current != NULL; current = current->next()) {
+    stats->global_handle_count++;
+    if (current->state_ == Node::WEAK) {
+      stats->weak_global_handle_count++;
+    } else if (current->state_ == Node::PENDING) {
+      stats->pending_global_handle_count++;
+    } else if (current->state_ == Node::NEAR_DEATH) {
+      stats->near_death_global_handle_count++;
+    } else if (current->state_ == Node::DESTROYED) {
+      stats->destroyed_global_handle_count++;
+    }
+  }
+}
+
  #ifdef DEBUG

  void GlobalHandles::PrintStats() {
=======================================
--- /branches/1.3/src/global-handles.h  Wed Oct 28 07:53:37 2009
+++ /branches/1.3/src/global-handles.h  Thu Dec  3 06:18:11 2009
@@ -76,6 +76,8 @@

    // Returns the current number of weak handles.
    static int NumberOfWeakHandles() { return number_of_weak_handles_; }
+
+  static void RecordStats(HeapStats* stats);

    // Returns the current number of weak handles to global objects.
    // These handles are also included in NumberOfWeakHandles().
=======================================
--- /branches/1.3/src/heap.cc   Tue Nov 17 13:43:00 2009
+++ /branches/1.3/src/heap.cc   Thu Dec  3 06:18:11 2009
@@ -3345,6 +3345,24 @@
  bool Heap::ConfigureHeapDefault() {
    return ConfigureHeap(FLAG_max_new_space_size / 2,  
FLAG_max_old_space_size);
  }
+
+
+void Heap::RecordStats(HeapStats* stats) {
+  stats->new_space_size = new_space_.Size();
+  stats->new_space_capacity = new_space_.Capacity();
+  stats->old_pointer_space_size = old_pointer_space_->Size();
+  stats->old_pointer_space_capacity = old_pointer_space_->Capacity();
+  stats->old_data_space_size = old_data_space_->Size();
+  stats->old_data_space_capacity = old_data_space_->Capacity();
+  stats->code_space_size = code_space_->Size();
+  stats->code_space_capacity = code_space_->Capacity();
+  stats->map_space_size = map_space_->Size();
+  stats->map_space_capacity = map_space_->Capacity();
+  stats->cell_space_size = cell_space_->Size();
+  stats->cell_space_capacity = cell_space_->Capacity();
+  stats->lo_space_size = lo_space_->Size();
+  GlobalHandles::RecordStats(stats);
+}


  int Heap::PromotedSpaceSize() {
=======================================
--- /branches/1.3/src/heap.h    Wed Oct 28 07:53:37 2009
+++ /branches/1.3/src/heap.h    Thu Dec  3 06:18:11 2009
@@ -230,6 +230,7 @@

  // Forward declaration of the GCTracer class.
  class GCTracer;
+class HeapStats;


  // The all static Heap captures the interface to the global object heap.
@@ -915,6 +916,8 @@
    static RootListIndex RootIndexForExternalArrayType(
        ExternalArrayType array_type);

+  static void RecordStats(HeapStats* stats);
+
   private:
    static int reserved_semispace_size_;
    static int max_semispace_size_;
@@ -1147,6 +1150,29 @@
  };


+class HeapStats {
+ public:
+  int new_space_size;
+  int new_space_capacity;
+  int old_pointer_space_size;
+  int old_pointer_space_capacity;
+  int old_data_space_size;
+  int old_data_space_capacity;
+  int code_space_size;
+  int code_space_capacity;
+  int map_space_size;
+  int map_space_capacity;
+  int cell_space_size;
+  int cell_space_capacity;
+  int lo_space_size;
+  int global_handle_count;
+  int weak_global_handle_count;
+  int pending_global_handle_count;
+  int near_death_global_handle_count;
+  int destroyed_global_handle_count;
+};
+
+
  class AlwaysAllocateScope {
   public:
    AlwaysAllocateScope() {
=======================================
--- /branches/1.3/src/version.cc        Mon Nov 30 03:23:58 2009
+++ /branches/1.3/src/version.cc        Thu Dec  3 06:18:11 2009
@@ -35,7 +35,7 @@
  #define MAJOR_VERSION     1
  #define MINOR_VERSION     3
  #define BUILD_NUMBER      18
-#define PATCH_LEVEL       14
+#define PATCH_LEVEL       15
  #define CANDIDATE_VERSION false

  // Define SONAME to have the SCons build the put a specific SONAME into the

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

Reply via email to