| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 3571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3582 | 3582 |
| 3583 ASSEMBLER_TEST_RUN(ConditionalMovesNoOverflow, test) { | 3583 ASSEMBLER_TEST_RUN(ConditionalMovesNoOverflow, test) { |
| 3584 typedef int (*ConditionalMovesNoOverflowCode)(int64_t i, int64_t j); | 3584 typedef int (*ConditionalMovesNoOverflowCode)(int64_t i, int64_t j); |
| 3585 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>( | 3585 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>( |
| 3586 test->entry())(0x7fffffffffffffff, 2); | 3586 test->entry())(0x7fffffffffffffff, 2); |
| 3587 EXPECT_EQ(1, res); | 3587 EXPECT_EQ(1, res); |
| 3588 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1); | 3588 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1); |
| 3589 EXPECT_EQ(0, res); | 3589 EXPECT_EQ(0, res); |
| 3590 } | 3590 } |
| 3591 | 3591 |
| 3592 | |
| 3593 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { | |
| 3594 Label miss; | |
| 3595 __ movq(RDX, CallingConventions::kArg1Reg); | |
| 3596 __ ComputeRange(RAX, RDX, &miss); | |
| 3597 __ ret(); | |
| 3598 | |
| 3599 __ Bind(&miss); | |
| 3600 __ movq(RAX, Immediate(0)); | |
| 3601 __ ret(); | |
| 3602 } | |
| 3603 | |
| 3604 | |
| 3605 ASSEMBLER_TEST_RUN(ComputeRange, test) { | |
| 3606 typedef intptr_t (*ComputeRange)(RawObject*); | |
| 3607 ComputeRange range_of = reinterpret_cast<ComputeRange>(test->entry()); | |
| 3608 | |
| 3609 EXPECT_EQ(ICData::kInt32RangeBit, range_of(Smi::New(0))); | |
| 3610 EXPECT_EQ(ICData::kInt32RangeBit, range_of(Smi::New(1))); | |
| 3611 EXPECT_EQ(ICData::kInt32RangeBit, range_of(Smi::New(kMaxInt32))); | |
| 3612 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | |
| 3613 range_of(Smi::New(-1))); | |
| 3614 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | |
| 3615 range_of(Smi::New(kMinInt32))); | |
| 3616 | |
| 3617 EXPECT_EQ(ICData::kUint32RangeBit, | |
| 3618 range_of(Smi::New(static_cast<int64_t>(kMaxInt32) + 1))); | |
| 3619 EXPECT_EQ(ICData::kUint32RangeBit, | |
| 3620 range_of(Smi::New(kMaxUint32))); | |
| 3621 | |
| 3622 // On 64-bit platforms we don't track the sign of the smis outside of | |
| 3623 // int32 range because it is not needed to distinguish kInt32Range from | |
| 3624 // kUint32Range. | |
| 3625 EXPECT_EQ(ICData::kSignedRangeBit, | |
| 3626 range_of(Smi::New(static_cast<int64_t>(kMinInt32) - 1))); | |
| 3627 EXPECT_EQ(ICData::kSignedRangeBit, | |
| 3628 range_of(Smi::New(static_cast<int64_t>(kMaxUint32) + 1))); | |
| 3629 EXPECT_EQ(ICData::kSignedRangeBit, range_of(Smi::New(Smi::kMaxValue))); | |
| 3630 EXPECT_EQ(ICData::kSignedRangeBit, range_of(Smi::New(Smi::kMinValue))); | |
| 3631 | |
| 3632 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(Smi::kMaxValue + 1))); | |
| 3633 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(Smi::kMinValue - 1))); | |
| 3634 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); | |
| 3635 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); | |
| 3636 | |
| 3637 EXPECT_EQ(0, range_of(Bool::True().raw())); | |
| 3638 } | |
| 3639 | |
| 3640 | |
| 3641 } // namespace dart | 3592 } // namespace dart |
| 3642 | 3593 |
| 3643 #endif // defined TARGET_ARCH_X64 | 3594 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |