| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 __ ret(); | 556 __ ret(); |
| 557 } | 557 } |
| 558 | 558 |
| 559 | 559 |
| 560 ASSEMBLER_TEST_RUN(LoadStorePairOffset, test) { | 560 ASSEMBLER_TEST_RUN(LoadStorePairOffset, test) { |
| 561 typedef int64_t (*Int64Return)() DART_UNUSED; | 561 typedef int64_t (*Int64Return)() DART_UNUSED; |
| 562 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); | 562 EXPECT_EQ(1, EXECUTE_TEST_CODE_INT64(Int64Return, test->entry())); |
| 563 } | 563 } |
| 564 | 564 |
| 565 | 565 |
| 566 ASSEMBLER_TEST_GENERATE(Semaphore, assembler) { |
| 567 __ SetupDartSP(kTestStackSpace); |
| 568 __ movz(R0, Immediate(40), 0); |
| 569 __ movz(R1, Immediate(42), 0); |
| 570 __ Push(R0); |
| 571 Label retry; |
| 572 __ Bind(&retry); |
| 573 __ ldxr(R0, SP); |
| 574 __ stxr(TMP, R1, SP); // IP == 0, success |
| 575 __ cmp(TMP, Operand(0)); |
| 576 __ b(&retry, NE); // NE if context switch occurred between ldrex and strex. |
| 577 __ Pop(R0); // 42 |
| 578 __ mov(CSP, SP); |
| 579 __ ret(); |
| 580 } |
| 581 |
| 582 |
| 583 ASSEMBLER_TEST_RUN(Semaphore, test) { |
| 584 EXPECT(test != NULL); |
| 585 typedef int (*Semaphore)() DART_UNUSED; |
| 586 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT64(Semaphore, test->entry())); |
| 587 } |
| 588 |
| 589 |
| 590 ASSEMBLER_TEST_GENERATE(FailedSemaphore, assembler) { |
| 591 __ SetupDartSP(kTestStackSpace); |
| 592 __ movz(R0, Immediate(40), 0); |
| 593 __ movz(R1, Immediate(42), 0); |
| 594 __ Push(R0); |
| 595 __ ldxr(R0, SP); |
| 596 __ clrex(); // Simulate a context switch. |
| 597 __ stxr(TMP, R1, SP); // IP == 1, failure |
| 598 __ Pop(R0); // 40 |
| 599 __ add(R0, R0, Operand(TMP)); |
| 600 __ mov(CSP, SP); |
| 601 __ ret(); |
| 602 } |
| 603 |
| 604 |
| 605 ASSEMBLER_TEST_RUN(FailedSemaphore, test) { |
| 606 EXPECT(test != NULL); |
| 607 typedef int (*FailedSemaphore)() DART_UNUSED; |
| 608 EXPECT_EQ(41, EXECUTE_TEST_CODE_INT64(FailedSemaphore, test->entry())); |
| 609 } |
| 610 |
| 611 |
| 566 // Logical register operations. | 612 // Logical register operations. |
| 567 ASSEMBLER_TEST_GENERATE(AndRegs, assembler) { | 613 ASSEMBLER_TEST_GENERATE(AndRegs, assembler) { |
| 568 __ movz(R1, Immediate(43), 0); | 614 __ movz(R1, Immediate(43), 0); |
| 569 __ movz(R2, Immediate(42), 0); | 615 __ movz(R2, Immediate(42), 0); |
| 570 __ and_(R0, R1, Operand(R2)); | 616 __ and_(R0, R1, Operand(R2)); |
| 571 __ ret(); | 617 __ ret(); |
| 572 } | 618 } |
| 573 | 619 |
| 574 | 620 |
| 575 ASSEMBLER_TEST_RUN(AndRegs, test) { | 621 ASSEMBLER_TEST_RUN(AndRegs, test) { |
| (...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3630 | 3676 |
| 3631 EXPECT_EQ(-1, RANGE_OF(RawBool*, Bool::True().raw())); | 3677 EXPECT_EQ(-1, RANGE_OF(RawBool*, Bool::True().raw())); |
| 3632 | 3678 |
| 3633 #undef RANGE_OF | 3679 #undef RANGE_OF |
| 3634 } | 3680 } |
| 3635 | 3681 |
| 3636 | 3682 |
| 3637 } // namespace dart | 3683 } // namespace dart |
| 3638 | 3684 |
| 3639 #endif // defined(TARGET_ARCH_ARM64) | 3685 #endif // defined(TARGET_ARCH_ARM64) |
| OLD | NEW |