Version 3.12.12

Added an option to the tickprocessor to specify the directory for lib lookup.

Fixed ICs for slow objects with native accessor (Chromium issue 137002).

Fixed transcendental cache on ARM in optimized code (issue 2234).

New heap inspection tools: counters for object sizes and counts, histograms for external fragmentation.

Incorporated constness into inferred interfaces (in preparation for handling imports) (issue 1569).

Performance and stability improvements on all platforms.

git-svn-id: http://v8.googlecode.com/svn/trunk@12091 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/heap.cc b/src/heap.cc
index a448292..9e38f51 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -179,6 +179,8 @@
   // Put a dummy entry in the remembered pages so we can find the list the
   // minidump even if there are no real unmapped pages.
   RememberUnmappedPage(NULL, false);
+
+  ClearObjectStats(true);
 }
 
 
@@ -445,54 +447,26 @@
   isolate_->counters()->number_of_symbols()->Set(
       symbol_table()->NumberOfElements());
 
-  isolate_->counters()->new_space_bytes_available()->Set(
-      static_cast<int>(new_space()->Available()));
-  isolate_->counters()->new_space_bytes_committed()->Set(
-      static_cast<int>(new_space()->CommittedMemory()));
-  isolate_->counters()->new_space_bytes_used()->Set(
-      static_cast<int>(new_space()->SizeOfObjects()));
-
-  isolate_->counters()->old_pointer_space_bytes_available()->Set(
-      static_cast<int>(old_pointer_space()->Available()));
-  isolate_->counters()->old_pointer_space_bytes_committed()->Set(
-      static_cast<int>(old_pointer_space()->CommittedMemory()));
-  isolate_->counters()->old_pointer_space_bytes_used()->Set(
-      static_cast<int>(old_pointer_space()->SizeOfObjects()));
-
-  isolate_->counters()->old_data_space_bytes_available()->Set(
-      static_cast<int>(old_data_space()->Available()));
-  isolate_->counters()->old_data_space_bytes_committed()->Set(
-      static_cast<int>(old_data_space()->CommittedMemory()));
-  isolate_->counters()->old_data_space_bytes_used()->Set(
-      static_cast<int>(old_data_space()->SizeOfObjects()));
-
-  isolate_->counters()->code_space_bytes_available()->Set(
-      static_cast<int>(code_space()->Available()));
-  isolate_->counters()->code_space_bytes_committed()->Set(
-      static_cast<int>(code_space()->CommittedMemory()));
-  isolate_->counters()->code_space_bytes_used()->Set(
-      static_cast<int>(code_space()->SizeOfObjects()));
-
-  isolate_->counters()->map_space_bytes_available()->Set(
-      static_cast<int>(map_space()->Available()));
-  isolate_->counters()->map_space_bytes_committed()->Set(
-      static_cast<int>(map_space()->CommittedMemory()));
-  isolate_->counters()->map_space_bytes_used()->Set(
-      static_cast<int>(map_space()->SizeOfObjects()));
-
-  isolate_->counters()->cell_space_bytes_available()->Set(
-      static_cast<int>(cell_space()->Available()));
-  isolate_->counters()->cell_space_bytes_committed()->Set(
-      static_cast<int>(cell_space()->CommittedMemory()));
-  isolate_->counters()->cell_space_bytes_used()->Set(
-      static_cast<int>(cell_space()->SizeOfObjects()));
-
-  isolate_->counters()->lo_space_bytes_available()->Set(
-      static_cast<int>(lo_space()->Available()));
-  isolate_->counters()->lo_space_bytes_committed()->Set(
-      static_cast<int>(lo_space()->CommittedMemory()));
-  isolate_->counters()->lo_space_bytes_used()->Set(
-      static_cast<int>(lo_space()->SizeOfObjects()));
+#define UPDATE_COUNTERS_FOR_SPACE(space)                                     \
+  isolate_->counters()->space##_bytes_available()->Set(                      \
+      static_cast<int>(space()->Available()));                               \
+  isolate_->counters()->space##_bytes_committed()->Set(                      \
+      static_cast<int>(space()->CommittedMemory()));                         \
+  isolate_->counters()->space##_bytes_used()->Set(                           \
+      static_cast<int>(space()->SizeOfObjects()));                           \
+  if (space()->CommittedMemory() > 0) {                                      \
+    isolate_->counters()->external_fragmentation_##space()->AddSample(       \
+        static_cast<int>(                                                    \
+            (space()->SizeOfObjects() * 100) / space()->CommittedMemory())); \
+  }
+  UPDATE_COUNTERS_FOR_SPACE(new_space)
+  UPDATE_COUNTERS_FOR_SPACE(old_pointer_space)
+  UPDATE_COUNTERS_FOR_SPACE(old_data_space)
+  UPDATE_COUNTERS_FOR_SPACE(code_space)
+  UPDATE_COUNTERS_FOR_SPACE(map_space)
+  UPDATE_COUNTERS_FOR_SPACE(cell_space)
+  UPDATE_COUNTERS_FOR_SPACE(lo_space)
+#undef UPDATE_COUNTERS_FOR_SPACE
 
 #if defined(DEBUG)
   ReportStatisticsAfterGC();
@@ -7225,4 +7199,37 @@
   remembered_unmapped_pages_index_ %= kRememberedUnmappedPages;
 }
 
+
+void Heap::ClearObjectStats(bool clear_last_time_stats) {
+  memset(object_counts_, 0, sizeof(object_counts_));
+  memset(object_sizes_, 0, sizeof(object_sizes_));
+  if (clear_last_time_stats) {
+    memset(object_counts_last_time_, 0, sizeof(object_counts_last_time_));
+    memset(object_sizes_last_time_, 0, sizeof(object_sizes_last_time_));
+  }
+}
+
+
+static LazyMutex checkpoint_object_stats_mutex = LAZY_MUTEX_INITIALIZER;
+
+
+void Heap::CheckpointObjectStats() {
+  ScopedLock lock(checkpoint_object_stats_mutex.Pointer());
+  Counters* counters = isolate()->counters();
+#define ADJUST_LAST_TIME_OBJECT_COUNT(name)                                    \
+  counters->count_of_##name()->Increment(                                      \
+      static_cast<int>(object_counts_[name]));                                 \
+  counters->count_of_##name()->Decrement(                                      \
+      static_cast<int>(object_counts_last_time_[name]));                       \
+  counters->size_of_##name()->Increment(                                       \
+      static_cast<int>(object_sizes_[name]));                                  \
+  counters->size_of_##name()->Decrement(                                       \
+      static_cast<int>(object_sizes_last_time_[name]));
+  INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
+#undef ADJUST_LAST_TIME_OBJECT_COUNT
+  memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
+  memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
+  ClearObjectStats();
+}
+
 } }  // namespace v8::internal