summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/compiler/test-representation-change.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/compiler/test-representation-change.cc')
-rw-r--r--deps/v8/test/cctest/compiler/test-representation-change.cc98
1 files changed, 69 insertions, 29 deletions
diff --git a/deps/v8/test/cctest/compiler/test-representation-change.cc b/deps/v8/test/cctest/compiler/test-representation-change.cc
index c334ecb383..f4218467f7 100644
--- a/deps/v8/test/cctest/compiler/test-representation-change.cc
+++ b/deps/v8/test/cctest/compiler/test-representation-change.cc
@@ -71,7 +71,7 @@ class RepresentationChangerTester : public HandleAndZoneScope,
CHECK_FLOAT_EQ(expected, fval);
}
- void CheckHeapConstant(Node* n, HeapObject* expected) {
+ void CheckHeapConstant(Node* n, HeapObject expected) {
HeapObjectMatcher m(n);
CHECK(m.HasValue());
CHECK_EQ(expected, *m.Value());
@@ -204,6 +204,15 @@ TEST(ToFloat64_constant) {
UseInfo(MachineRepresentation::kFloat64, Truncation::None()));
r.CheckFloat64Constant(c, i);
}
+
+ {
+ Node* n = r.jsgraph()->Constant(0);
+ Node* use = r.Return(n);
+ Node* c = r.changer()->GetRepresentationFor(
+ n, MachineRepresentation::kWord64, Type::Range(0, 0, r.zone()), use,
+ UseInfo(MachineRepresentation::kFloat64, Truncation::None()));
+ r.CheckFloat64Constant(c, 0);
+ }
}
@@ -280,7 +289,7 @@ TEST(ToInt64_constant) {
Node* n = r.jsgraph()->Constant(*i);
Node* use = r.Return(n);
Node* c = r.changer()->GetRepresentationFor(
- n, MachineRepresentation::kTagged, TypeCache::Get().kSafeInteger, use,
+ n, MachineRepresentation::kTagged, TypeCache::Get()->kSafeInteger, use,
UseInfo(MachineRepresentation::kWord64, Truncation::None()));
r.CheckInt64Constant(c, *i);
}
@@ -299,7 +308,8 @@ static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
CHECK_EQ(expected, c->opcode());
CHECK_EQ(n, c->InputAt(0));
- if (expected == IrOpcode::kCheckedFloat64ToInt32) {
+ if (expected == IrOpcode::kCheckedFloat64ToInt32 ||
+ expected == IrOpcode::kCheckedFloat64ToInt64) {
CheckForMinusZeroMode mode =
from_type.Maybe(Type::MinusZero())
? use_info.minus_zero_check()
@@ -316,13 +326,13 @@ static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
static void CheckTwoChanges(IrOpcode::Value expected2,
IrOpcode::Value expected1,
MachineRepresentation from, Type from_type,
- MachineRepresentation to) {
+ MachineRepresentation to, UseInfo use_info) {
RepresentationChangerTester r;
Node* n = r.Parameter();
Node* use = r.Return(n);
- Node* c1 = r.changer()->GetRepresentationFor(n, from, from_type, use,
- UseInfo(to, Truncation::None()));
+ Node* c1 =
+ r.changer()->GetRepresentationFor(n, from, from_type, use, use_info);
CHECK_NE(c1, n);
CHECK_EQ(expected1, c1->opcode());
@@ -332,6 +342,14 @@ static void CheckTwoChanges(IrOpcode::Value expected2,
CHECK_EQ(n, c2->InputAt(0));
}
+static void CheckTwoChanges(IrOpcode::Value expected2,
+ IrOpcode::Value expected1,
+ MachineRepresentation from, Type from_type,
+ MachineRepresentation to) {
+ CheckTwoChanges(expected2, expected1, from, from_type, to,
+ UseInfo(to, Truncation::None()));
+}
+
static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
Type from_type, MachineRepresentation to,
UseInfo use_info) {
@@ -349,13 +367,13 @@ static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
TEST(Word64) {
CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord8,
- TypeCache::Get().kInt8, MachineRepresentation::kWord64);
+ TypeCache::Get()->kInt8, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord8,
- TypeCache::Get().kUint8, MachineRepresentation::kWord64);
+ TypeCache::Get()->kUint8, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord16,
- TypeCache::Get().kInt16, MachineRepresentation::kWord64);
+ TypeCache::Get()->kInt16, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord16,
- TypeCache::Get().kUint16, MachineRepresentation::kWord64);
+ TypeCache::Get()->kUint16, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeInt32ToInt64, MachineRepresentation::kWord32,
Type::Signed32(), MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeUint32ToUint64, MachineRepresentation::kWord32,
@@ -366,15 +384,15 @@ TEST(Word64) {
CheckChange(IrOpcode::kTruncateInt64ToInt32, MachineRepresentation::kWord64,
Type::Unsigned32(), MachineRepresentation::kWord32);
CheckChange(IrOpcode::kTruncateInt64ToInt32, MachineRepresentation::kWord64,
- TypeCache::Get().kSafeInteger, MachineRepresentation::kWord32,
+ TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord32,
UseInfo::TruncatingWord32());
CheckChange(
IrOpcode::kCheckedInt64ToInt32, MachineRepresentation::kWord64,
- TypeCache::Get().kSafeInteger, MachineRepresentation::kWord32,
+ TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord32,
UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair()));
CheckChange(
IrOpcode::kCheckedUint64ToInt32, MachineRepresentation::kWord64,
- TypeCache::Get().kPositiveSafeInteger, MachineRepresentation::kWord32,
+ TypeCache::Get()->kPositiveSafeInteger, MachineRepresentation::kWord32,
UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair()));
CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64,
@@ -382,18 +400,22 @@ TEST(Word64) {
CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64,
Type::Unsigned32(), MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64,
- TypeCache::Get().kSafeInteger, MachineRepresentation::kWord64);
+ TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeFloat64ToInt64, MachineRepresentation::kFloat64,
- TypeCache::Get().kInt64, MachineRepresentation::kWord64);
+ TypeCache::Get()->kInt64, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeFloat64ToUint64, MachineRepresentation::kFloat64,
- TypeCache::Get().kUint64, MachineRepresentation::kWord64);
+ TypeCache::Get()->kUint64, MachineRepresentation::kWord64);
+ CheckChange(
+ IrOpcode::kCheckedFloat64ToInt64, MachineRepresentation::kFloat64,
+ Type::Number(), MachineRepresentation::kWord64,
+ UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, VectorSlotPair()));
CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64,
Type::Signed32(), MachineRepresentation::kFloat64);
CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64,
Type::Unsigned32(), MachineRepresentation::kFloat64);
CheckChange(IrOpcode::kChangeInt64ToFloat64, MachineRepresentation::kWord64,
- TypeCache::Get().kSafeInteger, MachineRepresentation::kFloat64);
+ TypeCache::Get()->kSafeInteger, MachineRepresentation::kFloat64);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
IrOpcode::kChangeFloat64ToInt64,
@@ -405,12 +427,17 @@ TEST(Word64) {
MachineRepresentation::kWord64);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
IrOpcode::kChangeFloat64ToInt64,
- MachineRepresentation::kFloat32, TypeCache::Get().kInt64,
+ MachineRepresentation::kFloat32, TypeCache::Get()->kInt64,
MachineRepresentation::kWord64);
CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
IrOpcode::kChangeFloat64ToUint64,
- MachineRepresentation::kFloat32, TypeCache::Get().kUint64,
+ MachineRepresentation::kFloat32, TypeCache::Get()->kUint64,
MachineRepresentation::kWord64);
+ CheckTwoChanges(
+ IrOpcode::kChangeFloat32ToFloat64, IrOpcode::kCheckedFloat64ToInt64,
+ MachineRepresentation::kFloat32, Type::Number(),
+ MachineRepresentation::kWord64,
+ UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, VectorSlotPair()));
CheckTwoChanges(IrOpcode::kChangeInt64ToFloat64,
IrOpcode::kTruncateFloat64ToFloat32,
@@ -422,12 +449,20 @@ TEST(Word64) {
CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged,
Type::Unsigned32(), MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged,
- TypeCache::Get().kSafeInteger, MachineRepresentation::kWord64);
+ TypeCache::Get()->kSafeInteger, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeTaggedToInt64, MachineRepresentation::kTagged,
- TypeCache::Get().kInt64, MachineRepresentation::kWord64);
+ TypeCache::Get()->kInt64, MachineRepresentation::kWord64);
CheckChange(IrOpcode::kChangeTaggedSignedToInt64,
MachineRepresentation::kTaggedSigned, Type::SignedSmall(),
MachineRepresentation::kWord64);
+ CheckChange(
+ IrOpcode::kCheckedTaggedToInt64, MachineRepresentation::kTagged,
+ Type::Number(), MachineRepresentation::kWord64,
+ UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, VectorSlotPair()));
+ CheckChange(
+ IrOpcode::kCheckedTaggedToInt64, MachineRepresentation::kTaggedPointer,
+ Type::Number(), MachineRepresentation::kWord64,
+ UseInfo::CheckedSigned64AsWord64(kIdentifyZeros, VectorSlotPair()));
CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32,
IrOpcode::kChangeInt31ToTaggedSigned,
@@ -442,9 +477,9 @@ TEST(Word64) {
MachineRepresentation::kWord64, Type::Unsigned32(),
MachineRepresentation::kTagged);
CheckChange(IrOpcode::kChangeInt64ToTagged, MachineRepresentation::kWord64,
- TypeCache::Get().kSafeInteger, MachineRepresentation::kTagged);
+ TypeCache::Get()->kSafeInteger, MachineRepresentation::kTagged);
CheckChange(IrOpcode::kChangeUint64ToTagged, MachineRepresentation::kWord64,
- TypeCache::Get().kPositiveSafeInteger,
+ TypeCache::Get()->kPositiveSafeInteger,
MachineRepresentation::kTagged);
CheckTwoChanges(IrOpcode::kTruncateInt64ToInt32,
@@ -458,19 +493,19 @@ TEST(Word64) {
MachineRepresentation::kTaggedSigned);
}
CheckChange(IrOpcode::kCheckedInt64ToTaggedSigned,
- MachineRepresentation::kWord64, TypeCache::Get().kSafeInteger,
+ MachineRepresentation::kWord64, TypeCache::Get()->kSafeInteger,
MachineRepresentation::kTaggedSigned,
UseInfo::CheckedSignedSmallAsTaggedSigned(VectorSlotPair()));
CheckChange(IrOpcode::kCheckedUint64ToTaggedSigned,
MachineRepresentation::kWord64,
- TypeCache::Get().kPositiveSafeInteger,
+ TypeCache::Get()->kPositiveSafeInteger,
MachineRepresentation::kTaggedSigned,
UseInfo::CheckedSignedSmallAsTaggedSigned(VectorSlotPair()));
- CheckTwoChanges(IrOpcode::kChangeInt64ToFloat64,
- IrOpcode::kChangeFloat64ToTaggedPointer,
- MachineRepresentation::kWord64, TypeCache::Get().kSafeInteger,
- MachineRepresentation::kTaggedPointer);
+ CheckTwoChanges(
+ IrOpcode::kChangeInt64ToFloat64, IrOpcode::kChangeFloat64ToTaggedPointer,
+ MachineRepresentation::kWord64, TypeCache::Get()->kSafeInteger,
+ MachineRepresentation::kTaggedPointer);
}
TEST(SingleChanges) {
@@ -589,6 +624,11 @@ TEST(SignednessInWord32) {
IrOpcode::kTruncateFloat64ToWord32,
MachineRepresentation::kFloat32, Type::Number(),
MachineRepresentation::kWord32);
+
+ CheckChange(
+ IrOpcode::kCheckedUint32ToInt32, MachineRepresentation::kWord32,
+ Type::Unsigned32(),
+ UseInfo::CheckedSigned32AsWord32(kIdentifyZeros, VectorSlotPair()));
}
static void TestMinusZeroCheck(IrOpcode::Value expected, Type from_type) {