[object-stats] Better accounting

- Add WASM types
- Account for FeedbackMetadata
- Account entries in FunctionTemplateInfo

Bug: v8:7266
Change-Id: I527792768bb11a3540a34e7c00db311609a40b01
Reviewed-on: https://chromium-review.googlesource.com/894524
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50977}
This commit is contained in:
Michael Lippautz 2018-01-31 09:01:52 +01:00 committed by Commit Bot
parent 268531b375
commit 768c41c879
3 changed files with 42 additions and 14 deletions

View File

@ -214,9 +214,12 @@ class ObjectStatsCollectorImpl {
kIgnoreCow,
};
Isolate* isolate() { return heap_->isolate(); }
bool RecordVirtualObjectStats(HeapObject* parent, HeapObject* obj,
ObjectStats::VirtualInstanceType type,
size_t size, size_t over_allocated);
size_t size, size_t over_allocated,
CowMode check_cow_array = kCheckCow);
// Gets size from |ob| and assumes no over allocating.
bool RecordSimpleVirtualObjectStats(HeapObject* parent, HeapObject* obj,
ObjectStats::VirtualInstanceType type);
@ -249,6 +252,7 @@ class ObjectStatsCollectorImpl {
void RecordVirtualContext(Context* context);
void RecordVirtualFeedbackVectorDetails(FeedbackVector* vector);
void RecordVirtualFixedArrayDetails(FixedArray* array);
void RecordVirtualFunctionTemplateInfoDetails(FunctionTemplateInfo* fti);
void RecordVirtualJSGlobalObjectDetails(JSGlobalObject* object);
void RecordVirtualJSCollectionDetails(JSObject* object);
void RecordVirtualJSObjectDetails(JSObject* object);
@ -293,13 +297,13 @@ bool ObjectStatsCollectorImpl::RecordSimpleVirtualObjectStats(
HeapObject* parent, HeapObject* obj,
ObjectStats::VirtualInstanceType type) {
return RecordVirtualObjectStats(parent, obj, type, obj->Size(),
ObjectStats::kNoOverAllocation);
ObjectStats::kNoOverAllocation, kCheckCow);
}
bool ObjectStatsCollectorImpl::RecordVirtualObjectStats(
HeapObject* parent, HeapObject* obj, ObjectStats::VirtualInstanceType type,
size_t size, size_t over_allocated) {
if (!SameLiveness(parent, obj) || !ShouldRecordObject(obj, kCheckCow))
size_t size, size_t over_allocated, CowMode check_cow_array) {
if (!SameLiveness(parent, obj) || !ShouldRecordObject(obj, check_cow_array))
return false;
if (virtual_objects_.find(obj) == virtual_objects_.end()) {
@ -339,6 +343,22 @@ void ObjectStatsCollectorImpl::RecordVirtualAllocationSiteDetails(
ObjectStats::BOILERPLATE_ELEMENTS_TYPE);
}
void ObjectStatsCollectorImpl::RecordVirtualFunctionTemplateInfoDetails(
FunctionTemplateInfo* fti) {
// named_property_handler and indexed_property_handler are recorded as
// INTERCEPTOR_INFO_TYPE.
if (!fti->call_code()->IsUndefined(isolate())) {
RecordSimpleVirtualObjectStats(
fti, CallHandlerInfo::cast(fti->call_code()),
ObjectStats::FUNCTION_TEMPLATE_INFO_ENTRIES_TYPE);
}
if (!fti->instance_call_handler()->IsUndefined(isolate())) {
RecordSimpleVirtualObjectStats(
fti, CallHandlerInfo::cast(fti->instance_call_handler()),
ObjectStats::FUNCTION_TEMPLATE_INFO_ENTRIES_TYPE);
}
}
void ObjectStatsCollectorImpl::RecordVirtualJSGlobalObjectDetails(
JSGlobalObject* object) {
// Properties.
@ -400,16 +420,9 @@ void ObjectStatsCollectorImpl::RecordVirtualFeedbackVectorDetails(
void ObjectStatsCollectorImpl::RecordVirtualFixedArrayDetails(
FixedArray* array) {
if (IsCowArray(array)) {
// Manually check and dispatch to lower level recording due to COW array
// check. No need for SameLiveness as we call it on a single object.
if (!ShouldRecordObject(array, kIgnoreCow)) return;
if (virtual_objects_.find(array) == virtual_objects_.end()) {
virtual_objects_.insert(array);
stats_->RecordVirtualObjectStats(ObjectStats::COW_ARRAY_TYPE,
array->Size(),
ObjectStats::kNoOverAllocation);
}
RecordVirtualObjectStats(nullptr, array, ObjectStats::COW_ARRAY_TYPE,
array->Size(), ObjectStats::kNoOverAllocation,
kIgnoreCow);
}
}
@ -425,6 +438,9 @@ void ObjectStatsCollectorImpl::CollectStatistics(HeapObject* obj, Phase phase) {
RecordVirtualBytecodeArrayDetails(BytecodeArray::cast(obj));
} else if (obj->IsCode()) {
RecordVirtualCodeDetails(Code::cast(obj));
} else if (obj->IsFunctionTemplateInfo()) {
RecordVirtualFunctionTemplateInfoDetails(
FunctionTemplateInfo::cast(obj));
} else if (obj->IsJSGlobalObject()) {
RecordVirtualJSGlobalObjectDetails(JSGlobalObject::cast(obj));
} else if (obj->IsJSObject()) {
@ -571,6 +587,10 @@ void ObjectStatsCollectorImpl::RecordVirtualSharedFunctionInfoDetails(
// SharedFunctonInfo::feedback_metadata() is a COW array.
RecordSimpleVirtualObjectStats(info, info->scope_info(),
ObjectStats::SCOPE_INFO_TYPE);
FeedbackMetadata* fm = FeedbackMetadata::cast(info->feedback_metadata());
RecordVirtualObjectStats(info, fm, ObjectStats::FEEDBACK_METADATA_TYPE,
fm->Size(), ObjectStats::kNoOverAllocation,
kIgnoreCow);
}
namespace {

View File

@ -29,8 +29,10 @@
V(EMBEDDED_OBJECT_TYPE) \
V(ENUM_CACHE_TYPE) \
V(ENUM_INDICES_CACHE_TYPE) \
V(FEEDBACK_METADATA_TYPE) \
V(FEEDBACK_VECTOR_ENTRY_TYPE) \
V(FUNCTION_CONTEXT_TYPE) \
V(FUNCTION_TEMPLATE_INFO_ENTRIES_TYPE) \
V(GLOBAL_ELEMENTS_TYPE) \
V(GLOBAL_PROPERTIES_TYPE) \
V(JS_ARRAY_BOILERPLATE_TYPE) \

View File

@ -56,6 +56,7 @@ const CATEGORIES = new Map([
'JS_SET_TYPE',
'JS_SET_VALUE_ITERATOR_TYPE',
'JS_STRING_ITERATOR_TYPE',
'JS_TO_WASM_FUNCTION',
'JS_TYPED_ARRAY_TYPE',
'JS_VALUE_TYPE',
'JS_WEAK_MAP_TYPE',
@ -75,6 +76,9 @@ const CATEGORIES = new Map([
'SYMBOL_TYPE',
'THIN_ONE_BYTE_STRING_TYPE',
'THIN_STRING_TYPE',
'WASM_INSTANCE_TYPE',
'WASM_MEMORY_TYPE',
'WASM_MODULE_TYPE',
])
],
[
@ -94,6 +98,7 @@ const CATEGORIES = new Map([
'ENUM_CACHE_TYPE',
'ENUM_INDICES_CACHE_TYPE',
'FOREIGN_TYPE',
'FUNCTION_TEMPLATE_INFO_ENTRIES_TYPE',
'FUNCTION_TEMPLATE_INFO_TYPE',
'INTERCEPTOR_INFO_TYPE',
'JS_API_OBJECT_TYPE',
@ -138,6 +143,7 @@ const CATEGORIES = new Map([
'CODE_DATA_CONTAINER_TYPE',
'DEOPTIMIZATION_DATA_TYPE',
'EMBEDDED_OBJECT_TYPE',
'FEEDBACK_METADATA_TYPE',
'FEEDBACK_VECTOR_ENTRY_TYPE',
'FEEDBACK_VECTOR_TYPE',
'LOAD_HANDLER_TYPE',