Commit 331ce91c authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Serialize only the relevant property descriptor

Bug: v8:7790
Change-Id: Ib729393c38ca064bf3af141674ab5f697872a1b8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1613991Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61571}
parent 30bcdcab
...@@ -347,13 +347,12 @@ PropertyAccessInfo AccessInfoFactory::ComputeDataFieldAccessInfo( ...@@ -347,13 +347,12 @@ PropertyAccessInfo AccessInfoFactory::ComputeDataFieldAccessInfo(
MachineType::RepCompressedTagged(); MachineType::RepCompressedTagged();
MaybeHandle<Map> field_map; MaybeHandle<Map> field_map;
MapRef map_ref(broker(), map); MapRef map_ref(broker(), map);
map_ref.SerializeOwnDescriptors(); // TODO(neis): Remove later.
ZoneVector<CompilationDependencies::Dependency const*> ZoneVector<CompilationDependencies::Dependency const*>
unrecorded_dependencies(zone()); unrecorded_dependencies(zone());
if (details_representation.IsSmi()) { if (details_representation.IsSmi()) {
field_type = Type::SignedSmall(); field_type = Type::SignedSmall();
field_representation = MachineType::RepCompressedTaggedSigned(); field_representation = MachineType::RepCompressedTaggedSigned();
map_ref.SerializeOwnDescriptors(); // TODO(neis): Remove later. map_ref.SerializeOwnDescriptor(descriptor);
unrecorded_dependencies.push_back( unrecorded_dependencies.push_back(
dependencies()->FieldRepresentationDependencyOffTheRecord(map_ref, dependencies()->FieldRepresentationDependencyOffTheRecord(map_ref,
descriptor)); descriptor));
...@@ -375,7 +374,7 @@ PropertyAccessInfo AccessInfoFactory::ComputeDataFieldAccessInfo( ...@@ -375,7 +374,7 @@ PropertyAccessInfo AccessInfoFactory::ComputeDataFieldAccessInfo(
// The field type was cleared by the GC, so we don't know anything // The field type was cleared by the GC, so we don't know anything
// about the contents now. // about the contents now.
} }
map_ref.SerializeOwnDescriptors(); // TODO(neis): Remove later. map_ref.SerializeOwnDescriptor(descriptor);
unrecorded_dependencies.push_back( unrecorded_dependencies.push_back(
dependencies()->FieldRepresentationDependencyOffTheRecord(map_ref, dependencies()->FieldRepresentationDependencyOffTheRecord(map_ref,
descriptor)); descriptor));
...@@ -388,7 +387,7 @@ PropertyAccessInfo AccessInfoFactory::ComputeDataFieldAccessInfo( ...@@ -388,7 +387,7 @@ PropertyAccessInfo AccessInfoFactory::ComputeDataFieldAccessInfo(
field_map = MaybeHandle<Map>(map); field_map = MaybeHandle<Map>(map);
} }
} }
map_ref.SerializeOwnDescriptors(); // TODO(neis): Remove later. map_ref.SerializeOwnDescriptor(descriptor);
PropertyConstness constness = PropertyConstness constness =
dependencies()->DependOnFieldConstness(map_ref, descriptor); dependencies()->DependOnFieldConstness(map_ref, descriptor);
switch (constness) { switch (constness) {
...@@ -779,7 +778,7 @@ PropertyAccessInfo AccessInfoFactory::LookupTransition( ...@@ -779,7 +778,7 @@ PropertyAccessInfo AccessInfoFactory::LookupTransition(
if (details_representation.IsSmi()) { if (details_representation.IsSmi()) {
field_type = Type::SignedSmall(); field_type = Type::SignedSmall();
field_representation = MachineType::RepCompressedTaggedSigned(); field_representation = MachineType::RepCompressedTaggedSigned();
transition_map_ref.SerializeOwnDescriptors(); // TODO(neis): Remove later. transition_map_ref.SerializeOwnDescriptor(number);
unrecorded_dependencies.push_back( unrecorded_dependencies.push_back(
dependencies()->FieldRepresentationDependencyOffTheRecord( dependencies()->FieldRepresentationDependencyOffTheRecord(
transition_map_ref, number)); transition_map_ref, number));
...@@ -797,7 +796,7 @@ PropertyAccessInfo AccessInfoFactory::LookupTransition( ...@@ -797,7 +796,7 @@ PropertyAccessInfo AccessInfoFactory::LookupTransition(
// Store is not safe if the field type was cleared. // Store is not safe if the field type was cleared.
return PropertyAccessInfo::Invalid(zone()); return PropertyAccessInfo::Invalid(zone());
} }
transition_map_ref.SerializeOwnDescriptors(); // TODO(neis): Remove later. transition_map_ref.SerializeOwnDescriptor(number);
unrecorded_dependencies.push_back( unrecorded_dependencies.push_back(
dependencies()->FieldRepresentationDependencyOffTheRecord( dependencies()->FieldRepresentationDependencyOffTheRecord(
transition_map_ref, number)); transition_map_ref, number));
......
...@@ -854,11 +854,11 @@ class MapData : public HeapObjectData { ...@@ -854,11 +854,11 @@ class MapData : public HeapObjectData {
return elements_kind_generalizations_; return elements_kind_generalizations_;
} }
// Serialize the own part of the descriptor array and, recursively, that of // Serialize a single (or all) own slot(s) of the descriptor array and recurse
// any field owner. // on field owner(s).
void SerializeOwnDescriptor(JSHeapBroker* broker, int descriptor_index);
void SerializeOwnDescriptors(JSHeapBroker* broker); void SerializeOwnDescriptors(JSHeapBroker* broker);
DescriptorArrayData* instance_descriptors() const { DescriptorArrayData* instance_descriptors() const {
CHECK(serialized_own_descriptors_);
return instance_descriptors_; return instance_descriptors_;
} }
...@@ -1102,10 +1102,10 @@ class DescriptorArrayData : public HeapObjectData { ...@@ -1102,10 +1102,10 @@ class DescriptorArrayData : public HeapObjectData {
Handle<DescriptorArray> object) Handle<DescriptorArray> object)
: HeapObjectData(broker, storage, object), contents_(broker->zone()) {} : HeapObjectData(broker, storage, object), contents_(broker->zone()) {}
ZoneVector<PropertyDescriptor>& contents() { return contents_; } ZoneMap<int, PropertyDescriptor>& contents() { return contents_; }
private: private:
ZoneVector<PropertyDescriptor> contents_; ZoneMap<int, PropertyDescriptor> contents_;
}; };
class FeedbackCellData : public HeapObjectData { class FeedbackCellData : public HeapObjectData {
...@@ -1683,52 +1683,55 @@ void MapData::SerializeOwnDescriptors(JSHeapBroker* broker) { ...@@ -1683,52 +1683,55 @@ void MapData::SerializeOwnDescriptors(JSHeapBroker* broker) {
TraceScope tracer(broker, this, "MapData::SerializeOwnDescriptors"); TraceScope tracer(broker, this, "MapData::SerializeOwnDescriptors");
Handle<Map> map = Handle<Map>::cast(object()); Handle<Map> map = Handle<Map>::cast(object());
DCHECK_NULL(instance_descriptors_);
instance_descriptors_ =
broker->GetOrCreateData(map->instance_descriptors())->AsDescriptorArray();
int const number_of_own = map->NumberOfOwnDescriptors(); int const number_of_own = map->NumberOfOwnDescriptors();
ZoneVector<PropertyDescriptor>& contents = instance_descriptors_->contents(); for (int i = 0; i < number_of_own; ++i) {
int const current_size = static_cast<int>(contents.size()); SerializeOwnDescriptor(broker, i);
if (number_of_own <= current_size) return; }
}
void MapData::SerializeOwnDescriptor(JSHeapBroker* broker,
int descriptor_index) {
TraceScope tracer(broker, this, "MapData::SerializeOwnDescriptor");
Handle<Map> map = Handle<Map>::cast(object());
if (instance_descriptors_ == nullptr) {
instance_descriptors_ = broker->GetOrCreateData(map->instance_descriptors())
->AsDescriptorArray();
}
ZoneMap<int, PropertyDescriptor>& contents =
instance_descriptors_->contents();
CHECK_LT(descriptor_index, map->NumberOfOwnDescriptors());
if (contents.find(descriptor_index) != contents.end()) return;
Isolate* const isolate = broker->isolate(); Isolate* const isolate = broker->isolate();
auto descriptors = auto descriptors =
Handle<DescriptorArray>::cast(instance_descriptors_->object()); Handle<DescriptorArray>::cast(instance_descriptors_->object());
CHECK_EQ(*descriptors, map->instance_descriptors()); CHECK_EQ(*descriptors, map->instance_descriptors());
contents.reserve(number_of_own);
PropertyDescriptor d;
// Copy the new descriptors. d.key =
for (int i = current_size; i < number_of_own; ++i) { broker->GetOrCreateData(descriptors->GetKey(descriptor_index))->AsName();
PropertyDescriptor d; d.details = descriptors->GetDetails(descriptor_index);
d.key = broker->GetOrCreateData(descriptors->GetKey(i))->AsName(); if (d.details.location() == kField) {
d.details = descriptors->GetDetails(i); d.field_index = FieldIndex::ForDescriptor(*map, descriptor_index);
if (d.details.location() == kField) { d.field_owner =
d.field_index = FieldIndex::ForDescriptor(*map, i); broker->GetOrCreateData(map->FindFieldOwner(isolate, descriptor_index))
d.field_owner = ->AsMap();
broker->GetOrCreateData(map->FindFieldOwner(isolate, i))->AsMap(); d.field_type =
d.field_type = broker->GetOrCreateData(descriptors->GetFieldType(i)); broker->GetOrCreateData(descriptors->GetFieldType(descriptor_index));
d.is_unboxed_double_field = map->IsUnboxedDoubleField(d.field_index); d.is_unboxed_double_field = map->IsUnboxedDoubleField(d.field_index);
// Recurse. }
} contents[descriptor_index] = d;
contents.push_back(d);
} if (d.details.location() == kField) {
CHECK_EQ(number_of_own, contents.size()); // Recurse on the owner map.
d.field_owner->SerializeOwnDescriptor(broker, descriptor_index);
// Recurse on the new owner maps.
for (int i = current_size; i < number_of_own; ++i) {
const PropertyDescriptor& d = contents[i];
if (d.details.location() == kField) {
CHECK_LE(
Handle<Map>::cast(d.field_owner->object())->NumberOfOwnDescriptors(),
number_of_own);
d.field_owner->SerializeOwnDescriptors(broker);
}
} }
TRACE(broker, "Copied " << number_of_own - current_size TRACE(broker, "Copied descriptor " << descriptor_index << " into "
<< " descriptors into " << instance_descriptors_ << instance_descriptors_ << " ("
<< " (" << number_of_own << " total)"); << contents.size() << " total)");
} }
void JSObjectData::SerializeRecursive(JSHeapBroker* broker, int depth) { void JSObjectData::SerializeRecursive(JSHeapBroker* broker, int depth) {
...@@ -3161,6 +3164,12 @@ void MapRef::SerializeOwnDescriptors() { ...@@ -3161,6 +3164,12 @@ void MapRef::SerializeOwnDescriptors() {
data()->AsMap()->SerializeOwnDescriptors(broker()); data()->AsMap()->SerializeOwnDescriptors(broker());
} }
void MapRef::SerializeOwnDescriptor(int descriptor_index) {
if (broker()->mode() == JSHeapBroker::kDisabled) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
data()->AsMap()->SerializeOwnDescriptor(broker(), descriptor_index);
}
void MapRef::SerializeBackPointer() { void MapRef::SerializeBackPointer() {
if (broker()->mode() == JSHeapBroker::kDisabled) return; if (broker()->mode() == JSHeapBroker::kDisabled) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing); CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
......
...@@ -528,6 +528,7 @@ class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef { ...@@ -528,6 +528,7 @@ class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef {
// Concerning the underlying instance_descriptors: // Concerning the underlying instance_descriptors:
void SerializeOwnDescriptors(); void SerializeOwnDescriptors();
void SerializeOwnDescriptor(int descriptor_index);
MapRef FindFieldOwner(int descriptor_index) const; MapRef FindFieldOwner(int descriptor_index) const;
PropertyDetails GetPropertyDetails(int descriptor_index) const; PropertyDetails GetPropertyDetails(int descriptor_index) const;
NameRef GetPropertyKey(int descriptor_index) const; NameRef GetPropertyKey(int descriptor_index) const;
......
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