Commit a9b9c338 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Pass Truncation::Any() for memory access indices.

For 64-bit indices it's not safe to pass Truncation::Word32() for
indices, as operations will incorrectly truncate the outputs to
32-bit integers. There's also not really a point in not passing
Truncation::Any(), but it might have performance impact (since we
misuse IsUsedAsWord32 in various places).

Bug: v8:8178
Change-Id: Ie33b8e03a82e46e314dfb3f268c74c9356653aec
Reviewed-on: https://chromium-review.googlesource.com/1230653Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56006}
parent cbda8ebc
......@@ -158,10 +158,6 @@ UseInfo UseInfoForBasePointer(const ElementAccess& access) {
return access.tag() != 0 ? UseInfo::AnyTagged() : UseInfo::Word();
}
UseInfo UseInfoForIndex() {
return UseInfo(MachineType::PointerRepresentation(), Truncation::Word32());
}
void ReplaceEffectControlUses(Node* node, Node* effect, Node* control) {
for (Edge edge : node->use_edges()) {
if (NodeProperties::IsControlEdge(edge)) {
......@@ -2429,11 +2425,11 @@ class RepresentationSelector {
MachineRepresentation::kTaggedPointer);
}
case IrOpcode::kStringCharCodeAt: {
return VisitBinop(node, UseInfo::AnyTagged(), UseInfoForIndex(),
return VisitBinop(node, UseInfo::AnyTagged(), UseInfo::Word(),
MachineRepresentation::kWord32);
}
case IrOpcode::kStringCodePointAt: {
return VisitBinop(node, UseInfo::AnyTagged(), UseInfoForIndex(),
return VisitBinop(node, UseInfo::AnyTagged(), UseInfo::Word(),
MachineRepresentation::kTaggedSigned);
}
case IrOpcode::kStringFromSingleCharCode: {
......@@ -2567,7 +2563,7 @@ class RepresentationSelector {
}
case IrOpcode::kAllocate: {
ProcessInput(node, 0, UseInfoForIndex());
ProcessInput(node, 0, UseInfo::Word());
ProcessRemainingInputs(node, 1);
SetOutput(node, MachineRepresentation::kTaggedPointer);
return;
......@@ -2619,7 +2615,7 @@ class RepresentationSelector {
case IrOpcode::kLoadElement: {
if (truncation.IsUnused()) return VisitUnused(node);
ElementAccess access = ElementAccessOf(node->op());
VisitBinop(node, UseInfoForBasePointer(access), UseInfoForIndex(),
VisitBinop(node, UseInfoForBasePointer(access), UseInfo::Word(),
access.machine_type.representation());
return;
}
......@@ -2639,7 +2635,7 @@ class RepresentationSelector {
access.base_is_tagged, element_representation, access.type,
input_info->representation(), value_node);
ProcessInput(node, 0, UseInfoForBasePointer(access)); // base
ProcessInput(node, 1, UseInfoForIndex()); // index
ProcessInput(node, 1, UseInfo::Word()); // index
ProcessInput(node, 2,
TruncatingUseInfoFromRepresentation(
element_representation)); // value
......@@ -2663,7 +2659,7 @@ class RepresentationSelector {
Type value_type = TypeOf(node->InputAt(2));
ProcessInput(node, 0, UseInfo::AnyTagged()); // array
ProcessInput(node, 1, UseInfoForIndex()); // index
ProcessInput(node, 1, UseInfo::Word()); // index
if (value_type.Is(Type::SignedSmall())) {
ProcessInput(node, 2, UseInfo::TruncatingWord32()); // value
......@@ -2701,7 +2697,7 @@ class RepresentationSelector {
ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
ProcessInput(node, 1, UseInfo::AnyTagged()); // base pointer
ProcessInput(node, 2, UseInfo::Word()); // external pointer
ProcessInput(node, 3, UseInfoForIndex()); // index
ProcessInput(node, 3, UseInfo::Word()); // index
ProcessRemainingInputs(node, 4);
SetOutput(node, rep);
return;
......@@ -2711,7 +2707,7 @@ class RepresentationSelector {
MachineRepresentationFromArrayType(ExternalArrayTypeOf(node->op()));
ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
ProcessInput(node, 1, UseInfo::Word()); // external pointer
ProcessInput(node, 2, UseInfoForIndex()); // index
ProcessInput(node, 2, UseInfo::Word()); // index
ProcessInput(node, 3, UseInfo::Bool()); // little-endian
ProcessRemainingInputs(node, 4);
SetOutput(node, rep);
......@@ -2723,7 +2719,7 @@ class RepresentationSelector {
ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
ProcessInput(node, 1, UseInfo::AnyTagged()); // base pointer
ProcessInput(node, 2, UseInfo::Word()); // external pointer
ProcessInput(node, 3, UseInfoForIndex()); // index
ProcessInput(node, 3, UseInfo::Word()); // index
ProcessInput(node, 4,
TruncatingUseInfoFromRepresentation(rep)); // value
ProcessRemainingInputs(node, 5);
......@@ -2735,7 +2731,7 @@ class RepresentationSelector {
MachineRepresentationFromArrayType(ExternalArrayTypeOf(node->op()));
ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
ProcessInput(node, 1, UseInfo::Word()); // external pointer
ProcessInput(node, 2, UseInfoForIndex()); // index
ProcessInput(node, 2, UseInfo::Word()); // index
ProcessInput(node, 3,
TruncatingUseInfoFromRepresentation(rep)); // value
ProcessInput(node, 4, UseInfo::Bool()); // little-endian
......
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