Commit cb989656 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[heap] Fix elements / properties backing store accounting.

Avoid divide by zero for empty elements backing stores, and generally
don't account for empty_property_array / empty_fixed_array.

Bug: v8:7266
Change-Id: I5d1c5f43165810f7ec3bcebf3caf1bc737b46e59
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1559865
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60724}
parent 0b1e9ef2
...@@ -553,13 +553,13 @@ void ObjectStatsCollectorImpl::RecordVirtualJSObjectDetails(JSObject object) { ...@@ -553,13 +553,13 @@ void ObjectStatsCollectorImpl::RecordVirtualJSObjectDetails(JSObject object) {
// Properties. // Properties.
if (object->HasFastProperties()) { if (object->HasFastProperties()) {
PropertyArray properties = object->property_array(); PropertyArray properties = object->property_array();
size_t over_allocated = ObjectStats::kNoOverAllocation;
if (properties != ReadOnlyRoots(heap_).empty_property_array()) { if (properties != ReadOnlyRoots(heap_).empty_property_array()) {
over_allocated += object->map()->UnusedPropertyFields() * kTaggedSize; size_t over_allocated =
object->map()->UnusedPropertyFields() * kTaggedSize;
RecordVirtualObjectStats(object, properties,
ObjectStats::OBJECT_PROPERTY_ARRAY_TYPE,
properties->Size(), over_allocated);
} }
RecordVirtualObjectStats(object, properties,
ObjectStats::OBJECT_PROPERTY_ARRAY_TYPE,
properties->Size(), over_allocated);
} else { } else {
NameDictionary properties = object->property_dictionary(); NameDictionary properties = object->property_dictionary();
RecordHashTableVirtualObjectStats( RecordHashTableVirtualObjectStats(
...@@ -574,12 +574,15 @@ void ObjectStatsCollectorImpl::RecordVirtualJSObjectDetails(JSObject object) { ...@@ -574,12 +574,15 @@ void ObjectStatsCollectorImpl::RecordVirtualJSObjectDetails(JSObject object) {
object->IsJSArray() ? ObjectStats::ARRAY_DICTIONARY_ELEMENTS_TYPE object->IsJSArray() ? ObjectStats::ARRAY_DICTIONARY_ELEMENTS_TYPE
: ObjectStats::OBJECT_DICTIONARY_ELEMENTS_TYPE); : ObjectStats::OBJECT_DICTIONARY_ELEMENTS_TYPE);
} else if (object->IsJSArray()) { } else if (object->IsJSArray()) {
size_t element_size = if (elements != ReadOnlyRoots(heap_).empty_fixed_array()) {
(elements->Size() - FixedArrayBase::kHeaderSize) / elements->length(); size_t element_size =
uint32_t length = JSArray::cast(object)->length()->Number(); (elements->Size() - FixedArrayBase::kHeaderSize) / elements->length();
size_t over_allocated = (elements->length() - length) * element_size; uint32_t length = JSArray::cast(object)->length()->Number();
RecordVirtualObjectStats(object, elements, ObjectStats::ARRAY_ELEMENTS_TYPE, size_t over_allocated = (elements->length() - length) * element_size;
elements->Size(), over_allocated); RecordVirtualObjectStats(object, elements,
ObjectStats::ARRAY_ELEMENTS_TYPE,
elements->Size(), over_allocated);
}
} else { } else {
RecordSimpleVirtualObjectStats(object, elements, RecordSimpleVirtualObjectStats(object, elements,
ObjectStats::OBJECT_ELEMENTS_TYPE); ObjectStats::OBJECT_ELEMENTS_TYPE);
......
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