Changed recording of heap stats on OOM to store data directly in local
authorchristian.plesner.hansen@gmail.com <christian.plesner.hansen@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 4 Dec 2009 10:18:30 +0000 (10:18 +0000)
committerchristian.plesner.hansen@gmail.com <christian.plesner.hansen@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 4 Dec 2009 10:18:30 +0000 (10:18 +0000)
variables rather than in a stack-allocated struct.  The struct field
values turned out not to be available in minidumps.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3417 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/api.cc
src/global-handles.cc
src/heap.cc
src/heap.h

index eaff862..93807a7 100644 (file)
@@ -125,8 +125,49 @@ static FatalErrorCallback& GetFatalErrorHandler() {
 
 // When V8 cannot allocated memory FatalProcessOutOfMemory is called.
 // The default fatal error handler is called and execution is stopped.
-static void ExecuteFatalProcessOutOfMemory(const char* location,
-                                           i::HeapStats* heap_stats) {
+void i::V8::FatalProcessOutOfMemory(const char* location) {
+  i::HeapStats heap_stats;
+  int start_marker;
+  heap_stats.start_marker = &start_marker;
+  int new_space_size;
+  heap_stats.new_space_size = &new_space_size;
+  int new_space_capacity;
+  heap_stats.new_space_capacity = &new_space_capacity;
+  int old_pointer_space_size;
+  heap_stats.old_pointer_space_size = &old_pointer_space_size;
+  int old_pointer_space_capacity;
+  heap_stats.old_pointer_space_capacity = &old_pointer_space_capacity;
+  int old_data_space_size;
+  heap_stats.old_data_space_size = &old_data_space_size;
+  int old_data_space_capacity;
+  heap_stats.old_data_space_capacity = &old_data_space_capacity;
+  int code_space_size;
+  heap_stats.code_space_size = &code_space_size;
+  int code_space_capacity;
+  heap_stats.code_space_capacity = &code_space_capacity;
+  int map_space_size;
+  heap_stats.map_space_size = &map_space_size;
+  int map_space_capacity;
+  heap_stats.map_space_capacity = &map_space_capacity;
+  int cell_space_size;
+  heap_stats.cell_space_size = &cell_space_size;
+  int cell_space_capacity;
+  heap_stats.cell_space_capacity = &cell_space_capacity;
+  int lo_space_size;
+  heap_stats.lo_space_size = &lo_space_size;
+  int global_handle_count;
+  heap_stats.global_handle_count = &global_handle_count;
+  int weak_global_handle_count;
+  heap_stats.weak_global_handle_count = &weak_global_handle_count;
+  int pending_global_handle_count;
+  heap_stats.pending_global_handle_count = &pending_global_handle_count;
+  int near_death_global_handle_count;
+  heap_stats.near_death_global_handle_count = &near_death_global_handle_count;
+  int destroyed_global_handle_count;
+  heap_stats.destroyed_global_handle_count = &destroyed_global_handle_count;
+  int end_marker;
+  heap_stats.end_marker = &end_marker;
+  i::Heap::RecordStats(&heap_stats);
   i::V8::SetFatalError();
   FatalErrorCallback callback = GetFatalErrorHandler();
   {
@@ -138,13 +179,6 @@ static void ExecuteFatalProcessOutOfMemory(const char* location,
 }
 
 
-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) {
   exception_behavior = that;
 }
index 5b01f61..f3b2b0c 100644 (file)
@@ -430,21 +430,21 @@ 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;
+  *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++;
+    *stats->global_handle_count++;
     if (current->state_ == Node::WEAK) {
-      stats->weak_global_handle_count++;
+      *stats->weak_global_handle_count++;
     } else if (current->state_ == Node::PENDING) {
-      stats->pending_global_handle_count++;
+      *stats->pending_global_handle_count++;
     } else if (current->state_ == Node::NEAR_DEATH) {
-      stats->near_death_global_handle_count++;
+      *stats->near_death_global_handle_count++;
     } else if (current->state_ == Node::DESTROYED) {
-      stats->destroyed_global_handle_count++;
+      *stats->destroyed_global_handle_count++;
     }
   }
 }
index 39f00d3..4e4cd1c 100644 (file)
@@ -3274,19 +3274,21 @@ bool Heap::ConfigureHeapDefault() {
 
 
 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();
+  *stats->start_marker = 0xDECADE00;
+  *stats->end_marker = 0xDECADE01;
+  *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);
 }
 
index 68182fa..b37fe4b 100644 (file)
@@ -1105,24 +1105,26 @@ class Heap : public AllStatic {
 
 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;
+  int *start_marker;
+  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;
+  int *end_marker;
 };