Commit 9766a896 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[ptr-cmpr] Allow tagged values in Word32Equal

Since we use Word32Equal with a (truncating) ReinterpretCast for pointer
compressed TaggedEqual, we also have to allow it in the machine
verifier.

Change-Id: Ic16af837f03ebc51dde5bdc7f0c574b2aaf11909
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1771784
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63410}
parent eeb0df63
......@@ -100,7 +100,8 @@ Node* GraphAssembler::IntPtrEqual(Node* left, Node* right) {
Node* GraphAssembler::TaggedEqual(Node* left, Node* right) {
if (machine()->Is64() && COMPRESS_POINTERS_BOOL) {
return Word32Equal(TruncateInt64ToInt32(left), TruncateInt64ToInt32(right));
// Allow implicit truncation.
return Word32Equal(left, right);
}
return WordEqual(left, right);
}
......
......@@ -232,6 +232,10 @@ class MachineRepresentationInferrer {
case IrOpcode::kWord64PoisonOnSpeculation:
representation_vector_[node->id()] = MachineRepresentation::kWord64;
break;
case IrOpcode::kCompressedHeapConstant:
representation_vector_[node->id()] =
MachineRepresentation::kCompressedPointer;
break;
case IrOpcode::kExternalConstant:
representation_vector_[node->id()] =
MachineType::PointerRepresentation();
......@@ -516,8 +520,15 @@ class MachineRepresentationChecker {
node, 1, inferrer_->GetRepresentation(node->InputAt(0)));
}
} else {
CheckValueIsCompressedOrInt32(node, 0);
CheckValueIsCompressedOrInt32(node, 1);
if (COMPRESS_POINTERS_BOOL) {
// We explicitly allow 64-bit tagged values into Word32Equal,
// for truncating tagged pointer comparison.
CheckValueIsCompressedOrTaggedOrInt32(node, 0);
CheckValueIsCompressedOrTaggedOrInt32(node, 0);
} else {
CheckValueIsCompressedOrInt32(node, 0);
CheckValueIsCompressedOrInt32(node, 1);
}
}
break;
......@@ -771,11 +782,6 @@ class MachineRepresentationChecker {
case MachineRepresentation::kCompressedPointer:
case MachineRepresentation::kCompressedSigned:
return;
case MachineRepresentation::kNone:
if (input->opcode() == IrOpcode::kCompressedHeapConstant) {
return;
}
break;
default:
break;
}
......@@ -878,17 +884,6 @@ class MachineRepresentationChecker {
case MachineRepresentation::kCompressedSigned:
case MachineRepresentation::kCompressedPointer:
return;
case MachineRepresentation::kNone: {
if (input->opcode() == IrOpcode::kCompressedHeapConstant) {
return;
}
std::ostringstream str;
str << "TypeError: node #" << input->id() << ":" << *input->op()
<< " is untyped.";
PrintDebugHelp(str, node);
FATAL("%s", str.str().c_str());
break;
}
default:
break;
}
......@@ -901,6 +896,34 @@ class MachineRepresentationChecker {
FATAL("%s", str.str().c_str());
}
void CheckValueIsCompressedOrTaggedOrInt32(Node const* node, int index) {
Node const* input = node->InputAt(index);
switch (inferrer_->GetRepresentation(input)) {
case MachineRepresentation::kBit:
case MachineRepresentation::kWord8:
case MachineRepresentation::kWord16:
case MachineRepresentation::kWord32:
return;
case MachineRepresentation::kTagged:
case MachineRepresentation::kTaggedPointer:
case MachineRepresentation::kTaggedSigned:
return;
case MachineRepresentation::kCompressed:
case MachineRepresentation::kCompressedSigned:
case MachineRepresentation::kCompressedPointer:
return;
default:
break;
}
std::ostringstream str;
str << "TypeError: node #" << node->id() << ":" << *node->op()
<< " uses node #" << input->id() << ":" << *input->op()
<< " which doesn't have a compressed, tagged, or int32-compatible "
"representation.";
PrintDebugHelp(str, node);
FATAL("%s", str.str().c_str());
}
void CheckValueInputForInt64Op(Node const* node, int index) {
Node const* input = node->InputAt(index);
MachineRepresentation input_representation =
......
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