Commit 3d4ddb30 authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] ObjectStats: Cleanup and more FIXED_ARRAY sub types

Reduces the dark matter of reported fixed arrays to < 5%.

BUG=chromium:631094
R=ulan@chromium.org

Review-Url: https://codereview.chromium.org/2181623002
Cr-Commit-Position: refs/heads/master@{#38032}
parent 258c2c35
......@@ -2243,25 +2243,28 @@ void MarkCompactCollector::RegisterExternallyReferencedObject(Object** object) {
class MarkCompactCollector::ObjectStatsVisitor
: public MarkCompactCollector::HeapObjectVisitor {
public:
ObjectStatsVisitor(ObjectStats* live_stats, ObjectStats* dead_stats)
: live_stats_(live_stats), dead_stats_(dead_stats) {
DCHECK_NOT_NULL(live_stats_);
DCHECK_NOT_NULL(dead_stats_);
ObjectStatsVisitor(Heap* heap, ObjectStats* live_stats,
ObjectStats* dead_stats)
: live_collector_(heap, live_stats), dead_collector_(heap, dead_stats) {
DCHECK_NOT_NULL(live_stats);
DCHECK_NOT_NULL(dead_stats);
// Global objects are roots and thus recorded as live.
live_collector_.CollectGlobalStatistics();
}
bool Visit(HeapObject* obj) override {
if (Marking::IsBlack(ObjectMarking::MarkBitFrom(obj))) {
ObjectStatsCollector::CollectStatistics(live_stats_, obj);
live_collector_.CollectStatistics(obj);
} else {
DCHECK(!Marking::IsGrey(ObjectMarking::MarkBitFrom(obj)));
ObjectStatsCollector::CollectStatistics(dead_stats_, obj);
dead_collector_.CollectStatistics(obj);
}
return true;
}
private:
ObjectStats* live_stats_;
ObjectStats* dead_stats_;
ObjectStatsCollector live_collector_;
ObjectStatsCollector dead_collector_;
};
void MarkCompactCollector::VisitAllObjects(HeapObjectVisitor* visitor) {
......@@ -2277,7 +2280,7 @@ void MarkCompactCollector::VisitAllObjects(HeapObjectVisitor* visitor) {
void MarkCompactCollector::RecordObjectStats() {
if (FLAG_track_gc_object_stats) {
ObjectStatsVisitor visitor(heap()->live_object_stats_,
ObjectStatsVisitor visitor(heap(), heap()->live_object_stats_,
heap()->dead_object_stats_);
VisitAllObjects(&visitor);
if (FLAG_trace_gc_object_stats) {
......
This diff is collapsed.
......@@ -60,19 +60,22 @@ class ObjectStats {
size_histogram_[code_age_index][idx]++;
}
void RecordFixedArraySubTypeStats(FixedArrayBase* array, int array_sub_type,
bool RecordFixedArraySubTypeStats(FixedArrayBase* array, int array_sub_type,
size_t size, size_t over_allocated) {
auto it = visited_fixed_array_sub_types_.insert(array);
if (!it.second) return;
if (!it.second) return false;
DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE);
object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++;
object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size;
size_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]
[HistogramIndexFromSize(size)]++;
over_allocated_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] +=
over_allocated;
over_allocated_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]
[HistogramIndexFromSize(over_allocated)]++;
if (over_allocated > 0) {
over_allocated_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] +=
over_allocated;
over_allocated_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]
[HistogramIndexFromSize(over_allocated)]++;
}
return true;
}
size_t object_count_last_gc(size_t index) {
......@@ -117,26 +120,31 @@ class ObjectStats {
class ObjectStatsCollector {
public:
static void CollectStatistics(ObjectStats* stats, HeapObject* obj);
ObjectStatsCollector(Heap* heap, ObjectStats* stats)
: heap_(heap), stats_(stats) {}
void CollectGlobalStatistics();
void CollectStatistics(HeapObject* obj);
private:
static void RecordMapDetails(ObjectStats* stats, Heap* heap, HeapObject* obj);
static void RecordCodeDetails(ObjectStats* stats, Heap* heap,
HeapObject* obj);
static void RecordSharedFunctionInfoDetails(ObjectStats* stats, Heap* heap,
HeapObject* obj);
static void RecordFixedArrayDetails(ObjectStats* stats, Heap* heap,
HeapObject* obj);
static void RecordJSObjectDetails(ObjectStats* stats, Heap* heap,
JSObject* object);
static void RecordJSWeakCollectionDetails(ObjectStats* stats, Heap* heap,
JSWeakCollection* obj);
static void RecordScriptDetails(ObjectStats* stats, Heap* heap, Script* obj);
static void RecordFixedArrayHelper(ObjectStats* stats, Heap* heap,
HeapObject* parent, FixedArray* array,
int subtype, size_t overhead);
void RecordCodeDetails(Code* code);
void RecordFixedArrayDetails(FixedArray* array);
void RecordJSCollectionDetails(JSObject* obj);
void RecordJSFunctionDetails(JSFunction* function);
void RecordJSObjectDetails(JSObject* object);
void RecordJSWeakCollectionDetails(JSWeakCollection* obj);
void RecordMapDetails(Map* map);
void RecordScriptDetails(Script* obj);
void RecordSharedFunctionInfoDetails(SharedFunctionInfo* sfi);
bool RecordFixedArrayHelper(HeapObject* parent, FixedArray* array,
int subtype, size_t overhead);
void RecursivelyRecordFixedArrayHelper(HeapObject* parent, FixedArray* array,
int subtype);
template <class HashTable>
void RecordHashTableHelper(HeapObject* parent, HashTable* array, int subtype);
Heap* heap_;
ObjectStats* stats_;
};
} // namespace internal
......
......@@ -705,6 +705,8 @@ bool HeapObject::IsJSWeakCollection() const {
return IsJSWeakMap() || IsJSWeakSet();
}
bool HeapObject::IsJSCollection() const { return IsJSMap() || IsJSSet(); }
bool HeapObject::IsDescriptorArray() const { return IsFixedArray(); }
bool HeapObject::IsArrayList() const { return IsFixedArray(); }
......
......@@ -776,17 +776,27 @@ std::ostream& operator<<(std::ostream& os, InstanceType instance_type);
V(EMBEDDED_OBJECT_SUB_TYPE) \
V(ENUM_CACHE_SUB_TYPE) \
V(ENUM_INDICES_CACHE_SUB_TYPE) \
V(DEPENDENT_CODE_SUB_TYPE) \
V(DICTIONARY_ELEMENTS_SUB_TYPE) \
V(DICTIONARY_PROPERTIES_SUB_TYPE) \
V(EMPTY_PROPERTIES_DICTIONARY_SUB_TYPE) \
V(FAST_ELEMENTS_SUB_TYPE) \
V(FAST_PROPERTIES_SUB_TYPE) \
V(HANDLER_TABLE_SUB_TYPE) \
V(INTRINSIC_FUNCTION_NAMES_SUB_TYPE) \
V(JS_COLLECTION_SUB_TYPE) \
V(JS_WEAK_COLLECTION_SUB_TYPE) \
V(LITERALS_ARRAY_SUB_TYPE) \
V(MAP_CODE_CACHE_SUB_TYPE) \
V(NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE) \
V(NUMBER_STRING_CACHE_SUB_TYPE) \
V(OBJECT_TO_CODE_SUB_TYPE) \
V(OPTIMIZED_CODE_MAP_SUB_TYPE) \
V(PROTOTYPE_USERS_SUB_TYPE) \
V(REGEXP_MULTIPLE_CACHE_SUB_TYPE) \
V(RETAINED_MAPS_SUB_TYPE) \
V(SCOPE_INFO_SUB_TYPE) \
V(SCRIPT_LIST_SUB_TYPE) \
V(SERIALIZED_TEMPLATES_SUB_TYPE) \
V(SHARED_FUNCTION_INFOS_SUB_TYPE) \
V(SINGLE_CHARACTER_STRING_CACHE_SUB_TYPE) \
......@@ -795,7 +805,6 @@ std::ostream& operator<<(std::ostream& os, InstanceType instance_type);
V(TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \
V(TYPE_FEEDBACK_VECTOR_SUB_TYPE) \
V(TYPE_FEEDBACK_METADATA_SUB_TYPE) \
V(WEAK_COLLECTION_SUB_TYPE) \
V(WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE)
enum FixedArraySubInstanceType {
......@@ -975,6 +984,7 @@ template <class C> inline bool Is(Object* obj);
V(JSArray) \
V(JSArrayBuffer) \
V(JSArrayBufferView) \
V(JSCollection) \
V(JSTypedArray) \
V(JSDataView) \
V(JSProxy) \
......@@ -5598,6 +5608,9 @@ class DependentCode: public FixedArray {
};
static const int kGroupCount = kAllocationSiteTransitionChangedGroup + 1;
static const int kNextLinkIndex = 0;
static const int kFlagsIndex = 1;
static const int kCodesStartIndex = 2;
bool Contains(DependencyGroup group, WeakCell* code_cell);
bool IsEmpty(DependencyGroup group);
......@@ -5658,9 +5671,6 @@ class DependentCode: public FixedArray {
class GroupField : public BitField<int, 0, 3> {};
class CountField : public BitField<int, 3, 27> {};
STATIC_ASSERT(kGroupCount <= GroupField::kMax + 1);
static const int kNextLinkIndex = 0;
static const int kFlagsIndex = 1;
static const int kCodesStartIndex = 2;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment