Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/heap/object-stats.cc b/src/heap/object-stats.cc
index 0198c6b..e7d90b3 100644
--- a/src/heap/object-stats.cc
+++ b/src/heap/object-stats.cc
@@ -134,8 +134,7 @@
Isolate* ObjectStats::isolate() { return heap()->isolate(); }
-
-void ObjectStatsVisitor::CountFixedArray(
+void ObjectStatsCollector::CountFixedArray(
FixedArrayBase* fixed_array, FixedArraySubInstanceType fast_type,
FixedArraySubInstanceType dictionary_type) {
Heap* heap = fixed_array->map()->GetHeap();
@@ -152,12 +151,32 @@
}
}
+void ObjectStatsCollector::CollectStatistics(StaticVisitorBase::VisitorId id,
+ Map* map, HeapObject* obj) {
+ // Record any type specific statistics here.
+ switch (id) {
+ case StaticVisitorBase::kVisitMap:
+ RecordMapStats(map, obj);
+ break;
+ case StaticVisitorBase::kVisitCode:
+ RecordCodeStats(map, obj);
+ break;
+ case StaticVisitorBase::kVisitSharedFunctionInfo:
+ RecordSharedFunctionInfoStats(map, obj);
+ break;
+ case StaticVisitorBase::kVisitFixedArray:
+ RecordFixedArrayStats(map, obj);
+ break;
+ default:
+ break;
+ }
-void ObjectStatsVisitor::VisitBase(VisitorId id, Map* map, HeapObject* obj) {
Heap* heap = map->GetHeap();
int object_size = obj->Size();
heap->object_stats_->RecordObjectStats(map->instance_type(), object_size);
- table_.GetVisitorById(id)(map, obj);
+}
+
+void ObjectStatsCollector::CollectFixedArrayStatistics(HeapObject* obj) {
if (obj->IsJSObject()) {
JSObject* object = JSObject::cast(obj);
CountFixedArray(object->elements(), DICTIONARY_ELEMENTS_SUB_TYPE,
@@ -167,16 +186,7 @@
}
}
-
-template <ObjectStatsVisitor::VisitorId id>
-void ObjectStatsVisitor::Visit(Map* map, HeapObject* obj) {
- VisitBase(id, map, obj);
-}
-
-
-template <>
-void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitMap>(Map* map,
- HeapObject* obj) {
+void ObjectStatsCollector::RecordMapStats(Map* map, HeapObject* obj) {
Heap* heap = map->GetHeap();
Map* map_obj = Map::cast(obj);
DCHECK(map->instance_type() == MAP_TYPE);
@@ -187,54 +197,42 @@
fixed_array_size);
}
if (map_obj->has_code_cache()) {
- FixedArray* cache = FixedArray::cast(map_obj->code_cache());
+ FixedArray* cache = map_obj->code_cache();
heap->object_stats_->RecordFixedArraySubTypeStats(MAP_CODE_CACHE_SUB_TYPE,
cache->Size());
}
- VisitBase(kVisitMap, map, obj);
}
-
-template <>
-void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitCode>(
- Map* map, HeapObject* obj) {
+void ObjectStatsCollector::RecordCodeStats(Map* map, HeapObject* obj) {
Heap* heap = map->GetHeap();
int object_size = obj->Size();
DCHECK(map->instance_type() == CODE_TYPE);
Code* code_obj = Code::cast(obj);
heap->object_stats_->RecordCodeSubTypeStats(code_obj->kind(),
code_obj->GetAge(), object_size);
- VisitBase(kVisitCode, map, obj);
}
-
-template <>
-void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitSharedFunctionInfo>(
- Map* map, HeapObject* obj) {
+void ObjectStatsCollector::RecordSharedFunctionInfoStats(Map* map,
+ HeapObject* obj) {
Heap* heap = map->GetHeap();
SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
if (sfi->scope_info() != heap->empty_fixed_array()) {
heap->object_stats_->RecordFixedArraySubTypeStats(
SCOPE_INFO_SUB_TYPE, FixedArray::cast(sfi->scope_info())->Size());
}
- VisitBase(kVisitSharedFunctionInfo, map, obj);
}
-
-template <>
-void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitFixedArray>(
- Map* map, HeapObject* obj) {
+void ObjectStatsCollector::RecordFixedArrayStats(Map* map, HeapObject* obj) {
Heap* heap = map->GetHeap();
FixedArray* fixed_array = FixedArray::cast(obj);
if (fixed_array == heap->string_table()) {
heap->object_stats_->RecordFixedArraySubTypeStats(STRING_TABLE_SUB_TYPE,
fixed_array->Size());
}
- VisitBase(kVisitFixedArray, map, obj);
}
-
-void ObjectStatsVisitor::Initialize(VisitorDispatchTable<Callback>* original) {
+void MarkCompactObjectStatsVisitor::Initialize(
+ VisitorDispatchTable<Callback>* original) {
// Copy the original visitor table to make call-through possible. After we
// preserved a copy locally, we patch the original table to call us.
table_.CopyFrom(original);
@@ -243,5 +241,29 @@
#undef COUNT_FUNCTION
}
+template <MarkCompactObjectStatsVisitor::VisitorId id>
+void MarkCompactObjectStatsVisitor::Visit(Map* map, HeapObject* obj) {
+ ObjectStatsCollector::CollectStatistics(id, map, obj);
+ table_.GetVisitorById(id)(map, obj);
+ ObjectStatsCollector::CollectFixedArrayStatistics(obj);
+}
+
+void IncrementalMarkingObjectStatsVisitor::Initialize(
+ VisitorDispatchTable<Callback>* original) {
+ // Copy the original visitor table to make call-through possible. After we
+ // preserved a copy locally, we patch the original table to call us.
+ table_.CopyFrom(original);
+#define COUNT_FUNCTION(id) original->Register(kVisit##id, Visit<kVisit##id>);
+ VISITOR_ID_LIST(COUNT_FUNCTION)
+#undef COUNT_FUNCTION
+}
+
+template <IncrementalMarkingObjectStatsVisitor::VisitorId id>
+void IncrementalMarkingObjectStatsVisitor::Visit(Map* map, HeapObject* obj) {
+ ObjectStatsCollector::CollectStatistics(id, map, obj);
+ table_.GetVisitorById(id)(map, obj);
+ ObjectStatsCollector::CollectFixedArrayStatistics(obj);
+}
+
} // namespace internal
} // namespace v8