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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 __ popl(EAX); // Discard. | 391 __ popl(EAX); // Discard. |
392 __ movl(EAX, Immediate(1)); | 392 __ movl(EAX, Immediate(1)); |
393 __ orl(ECX, EAX); // 0x641. | 393 __ orl(ECX, EAX); // 0x641. |
394 __ pushl(Immediate(0x7)); | 394 __ pushl(Immediate(0x7)); |
395 __ orl(ECX, Address(ESP, 0)); // 0x647. | 395 __ orl(ECX, Address(ESP, 0)); // 0x647. |
396 __ popl(EAX); // Discard. | 396 __ popl(EAX); // Discard. |
397 __ xorl(ECX, Immediate(0)); // 0x647. | 397 __ xorl(ECX, Immediate(0)); // 0x647. |
398 __ pushl(Immediate(0x1C)); | 398 __ pushl(Immediate(0x1C)); |
399 __ xorl(ECX, Address(ESP, 0)); // 0x65B. | 399 __ xorl(ECX, Address(ESP, 0)); // 0x65B. |
400 __ popl(EAX); // Discard. | 400 __ popl(EAX); // Discard. |
| 401 __ movl(EAX, Address(ESP, kWordSize)); |
| 402 __ movl(EDX, Immediate(0xB0)); |
| 403 __ orl(Address(EAX, 0), EDX); |
401 __ movl(EAX, ECX); | 404 __ movl(EAX, ECX); |
402 __ ret(); | 405 __ ret(); |
403 } | 406 } |
404 | 407 |
405 | 408 |
406 ASSEMBLER_TEST_RUN(Bitwise, test) { | 409 ASSEMBLER_TEST_RUN(Bitwise, test) { |
407 typedef int (*Bitwise)(); | 410 typedef int (*Bitwise)(int* value); |
408 EXPECT_EQ(0x65B, reinterpret_cast<Bitwise>(test->entry())()); | 411 int value = 0xA; |
| 412 const int result = reinterpret_cast<Bitwise>(test->entry())(&value); |
| 413 EXPECT_EQ(0x65B, result); |
| 414 EXPECT_EQ(0xBA, value); |
409 } | 415 } |
410 | 416 |
411 | 417 |
412 ASSEMBLER_TEST_GENERATE(LogicalOps, assembler) { | 418 ASSEMBLER_TEST_GENERATE(LogicalOps, assembler) { |
413 Label donetest1; | 419 Label donetest1; |
414 __ movl(EAX, Immediate(4)); | 420 __ movl(EAX, Immediate(4)); |
415 __ andl(EAX, Immediate(2)); | 421 __ andl(EAX, Immediate(2)); |
416 __ cmpl(EAX, Immediate(0)); | 422 __ cmpl(EAX, Immediate(0)); |
417 __ j(EQUAL, &donetest1); | 423 __ j(EQUAL, &donetest1); |
418 // Be sure to skip this crashing code. | 424 // Be sure to skip this crashing code. |
(...skipping 2973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3392 __ ret(); | 3398 __ ret(); |
3393 } | 3399 } |
3394 | 3400 |
3395 | 3401 |
3396 ASSEMBLER_TEST_RUN(BitTest, test) { | 3402 ASSEMBLER_TEST_RUN(BitTest, test) { |
3397 typedef int (*BitTest)(); | 3403 typedef int (*BitTest)(); |
3398 EXPECT_EQ(1, reinterpret_cast<BitTest>(test->entry())()); | 3404 EXPECT_EQ(1, reinterpret_cast<BitTest>(test->entry())()); |
3399 } | 3405 } |
3400 | 3406 |
3401 | 3407 |
| 3408 ASSEMBLER_TEST_GENERATE(ComputeRange, assembler) { |
| 3409 Label miss, done; |
| 3410 __ movl(ECX, Address(ESP, 1 * kWordSize)); |
| 3411 |
| 3412 __ pushl(ESI); |
| 3413 __ pushl(EDI); |
| 3414 __ ComputeRange(EAX, ECX, ESI, EDI, &miss); |
| 3415 __ jmp(&done); |
| 3416 |
| 3417 __ Bind(&miss); |
| 3418 __ movl(EAX, Immediate(-1)); |
| 3419 |
| 3420 __ Bind(&done); |
| 3421 __ popl(EDI); |
| 3422 __ popl(ESI); |
| 3423 __ ret(); |
| 3424 } |
| 3425 |
| 3426 |
| 3427 ASSEMBLER_TEST_RUN(ComputeRange, test) { |
| 3428 typedef intptr_t (*ComputeRange)(RawObject* value); |
| 3429 ComputeRange range_of = reinterpret_cast<ComputeRange>(test->entry()); |
| 3430 |
| 3431 EXPECT_EQ(0, range_of(Smi::New(0))); |
| 3432 EXPECT_EQ(0, range_of(Smi::New(1))); |
| 3433 EXPECT_EQ(ICData::kSignBit, range_of(Smi::New(-1))); |
| 3434 EXPECT_EQ(0, range_of(Smi::New(Smi::kMaxValue))); |
| 3435 EXPECT_EQ(ICData::kSignBit, range_of(Smi::New(Smi::kMinValue))); |
| 3436 |
| 3437 EXPECT_EQ(ICData::kInt32Bit, range_of(Integer::New(Smi::kMaxValue + 1))); |
| 3438 EXPECT_EQ(ICData::kInt32Bit | ICData::kSignBit, |
| 3439 range_of(Integer::New(Smi::kMinValue - 1))); |
| 3440 EXPECT_EQ(ICData::kInt32Bit, range_of(Integer::New(kMaxInt32))); |
| 3441 EXPECT_EQ(ICData::kInt32Bit | ICData::kSignBit, |
| 3442 range_of(Integer::New(kMinInt32))); |
| 3443 |
| 3444 EXPECT_EQ(ICData::kUint32Bit, |
| 3445 range_of(Integer::New(static_cast<int64_t>(kMaxInt32) + 1))); |
| 3446 EXPECT_EQ(ICData::kUint32Bit, range_of(Integer::New(kMaxUint32))); |
| 3447 |
| 3448 EXPECT_EQ(ICData::kInt64Bit, |
| 3449 range_of(Integer::New(static_cast<int64_t>(kMaxUint32) + 1))); |
| 3450 EXPECT_EQ(ICData::kInt64Bit, |
| 3451 range_of(Integer::New(static_cast<int64_t>(kMinInt32) - 1))); |
| 3452 EXPECT_EQ(ICData::kInt64Bit, range_of(Integer::New(kMaxInt64))); |
| 3453 EXPECT_EQ(ICData::kInt64Bit, range_of(Integer::New(kMinInt64))); |
| 3454 |
| 3455 EXPECT_EQ(-1, range_of(Bool::True().raw())); |
| 3456 } |
| 3457 |
| 3458 |
3402 } // namespace dart | 3459 } // namespace dart |
3403 | 3460 |
3404 #endif // defined TARGET_ARCH_IA32 | 3461 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |