Commit 5d9deb25 authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] ObjectStats: Various new categories

- Add object template categories.
- Add optimized code literals.
- Add compilation cache hash tables.
- Report overhead for code cache when used as hashtable.

BUG=chromium:631094

Review-Url: https://codereview.chromium.org/2246473002
Cr-Commit-Position: refs/heads/master@{#38667}
parent e7ccf0c2
......@@ -757,6 +757,7 @@ DEFINE_BOOL(track_gc_object_stats, false,
DEFINE_BOOL(trace_gc_object_stats, false,
"trace object counts and memory usage")
DEFINE_IMPLICATION(trace_gc_object_stats, track_gc_object_stats)
DEFINE_NEG_IMPLICATION(trace_gc_object_stats, incremental_marking)
DEFINE_BOOL(track_detached_contexts, true,
"track native contexts that are expected to be garbage collected")
DEFINE_BOOL(trace_detached_contexts, false,
......
......@@ -4,6 +4,7 @@
#include "src/heap/object-stats.h"
#include "src/compilation-cache.h"
#include "src/counters.h"
#include "src/heap/heap-inl.h"
#include "src/isolate.h"
......@@ -173,6 +174,9 @@ void ObjectStatsCollector::CollectStatistics(HeapObject* obj) {
// Record specific sub types where possible.
if (obj->IsMap()) RecordMapDetails(Map::cast(obj));
if (obj->IsObjectTemplateInfo() || obj->IsFunctionTemplateInfo()) {
RecordTemplateInfoDetails(TemplateInfo::cast(obj));
}
if (obj->IsBytecodeArray()) {
RecordBytecodeArrayDetails(BytecodeArray::cast(obj));
}
......@@ -192,6 +196,26 @@ void ObjectStatsCollector::CollectStatistics(HeapObject* obj) {
if (obj->IsScript()) RecordScriptDetails(Script::cast(obj));
}
class ObjectStatsCollector::CompilationCacheTableVisitor
: public ObjectVisitor {
public:
explicit CompilationCacheTableVisitor(ObjectStatsCollector* parent)
: parent_(parent) {}
void VisitPointers(Object** start, Object** end) override {
for (Object** current = start; current < end; current++) {
HeapObject* obj = HeapObject::cast(*current);
if (obj->IsUndefined(parent_->heap_->isolate())) continue;
CHECK(obj->IsCompilationCacheTable());
parent_->RecordHashTableHelper(nullptr, CompilationCacheTable::cast(obj),
COMPILATION_CACHE_TABLE_SUB_TYPE);
}
}
private:
ObjectStatsCollector* parent_;
};
void ObjectStatsCollector::CollectGlobalStatistics() {
// Global FixedArrays.
RecordFixedArrayHelper(nullptr, heap_->weak_new_space_object_to_code_list(),
......@@ -226,6 +250,9 @@ void ObjectStatsCollector::CollectGlobalStatistics() {
INTRINSIC_FUNCTION_NAMES_SUB_TYPE);
RecordHashTableHelper(nullptr, heap_->empty_properties_dictionary(),
EMPTY_PROPERTIES_DICTIONARY_SUB_TYPE);
CompilationCache* compilation_cache = heap_->isolate()->compilation_cache();
CompilationCacheTableVisitor v(this);
compilation_cache->Iterate(&v);
}
static bool CanRecordFixedArray(Heap* heap, FixedArrayBase* array) {
......@@ -366,8 +393,13 @@ void ObjectStatsCollector::RecordMapDetails(Map* map_obj) {
}
if (map_obj->has_code_cache()) {
RecordFixedArrayHelper(map_obj, map_obj->code_cache(),
MAP_CODE_CACHE_SUB_TYPE, 0);
FixedArray* code_cache = map_obj->code_cache();
if (code_cache->IsCodeCacheHashTable()) {
RecordHashTableHelper(map_obj, CodeCacheHashTable::cast(code_cache),
MAP_CODE_CACHE_SUB_TYPE);
} else {
RecordFixedArrayHelper(map_obj, code_cache, MAP_CODE_CACHE_SUB_TYPE, 0);
}
}
for (DependentCode* cur_dependent_code = map_obj->dependent_code();
......@@ -390,6 +422,17 @@ void ObjectStatsCollector::RecordMapDetails(Map* map_obj) {
}
}
void ObjectStatsCollector::RecordTemplateInfoDetails(TemplateInfo* obj) {
if (obj->property_accessors()->IsFixedArray()) {
RecordFixedArrayHelper(obj, FixedArray::cast(obj->property_accessors()),
TEMPLATE_INFO_SUB_TYPE, 0);
}
if (obj->property_list()->IsFixedArray()) {
RecordFixedArrayHelper(obj, FixedArray::cast(obj->property_list()),
TEMPLATE_INFO_SUB_TYPE, 0);
}
}
void ObjectStatsCollector::RecordBytecodeArrayDetails(BytecodeArray* obj) {
RecordFixedArrayHelper(obj, obj->constant_pool(),
BYTECODE_ARRAY_CONSTANT_POOL_SUB_TYPE, 0);
......@@ -401,6 +444,13 @@ void ObjectStatsCollector::RecordCodeDetails(Code* code) {
stats_->RecordCodeSubTypeStats(code->kind(), code->GetAge(), code->Size());
RecordFixedArrayHelper(code, code->deoptimization_data(),
DEOPTIMIZATION_DATA_SUB_TYPE, 0);
if (code->kind() == Code::Kind::OPTIMIZED_FUNCTION) {
DeoptimizationInputData* input_data =
DeoptimizationInputData::cast(code->deoptimization_data());
RecordFixedArrayHelper(code->deoptimization_data(),
input_data->LiteralArray(),
OPTIMIZED_CODE_LITERALS_SUB_TYPE, 0);
}
RecordFixedArrayHelper(code, code->handler_table(), HANDLER_TABLE_SUB_TYPE,
0);
int const mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
......
......@@ -127,6 +127,8 @@ class ObjectStatsCollector {
void CollectStatistics(HeapObject* obj);
private:
class CompilationCacheTableVisitor;
void RecordBytecodeArrayDetails(BytecodeArray* obj);
void RecordCodeDetails(Code* code);
void RecordFixedArrayDetails(FixedArray* array);
......@@ -136,6 +138,7 @@ class ObjectStatsCollector {
void RecordJSWeakCollectionDetails(JSWeakCollection* obj);
void RecordMapDetails(Map* map);
void RecordScriptDetails(Script* obj);
void RecordTemplateInfoDetails(TemplateInfo* obj);
void RecordSharedFunctionInfoDetails(SharedFunctionInfo* sfi);
bool RecordFixedArrayHelper(HeapObject* parent, FixedArray* array,
......@@ -146,6 +149,8 @@ class ObjectStatsCollector {
void RecordHashTableHelper(HeapObject* parent, HashTable* array, int subtype);
Heap* heap_;
ObjectStats* stats_;
friend class ObjectStatsCollector::CompilationCacheTableVisitor;
};
} // namespace internal
......
......@@ -3280,6 +3280,7 @@ CAST_ACCESSOR(StringSet)
CAST_ACCESSOR(StringTable)
CAST_ACCESSOR(Struct)
CAST_ACCESSOR(Symbol)
CAST_ACCESSOR(TemplateInfo)
CAST_ACCESSOR(Uint16x8)
CAST_ACCESSOR(Uint32x4)
CAST_ACCESSOR(Uint8x16)
......
......@@ -775,6 +775,7 @@ std::ostream& operator<<(std::ostream& os, InstanceType instance_type);
V(BYTECODE_ARRAY_CONSTANT_POOL_SUB_TYPE) \
V(BYTECODE_ARRAY_HANDLER_TABLE_SUB_TYPE) \
V(CODE_STUBS_TABLE_SUB_TYPE) \
V(COMPILATION_CACHE_TABLE_SUB_TYPE) \
V(CONTEXT_SUB_TYPE) \
V(COPY_ON_WRITE_SUB_TYPE) \
V(DEOPTIMIZATION_DATA_SUB_TYPE) \
......@@ -798,6 +799,7 @@ std::ostream& operator<<(std::ostream& os, InstanceType instance_type);
V(NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE) \
V(NUMBER_STRING_CACHE_SUB_TYPE) \
V(OBJECT_TO_CODE_SUB_TYPE) \
V(OPTIMIZED_CODE_LITERALS_SUB_TYPE) \
V(OPTIMIZED_CODE_MAP_SUB_TYPE) \
V(PROTOTYPE_USERS_SUB_TYPE) \
V(REGEXP_MULTIPLE_CACHE_SUB_TYPE) \
......@@ -810,6 +812,7 @@ std::ostream& operator<<(std::ostream& os, InstanceType instance_type);
V(SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \
V(STRING_SPLIT_CACHE_SUB_TYPE) \
V(STRING_TABLE_SUB_TYPE) \
V(TEMPLATE_INFO_SUB_TYPE) \
V(TYPE_FEEDBACK_VECTOR_SUB_TYPE) \
V(TYPE_FEEDBACK_METADATA_SUB_TYPE) \
V(WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE)
......@@ -10821,6 +10824,8 @@ class TemplateInfo: public Struct {
DECLARE_VERIFIER(TemplateInfo)
DECLARE_CAST(TemplateInfo)
static const int kTagOffset = HeapObject::kHeaderSize;
static const int kSerialNumberOffset = kTagOffset + kPointerSize;
static const int kNumberOfProperties = kSerialNumberOffset + kPointerSize;
......
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