Commit 7b10b36f authored by Mythri A's avatar Mythri A Committed by Commit Bot

[map] In FindElementsKindTransitionedMap only check for required element kinds

FindElementsKindTransitionedMap checks if we could transition from
the source map to one of the target maps without requiring any instance
rewriting. It does this by replaying all the property transitions of the
source map on each elements kind map and seeing if it needs a instance
rewrite. Since we already know the elements kind of the target maps, we can
avoid doing this for element kinds that are not in target map.

Change-Id: Ief9ba89992a411535a0335c3b67221666647f55e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1624208Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61741}
parent 1f0543af
...@@ -1215,6 +1215,15 @@ static bool ContainsMap(MapHandles const& maps, Map map) { ...@@ -1215,6 +1215,15 @@ static bool ContainsMap(MapHandles const& maps, Map map) {
return false; return false;
} }
static bool HasElementsKind(MapHandles const& maps,
ElementsKind elements_kind) {
for (Handle<Map> current : maps) {
if (!current.is_null() && current->elements_kind() == elements_kind)
return true;
}
return false;
}
Map Map::FindElementsKindTransitionedMap(Isolate* isolate, Map Map::FindElementsKindTransitionedMap(Isolate* isolate,
MapHandles const& candidates) { MapHandles const& candidates) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
...@@ -1238,6 +1247,9 @@ Map Map::FindElementsKindTransitionedMap(Isolate* isolate, ...@@ -1238,6 +1247,9 @@ Map Map::FindElementsKindTransitionedMap(Isolate* isolate,
for (root_map = root_map->ElementsTransitionMap(); for (root_map = root_map->ElementsTransitionMap();
!root_map.is_null() && root_map->has_fast_elements(); !root_map.is_null() && root_map->has_fast_elements();
root_map = root_map->ElementsTransitionMap()) { root_map = root_map->ElementsTransitionMap()) {
// If root_map's elements kind doesn't match any of the elements kind in
// the candidates there is no need to do any additional work.
if (!HasElementsKind(candidates, root_map->elements_kind())) continue;
Map current = root_map->TryReplayPropertyTransitions(isolate, *this); Map current = root_map->TryReplayPropertyTransitions(isolate, *this);
if (current.is_null()) continue; if (current.is_null()) continue;
if (InstancesNeedRewriting(current)) continue; if (InstancesNeedRewriting(current)) continue;
......
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