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 3502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3513 EXPECT(test != NULL); | 3513 EXPECT(test != NULL); |
3514 typedef int (*Tst)() DART_UNUSED; | 3514 typedef int (*Tst)() DART_UNUSED; |
3515 EXPECT_EQ(14, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); | 3515 EXPECT_EQ(14, EXECUTE_TEST_CODE_INT32(Tst, test->entry())); |
3516 } | 3516 } |
3517 | 3517 |
3518 | 3518 |
3519 // This is the same function as in the Simulator. | 3519 // This is the same function as in the Simulator. |
3520 static float arm_recip_estimate(float a) { | 3520 static float arm_recip_estimate(float a) { |
3521 // From the ARM Architecture Reference Manual A2-85. | 3521 // From the ARM Architecture Reference Manual A2-85. |
3522 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 3522 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; |
3523 else if (a == 0.0) return INFINITY; | 3523 else if (a == 0.0) return kPosInfinity; |
3524 else if (isnan(a)) return a; | 3524 else if (isnan(a)) return a; |
3525 | 3525 |
3526 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 3526 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
3527 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) | 3527 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) |
3528 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | | 3528 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | |
3529 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 3529 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
3530 // result_exp = 253 - UInt(a<30:23>) | 3530 // result_exp = 253 - UInt(a<30:23>) |
3531 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); | 3531 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); |
3532 ASSERT((result_exp >= 1) && (result_exp <= 252)); | 3532 ASSERT((result_exp >= 1) && (result_exp <= 252)); |
3533 | 3533 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3633 EXPECT(test != NULL); | 3633 EXPECT(test != NULL); |
3634 typedef float (*Reciprocal)() DART_UNUSED; | 3634 typedef float (*Reciprocal)() DART_UNUSED; |
3635 float res = EXECUTE_TEST_CODE_FLOAT(Reciprocal, test->entry()); | 3635 float res = EXECUTE_TEST_CODE_FLOAT(Reciprocal, test->entry()); |
3636 EXPECT_FLOAT_EQ(1.0/147000.0, res, 0.0001f); | 3636 EXPECT_FLOAT_EQ(1.0/147000.0, res, 0.0001f); |
3637 } | 3637 } |
3638 | 3638 |
3639 | 3639 |
3640 static float arm_reciprocal_sqrt_estimate(float a) { | 3640 static float arm_reciprocal_sqrt_estimate(float a) { |
3641 // From the ARM Architecture Reference Manual A2-87. | 3641 // From the ARM Architecture Reference Manual A2-87. |
3642 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; | 3642 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; |
3643 else if (a == 0.0) return INFINITY; | 3643 else if (a == 0.0) return kPosInfinity; |
3644 else if (isnan(a)) return a; | 3644 else if (isnan(a)) return a; |
3645 | 3645 |
3646 uint32_t a_bits = bit_cast<uint32_t, float>(a); | 3646 uint32_t a_bits = bit_cast<uint32_t, float>(a); |
3647 uint64_t scaled; | 3647 uint64_t scaled; |
3648 if (((a_bits >> 23) & 1) != 0) { | 3648 if (((a_bits >> 23) & 1) != 0) { |
3649 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) | 3649 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) |
3650 scaled = (static_cast<uint64_t>(0x3fd) << 52) | | 3650 scaled = (static_cast<uint64_t>(0x3fd) << 52) | |
3651 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); | 3651 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); |
3652 } else { | 3652 } else { |
3653 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) | 3653 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4076 __ StoreIntoObject(R2, | 4076 __ StoreIntoObject(R2, |
4077 FieldAddress(R2, GrowableObjectArray::data_offset()), | 4077 FieldAddress(R2, GrowableObjectArray::data_offset()), |
4078 R1); | 4078 R1); |
4079 __ PopList((1 << CTX) | (1 << LR)); | 4079 __ PopList((1 << CTX) | (1 << LR)); |
4080 __ Ret(); | 4080 __ Ret(); |
4081 } | 4081 } |
4082 | 4082 |
4083 } // namespace dart | 4083 } // namespace dart |
4084 | 4084 |
4085 #endif // defined TARGET_ARCH_ARM | 4085 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |