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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/os.h" | 10 #include "vm/os.h" |
(...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 __ movl(EAX, Immediate(1)); | 3418 __ movl(EAX, Immediate(1)); |
3419 __ ret(); | 3419 __ ret(); |
3420 } | 3420 } |
3421 | 3421 |
3422 | 3422 |
3423 ASSEMBLER_TEST_RUN(BitTest, test) { | 3423 ASSEMBLER_TEST_RUN(BitTest, test) { |
3424 typedef int (*BitTest)(); | 3424 typedef int (*BitTest)(); |
3425 EXPECT_EQ(1, reinterpret_cast<BitTest>(test->entry())()); | 3425 EXPECT_EQ(1, reinterpret_cast<BitTest>(test->entry())()); |
3426 } | 3426 } |
3427 | 3427 |
3428 | |
3429 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { | |
3430 Label miss, done; | |
3431 __ movl(ECX, Address(ESP, 1 * kWordSize)); | |
3432 | |
3433 __ pushl(ESI); | |
3434 __ pushl(EDI); | |
3435 __ ComputeRange(EAX, ECX, ESI, EDI, &miss); | |
3436 __ jmp(&done); | |
3437 | |
3438 __ Bind(&miss); | |
3439 __ movl(EAX, Immediate(-1)); | |
3440 | |
3441 __ Bind(&done); | |
3442 __ popl(EDI); | |
3443 __ popl(ESI); | |
3444 __ ret(); | |
3445 } | |
3446 | |
3447 | |
3448 ASSEMBLER_TEST_RUN(ComputeRange, test) { | |
3449 typedef intptr_t (*ComputeRange)(RawObject* value); | |
3450 ComputeRange range_of = reinterpret_cast<ComputeRange>(test->entry()); | |
3451 | |
3452 EXPECT_EQ(0, range_of(Smi::New(0))); | |
3453 EXPECT_EQ(0, range_of(Smi::New(1))); | |
3454 EXPECT_EQ(ICData::kSignedRangeBit, range_of(Smi::New(-1))); | |
3455 EXPECT_EQ(0, range_of(Smi::New(Smi::kMaxValue))); | |
3456 EXPECT_EQ(ICData::kSignedRangeBit, range_of(Smi::New(Smi::kMinValue))); | |
3457 | |
3458 EXPECT_EQ(ICData::kInt32RangeBit, range_of(Integer::New(Smi::kMaxValue + 1))); | |
3459 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | |
3460 range_of(Integer::New(Smi::kMinValue - 1))); | |
3461 EXPECT_EQ(ICData::kInt32RangeBit, range_of(Integer::New(kMaxInt32))); | |
3462 EXPECT_EQ(ICData::kInt32RangeBit | ICData::kSignedRangeBit, | |
3463 range_of(Integer::New(kMinInt32))); | |
3464 | |
3465 EXPECT_EQ(ICData::kUint32RangeBit, | |
3466 range_of(Integer::New(static_cast<int64_t>(kMaxInt32) + 1))); | |
3467 EXPECT_EQ(ICData::kUint32RangeBit, range_of(Integer::New(kMaxUint32))); | |
3468 | |
3469 EXPECT_EQ(ICData::kInt64RangeBit, | |
3470 range_of(Integer::New(static_cast<int64_t>(kMaxUint32) + 1))); | |
3471 EXPECT_EQ(ICData::kInt64RangeBit, | |
3472 range_of(Integer::New(static_cast<int64_t>(kMinInt32) - 1))); | |
3473 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMaxInt64))); | |
3474 EXPECT_EQ(ICData::kInt64RangeBit, range_of(Integer::New(kMinInt64))); | |
3475 | |
3476 EXPECT_EQ(-1, range_of(Bool::True().raw())); | |
3477 } | |
3478 | |
3479 | |
3480 } // namespace dart | 3428 } // namespace dart |
3481 | 3429 |
3482 #endif // defined TARGET_ARCH_IA32 | 3430 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |