Commit e1ec054c authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Try updating maps early on.

Then the various methods that take receiver maps don't need to
worry about deprecated maps.

Change-Id: I09c53939275b1af19d54430bfecb23809a4257c2
Reviewed-on: https://chromium-review.googlesource.com/c/1458243Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59496}
parent c6dc8be7
...@@ -290,21 +290,18 @@ bool AccessInfoFactory::ComputeElementAccessInfos( ...@@ -290,21 +290,18 @@ bool AccessInfoFactory::ComputeElementAccessInfos(
MapHandles possible_transition_targets; MapHandles possible_transition_targets;
possible_transition_targets.reserve(maps.size()); possible_transition_targets.reserve(maps.size());
for (Handle<Map> map : maps) { for (Handle<Map> map : maps) {
if (Map::TryUpdate(isolate(), map).ToHandle(&map)) {
if (CanInlineElementAccess(map) && if (CanInlineElementAccess(map) &&
IsFastElementsKind(map->elements_kind()) && IsFastElementsKind(map->elements_kind()) &&
GetInitialFastElementsKind() != map->elements_kind()) { GetInitialFastElementsKind() != map->elements_kind()) {
possible_transition_targets.push_back(map); possible_transition_targets.push_back(map);
} }
} }
}
// Separate the actual receiver maps and the possible transition sources. // Separate the actual receiver maps and the possible transition sources.
MapHandles receiver_maps; MapHandles receiver_maps;
receiver_maps.reserve(maps.size()); receiver_maps.reserve(maps.size());
std::vector<std::pair<Handle<Map>, Handle<Map>>> transitions(maps.size()); std::vector<std::pair<Handle<Map>, Handle<Map>>> transitions(maps.size());
for (Handle<Map> map : maps) { for (Handle<Map> map : maps) {
if (Map::TryUpdate(isolate(), map).ToHandle(&map)) {
// Don't generate elements kind transitions from stable maps. // Don't generate elements kind transitions from stable maps.
Map transition_target = map->is_stable() Map transition_target = map->is_stable()
? Map() ? Map()
...@@ -317,7 +314,6 @@ bool AccessInfoFactory::ComputeElementAccessInfos( ...@@ -317,7 +314,6 @@ bool AccessInfoFactory::ComputeElementAccessInfos(
std::make_pair(map, handle(transition_target, isolate()))); std::make_pair(map, handle(transition_target, isolate())));
} }
} }
}
for (Handle<Map> receiver_map : receiver_maps) { for (Handle<Map> receiver_map : receiver_maps) {
// Compute the element access information. // Compute the element access information.
...@@ -572,14 +568,12 @@ bool AccessInfoFactory::ComputePropertyAccessInfos( ...@@ -572,14 +568,12 @@ bool AccessInfoFactory::ComputePropertyAccessInfos(
ZoneVector<PropertyAccessInfo> infos(zone()); ZoneVector<PropertyAccessInfo> infos(zone());
infos.reserve(maps.size()); infos.reserve(maps.size());
for (Handle<Map> map : maps) { for (Handle<Map> map : maps) {
if (Map::TryUpdate(isolate(), map).ToHandle(&map)) {
PropertyAccessInfo access_info; PropertyAccessInfo access_info;
if (!ComputePropertyAccessInfo(map, name, access_mode, &access_info)) { if (!ComputePropertyAccessInfo(map, name, access_mode, &access_info)) {
return false; return false;
} }
infos.push_back(access_info); infos.push_back(access_info);
} }
}
// Merge as many as possible and push into {access_infos}. // Merge as many as possible and push into {access_infos}.
for (auto it = infos.begin(), end = infos.end(); it != end; ++it) { for (auto it = infos.begin(), end = infos.end(); it != end; ++it) {
......
...@@ -3128,6 +3128,19 @@ bool JSNativeContextSpecialization::CanTreatHoleAsUndefined( ...@@ -3128,6 +3128,19 @@ bool JSNativeContextSpecialization::CanTreatHoleAsUndefined(
return true; return true;
} }
namespace {
void TryUpdateThenDropDeprecated(Isolate* isolate, MapHandles* maps) {
for (auto it = maps->begin(); it != maps->end();) {
if (Map::TryUpdate(isolate, *it).ToHandle(&*it)) {
DCHECK(!(*it)->is_deprecated());
++it;
} else {
it = maps->erase(it);
}
}
}
} // namespace
bool JSNativeContextSpecialization::ExtractReceiverMaps( bool JSNativeContextSpecialization::ExtractReceiverMaps(
Node* receiver, Node* effect, FeedbackNexus const& nexus, Node* receiver, Node* effect, FeedbackNexus const& nexus,
MapHandles* receiver_maps) { MapHandles* receiver_maps) {
...@@ -3142,7 +3155,7 @@ bool JSNativeContextSpecialization::ExtractReceiverMaps( ...@@ -3142,7 +3155,7 @@ bool JSNativeContextSpecialization::ExtractReceiverMaps(
bool use_inference = bool use_inference =
!IsKeyedStoreICKind(kind) && !IsStoreInArrayLiteralICKind(kind); !IsKeyedStoreICKind(kind) && !IsStoreInArrayLiteralICKind(kind);
if (use_inference && InferReceiverMaps(receiver, effect, receiver_maps)) { if (use_inference && InferReceiverMaps(receiver, effect, receiver_maps)) {
// We can assume that {receiver} still has the inferred {receiver_maps}. TryUpdateThenDropDeprecated(isolate(), receiver_maps);
return true; return true;
} }
} }
...@@ -3162,6 +3175,7 @@ bool JSNativeContextSpecialization::ExtractReceiverMaps( ...@@ -3162,6 +3175,7 @@ bool JSNativeContextSpecialization::ExtractReceiverMaps(
}), }),
receiver_maps->end()); receiver_maps->end());
} }
TryUpdateThenDropDeprecated(isolate(), receiver_maps);
return true; return true;
} }
......
...@@ -208,9 +208,6 @@ class V8_EXPORT_PRIVATE JSNativeContextSpecialization final ...@@ -208,9 +208,6 @@ class V8_EXPORT_PRIVATE JSNativeContextSpecialization final
MapHandles* receiver_maps); MapHandles* receiver_maps);
// Try to infer maps for the given {receiver} at the current {effect}. // Try to infer maps for the given {receiver} at the current {effect}.
// If maps are returned then you can be sure that the {receiver} definitely
// has one of the returned maps at this point in the program (identified
// by {effect}).
bool InferReceiverMaps(Node* receiver, Node* effect, bool InferReceiverMaps(Node* receiver, Node* effect,
MapHandles* receiver_maps); MapHandles* receiver_maps);
// Try to infer a root map for the {receiver} independent of the current // Try to infer a root map for the {receiver} independent of the current
......
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