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 <setjmp.h> // NOLINT | 5 #include <setjmp.h> // NOLINT |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #if defined(TARGET_ARCH_ARM) | 9 #if defined(TARGET_ARCH_ARM) |
10 | 10 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 "r12", "r13", "r14", "r15", | 138 "r12", "r13", "r14", "r15", |
139 "pc", "lr", "sp", "ip", | 139 "pc", "lr", "sp", "ip", |
140 "fp", "pp", "ctx" | 140 "fp", "pp", "ctx" |
141 }; | 141 }; |
142 static const Register kRegisters[] = { | 142 static const Register kRegisters[] = { |
143 R0, R1, R2, R3, | 143 R0, R1, R2, R3, |
144 R4, R5, R6, R7, | 144 R4, R5, R6, R7, |
145 R8, R9, R10, R11, | 145 R8, R9, R10, R11, |
146 R12, R13, R14, R15, | 146 R12, R13, R14, R15, |
147 PC, LR, SP, IP, | 147 PC, LR, SP, IP, |
148 FP, R10, R9 | 148 FP, PP, CTX |
149 }; | 149 }; |
150 ASSERT(ARRAY_SIZE(kNames) == ARRAY_SIZE(kRegisters)); | 150 ASSERT(ARRAY_SIZE(kNames) == ARRAY_SIZE(kRegisters)); |
151 for (unsigned i = 0; i < ARRAY_SIZE(kNames); i++) { | 151 for (unsigned i = 0; i < ARRAY_SIZE(kNames); i++) { |
152 if (strcmp(kNames[i], name) == 0) { | 152 if (strcmp(kNames[i], name) == 0) { |
153 return kRegisters[i]; | 153 return kRegisters[i]; |
154 } | 154 } |
155 } | 155 } |
156 return kNoRegister; | 156 return kNoRegister; |
157 } | 157 } |
158 | 158 |
(...skipping 3569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3728 set_register(LR, kEndSimulatingPC); | 3728 set_register(LR, kEndSimulatingPC); |
3729 | 3729 |
3730 // Remember the values of callee-saved registers. | 3730 // Remember the values of callee-saved registers. |
3731 // The code below assumes that r9 is not used as sb (static base) in | 3731 // The code below assumes that r9 is not used as sb (static base) in |
3732 // simulator code and therefore is regarded as a callee-saved register. | 3732 // simulator code and therefore is regarded as a callee-saved register. |
3733 int32_t r4_val = get_register(R4); | 3733 int32_t r4_val = get_register(R4); |
3734 int32_t r5_val = get_register(R5); | 3734 int32_t r5_val = get_register(R5); |
3735 int32_t r6_val = get_register(R6); | 3735 int32_t r6_val = get_register(R6); |
3736 int32_t r7_val = get_register(R7); | 3736 int32_t r7_val = get_register(R7); |
3737 int32_t r8_val = get_register(R8); | 3737 int32_t r8_val = get_register(R8); |
| 3738 #if !defined(TARGET_OS_MACOS) |
3738 int32_t r9_val = get_register(R9); | 3739 int32_t r9_val = get_register(R9); |
| 3740 #endif |
3739 int32_t r10_val = get_register(R10); | 3741 int32_t r10_val = get_register(R10); |
3740 int32_t r11_val = get_register(R11); | 3742 int32_t r11_val = get_register(R11); |
3741 | 3743 |
3742 double d8_val = 0.0; | 3744 double d8_val = 0.0; |
3743 double d9_val = 0.0; | 3745 double d9_val = 0.0; |
3744 double d10_val = 0.0; | 3746 double d10_val = 0.0; |
3745 double d11_val = 0.0; | 3747 double d11_val = 0.0; |
3746 double d12_val = 0.0; | 3748 double d12_val = 0.0; |
3747 double d13_val = 0.0; | 3749 double d13_val = 0.0; |
3748 double d14_val = 0.0; | 3750 double d14_val = 0.0; |
(...skipping 11 matching lines...) Expand all Loading... |
3760 } | 3762 } |
3761 | 3763 |
3762 // Setup the callee-saved registers with a known value. To be able to check | 3764 // Setup the callee-saved registers with a known value. To be able to check |
3763 // that they are preserved properly across dart execution. | 3765 // that they are preserved properly across dart execution. |
3764 int32_t callee_saved_value = icount_; | 3766 int32_t callee_saved_value = icount_; |
3765 set_register(R4, callee_saved_value); | 3767 set_register(R4, callee_saved_value); |
3766 set_register(R5, callee_saved_value); | 3768 set_register(R5, callee_saved_value); |
3767 set_register(R6, callee_saved_value); | 3769 set_register(R6, callee_saved_value); |
3768 set_register(R7, callee_saved_value); | 3770 set_register(R7, callee_saved_value); |
3769 set_register(R8, callee_saved_value); | 3771 set_register(R8, callee_saved_value); |
| 3772 #if !defined(TARGET_OS_MACOS) |
3770 set_register(R9, callee_saved_value); | 3773 set_register(R9, callee_saved_value); |
| 3774 #endif |
3771 set_register(R10, callee_saved_value); | 3775 set_register(R10, callee_saved_value); |
3772 set_register(R11, callee_saved_value); | 3776 set_register(R11, callee_saved_value); |
3773 | 3777 |
3774 double callee_saved_dvalue = 0.0; | 3778 double callee_saved_dvalue = 0.0; |
3775 if (TargetCPUFeatures::vfp_supported()) { | 3779 if (TargetCPUFeatures::vfp_supported()) { |
3776 callee_saved_dvalue = static_cast<double>(icount_); | 3780 callee_saved_dvalue = static_cast<double>(icount_); |
3777 set_dregister(D8, callee_saved_dvalue); | 3781 set_dregister(D8, callee_saved_dvalue); |
3778 set_dregister(D9, callee_saved_dvalue); | 3782 set_dregister(D9, callee_saved_dvalue); |
3779 set_dregister(D10, callee_saved_dvalue); | 3783 set_dregister(D10, callee_saved_dvalue); |
3780 set_dregister(D11, callee_saved_dvalue); | 3784 set_dregister(D11, callee_saved_dvalue); |
3781 set_dregister(D12, callee_saved_dvalue); | 3785 set_dregister(D12, callee_saved_dvalue); |
3782 set_dregister(D13, callee_saved_dvalue); | 3786 set_dregister(D13, callee_saved_dvalue); |
3783 set_dregister(D14, callee_saved_dvalue); | 3787 set_dregister(D14, callee_saved_dvalue); |
3784 set_dregister(D15, callee_saved_dvalue); | 3788 set_dregister(D15, callee_saved_dvalue); |
3785 } | 3789 } |
3786 | 3790 |
3787 // Start the simulation | 3791 // Start the simulation |
3788 Execute(); | 3792 Execute(); |
3789 | 3793 |
3790 // Check that the callee-saved registers have been preserved. | 3794 // Check that the callee-saved registers have been preserved. |
3791 ASSERT(callee_saved_value == get_register(R4)); | 3795 ASSERT(callee_saved_value == get_register(R4)); |
3792 ASSERT(callee_saved_value == get_register(R5)); | 3796 ASSERT(callee_saved_value == get_register(R5)); |
3793 ASSERT(callee_saved_value == get_register(R6)); | 3797 ASSERT(callee_saved_value == get_register(R6)); |
3794 ASSERT(callee_saved_value == get_register(R7)); | 3798 ASSERT(callee_saved_value == get_register(R7)); |
3795 ASSERT(callee_saved_value == get_register(R8)); | 3799 ASSERT(callee_saved_value == get_register(R8)); |
| 3800 #if !defined(TARGET_OS_MACOS) |
3796 ASSERT(callee_saved_value == get_register(R9)); | 3801 ASSERT(callee_saved_value == get_register(R9)); |
| 3802 #endif |
3797 ASSERT(callee_saved_value == get_register(R10)); | 3803 ASSERT(callee_saved_value == get_register(R10)); |
3798 ASSERT(callee_saved_value == get_register(R11)); | 3804 ASSERT(callee_saved_value == get_register(R11)); |
3799 | 3805 |
3800 if (TargetCPUFeatures::vfp_supported()) { | 3806 if (TargetCPUFeatures::vfp_supported()) { |
3801 ASSERT(callee_saved_dvalue == get_dregister(D8)); | 3807 ASSERT(callee_saved_dvalue == get_dregister(D8)); |
3802 ASSERT(callee_saved_dvalue == get_dregister(D9)); | 3808 ASSERT(callee_saved_dvalue == get_dregister(D9)); |
3803 ASSERT(callee_saved_dvalue == get_dregister(D10)); | 3809 ASSERT(callee_saved_dvalue == get_dregister(D10)); |
3804 ASSERT(callee_saved_dvalue == get_dregister(D11)); | 3810 ASSERT(callee_saved_dvalue == get_dregister(D11)); |
3805 ASSERT(callee_saved_dvalue == get_dregister(D12)); | 3811 ASSERT(callee_saved_dvalue == get_dregister(D12)); |
3806 ASSERT(callee_saved_dvalue == get_dregister(D13)); | 3812 ASSERT(callee_saved_dvalue == get_dregister(D13)); |
3807 ASSERT(callee_saved_dvalue == get_dregister(D14)); | 3813 ASSERT(callee_saved_dvalue == get_dregister(D14)); |
3808 ASSERT(callee_saved_dvalue == get_dregister(D15)); | 3814 ASSERT(callee_saved_dvalue == get_dregister(D15)); |
3809 } | 3815 } |
3810 | 3816 |
3811 // Restore callee-saved registers with the original value. | 3817 // Restore callee-saved registers with the original value. |
3812 set_register(R4, r4_val); | 3818 set_register(R4, r4_val); |
3813 set_register(R5, r5_val); | 3819 set_register(R5, r5_val); |
3814 set_register(R6, r6_val); | 3820 set_register(R6, r6_val); |
3815 set_register(R7, r7_val); | 3821 set_register(R7, r7_val); |
3816 set_register(R8, r8_val); | 3822 set_register(R8, r8_val); |
| 3823 #if !defined(TARGET_OS_MACOS) |
3817 set_register(R9, r9_val); | 3824 set_register(R9, r9_val); |
| 3825 #endif |
3818 set_register(R10, r10_val); | 3826 set_register(R10, r10_val); |
3819 set_register(R11, r11_val); | 3827 set_register(R11, r11_val); |
3820 | 3828 |
3821 if (TargetCPUFeatures::vfp_supported()) { | 3829 if (TargetCPUFeatures::vfp_supported()) { |
3822 set_dregister(D8, d8_val); | 3830 set_dregister(D8, d8_val); |
3823 set_dregister(D9, d9_val); | 3831 set_dregister(D9, d9_val); |
3824 set_dregister(D10, d10_val); | 3832 set_dregister(D10, d10_val); |
3825 set_dregister(D11, d11_val); | 3833 set_dregister(D11, d11_val); |
3826 set_dregister(D12, d12_val); | 3834 set_dregister(D12, d12_val); |
3827 set_dregister(D13, d13_val); | 3835 set_dregister(D13, d13_val); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3875 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 3883 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
3876 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 3884 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
3877 buf->Longjmp(); | 3885 buf->Longjmp(); |
3878 } | 3886 } |
3879 | 3887 |
3880 } // namespace dart | 3888 } // namespace dart |
3881 | 3889 |
3882 #endif // defined(USING_SIMULATOR) | 3890 #endif // defined(USING_SIMULATOR) |
3883 | 3891 |
3884 #endif // defined TARGET_ARCH_ARM | 3892 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |