Commit d4381010 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[object-stats] Improve FixedArray classification

IsFixedArray is too broad in many cases and should be replaced by
IsFixedArrayExact in the objects stats collection.

Bug: v8:7266
Change-Id: I3d5de8b70dc596a391ffdc2a5b4bdeaa5d437712
Reviewed-on: https://chromium-review.googlesource.com/948502Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51739}
parent 9a97d975
...@@ -277,7 +277,7 @@ ObjectStatsCollectorImpl::ObjectStatsCollectorImpl(Heap* heap, ...@@ -277,7 +277,7 @@ ObjectStatsCollectorImpl::ObjectStatsCollectorImpl(Heap* heap,
bool ObjectStatsCollectorImpl::ShouldRecordObject(HeapObject* obj, bool ObjectStatsCollectorImpl::ShouldRecordObject(HeapObject* obj,
CowMode check_cow_array) { CowMode check_cow_array) {
if (obj->IsFixedArray()) { if (obj->IsFixedArrayExact()) {
FixedArray* fixed_array = FixedArray::cast(obj); FixedArray* fixed_array = FixedArray::cast(obj);
bool cow_check = check_cow_array == kIgnoreCow || !IsCowArray(fixed_array); bool cow_check = check_cow_array == kIgnoreCow || !IsCowArray(fixed_array);
return CanRecordFixedArray(fixed_array) && cow_check; return CanRecordFixedArray(fixed_array) && cow_check;
...@@ -480,7 +480,7 @@ void ObjectStatsCollectorImpl::RecordVirtualFeedbackVectorDetails( ...@@ -480,7 +480,7 @@ void ObjectStatsCollectorImpl::RecordVirtualFeedbackVectorDetails(
Object* raw_object = vector->get(slot.ToInt() + i); Object* raw_object = vector->get(slot.ToInt() + i);
if (!raw_object->IsHeapObject()) continue; if (!raw_object->IsHeapObject()) continue;
HeapObject* object = HeapObject::cast(raw_object); HeapObject* object = HeapObject::cast(raw_object);
if (object->IsCell() || object->IsFixedArray()) { if (object->IsCell() || object->IsFixedArrayExact()) {
RecordSimpleVirtualObjectStats( RecordSimpleVirtualObjectStats(
vector, object, ObjectStats::FEEDBACK_VECTOR_ENTRY_TYPE); vector, object, ObjectStats::FEEDBACK_VECTOR_ENTRY_TYPE);
} }
...@@ -531,7 +531,7 @@ void ObjectStatsCollectorImpl::CollectStatistics(HeapObject* obj, Phase phase) { ...@@ -531,7 +531,7 @@ void ObjectStatsCollectorImpl::CollectStatistics(HeapObject* obj, Phase phase) {
RecordVirtualContext(Context::cast(obj)); RecordVirtualContext(Context::cast(obj));
} else if (obj->IsScript()) { } else if (obj->IsScript()) {
RecordVirtualScriptDetails(Script::cast(obj)); RecordVirtualScriptDetails(Script::cast(obj));
} else if (obj->IsFixedArray()) { } else if (obj->IsFixedArrayExact()) {
// Has to go last as it triggers too eagerly. // Has to go last as it triggers too eagerly.
RecordVirtualFixedArrayDetails(FixedArray::cast(obj)); RecordVirtualFixedArrayDetails(FixedArray::cast(obj));
} }
...@@ -702,7 +702,7 @@ namespace { ...@@ -702,7 +702,7 @@ namespace {
bool MatchesConstantElementsPair(Object* object) { bool MatchesConstantElementsPair(Object* object) {
if (!object->IsTuple2()) return false; if (!object->IsTuple2()) return false;
Tuple2* tuple = Tuple2::cast(object); Tuple2* tuple = Tuple2::cast(object);
return tuple->value1()->IsSmi() && tuple->value2()->IsFixedArray(); return tuple->value1()->IsSmi() && tuple->value2()->IsFixedArrayExact();
} }
} // namespace } // namespace
...@@ -711,20 +711,19 @@ void ObjectStatsCollectorImpl:: ...@@ -711,20 +711,19 @@ void ObjectStatsCollectorImpl::
RecordVirtualObjectsForConstantPoolOrEmbeddedObjects( RecordVirtualObjectsForConstantPoolOrEmbeddedObjects(
HeapObject* parent, HeapObject* object, HeapObject* parent, HeapObject* object,
ObjectStats::VirtualInstanceType type) { ObjectStats::VirtualInstanceType type) {
if (RecordSimpleVirtualObjectStats(parent, object, type)) { if (!RecordSimpleVirtualObjectStats(parent, object, type)) return;
if (object->IsFixedArray()) { if (object->IsFixedArrayExact()) {
FixedArray* array = FixedArray::cast(object); FixedArray* array = FixedArray::cast(object);
for (int i = 0; i < array->length(); i++) { for (int i = 0; i < array->length(); i++) {
Object* entry = array->get(i); Object* entry = array->get(i);
if (!entry->IsHeapObject()) continue; if (!entry->IsHeapObject()) continue;
RecordVirtualObjectsForConstantPoolOrEmbeddedObjects(
array, HeapObject::cast(entry), type);
}
} else if (MatchesConstantElementsPair(object)) {
Tuple2* tuple = Tuple2::cast(object);
RecordVirtualObjectsForConstantPoolOrEmbeddedObjects( RecordVirtualObjectsForConstantPoolOrEmbeddedObjects(
tuple, HeapObject::cast(tuple->value2()), type); array, HeapObject::cast(entry), type);
} }
} else if (MatchesConstantElementsPair(object)) {
Tuple2* tuple = Tuple2::cast(object);
RecordVirtualObjectsForConstantPoolOrEmbeddedObjects(
tuple, HeapObject::cast(tuple->value2()), type);
} }
} }
...@@ -738,7 +737,7 @@ void ObjectStatsCollectorImpl::RecordVirtualBytecodeArrayDetails( ...@@ -738,7 +737,7 @@ void ObjectStatsCollectorImpl::RecordVirtualBytecodeArrayDetails(
FixedArray* constant_pool = FixedArray::cast(bytecode->constant_pool()); FixedArray* constant_pool = FixedArray::cast(bytecode->constant_pool());
for (int i = 0; i < constant_pool->length(); i++) { for (int i = 0; i < constant_pool->length(); i++) {
Object* entry = constant_pool->get(i); Object* entry = constant_pool->get(i);
if (entry->IsFixedArray() || MatchesConstantElementsPair(entry)) { if (entry->IsFixedArrayExact() || MatchesConstantElementsPair(entry)) {
RecordVirtualObjectsForConstantPoolOrEmbeddedObjects( RecordVirtualObjectsForConstantPoolOrEmbeddedObjects(
constant_pool, HeapObject::cast(entry), constant_pool, HeapObject::cast(entry),
ObjectStats::EMBEDDED_OBJECT_TYPE); ObjectStats::EMBEDDED_OBJECT_TYPE);
...@@ -786,7 +785,7 @@ void ObjectStatsCollectorImpl::RecordVirtualCodeDetails(Code* code) { ...@@ -786,7 +785,7 @@ void ObjectStatsCollectorImpl::RecordVirtualCodeDetails(Code* code) {
RelocInfo::Mode mode = it.rinfo()->rmode(); RelocInfo::Mode mode = it.rinfo()->rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) { if (mode == RelocInfo::EMBEDDED_OBJECT) {
Object* target = it.rinfo()->target_object(); Object* target = it.rinfo()->target_object();
if (target->IsFixedArray() || MatchesConstantElementsPair(target)) { if (target->IsFixedArrayExact() || MatchesConstantElementsPair(target)) {
RecordVirtualObjectsForConstantPoolOrEmbeddedObjects( RecordVirtualObjectsForConstantPoolOrEmbeddedObjects(
code, HeapObject::cast(target), ObjectStats::EMBEDDED_OBJECT_TYPE); code, HeapObject::cast(target), ObjectStats::EMBEDDED_OBJECT_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