| 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_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 } | 659 } |
| 660 | 660 |
| 661 | 661 |
| 662 ASSEMBLER_TEST_RUN(LoadStore, test) { | 662 ASSEMBLER_TEST_RUN(LoadStore, test) { |
| 663 EXPECT(test != NULL); | 663 EXPECT(test != NULL); |
| 664 typedef int (*LoadStore)() DART_UNUSED; | 664 typedef int (*LoadStore)() DART_UNUSED; |
| 665 EXPECT_EQ(123, EXECUTE_TEST_CODE_INT32(LoadStore, test->entry())); | 665 EXPECT_EQ(123, EXECUTE_TEST_CODE_INT32(LoadStore, test->entry())); |
| 666 } | 666 } |
| 667 | 667 |
| 668 | 668 |
| 669 ASSEMBLER_TEST_GENERATE(Semaphore, assembler) { |
| 670 if (TargetCPUFeatures::arm_version() == ARMv5TE) { |
| 671 __ mov(R0, Operand(42)); |
| 672 __ bx(LR); |
| 673 } else { |
| 674 __ mov(R0, Operand(40)); |
| 675 __ mov(R1, Operand(42)); |
| 676 __ Push(R0); |
| 677 Label retry; |
| 678 __ Bind(&retry); |
| 679 __ ldrex(R0, SP); |
| 680 __ strex(IP, R1, SP); // IP == 0, success |
| 681 __ tst(IP, Operand(0)); |
| 682 __ b(&retry, NE); // NE if context switch occurred between ldrex and strex. |
| 683 __ Pop(R0); // 42 |
| 684 __ bx(LR); |
| 685 } |
| 686 } |
| 687 |
| 688 |
| 689 ASSEMBLER_TEST_RUN(Semaphore, test) { |
| 690 EXPECT(test != NULL); |
| 691 typedef int (*Semaphore)(); |
| 692 EXPECT_EQ(42, EXECUTE_TEST_CODE_INT32(Semaphore, test->entry())); |
| 693 } |
| 694 |
| 695 |
| 696 ASSEMBLER_TEST_GENERATE(FailedSemaphore, assembler) { |
| 697 if (TargetCPUFeatures::arm_version() == ARMv5TE) { |
| 698 __ mov(R0, Operand(41)); |
| 699 __ bx(LR); |
| 700 } else { |
| 701 __ mov(R0, Operand(40)); |
| 702 __ mov(R1, Operand(42)); |
| 703 __ Push(R0); |
| 704 __ ldrex(R0, SP); |
| 705 __ clrex(); // Simulate a context switch. |
| 706 __ strex(IP, R1, SP); // IP == 1, failure |
| 707 __ Pop(R0); // 40 |
| 708 __ add(R0, R0, Operand(IP)); |
| 709 __ bx(LR); |
| 710 } |
| 711 } |
| 712 |
| 713 |
| 714 ASSEMBLER_TEST_RUN(FailedSemaphore, test) { |
| 715 EXPECT(test != NULL); |
| 716 typedef int (*FailedSemaphore)(); |
| 717 EXPECT_EQ(41, EXECUTE_TEST_CODE_INT32(FailedSemaphore, test->entry())); |
| 718 } |
| 719 |
| 720 |
| 669 ASSEMBLER_TEST_GENERATE(AddSub, assembler) { | 721 ASSEMBLER_TEST_GENERATE(AddSub, assembler) { |
| 670 __ mov(R1, Operand(40)); | 722 __ mov(R1, Operand(40)); |
| 671 __ sub(R1, R1, Operand(2)); | 723 __ sub(R1, R1, Operand(2)); |
| 672 __ add(R0, R1, Operand(4)); | 724 __ add(R0, R1, Operand(4)); |
| 673 __ rsbs(R0, R0, Operand(100)); | 725 __ rsbs(R0, R0, Operand(100)); |
| 674 __ rsc(R0, R0, Operand(100)); | 726 __ rsc(R0, R0, Operand(100)); |
| 675 __ bx(LR); | 727 __ bx(LR); |
| 676 } | 728 } |
| 677 | 729 |
| 678 | 730 |
| (...skipping 3397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4076 __ StoreIntoObject(R2, | 4128 __ StoreIntoObject(R2, |
| 4077 FieldAddress(R2, GrowableObjectArray::data_offset()), | 4129 FieldAddress(R2, GrowableObjectArray::data_offset()), |
| 4078 R1); | 4130 R1); |
| 4079 __ PopList((1 << CTX) | (1 << LR)); | 4131 __ PopList((1 << CTX) | (1 << LR)); |
| 4080 __ Ret(); | 4132 __ Ret(); |
| 4081 } | 4133 } |
| 4082 | 4134 |
| 4083 } // namespace dart | 4135 } // namespace dart |
| 4084 | 4136 |
| 4085 #endif // defined TARGET_ARCH_ARM | 4137 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |