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) { ...@@ -158,10 +158,6 @@ UseInfo UseInfoForBasePointer(const ElementAccess& access) {
return access.tag() != 0 ? UseInfo::AnyTagged() : UseInfo::Word(); return access.tag() != 0 ? UseInfo::AnyTagged() : UseInfo::Word();
} }
UseInfo UseInfoForIndex() {
return UseInfo(MachineType::PointerRepresentation(), Truncation::Word32());
}
void ReplaceEffectControlUses(Node* node, Node* effect, Node* control) { void ReplaceEffectControlUses(Node* node, Node* effect, Node* control) {
for (Edge edge : node->use_edges()) { for (Edge edge : node->use_edges()) {
if (NodeProperties::IsControlEdge(edge)) { if (NodeProperties::IsControlEdge(edge)) {
...@@ -2429,11 +2425,11 @@ class RepresentationSelector { ...@@ -2429,11 +2425,11 @@ class RepresentationSelector {
MachineRepresentation::kTaggedPointer); MachineRepresentation::kTaggedPointer);
} }
case IrOpcode::kStringCharCodeAt: { case IrOpcode::kStringCharCodeAt: {
return VisitBinop(node, UseInfo::AnyTagged(), UseInfoForIndex(), return VisitBinop(node, UseInfo::AnyTagged(), UseInfo::Word(),
MachineRepresentation::kWord32); MachineRepresentation::kWord32);
} }
case IrOpcode::kStringCodePointAt: { case IrOpcode::kStringCodePointAt: {
return VisitBinop(node, UseInfo::AnyTagged(), UseInfoForIndex(), return VisitBinop(node, UseInfo::AnyTagged(), UseInfo::Word(),
MachineRepresentation::kTaggedSigned); MachineRepresentation::kTaggedSigned);
} }
case IrOpcode::kStringFromSingleCharCode: { case IrOpcode::kStringFromSingleCharCode: {
...@@ -2567,7 +2563,7 @@ class RepresentationSelector { ...@@ -2567,7 +2563,7 @@ class RepresentationSelector {
} }
case IrOpcode::kAllocate: { case IrOpcode::kAllocate: {
ProcessInput(node, 0, UseInfoForIndex()); ProcessInput(node, 0, UseInfo::Word());
ProcessRemainingInputs(node, 1); ProcessRemainingInputs(node, 1);
SetOutput(node, MachineRepresentation::kTaggedPointer); SetOutput(node, MachineRepresentation::kTaggedPointer);
return; return;
...@@ -2619,7 +2615,7 @@ class RepresentationSelector { ...@@ -2619,7 +2615,7 @@ class RepresentationSelector {
case IrOpcode::kLoadElement: { case IrOpcode::kLoadElement: {
if (truncation.IsUnused()) return VisitUnused(node); if (truncation.IsUnused()) return VisitUnused(node);
ElementAccess access = ElementAccessOf(node->op()); ElementAccess access = ElementAccessOf(node->op());
VisitBinop(node, UseInfoForBasePointer(access), UseInfoForIndex(), VisitBinop(node, UseInfoForBasePointer(access), UseInfo::Word(),
access.machine_type.representation()); access.machine_type.representation());
return; return;
} }
...@@ -2639,7 +2635,7 @@ class RepresentationSelector { ...@@ -2639,7 +2635,7 @@ class RepresentationSelector {
access.base_is_tagged, element_representation, access.type, access.base_is_tagged, element_representation, access.type,
input_info->representation(), value_node); input_info->representation(), value_node);
ProcessInput(node, 0, UseInfoForBasePointer(access)); // base ProcessInput(node, 0, UseInfoForBasePointer(access)); // base
ProcessInput(node, 1, UseInfoForIndex()); // index ProcessInput(node, 1, UseInfo::Word()); // index
ProcessInput(node, 2, ProcessInput(node, 2,
TruncatingUseInfoFromRepresentation( TruncatingUseInfoFromRepresentation(
element_representation)); // value element_representation)); // value
...@@ -2663,7 +2659,7 @@ class RepresentationSelector { ...@@ -2663,7 +2659,7 @@ class RepresentationSelector {
Type value_type = TypeOf(node->InputAt(2)); Type value_type = TypeOf(node->InputAt(2));
ProcessInput(node, 0, UseInfo::AnyTagged()); // array ProcessInput(node, 0, UseInfo::AnyTagged()); // array
ProcessInput(node, 1, UseInfoForIndex()); // index ProcessInput(node, 1, UseInfo::Word()); // index
if (value_type.Is(Type::SignedSmall())) { if (value_type.Is(Type::SignedSmall())) {
ProcessInput(node, 2, UseInfo::TruncatingWord32()); // value ProcessInput(node, 2, UseInfo::TruncatingWord32()); // value
...@@ -2701,7 +2697,7 @@ class RepresentationSelector { ...@@ -2701,7 +2697,7 @@ class RepresentationSelector {
ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
ProcessInput(node, 1, UseInfo::AnyTagged()); // base pointer ProcessInput(node, 1, UseInfo::AnyTagged()); // base pointer
ProcessInput(node, 2, UseInfo::Word()); // external pointer ProcessInput(node, 2, UseInfo::Word()); // external pointer
ProcessInput(node, 3, UseInfoForIndex()); // index ProcessInput(node, 3, UseInfo::Word()); // index
ProcessRemainingInputs(node, 4); ProcessRemainingInputs(node, 4);
SetOutput(node, rep); SetOutput(node, rep);
return; return;
...@@ -2711,7 +2707,7 @@ class RepresentationSelector { ...@@ -2711,7 +2707,7 @@ class RepresentationSelector {
MachineRepresentationFromArrayType(ExternalArrayTypeOf(node->op())); MachineRepresentationFromArrayType(ExternalArrayTypeOf(node->op()));
ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
ProcessInput(node, 1, UseInfo::Word()); // external pointer 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 ProcessInput(node, 3, UseInfo::Bool()); // little-endian
ProcessRemainingInputs(node, 4); ProcessRemainingInputs(node, 4);
SetOutput(node, rep); SetOutput(node, rep);
...@@ -2723,7 +2719,7 @@ class RepresentationSelector { ...@@ -2723,7 +2719,7 @@ class RepresentationSelector {
ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
ProcessInput(node, 1, UseInfo::AnyTagged()); // base pointer ProcessInput(node, 1, UseInfo::AnyTagged()); // base pointer
ProcessInput(node, 2, UseInfo::Word()); // external pointer ProcessInput(node, 2, UseInfo::Word()); // external pointer
ProcessInput(node, 3, UseInfoForIndex()); // index ProcessInput(node, 3, UseInfo::Word()); // index
ProcessInput(node, 4, ProcessInput(node, 4,
TruncatingUseInfoFromRepresentation(rep)); // value TruncatingUseInfoFromRepresentation(rep)); // value
ProcessRemainingInputs(node, 5); ProcessRemainingInputs(node, 5);
...@@ -2735,7 +2731,7 @@ class RepresentationSelector { ...@@ -2735,7 +2731,7 @@ class RepresentationSelector {
MachineRepresentationFromArrayType(ExternalArrayTypeOf(node->op())); MachineRepresentationFromArrayType(ExternalArrayTypeOf(node->op()));
ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
ProcessInput(node, 1, UseInfo::Word()); // external pointer ProcessInput(node, 1, UseInfo::Word()); // external pointer
ProcessInput(node, 2, UseInfoForIndex()); // index ProcessInput(node, 2, UseInfo::Word()); // index
ProcessInput(node, 3, ProcessInput(node, 3,
TruncatingUseInfoFromRepresentation(rep)); // value TruncatingUseInfoFromRepresentation(rep)); // value
ProcessInput(node, 4, UseInfo::Bool()); // little-endian 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