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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 int64_t bh = 11; | 1001 int64_t bh = 11; |
1002 int64_t res = reinterpret_cast<SubCode>(test->entry())(al, ah, bl, bh); | 1002 int64_t res = reinterpret_cast<SubCode>(test->entry())(al, ah, bl, bh); |
1003 EXPECT_EQ((ah - bh), res); | 1003 EXPECT_EQ((ah - bh), res); |
1004 al = 10; | 1004 al = 10; |
1005 res = reinterpret_cast<SubCode>(test->entry())(al, ah, bl, bh); | 1005 res = reinterpret_cast<SubCode>(test->entry())(al, ah, bl, bh); |
1006 EXPECT_EQ((ah - bh - 1), res); | 1006 EXPECT_EQ((ah - bh - 1), res); |
1007 } | 1007 } |
1008 | 1008 |
1009 | 1009 |
1010 ASSEMBLER_TEST_GENERATE(Bitwise, assembler) { | 1010 ASSEMBLER_TEST_GENERATE(Bitwise, assembler) { |
| 1011 __ movq(R10, Immediate(-1)); |
| 1012 __ orl(Address(CallingConventions::kArg1Reg, 0), R10); |
| 1013 __ orl(Address(CallingConventions::kArg2Reg, 0), R10); |
1011 __ movl(RCX, Immediate(42)); | 1014 __ movl(RCX, Immediate(42)); |
1012 __ xorl(RCX, RCX); | 1015 __ xorl(RCX, RCX); |
1013 __ orl(RCX, Immediate(256)); | 1016 __ orl(RCX, Immediate(256)); |
1014 __ movl(RAX, Immediate(4)); | 1017 __ movl(RAX, Immediate(4)); |
1015 __ orl(RCX, RAX); | 1018 __ orl(RCX, RAX); |
1016 __ movl(RAX, Immediate(0xfff0)); | 1019 __ movl(RAX, Immediate(0xfff0)); |
1017 __ andl(RCX, RAX); | 1020 __ andl(RCX, RAX); |
1018 __ movl(RAX, Immediate(1)); | 1021 __ movl(RAX, Immediate(1)); |
1019 __ orl(RCX, RAX); | 1022 __ orl(RCX, RAX); |
1020 __ movl(RAX, RCX); | 1023 __ movl(RAX, RCX); |
1021 __ ret(); | 1024 __ ret(); |
1022 } | 1025 } |
1023 | 1026 |
1024 | 1027 |
1025 ASSEMBLER_TEST_RUN(Bitwise, test) { | 1028 ASSEMBLER_TEST_RUN(Bitwise, test) { |
1026 typedef int (*Bitwise)(); | 1029 uint64_t f1; |
1027 EXPECT_EQ(256 + 1, reinterpret_cast<Bitwise>(test->entry())()); | 1030 uint64_t f2; |
| 1031 typedef int (*Bitwise)(void*, void*); |
| 1032 int result = reinterpret_cast<Bitwise>(test->entry())(&f1, &f2); |
| 1033 EXPECT_EQ(256 + 1, result); |
| 1034 EXPECT_EQ(kMaxUint32, f1); |
| 1035 EXPECT_EQ(kMaxUint32, f2); |
1028 } | 1036 } |
1029 | 1037 |
1030 | 1038 |
1031 ASSEMBLER_TEST_GENERATE(Bitwise64, assembler) { | 1039 ASSEMBLER_TEST_GENERATE(Bitwise64, assembler) { |
1032 Label error; | 1040 Label error; |
1033 __ movq(RAX, Immediate(42)); | 1041 __ movq(RAX, Immediate(42)); |
1034 __ pushq(RAX); | 1042 __ pushq(RAX); |
1035 __ xorq(RAX, Address(RSP, 0)); | 1043 __ xorq(RAX, Address(RSP, 0)); |
1036 __ popq(RCX); | 1044 __ popq(RCX); |
1037 __ cmpq(RAX, Immediate(0)); | 1045 __ cmpq(RAX, Immediate(0)); |
(...skipping 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3396 | 3404 |
3397 ASSEMBLER_TEST_RUN(ConditionalMovesNoOverflow, test) { | 3405 ASSEMBLER_TEST_RUN(ConditionalMovesNoOverflow, test) { |
3398 typedef int (*ConditionalMovesNoOverflowCode)(int64_t i, int64_t j); | 3406 typedef int (*ConditionalMovesNoOverflowCode)(int64_t i, int64_t j); |
3399 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>( | 3407 int res = reinterpret_cast<ConditionalMovesNoOverflowCode>( |
3400 test->entry())(0x7fffffffffffffff, 2); | 3408 test->entry())(0x7fffffffffffffff, 2); |
3401 EXPECT_EQ(1, res); | 3409 EXPECT_EQ(1, res); |
3402 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1); | 3410 res = reinterpret_cast<ConditionalMovesNoOverflowCode>(test->entry())(1, 1); |
3403 EXPECT_EQ(0, res); | 3411 EXPECT_EQ(0, res); |
3404 } | 3412 } |
3405 | 3413 |
| 3414 |
| 3415 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { |
| 3416 Label miss; |
| 3417 __ movq(RDX, CallingConventions::kArg1Reg); |
| 3418 __ ComputeRange(RAX, RDX, &miss); |
| 3419 __ ret(); |
| 3420 |
| 3421 __ Bind(&miss); |
| 3422 __ movq(RAX, Immediate(0)); |
| 3423 __ ret(); |
| 3424 } |
| 3425 |
| 3426 |
| 3427 ASSEMBLER_TEST_RUN(ComputeRange, test) { |
| 3428 typedef intptr_t (*ComputeRange)(RawObject*); |
| 3429 ComputeRange range_of = reinterpret_cast<ComputeRange>(test->entry()); |
| 3430 |
| 3431 EXPECT_EQ(ICData::kInt32RangeBit, range_of(Smi::New(0))); |
| 3432 EXPECT_EQ(ICData::kInt32RangeBit, range_of(Smi::New(1))); |
| 3433 EXPECT_EQ(ICData::kInt32RangeBit, range_of(Smi::New(kMaxInt32))); |
| 3434 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, |
| 3435 range_of(Smi::New(-1))); |
| 3436 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, |
| 3437 range_of(Smi::New(kMinInt32))); |
| 3438 |
| 3439 EXPECT_EQ(ICData::kUint32RangeBit, |
| 3440 range_of(Smi::New(static_cast<int64_t>(kMaxInt32) + 1))); |
| 3441 EXPECT_EQ(ICData::kUint32RangeBit, |
| 3442 range_of(Smi::New(kMaxUint32))); |
| 3443 |
| 3444 // On 64-bit platforms we don't track the sign of the smis outside of |
| 3445 // int32 range because it is not needed to distinguish kInt32Range from |
| 3446 // kUint32Range. |
| 3447 EXPECT_EQ(ICData::kSignedRangeBit, |
| 3448 range_of(Smi::New(static_cast<int64_t>(kMinInt32) - 1))); |
| 3449 EXPECT_EQ(ICData::kSignedRangeBit, |
| 3450 range_of(Smi::New(static_cast<int64_t>(kMaxUint32) + 1))); |
| 3451 EXPECT_EQ(ICData::kSignedRangeBit, range_of(Smi::New(Smi::kMaxValue))); |
| 3452 EXPECT_EQ(ICData::kSignedRangeBit, range_of(Smi::New(Smi::kMinValue))); |
| 3453 |
| 3454 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(Smi::kMaxValue + 1))); |
| 3455 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(Smi::kMinValue - 1))); |
| 3456 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); |
| 3457 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); |
| 3458 |
| 3459 EXPECT_EQ(0, range_of(Bool::True().raw())); |
| 3460 } |
| 3461 |
| 3462 |
3406 } // namespace dart | 3463 } // namespace dart |
3407 | 3464 |
3408 #endif // defined TARGET_ARCH_X64 | 3465 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |