Commit 91618802 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[object-stats] Redo recording of non-existing instance types

- Base recording just on the concept of virtual instance types.
- Re-add dropped types incrementally.

Bug: v8:7266
Change-Id: Ic8209ce8c6067e24536a0c62404e1160f86377db
Reviewed-on: https://chromium-review.googlesource.com/873646Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50714}
parent cdc6f7e1
......@@ -6479,19 +6479,13 @@ bool Heap::GetObjectTypeName(size_t index, const char** object_type,
return true;
INSTANCE_TYPE_LIST(COMPARE_AND_RETURN_NAME)
#undef COMPARE_AND_RETURN_NAME
#define COMPARE_AND_RETURN_NAME(name) \
case ObjectStats::FIRST_CODE_KIND_SUB_TYPE + Code::name: \
*object_type = "CODE_TYPE"; \
*object_sub_type = "CODE_KIND/" #name; \
return true;
CODE_KIND_LIST(COMPARE_AND_RETURN_NAME)
#undef COMPARE_AND_RETURN_NAME
#define COMPARE_AND_RETURN_NAME(name) \
case ObjectStats::FIRST_FIXED_ARRAY_SUB_TYPE + name: \
*object_type = "FIXED_ARRAY_TYPE"; \
*object_sub_type = #name; \
#define COMPARE_AND_RETURN_NAME(name) \
case ObjectStats::FIRST_VIRTUAL_TYPE + ObjectStats::name: \
*object_type = #name; \
*object_sub_type = ""; \
return true;
FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(COMPARE_AND_RETURN_NAME)
VIRTUAL_INSTANCE_TYPE_LIST(COMPARE_AND_RETURN_NAME)
#undef COMPARE_AND_RETURN_NAME
}
return false;
......
This diff is collapsed.
......@@ -19,19 +19,37 @@
// tracing.
//
// Update LAST_VIRTUAL_TYPE below when changing this macro.
#define VIRTUAL_INSTANCE_TYPE_LIST(V) \
V(BOILERPLATE_ELEMENTS_TYPE) \
V(BOILERPLATE_NAME_DICTIONARY_TYPE) \
V(BOILERPLATE_PROPERTY_ARRAY_TYPE) \
V(FEEDBACK_VECTOR_ENTRY_TYPE) \
V(JS_ARRAY_BOILERPLATE_TYPE) \
V(JS_OBJECT_BOILERPLATE_TYPE)
#define VIRTUAL_INSTANCE_TYPE_LIST(V) \
CODE_KIND_LIST(V) \
V(BOILERPLATE_ELEMENTS_TYPE) \
V(BOILERPLATE_NAME_DICTIONARY_TYPE) \
V(BOILERPLATE_PROPERTY_ARRAY_TYPE) \
V(BYTECODE_ARRAY_CONSTANT_POOL_TYPE) \
V(BYTECODE_ARRAY_HANDLER_TABLE_TYPE) \
V(DEPENDENT_CODE_TYPE) \
V(ENUM_CACHE_TYPE) \
V(ENUM_INDICES_CACHE_TYPE) \
V(FEEDBACK_VECTOR_ENTRY_TYPE) \
V(JS_ARRAY_BOILERPLATE_TYPE) \
V(JS_OBJECT_BOILERPLATE_TYPE) \
V(NOSCRIPT_SHARED_FUNCTION_INFOS_TYPE) \
V(NUMBER_STRING_CACHE_TYPE) \
V(PROTOTYPE_USERS_TYPE) \
V(REGEXP_MULTIPLE_CACHE_TYPE) \
V(RETAINED_MAPS_TYPE) \
V(SCRIPT_LIST_TYPE) \
V(SERIALIZED_OBJECTS_TYPE) \
V(SINGLE_CHARACTER_STRING_CACHE_TYPE) \
V(STRING_SPLIT_CACHE_TYPE) \
V(WEAK_NEW_SPACE_OBJECT_TO_CODE_TYPE)
namespace v8 {
namespace internal {
class ObjectStats {
public:
static const size_t kNoOverAllocation = 0;
explicit ObjectStats(Heap* heap) : heap_(heap) { ClearObjectStats(); }
// See description on VIRTUAL_INSTANCE_TYPE_LIST.
......@@ -39,18 +57,14 @@ class ObjectStats {
#define DEFINE_VIRTUAL_INSTANCE_TYPE(type) type,
VIRTUAL_INSTANCE_TYPE_LIST(DEFINE_VIRTUAL_INSTANCE_TYPE)
#undef DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE
LAST_VIRTUAL_TYPE = JS_OBJECT_BOILERPLATE_TYPE,
LAST_VIRTUAL_TYPE = WEAK_NEW_SPACE_OBJECT_TO_CODE_TYPE,
};
// ObjectStats are kept in two arrays, counts and sizes. Related stats are
// stored in a contiguous linear buffer. Stats groups are stored one after
// another.
enum {
FIRST_CODE_KIND_SUB_TYPE = LAST_TYPE + 1,
FIRST_FIXED_ARRAY_SUB_TYPE =
FIRST_CODE_KIND_SUB_TYPE + Code::NUMBER_OF_KINDS,
FIRST_VIRTUAL_TYPE =
FIRST_FIXED_ARRAY_SUB_TYPE + LAST_FIXED_ARRAY_SUB_TYPE + 1,
FIRST_VIRTUAL_TYPE = LAST_TYPE + 1,
OBJECT_STATS_COUNT = FIRST_VIRTUAL_TYPE + LAST_VIRTUAL_TYPE + 1,
};
......@@ -61,10 +75,8 @@ class ObjectStats {
void CheckpointObjectStats();
void RecordObjectStats(InstanceType type, size_t size);
void RecordVirtualObjectStats(VirtualInstanceType type, size_t size);
void RecordCodeSubTypeStats(int code_sub_type, size_t size);
bool RecordFixedArraySubTypeStats(FixedArrayBase* array, int array_sub_type,
size_t size, size_t over_allocated);
void RecordVirtualObjectStats(VirtualInstanceType type, size_t size,
size_t over_allocated);
size_t object_count_last_gc(size_t index) {
return object_counts_last_time_[index];
......@@ -106,8 +118,6 @@ class ObjectStats {
// Detailed histograms by InstanceType.
size_t size_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets];
size_t over_allocated_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets];
std::set<FixedArrayBase*> visited_fixed_array_sub_types_;
};
class ObjectStatsCollector {
......
......@@ -6,12 +6,6 @@
const CATEGORIES = new Map([
[
'user', new Set([
'*FIXED_ARRAY_CONTEXT_SUB_TYPE',
'*FIXED_ARRAY_COPY_ON_WRITE_SUB_TYPE',
'*FIXED_ARRAY_DICTIONARY_PROPERTIES_SUB_TYPE',
'*FIXED_ARRAY_JS_COLLECTION_SUB_TYPE',
'*FIXED_ARRAY_JS_WEAK_COLLECTION_SUB_TYPE',
'*FIXED_ARRAY_PACKED_ELEMENTS_SUB_TYPE',
'CONS_ONE_BYTE_STRING_TYPE',
'CONS_STRING_TYPE',
'DESCRIPTOR_ARRAY_TYPE',
......@@ -89,20 +83,8 @@ const CATEGORIES = new Map([
'BYTE_ARRAY_TYPE',
'CELL_TYPE',
'CONTEXT_EXTENSION_TYPE',
'*FIXED_ARRAY_DEPENDENT_CODE_SUB_TYPE',
'*FIXED_ARRAY_ENUM_CACHE_SUB_TYPE',
'*FIXED_ARRAY_ENUM_INDICES_CACHE_SUB_TYPE',
'*FIXED_ARRAY_FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE',
'*FIXED_ARRAY_NUMBER_STRING_CACHE_SUB_TYPE',
'*FIXED_ARRAY_PROTOTYPE_USERS_SUB_TYPE',
'*FIXED_ARRAY_REGEXP_MULTIPLE_CACHE_SUB_TYPE',
'*FIXED_ARRAY_RETAINED_MAPS_SUB_TYPE',
'*FIXED_ARRAY_SCOPE_INFO_SUB_TYPE',
'*FIXED_ARRAY_SCRIPT_LIST_SUB_TYPE',
'*FIXED_ARRAY_SINGLE_CHARACTER_STRING_CACHE_SUB_TYPE',
'*FIXED_ARRAY_STRING_SPLIT_CACHE_SUB_TYPE',
'*FIXED_ARRAY_TEMPLATE_INFO_SUB_TYPE',
'*FIXED_ARRAY_WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE',
'ENUM_CACHE_TYPE',
'ENUM_INDICES_CACHE_TYPE',
'FOREIGN_TYPE',
'FUNCTION_TEMPLATE_INFO_TYPE',
'INTERCEPTOR_INFO_TYPE',
......@@ -117,6 +99,7 @@ const CATEGORIES = new Map([
'PROMISE_RESOLVE_THENABLE_JOB_INFO_TYPE',
'PROPERTY_CELL_TYPE',
'PROTOTYPE_INFO_TYPE',
'PROTOTYPE_USERS_TYPE',
'STACK_FRAME_INFO_TYPE',
'TRANSITION_ARRAY_TYPE',
'WEAK_CELL_TYPE'
......@@ -124,21 +107,13 @@ const CATEGORIES = new Map([
],
[
'code', new Set([
'*CODE_BUILTIN',
'*CODE_BYTECODE_HANDLER',
'*CODE_OPTIMIZED_FUNCTION',
'*CODE_REGEXP',
'*CODE_STUB',
'*FIXED_ARRAY_BYTECODE_ARRAY_CONSTANT_POOL_SUB_TYPE',
'*FIXED_ARRAY_BYTECODE_ARRAY_HANDLER_TABLE_SUB_TYPE',
'*FIXED_ARRAY_CODE_STUBS_TABLE_SUB_TYPE',
'*FIXED_ARRAY_COMPILATION_CACHE_TABLE_SUB_TYPE',
'*FIXED_ARRAY_DEOPTIMIZATION_DATA_SUB_TYPE',
'*FIXED_ARRAY_EMBEDDED_OBJECT_SUB_TYPE',
'*FIXED_ARRAY_HANDLER_TABLE_SUB_TYPE',
'*FIXED_ARRAY_NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE',
'*FIXED_ARRAY_OPTIMIZED_CODE_LITERALS_SUB_TYPE',
'*FIXED_ARRAY_SHARED_FUNCTION_INFOS_SUB_TYPE',
'BUILTIN',
'BYTECODE_HANDLER',
'OPTIMIZED_FUNCTION',
'REGEXP',
'STUB',
'BYTECODE_ARRAY_CONSTANT_POOL_TYPE',
'BYTECODE_ARRAY_HANDLER_TABLE_TYPE',
'BYTECODE_ARRAY_TYPE',
'CODE_DATA_CONTAINER_TYPE',
'FEEDBACK_VECTOR_ENTRY_TYPE',
......@@ -159,10 +134,3 @@ const CATEGORY_NAMES = new Map([
['code', 'Code'],
['unclassified', 'Unclassified'],
]);
// Instance types that are constructed from their sub types and
// should thus be hidden.
const IGNORED_INSTANCE_TYPES = new Set([
'FIXED_ARRAY_TYPE',
'CODE_TYPE',
]);
......@@ -178,7 +178,6 @@ class DetailsSelection extends HTMLElement {
for (let instance_type of this.data[this.selection.isolate]
.non_empty_instance_types) {
if (IGNORED_INSTANCE_TYPES.has(instance_type)) continue;
const category = this.categoryForType(instance_type);
categories[category].push(instance_type);
}
......
......@@ -144,62 +144,6 @@ class TraceFileReader extends HTMLElement {
}
return 0;
});
let known_count = 0;
let known_overall = 0;
let known_histogram =
Array(
data_set.instance_type_data.FIXED_ARRAY_TYPE.histogram.length)
.fill(0);
let known_over_allocated = 0;
let known_over_allocated_histogram =
Array(data_set.instance_type_data.FIXED_ARRAY_TYPE
.over_allocated_histogram.length)
.fill(0);
for (const instance_type in data_set.instance_type_data) {
if (!instance_type.startsWith('*FIXED_ARRAY')) continue;
const subtype = data_set.instance_type_data[instance_type];
known_count += subtype.count;
known_overall += subtype.count;
known_over_allocated += subtype.over_allocated;
for (let i = 0; i < subtype.histogram.length; i++) {
known_histogram[i] += subtype.histogram[i];
}
for (let i = 0; i < subtype.over_allocated_histogram.length; i++) {
known_over_allocated_histogram[i] +=
subtype.over_allocated_histogram[i];
}
}
const fixed_array_data = data_set.instance_type_data.FIXED_ARRAY_TYPE;
const unknown_entry = {
count: fixed_array_data.count - known_count,
overall: fixed_array_data.overall - known_overall,
histogram: fixed_array_data.histogram.map(
(value, index) => value - known_histogram[index]),
over_allocated:
fixed_array_data.over_allocated - known_over_allocated,
over_allocated_histogram:
fixed_array_data.over_allocated_histogram.map(
(value, index) =>
value - known_over_allocated_histogram[index])
};
// Check for non-negative values.
checkNonNegativeProperty(unknown_entry, 'count');
checkNonNegativeProperty(unknown_entry, 'overall');
checkNonNegativeProperty(unknown_entry, 'over_allocated');
for (let i = 0; i < unknown_entry.histogram.length; i++) {
checkNonNegativeProperty(unknown_entry.histogram, i);
}
for (let i = 0; i < unknown_entry.over_allocated_histogram.length;
i++) {
checkNonNegativeProperty(unknown_entry.over_allocated_histogram, i);
}
this.addInstanceTypeData(
data, keys, isolate, gc, data_set_key,
'*FIXED_ARRAY_UNKNOWN_SUB_TYPE', unknown_entry);
}
}
}
......
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