Commit 344db1ab authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Restrict a keyed access optimization to unique names.

Restrict the special handling of constant keys in ReduceKeyedAccess
to unique names. This eliminates two hurdles for concurrent optimization,
namely the need for ToName conversion and for string internalization.

Bug: v8:7790
Change-Id: Ifa2ff6ab1d5f3da1d27cca4dae3567733564801c
Reviewed-on: https://chromium-review.googlesource.com/c/1409168Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58779}
parent 78f0d327
......@@ -1802,21 +1802,13 @@ Reduction JSNativeContextSpecialization::ReduceKeyedAccess(
// Optimize access for constant {index}.
HeapObjectMatcher mindex(index);
if (mindex.HasValue() && mindex.Value()->IsPrimitive()) {
// Keyed access requires a ToPropertyKey on the {index} first before
// looking up the property on the object (see ES6 section 12.3.2.1).
// We can only do this for non-observable ToPropertyKey invocations,
// so we limit the constant indices to primitives at this point.
Handle<Name> name;
if (Object::ToName(isolate(), mindex.Value()).ToHandle(&name)) {
uint32_t array_index;
if (name->AsArrayIndex(&array_index)) {
// Use the constant array index.
index = jsgraph()->Constant(static_cast<double>(array_index));
} else {
name = factory()->InternalizeName(name); // TODO(neis): Do up-front.
return ReduceNamedAccess(node, value, receiver_maps, name, access_mode);
}
if (mindex.HasValue() && mindex.Value()->IsUniqueName()) {
auto name = Handle<Name>::cast(mindex.Value());
uint32_t array_index;
if (name->AsArrayIndex(&array_index)) {
index = jsgraph()->Constant(static_cast<double>(array_index));
} else {
return ReduceNamedAccess(node, value, receiver_maps, name, access_mode);
}
}
......
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