Fix --track_gc_object_stats option.
authordanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 18 Jul 2013 13:00:40 +0000 (13:00 +0000)
committerdanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 18 Jul 2013 13:00:40 +0000 (13:00 +0000)
 - Update ObjectStatsVisitTracker::Visit function to check if CodeCache is of
   CodeCache type, and extract the FixedArray from the struct if so
 - Fix typo in v8-counters.h where count_of_FIXED_ARRAY_XXX fields weren't being
   initialized.

BUG=v8:2780
R=danno@chromium.org, hpayer@chromium.org

Review URL: https://codereview.chromium.org/19257002

Patch from Ross McIlroy <mcilroy@chromium.org>.

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

src/mark-compact.cc
src/objects-inl.h
src/objects.h
src/v8-counters.cc

index df39a8a..5c91dbf 100644 (file)
@@ -1634,11 +1634,18 @@ class MarkCompactMarkingVisitor::ObjectStatsTracker<
                               TRANSITION_ARRAY_SUB_TYPE,
                               fixed_array_size);
     }
-    if (map_obj->code_cache() != heap->empty_fixed_array()) {
+    if (map_obj->has_code_cache()) {
+      CodeCache* cache = CodeCache::cast(map_obj->code_cache());
       heap->RecordObjectStats(
           FIXED_ARRAY_TYPE,
           MAP_CODE_CACHE_SUB_TYPE,
-          FixedArray::cast(map_obj->code_cache())->Size());
+          cache->default_cache()->Size());
+      if (!cache->normal_type_cache()->IsUndefined()) {
+        heap->RecordObjectStats(
+            FIXED_ARRAY_TYPE,
+            MAP_CODE_CACHE_SUB_TYPE,
+            FixedArray::cast(cache->normal_type_cache())->Size());
+      }
     }
     ObjectStatsVisitBase(kVisitMap, map, obj);
   }
index ea21460..0a5215c 100644 (file)
@@ -3617,6 +3617,11 @@ bool Map::is_frozen() {
 }
 
 
+bool Map::has_code_cache() {
+  return code_cache() != GetIsolate()->heap()->empty_fixed_array();
+}
+
+
 bool Map::CanBeDeprecated() {
   int descriptor = LastAdded();
   for (int i = 0; i <= descriptor; i++) {
index 5d5945e..6bcd412 100644 (file)
@@ -5344,6 +5344,9 @@ class Map: public HeapObject {
   inline void set_is_access_check_needed(bool access_check_needed);
   inline bool is_access_check_needed();
 
+  // Returns true if map has a non-empty stub code cache.
+  inline bool has_code_cache();
+
   // [prototype]: implicit prototype object.
   DECL_ACCESSORS(prototype, Object)
 
index b3e15bb..905e178 100644 (file)
@@ -73,7 +73,7 @@ Counters::Counters(Isolate* isolate) {
     count_of_FIXED_ARRAY_##name##_ = \
         StatsCounter("c:" "V8.CountOf_FIXED_ARRAY-" #name); \
     size_of_FIXED_ARRAY_##name##_ = \
-        StatsCounter("c:" "V8.SizeOf_FIXED_ARRAY-" #name); \
+        StatsCounter("c:" "V8.SizeOf_FIXED_ARRAY-" #name);
     FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC)
 #undef SC
 }