Index: runtime/vm/assembler_arm64_test.cc |
diff --git a/runtime/vm/assembler_arm64_test.cc b/runtime/vm/assembler_arm64_test.cc |
index bb6bd0acff3a58739dfb356f661befca8811a6ce..ab3874c94aa083ea86fd2c7d95862ed935eb1c0e 100644 |
--- a/runtime/vm/assembler_arm64_test.cc |
+++ b/runtime/vm/assembler_arm64_test.cc |
@@ -3523,6 +3523,67 @@ ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
__ ret(); |
} |
+ |
+ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { |
+ __ SetupDartSP(kTestStackSpace); |
+ __ TagAndPushPP(); |
+ __ LoadPoolPointer(PP); |
+ Label miss, done; |
+ __ mov(R1, R0); |
+ __ ComputeRange(R0, R1, R2, &miss); |
+ __ b(&done); |
+ |
+ __ Bind(&miss); |
+ __ LoadImmediate(R0, -1, kNoPP); |
+ |
+ __ Bind(&done); |
+ __ PopAndUntagPP(); |
+ __ mov(CSP, SP); |
+ __ ret(); |
+} |
+ |
+ |
+ASSEMBLER_TEST_RUN(ComputeRange, test) { |
+ typedef intptr_t (*ComputeRange)(intptr_t value) DART_UNUSED; |
+ |
+#define RANGE_OF(v) \ |
+ (EXECUTE_TEST_CODE_INTPTR_INTPTR( \ |
+ ComputeRange, test->entry(), reinterpret_cast<intptr_t>(v))) |
+ |
+ EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(Smi::New(0))); |
+ EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(Smi::New(1))); |
+ EXPECT_EQ(ICData::kInt32RangeBit, RANGE_OF(Smi::New(kMaxInt32))); |
+ EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, |
+ RANGE_OF(Smi::New(-1))); |
+ EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, |
+ RANGE_OF(Smi::New(kMinInt32))); |
+ |
+ EXPECT_EQ(ICData::kUint32RangeBit, |
+ RANGE_OF(Smi::New(static_cast<int64_t>(kMaxInt32) + 1))); |
+ EXPECT_EQ(ICData::kUint32RangeBit, |
+ RANGE_OF(Smi::New(kMaxUint32))); |
+ |
+ // On 64-bit platforms we don't track the sign of the smis outside of |
+ // int32 range because it is not needed to distinguish kInt32Range from |
+ // kUint32Range. |
+ EXPECT_EQ(ICData::kSignedRangeBit, |
+ RANGE_OF(Smi::New(static_cast<int64_t>(kMinInt32) - 1))); |
+ EXPECT_EQ(ICData::kSignedRangeBit, |
+ RANGE_OF(Smi::New(static_cast<int64_t>(kMaxUint32) + 1))); |
+ EXPECT_EQ(ICData::kSignedRangeBit, RANGE_OF(Smi::New(Smi::kMaxValue))); |
+ EXPECT_EQ(ICData::kSignedRangeBit, RANGE_OF(Smi::New(Smi::kMinValue))); |
+ |
+ EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(Smi::kMaxValue + 1))); |
+ EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(Smi::kMinValue - 1))); |
+ EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(kMaxInt64))); |
+ EXPECT_EQ(ICData::kInt64RangeBit, RANGE_OF(Integer::New(kMinInt64))); |
+ |
+ EXPECT_EQ(-1, RANGE_OF(Bool::True().raw())); |
+ |
+#undef RANGE_OF |
+} |
+ |
+ |
} // namespace dart |
#endif // defined(TARGET_ARCH_ARM64) |