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 <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
6 #include <setjmp.h> | 6 #include <setjmp.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
10 #if defined(TARGET_ARCH_ARM) | 10 #if defined(TARGET_ARCH_ARM) |
(...skipping 2950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2961 program_counter = get_pc(); | 2961 program_counter = get_pc(); |
2962 } | 2962 } |
2963 } | 2963 } |
2964 } | 2964 } |
2965 | 2965 |
2966 | 2966 |
2967 int64_t Simulator::Call(int32_t entry, | 2967 int64_t Simulator::Call(int32_t entry, |
2968 int32_t parameter0, | 2968 int32_t parameter0, |
2969 int32_t parameter1, | 2969 int32_t parameter1, |
2970 int32_t parameter2, | 2970 int32_t parameter2, |
2971 int32_t parameter3) { | 2971 int32_t parameter3, |
| 2972 bool fp_return, |
| 2973 bool fp_args) { |
2972 // Save the SP register before the call so we can restore it. | 2974 // Save the SP register before the call so we can restore it. |
2973 int32_t sp_before_call = get_register(SP); | 2975 int32_t sp_before_call = get_register(SP); |
2974 | 2976 |
2975 // Setup parameters. | 2977 // Setup parameters. |
2976 set_register(R0, parameter0); | 2978 if (fp_args) { |
2977 set_register(R1, parameter1); | 2979 set_sregister(S0, bit_cast<float, int32_t>(parameter0)); |
2978 set_register(R2, parameter2); | 2980 set_sregister(S1, bit_cast<float, int32_t>(parameter1)); |
2979 set_register(R3, parameter3); | 2981 set_sregister(S2, bit_cast<float, int32_t>(parameter2)); |
| 2982 set_sregister(S3, bit_cast<float, int32_t>(parameter3)); |
| 2983 } else { |
| 2984 set_register(R0, parameter0); |
| 2985 set_register(R1, parameter1); |
| 2986 set_register(R2, parameter2); |
| 2987 set_register(R3, parameter3); |
| 2988 } |
2980 | 2989 |
2981 // Make sure the activation frames are properly aligned. | 2990 // Make sure the activation frames are properly aligned. |
2982 int32_t stack_pointer = sp_before_call; | 2991 int32_t stack_pointer = sp_before_call; |
2983 static const int kFrameAlignment = OS::ActivationFrameAlignment(); | 2992 static const int kFrameAlignment = OS::ActivationFrameAlignment(); |
2984 if (kFrameAlignment > 0) { | 2993 if (kFrameAlignment > 0) { |
2985 stack_pointer = Utils::RoundDown(stack_pointer, kFrameAlignment); | 2994 stack_pointer = Utils::RoundDown(stack_pointer, kFrameAlignment); |
2986 } | 2995 } |
2987 set_register(SP, stack_pointer); | 2996 set_register(SP, stack_pointer); |
2988 | 2997 |
2989 // Prepare to execute the code at entry. | 2998 // Prepare to execute the code at entry. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3035 set_register(R5, r5_val); | 3044 set_register(R5, r5_val); |
3036 set_register(R6, r6_val); | 3045 set_register(R6, r6_val); |
3037 set_register(R7, r7_val); | 3046 set_register(R7, r7_val); |
3038 set_register(R8, r8_val); | 3047 set_register(R8, r8_val); |
3039 set_register(R9, r9_val); | 3048 set_register(R9, r9_val); |
3040 set_register(R10, r10_val); | 3049 set_register(R10, r10_val); |
3041 set_register(R11, r11_val); | 3050 set_register(R11, r11_val); |
3042 | 3051 |
3043 // Restore the SP register and return R1:R0. | 3052 // Restore the SP register and return R1:R0. |
3044 set_register(SP, sp_before_call); | 3053 set_register(SP, sp_before_call); |
3045 return Utils::LowHighTo64Bits(get_register(R0), get_register(R1)); | 3054 int64_t return_value; |
| 3055 if (fp_return) { |
| 3056 return_value = bit_cast<int64_t, double>(get_dregister(D0)); |
| 3057 } else { |
| 3058 return_value = Utils::LowHighTo64Bits(get_register(R0), get_register(R1)); |
| 3059 } |
| 3060 return return_value; |
3046 } | 3061 } |
3047 | 3062 |
3048 | 3063 |
3049 void Simulator::Longjmp(uword pc, | 3064 void Simulator::Longjmp(uword pc, |
3050 uword sp, | 3065 uword sp, |
3051 uword fp, | 3066 uword fp, |
3052 RawObject* raw_exception, | 3067 RawObject* raw_exception, |
3053 RawObject* raw_stacktrace) { | 3068 RawObject* raw_stacktrace) { |
3054 // Walk over all setjmp buffers (simulated --> C++ transitions) | 3069 // Walk over all setjmp buffers (simulated --> C++ transitions) |
3055 // and try to find the setjmp associated with the simulated stack pointer. | 3070 // and try to find the setjmp associated with the simulated stack pointer. |
(...skipping 23 matching lines...) Expand all Loading... |
3079 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 3094 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
3080 } | 3095 } |
3081 buf->Longjmp(); | 3096 buf->Longjmp(); |
3082 } | 3097 } |
3083 | 3098 |
3084 } // namespace dart | 3099 } // namespace dart |
3085 | 3100 |
3086 #endif // !defined(HOST_ARCH_ARM) | 3101 #endif // !defined(HOST_ARCH_ARM) |
3087 | 3102 |
3088 #endif // defined TARGET_ARCH_ARM | 3103 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |