Commit 042c5a79 authored by Georg Neis's avatar Georg Neis Committed by V8 LUCI CQ

[compiler] Simplify MapRef

We can now tighten the return type of FindRootMap and remove some
related code.

Bug: v8:7790
Change-Id: I08325e7e4f4c9261c45770f7674b6644cc5c2b80
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3123411Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76564}
parent ae8d4844
......@@ -765,10 +765,6 @@ class MapData : public HeapObjectData {
return is_abandoned_prototype_map_;
}
// Extra information.
void SerializeRootMap(JSHeapBroker* broker, NotConcurrentInliningTag tag);
ObjectData* FindRootMap() const;
void SerializeConstructor(JSHeapBroker* broker, NotConcurrentInliningTag tag);
ObjectData* GetConstructor() const {
CHECK(serialized_constructor_);
......@@ -796,8 +792,7 @@ class MapData : public HeapObjectData {
bool has_extra_serialized_data() const {
return serialized_constructor_ || serialized_backpointer_ ||
serialized_prototype_ || serialized_root_map_ ||
serialized_for_element_store_;
serialized_prototype_ || serialized_for_element_store_;
}
private:
......@@ -837,9 +832,6 @@ class MapData : public HeapObjectData {
bool serialized_prototype_ = false;
ObjectData* prototype_ = nullptr;
bool serialized_root_map_ = false;
ObjectData* root_map_ = nullptr;
bool serialized_for_element_store_ = false;
};
......@@ -1452,19 +1444,6 @@ bool MapData::TrySerializePrototype(JSHeapBroker* broker,
return true;
}
void MapData::SerializeRootMap(JSHeapBroker* broker,
NotConcurrentInliningTag tag) {
if (serialized_root_map_) return;
serialized_root_map_ = true;
TraceScope tracer(broker, this, "MapData::SerializeRootMap");
Handle<Map> map = Handle<Map>::cast(object());
DCHECK_NULL(root_map_);
root_map_ = broker->GetOrCreateData(map->FindRootMap(broker->isolate()));
}
ObjectData* MapData::FindRootMap() const { return root_map_; }
bool JSObjectData::SerializeAsBoilerplateRecursive(JSHeapBroker* broker,
NotConcurrentInliningTag tag,
int max_depth) {
......@@ -2412,27 +2391,11 @@ base::Optional<HeapObjectRef> MapRef::prototype() const {
return HeapObjectRef(broker(), prototype_data);
}
void MapRef::SerializeRootMap(NotConcurrentInliningTag tag) {
if (data_->should_access_heap()) return;
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
data()->AsMap()->SerializeRootMap(broker(), tag);
}
// TODO(solanes, v8:7790): Remove base::Optional from the return type when
// deleting serialization.
base::Optional<MapRef> MapRef::FindRootMap() const {
if (data_->should_access_heap() || broker()->is_concurrent_inlining()) {
// TODO(solanes): Change TryMakeRef to MakeRef when Map is moved to
// kNeverSerialized.
// TODO(solanes, v8:7790): Consider caching the result of the root map.
return TryMakeRef(broker(), object()->FindRootMap(broker()->isolate()));
}
ObjectData* map_data = data()->AsMap()->FindRootMap();
if (map_data != nullptr) {
return MapRef(broker(), map_data);
}
TRACE_BROKER_MISSING(broker(), "root map for object " << *this);
return base::nullopt;
MapRef MapRef::FindRootMap() const {
DCHECK(data_->should_access_heap() || broker()->is_concurrent_inlining());
// TODO(solanes, v8:7790): Consider caching the result of the root map.
return MakeRefAssumeMemoryFence(broker(),
object()->FindRootMap(broker()->isolate()));
}
bool JSTypedArrayRef::is_on_heap() const {
......
......@@ -630,11 +630,6 @@ class FeedbackCellRef : public HeapObjectRef {
Handle<FeedbackCell> object() const;
base::Optional<SharedFunctionInfoRef> shared_function_info() const;
// TODO(mvstanton): Once we allow inlining of functions we didn't see
// during serialization, we do need to ensure that any feedback vector
// we read here has been fully initialized (ie, store-ordered into the
// cell).
base::Optional<FeedbackVectorRef> value() const;
};
......@@ -754,6 +749,7 @@ class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef {
ZoneVector<MapRef>* prototype_maps);
// Concerning the underlying instance_descriptors:
DescriptorArrayRef instance_descriptors() const;
MapRef FindFieldOwner(InternalIndex descriptor_index) const;
PropertyDetails GetPropertyDetails(InternalIndex descriptor_index) const;
NameRef GetPropertyKey(InternalIndex descriptor_index) const;
......@@ -762,11 +758,7 @@ class V8_EXPORT_PRIVATE MapRef : public HeapObjectRef {
base::Optional<ObjectRef> GetStrongValue(
InternalIndex descriptor_number) const;
DescriptorArrayRef instance_descriptors() const;
void SerializeRootMap(NotConcurrentInliningTag tag);
base::Optional<MapRef> FindRootMap() const;
MapRef FindRootMap() const;
ObjectRef GetConstructor() const;
};
......
......@@ -864,10 +864,6 @@ ElementAccessFeedback const& JSHeapBroker::ProcessFeedbackMapsForElementAccess(
MapHandles possible_transition_targets;
possible_transition_targets.reserve(maps.size());
for (MapRef& map : maps) {
if (!is_concurrent_inlining()) {
map.SerializeRootMap(NotConcurrentInliningTag{this});
}
if (map.CanInlineElementAccess() &&
IsFastElementsKind(map.elements_kind()) &&
GetInitialFastElementsKind() != map.elements_kind()) {
......
......@@ -1635,8 +1635,7 @@ void JSNativeContextSpecialization::RemoveImpossibleMaps(
maps->erase(std::remove_if(maps->begin(), maps->end(),
[root_map](const MapRef& map) {
return map.is_abandoned_prototype_map() ||
(map.FindRootMap().has_value() &&
!map.FindRootMap()->equals(*root_map));
!map.FindRootMap().equals(*root_map);
}),
maps->end());
}
......@@ -3451,10 +3450,7 @@ base::Optional<MapRef> JSNativeContextSpecialization::InferRootMap(
base::Optional<MapRef> initial_map =
NodeProperties::GetJSCreateMap(broker(), object);
if (initial_map.has_value()) {
if (!initial_map->FindRootMap().has_value()) {
return base::nullopt;
}
DCHECK(initial_map->equals(*initial_map->FindRootMap()));
DCHECK(initial_map->equals(initial_map->FindRootMap()));
return *initial_map;
}
}
......
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