Commit d938c108 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by V8 LUCI CQ

[compiler] Remove part of DescriptorArrayData serialization

Some of the fields come from MapRef calls and we have to still serialize
them while Map is bg-serialized. An alternative would be to move them to
MapData but that comes with a cost since different maps with the same
descriptor array wouldn't share said data.

Bug: v8:7790
Change-Id: I25d8eaf7b0a8bf7de0f21272cc6f86cc172b8b08
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3008640
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75936}
parent fb0a2ea2
...@@ -921,12 +921,8 @@ class BigIntData : public HeapObjectData { ...@@ -921,12 +921,8 @@ class BigIntData : public HeapObjectData {
}; };
struct PropertyDescriptor { struct PropertyDescriptor {
ObjectData* key = nullptr;
ObjectData* value = nullptr;
PropertyDetails details = PropertyDetails::Empty();
FieldIndex field_index; FieldIndex field_index;
ObjectData* field_owner = nullptr; ObjectData* field_owner = nullptr;
ObjectData* field_type = nullptr;
}; };
class MapData : public HeapObjectData { class MapData : public HeapObjectData {
...@@ -1385,32 +1381,26 @@ class DescriptorArrayData : public HeapObjectData { ...@@ -1385,32 +1381,26 @@ class DescriptorArrayData : public HeapObjectData {
Handle<DescriptorArray> object) Handle<DescriptorArray> object)
: HeapObjectData(broker, storage, object), contents_(broker->zone()) { : HeapObjectData(broker, storage, object), contents_(broker->zone()) {
DCHECK(!broker->is_concurrent_inlining()); DCHECK(!broker->is_concurrent_inlining());
} // TODO(solanes, v8:7790): If Map moves to never serialized, the
// DescriptorArray can become never ever serialized. Alternatively, if
// bg-serialization is enabled for the default config we can also move
// DescriptorArray to never ever serialized.
STATIC_ASSERT(ref_traits<Map>::ref_serialization_kind ==
RefSerializationKind::kBackgroundSerialized);
}
// TODO(solanes, v8:7790): If we move FieldOwner and FieldIndex to MapData, we
// can make DescriptorArray never ever serialized but at the cost of different
// maps with the same descriptor not benefiting from having said same
// descriptor.
ObjectData* FindFieldOwner(InternalIndex descriptor_index) const { ObjectData* FindFieldOwner(InternalIndex descriptor_index) const {
return contents_.at(descriptor_index.as_int()).field_owner; return contents_.at(descriptor_index.as_int()).field_owner;
} }
PropertyDetails GetPropertyDetails(InternalIndex descriptor_index) const {
return contents_.at(descriptor_index.as_int()).details;
}
ObjectData* GetPropertyKey(InternalIndex descriptor_index) const {
return contents_.at(descriptor_index.as_int()).key;
}
FieldIndex GetFieldIndexFor(InternalIndex descriptor_index) const { FieldIndex GetFieldIndexFor(InternalIndex descriptor_index) const {
return contents_.at(descriptor_index.as_int()).field_index; return contents_.at(descriptor_index.as_int()).field_index;
} }
ObjectData* GetFieldType(InternalIndex descriptor_index) const {
return contents_.at(descriptor_index.as_int()).field_type;
}
ObjectData* GetStrongValue(InternalIndex descriptor_index) const {
return contents_.at(descriptor_index.as_int()).value;
}
bool serialized_descriptor(InternalIndex descriptor_index) const { bool serialized_descriptor(InternalIndex descriptor_index) const {
return contents_.find(descriptor_index.as_int()) != contents_.end(); return contents_.find(descriptor_index.as_int()) != contents_.end();
} }
...@@ -1435,23 +1425,16 @@ void DescriptorArrayData::SerializeDescriptor(JSHeapBroker* broker, ...@@ -1435,23 +1425,16 @@ void DescriptorArrayData::SerializeDescriptor(JSHeapBroker* broker,
CHECK_EQ(*descriptors, map->instance_descriptors(isolate)); CHECK_EQ(*descriptors, map->instance_descriptors(isolate));
PropertyDescriptor d; PropertyDescriptor d;
d.key = broker->GetOrCreateData(descriptors->GetKey(descriptor_index)); const bool is_field =
MaybeObject value = descriptors->GetValue(descriptor_index); descriptors->GetDetails(descriptor_index).location() == kField;
HeapObject obj; if (is_field) {
if (value.GetHeapObjectIfStrong(&obj)) {
d.value = broker->GetOrCreateData(obj);
}
d.details = descriptors->GetDetails(descriptor_index);
if (d.details.location() == kField) {
d.field_index = FieldIndex::ForDescriptor(*map, descriptor_index); d.field_index = FieldIndex::ForDescriptor(*map, descriptor_index);
d.field_owner = d.field_owner =
broker->GetOrCreateData(map->FindFieldOwner(isolate, descriptor_index)); broker->GetOrCreateData(map->FindFieldOwner(isolate, descriptor_index));
d.field_type =
broker->GetOrCreateData(descriptors->GetFieldType(descriptor_index));
} }
contents_[descriptor_index.as_int()] = d; contents_[descriptor_index.as_int()] = d;
if (d.details.location() == kField && !d.field_owner->should_access_heap()) { if (is_field && !d.field_owner->should_access_heap()) {
// Recurse on the owner map. // Recurse on the owner map.
d.field_owner->AsMap()->SerializeOwnDescriptor(broker, descriptor_index, d.field_owner->AsMap()->SerializeOwnDescriptor(broker, descriptor_index,
tag); tag);
...@@ -3632,35 +3615,24 @@ int FixedArrayBaseRef::length() const { ...@@ -3632,35 +3615,24 @@ int FixedArrayBaseRef::length() const {
PropertyDetails DescriptorArrayRef::GetPropertyDetails( PropertyDetails DescriptorArrayRef::GetPropertyDetails(
InternalIndex descriptor_index) const { InternalIndex descriptor_index) const {
if (data_->should_access_heap()) {
return object()->GetDetails(descriptor_index); return object()->GetDetails(descriptor_index);
}
return data()->AsDescriptorArray()->GetPropertyDetails(descriptor_index);
} }
NameRef DescriptorArrayRef::GetPropertyKey( NameRef DescriptorArrayRef::GetPropertyKey(
InternalIndex descriptor_index) const { InternalIndex descriptor_index) const {
if (data_->should_access_heap()) {
NameRef result = MakeRef(broker(), object()->GetKey(descriptor_index)); NameRef result = MakeRef(broker(), object()->GetKey(descriptor_index));
CHECK(result.IsUniqueName()); CHECK(result.IsUniqueName());
return result; return result;
}
return NameRef(broker(),
data()->AsDescriptorArray()->GetPropertyKey(descriptor_index));
} }
ObjectRef DescriptorArrayRef::GetFieldType( ObjectRef DescriptorArrayRef::GetFieldType(
InternalIndex descriptor_index) const { InternalIndex descriptor_index) const {
if (data_->should_access_heap()) { return MakeRef(broker(),
return MakeRef<Object>(broker(), object()->GetFieldType(descriptor_index)); Object::cast(object()->GetFieldType(descriptor_index)));
}
return ObjectRef(broker(),
data()->AsDescriptorArray()->GetFieldType(descriptor_index));
} }
base::Optional<ObjectRef> DescriptorArrayRef::GetStrongValue( base::Optional<ObjectRef> DescriptorArrayRef::GetStrongValue(
InternalIndex descriptor_index) const { InternalIndex descriptor_index) const {
if (data_->should_access_heap()) {
HeapObject heap_object; HeapObject heap_object;
if (!object() if (!object()
->GetValue(descriptor_index) ->GetValue(descriptor_index)
...@@ -3671,11 +3643,6 @@ base::Optional<ObjectRef> DescriptorArrayRef::GetStrongValue( ...@@ -3671,11 +3643,6 @@ base::Optional<ObjectRef> DescriptorArrayRef::GetStrongValue(
// via DescriptorArray::Replace, we might get a value that we haven't seen // via DescriptorArray::Replace, we might get a value that we haven't seen
// before. // before.
return TryMakeRef(broker(), heap_object); return TryMakeRef(broker(), heap_object);
}
ObjectData* value =
data()->AsDescriptorArray()->GetStrongValue(descriptor_index);
if (!value) return base::nullopt;
return ObjectRef(broker(), value);
} }
base::Optional<SharedFunctionInfoRef> FeedbackCellRef::shared_function_info() base::Optional<SharedFunctionInfoRef> FeedbackCellRef::shared_function_info()
......
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