OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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> | 5 #include <setjmp.h> |
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_ARM64) | 9 #if defined(TARGET_ARCH_ARM64) |
10 | 10 |
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2437 } | 2437 } |
2438 set_vregisterd(vd, idx, res); | 2438 set_vregisterd(vd, idx, res); |
2439 } | 2439 } |
2440 } | 2440 } |
2441 } | 2441 } |
2442 | 2442 |
2443 | 2443 |
2444 static float arm_reciprocal_sqrt_estimate(float a) { | 2444 static float arm_reciprocal_sqrt_estimate(float a) { |
2445 // From the ARM Architecture Reference Manual A2-87. | 2445 // From the ARM Architecture Reference Manual A2-87. |
2446 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 2446 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; |
2447 else if (a == 0.0) return INFINITY; | 2447 else if (a == 0.0) return kPosInfinity; |
2448 else if (isnan(a)) return a; | 2448 else if (isnan(a)) return a; |
2449 | 2449 |
2450 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 2450 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
2451 uint64_t scaled; | 2451 uint64_t scaled; |
2452 if (((a_bits >> 23) & 1) != 0) { | 2452 if (((a_bits >> 23) & 1) != 0) { |
2453 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) | 2453 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) |
2454 scaled = (static_cast<uint64_t>(0x3fd) << 52) | | 2454 scaled = (static_cast<uint64_t>(0x3fd) << 52) | |
2455 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 2455 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
2456 } else { | 2456 } else { |
2457 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) | 2457 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) |
(...skipping 30 matching lines...) Expand all Loading... |
2488 // result = 0 : result_exp<7:0> : estimate<51:29> | 2488 // result = 0 : result_exp<7:0> : estimate<51:29> |
2489 int32_t result_bits = ((result_exp & 0xff) << 23) | | 2489 int32_t result_bits = ((result_exp & 0xff) << 23) | |
2490 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); | 2490 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); |
2491 return bit_cast<float, int32_t>(result_bits); | 2491 return bit_cast<float, int32_t>(result_bits); |
2492 } | 2492 } |
2493 | 2493 |
2494 | 2494 |
2495 static float arm_recip_estimate(float a) { | 2495 static float arm_recip_estimate(float a) { |
2496 // From the ARM Architecture Reference Manual A2-85. | 2496 // From the ARM Architecture Reference Manual A2-85. |
2497 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 2497 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; |
2498 else if (a == 0.0) return INFINITY; | 2498 else if (a == 0.0) return kPosInfinity; |
2499 else if (isnan(a)) return a; | 2499 else if (isnan(a)) return a; |
2500 | 2500 |
2501 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 2501 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
2502 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) | 2502 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) |
2503 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | | 2503 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | |
2504 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 2504 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
2505 // result_exp = 253 - UInt(a<30:23>) | 2505 // result_exp = 253 - UInt(a<30:23>) |
2506 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); | 2506 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); |
2507 ASSERT((result_exp >= 1) && (result_exp <= 252)); | 2507 ASSERT((result_exp >= 1) && (result_exp <= 252)); |
2508 | 2508 |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3057 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); | 3057 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); |
3058 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); | 3058 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); |
3059 buf->Longjmp(); | 3059 buf->Longjmp(); |
3060 } | 3060 } |
3061 | 3061 |
3062 } // namespace dart | 3062 } // namespace dart |
3063 | 3063 |
3064 #endif // !defined(HOST_ARCH_ARM64) | 3064 #endif // !defined(HOST_ARCH_ARM64) |
3065 | 3065 |
3066 #endif // defined TARGET_ARCH_ARM64 | 3066 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |