Revision: 5190
Author: [email protected]
Date: Thu Aug  5 11:35:53 2010
Log: Backport http://code.google.com/p/v8/source/detail?r=5181 to 2.2.

[email protected]

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

Modified:
 /branches/2.2/src/api.cc
 /branches/2.2/src/heap-inl.h
 /branches/2.2/src/heap.cc
 /branches/2.2/src/heap.h
 /branches/2.2/src/v8.h
 /branches/2.2/src/version.cc

=======================================
--- /branches/2.2/src/api.cc    Wed Jul 14 02:01:13 2010
+++ /branches/2.2/src/api.cc    Thu Aug  5 11:35:53 2010
@@ -126,7 +126,7 @@

 // 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) {
+void i::V8::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
   i::HeapStats heap_stats;
   int start_marker;
   heap_stats.start_marker = &start_marker;
@@ -166,9 +166,17 @@
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 memory_allocator_size;
+  heap_stats.memory_allocator_size = &memory_allocator_size;
+  int memory_allocator_capacity;
+  heap_stats.memory_allocator_capacity = &memory_allocator_capacity;
+  int objects_per_type[LAST_TYPE + 1] = {0};
+  heap_stats.objects_per_type = objects_per_type;
+  int size_per_type[LAST_TYPE + 1] = {0};
+  heap_stats.size_per_type = size_per_type;
   int end_marker;
   heap_stats.end_marker = &end_marker;
-  i::Heap::RecordStats(&heap_stats);
+  i::Heap::RecordStats(&heap_stats, take_snapshot);
   i::V8::SetFatalError();
   FatalErrorCallback callback = GetFatalErrorHandler();
   {
=======================================
--- /branches/2.2/src/heap-inl.h        Mon Jun 14 00:35:38 2010
+++ /branches/2.2/src/heap-inl.h        Thu Aug  5 11:35:53 2010
@@ -390,7 +390,7 @@
     Object* __object__ = FUNCTION_CALL;                                   \
     if (!__object__->IsFailure()) RETURN_VALUE;                           \
     if (__object__->IsOutOfMemoryFailure()) {                             \
-      v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_0");      \
+      v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_0", true);\
     }                                                                     \
     if (!__object__->IsRetryAfterGC()) RETURN_EMPTY;                      \
     Heap::CollectGarbage(Failure::cast(__object__)->requested(),          \
@@ -398,7 +398,7 @@
     __object__ = FUNCTION_CALL;                                           \
     if (!__object__->IsFailure()) RETURN_VALUE;                           \
     if (__object__->IsOutOfMemoryFailure()) {                             \
-      v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_1");      \
+      v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_1", true);\
     }                                                                     \
     if (!__object__->IsRetryAfterGC()) RETURN_EMPTY;                      \
     Counters::gc_last_resort_from_handles.Increment();                    \
@@ -411,7 +411,7 @@
     if (__object__->IsOutOfMemoryFailure() ||                             \
         __object__->IsRetryAfterGC()) {                                   \
       /* TODO(1181417): Fix this. */                                      \
-      v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_2");      \
+      v8::internal::V8::FatalProcessOutOfMemory("CALL_AND_RETRY_2", true);\
     }                                                                     \
     RETURN_EMPTY;                                                         \
   } while (false)
=======================================
--- /branches/2.2/src/heap.cc   Tue Jul 13 13:58:03 2010
+++ /branches/2.2/src/heap.cc   Thu Aug  5 11:35:53 2010
@@ -4111,7 +4111,7 @@
 }


-void Heap::RecordStats(HeapStats* stats) {
+void Heap::RecordStats(HeapStats* stats, bool take_snapshot) {
   *stats->start_marker = 0xDECADE00;
   *stats->end_marker = 0xDECADE01;
   *stats->new_space_size = new_space_.Size();
@@ -4128,6 +4128,23 @@
   *stats->cell_space_capacity = cell_space_->Capacity();
   *stats->lo_space_size = lo_space_->Size();
   GlobalHandles::RecordStats(stats);
+  *stats->memory_allocator_size = MemoryAllocator::Size();
+  *stats->memory_allocator_capacity =
+      MemoryAllocator::Size() + MemoryAllocator::Available();
+  if (take_snapshot) {
+    HeapIterator iterator;
+    for (HeapObject* obj = iterator.next();
+         obj != NULL;
+         obj = iterator.next()) {
+ // Note: snapshot won't be precise because IsFreeListNode returns true
+      // for any bytearray.
+      if (FreeListNode::IsFreeListNode(obj)) continue;
+      InstanceType type = obj->map()->instance_type();
+      ASSERT(0 <= type && type <= LAST_TYPE);
+      stats->objects_per_type[type]++;
+      stats->size_per_type[type] += obj->Size();
+    }
+  }
 }


=======================================
--- /branches/2.2/src/heap.h    Tue Jul 13 13:58:03 2010
+++ /branches/2.2/src/heap.h    Thu Aug  5 11:35:53 2010
@@ -981,7 +981,7 @@
   static RootListIndex RootIndexForExternalArrayType(
       ExternalArrayType array_type);

-  static void RecordStats(HeapStats* stats);
+  static void RecordStats(HeapStats* stats, bool take_snapshot = false);

   static Scavenger GetScavenger(int instance_type, int instance_size);

@@ -1324,26 +1324,30 @@

 class HeapStats {
  public:
-  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;
+  int* start_marker;                    //  0
+  int* new_space_size;                  //  1
+  int* new_space_capacity;              //  2
+  int* old_pointer_space_size;          //  3
+  int* old_pointer_space_capacity;      //  4
+  int* old_data_space_size;             //  5
+  int* old_data_space_capacity;         //  6
+  int* code_space_size;                 //  7
+  int* code_space_capacity;             //  8
+  int* map_space_size;                  //  9
+  int* map_space_capacity;              // 10
+  int* cell_space_size;                 // 11
+  int* cell_space_capacity;             // 12
+  int* lo_space_size;                   // 13
+  int* global_handle_count;             // 14
+  int* weak_global_handle_count;        // 15
+  int* pending_global_handle_count;     // 16
+  int* near_death_global_handle_count;  // 17
+  int* destroyed_global_handle_count;   // 18
+  int* memory_allocator_size;           // 19
+  int* memory_allocator_capacity;       // 20
+  int* objects_per_type;                // 21
+  int* size_per_type;                   // 22
+  int* end_marker;                      // 23
 };


=======================================
--- /branches/2.2/src/v8.h      Mon Apr 12 04:30:10 2010
+++ /branches/2.2/src/v8.h      Thu Aug  5 11:35:53 2010
@@ -92,7 +92,8 @@
   static void SetFatalError();

   // Report process out of memory. Implementation found in api.cc.
-  static void FatalProcessOutOfMemory(const char* location);
+  static void FatalProcessOutOfMemory(const char* location,
+                                      bool take_snapshot = false);

   // Random number generation support. Not cryptographically safe.
   static uint32_t Random();
=======================================
--- /branches/2.2/src/version.cc        Thu Aug  5 08:01:05 2010
+++ /branches/2.2/src/version.cc        Thu Aug  5 11:35:53 2010
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     2
 #define MINOR_VERSION     2
 #define BUILD_NUMBER      24
-#define PATCH_LEVEL       9
+#define PATCH_LEVEL       11
 #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