Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Side by Side Diff: runtime/vm/simulator_arm.cc

Issue 353403004: Fixes Android build by using C++ math header instead of C one. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.
6 #include <setjmp.h> 5 #include <setjmp.h>
7 #include <stdlib.h> 6 #include <stdlib.h>
8 7
9 #include "vm/globals.h" 8 #include "vm/globals.h"
10 #if defined(TARGET_ARCH_ARM) 9 #if defined(TARGET_ARCH_ARM)
11 10
12 // Only build the simulator if not compiling for real ARM hardware. 11 // Only build the simulator if not compiling for real ARM hardware.
13 #if !defined(HOST_ARCH_ARM) 12 #if !defined(HOST_ARCH_ARM)
14 13
15 #include "vm/simulator.h" 14 #include "vm/simulator.h"
(...skipping 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 if (instr->Bit(8) == 0) { // vcmps 2645 if (instr->Bit(8) == 0) { // vcmps
2647 float sd_val = get_sregister(sd); 2646 float sd_val = get_sregister(sd);
2648 float sm_val; 2647 float sm_val;
2649 if (instr->Bit(16) == 0) { 2648 if (instr->Bit(16) == 0) {
2650 // Format(instr, "vcmps'cond 'sd, 'sm"); 2649 // Format(instr, "vcmps'cond 'sd, 'sm");
2651 sm_val = get_sregister(sm); 2650 sm_val = get_sregister(sm);
2652 } else { 2651 } else {
2653 // Format(instr, "vcmps'cond 'sd, #0.0"); 2652 // Format(instr, "vcmps'cond 'sd, #0.0");
2654 sm_val = 0.0f; 2653 sm_val = 0.0f;
2655 } 2654 }
2656 if (isnan(sd_val) || isnan(sm_val)) { 2655 if (std::isnan(sd_val) || std::isnan(sm_val)) {
2657 fp_c_flag_ = true; 2656 fp_c_flag_ = true;
2658 fp_v_flag_ = true; 2657 fp_v_flag_ = true;
2659 } else if (sd_val == sm_val) { 2658 } else if (sd_val == sm_val) {
2660 fp_z_flag_ = true; 2659 fp_z_flag_ = true;
2661 fp_c_flag_ = true; 2660 fp_c_flag_ = true;
2662 } else if (sd_val < sm_val) { 2661 } else if (sd_val < sm_val) {
2663 fp_n_flag_ = true; 2662 fp_n_flag_ = true;
2664 } else { 2663 } else {
2665 fp_c_flag_ = true; 2664 fp_c_flag_ = true;
2666 } 2665 }
2667 } else { // vcmpd 2666 } else { // vcmpd
2668 double dd_val = get_dregister(dd); 2667 double dd_val = get_dregister(dd);
2669 double dm_val; 2668 double dm_val;
2670 if (instr->Bit(16) == 0) { 2669 if (instr->Bit(16) == 0) {
2671 // Format(instr, "vcmpd'cond 'dd, 'dm"); 2670 // Format(instr, "vcmpd'cond 'dd, 'dm");
2672 dm_val = get_dregister(dm); 2671 dm_val = get_dregister(dm);
2673 } else { 2672 } else {
2674 // Format(instr, "vcmpd'cond 'dd, #0.0"); 2673 // Format(instr, "vcmpd'cond 'dd, #0.0");
2675 dm_val = 0.0; 2674 dm_val = 0.0;
2676 } 2675 }
2677 if (isnan(dd_val) || isnan(dm_val)) { 2676 if (std::isnan(dd_val) || std::isnan(dm_val)) {
2678 fp_c_flag_ = true; 2677 fp_c_flag_ = true;
2679 fp_v_flag_ = true; 2678 fp_v_flag_ = true;
2680 } else if (dd_val == dm_val) { 2679 } else if (dd_val == dm_val) {
2681 fp_z_flag_ = true; 2680 fp_z_flag_ = true;
2682 fp_c_flag_ = true; 2681 fp_c_flag_ = true;
2683 } else if (dd_val < dm_val) { 2682 } else if (dd_val < dm_val) {
2684 fp_n_flag_ = true; 2683 fp_n_flag_ = true;
2685 } else { 2684 } else {
2686 fp_c_flag_ = true; 2685 fp_c_flag_ = true;
2687 } 2686 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2774 ud_val = INT_MAX; 2773 ud_val = INT_MAX;
2775 } else if (dm_val > 0.0) { 2774 } else if (dm_val > 0.0) {
2776 ud_val = static_cast<uint32_t>(dm_val); 2775 ud_val = static_cast<uint32_t>(dm_val);
2777 } 2776 }
2778 } else { 2777 } else {
2779 // Format(instr, "vcvtid'cond 'sd, 'dm"); 2778 // Format(instr, "vcvtid'cond 'sd, 'dm");
2780 if (dm_val <= INT_MIN) { 2779 if (dm_val <= INT_MIN) {
2781 id_val = INT_MIN; 2780 id_val = INT_MIN;
2782 } else if (dm_val >= INT_MAX) { 2781 } else if (dm_val >= INT_MAX) {
2783 id_val = INT_MAX; 2782 id_val = INT_MAX;
2784 } else if (isnan(dm_val)) { 2783 } else if (std::isnan(dm_val)) {
2785 id_val = 0; 2784 id_val = 0;
2786 } else { 2785 } else {
2787 id_val = static_cast<int32_t>(dm_val); 2786 id_val = static_cast<int32_t>(dm_val);
2788 } 2787 }
2789 ASSERT((id_val >= 0) || !(dm_val >= 0.0)); 2788 ASSERT((id_val >= 0) || !(dm_val >= 0.0));
2790 } 2789 }
2791 } 2790 }
2792 int32_t sd_val; 2791 int32_t sd_val;
2793 if (instr->Bit(16) == 0) { 2792 if (instr->Bit(16) == 0) {
2794 sd_val = static_cast<int32_t>(ud_val); 2793 sd_val = static_cast<int32_t>(ud_val);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 } 2836 }
2838 } 2837 }
2839 } else { 2838 } else {
2840 UnimplementedInstruction(instr); 2839 UnimplementedInstruction(instr);
2841 } 2840 }
2842 } 2841 }
2843 2842
2844 2843
2845 static float arm_reciprocal_sqrt_estimate(float a) { 2844 static float arm_reciprocal_sqrt_estimate(float a) {
2846 // From the ARM Architecture Reference Manual A2-87. 2845 // From the ARM Architecture Reference Manual A2-87.
2847 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; 2846 if (std::isinf(a) || (fabs(a) >= exp2f(126))) return 0.0;
2848 else if (a == 0.0) return INFINITY; 2847 else if (a == 0.0) return INFINITY;
2849 else if (isnan(a)) return a; 2848 else if (std::isnan(a)) return a;
2850 2849
2851 uint32_t a_bits = bit_cast<uint32_t, float>(a); 2850 uint32_t a_bits = bit_cast<uint32_t, float>(a);
2852 uint64_t scaled; 2851 uint64_t scaled;
2853 if (((a_bits >> 23) & 1) != 0) { 2852 if (((a_bits >> 23) & 1) != 0) {
2854 // scaled = '0 01111111101' : operand<22:0> : Zeros(29) 2853 // scaled = '0 01111111101' : operand<22:0> : Zeros(29)
2855 scaled = (static_cast<uint64_t>(0x3fd) << 52) | 2854 scaled = (static_cast<uint64_t>(0x3fd) << 52) |
2856 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); 2855 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29);
2857 } else { 2856 } else {
2858 // scaled = '0 01111111110' : operand<22:0> : Zeros(29) 2857 // scaled = '0 01111111110' : operand<22:0> : Zeros(29)
2859 scaled = (static_cast<uint64_t>(0x3fe) << 52) | 2858 scaled = (static_cast<uint64_t>(0x3fe) << 52) |
(...skipping 28 matching lines...) Expand all
2888 2887
2889 // result = 0 : result_exp<7:0> : estimate<51:29> 2888 // result = 0 : result_exp<7:0> : estimate<51:29>
2890 int32_t result_bits = ((result_exp & 0xff) << 23) | 2889 int32_t result_bits = ((result_exp & 0xff) << 23) |
2891 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff); 2890 ((bit_cast<uint64_t, double>(estimate) >> 29) & 0x7fffff);
2892 return bit_cast<float, int32_t>(result_bits); 2891 return bit_cast<float, int32_t>(result_bits);
2893 } 2892 }
2894 2893
2895 2894
2896 static float arm_recip_estimate(float a) { 2895 static float arm_recip_estimate(float a) {
2897 // From the ARM Architecture Reference Manual A2-85. 2896 // From the ARM Architecture Reference Manual A2-85.
2898 if (isinf(a) || (fabs(a) >= exp2f(126))) return 0.0; 2897 if (std::isinf(a) || (fabs(a) >= exp2f(126))) return 0.0;
2899 else if (a == 0.0) return INFINITY; 2898 else if (a == 0.0) return INFINITY;
2900 else if (isnan(a)) return a; 2899 else if (std::isnan(a)) return a;
2901 2900
2902 uint32_t a_bits = bit_cast<uint32_t, float>(a); 2901 uint32_t a_bits = bit_cast<uint32_t, float>(a);
2903 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29) 2902 // scaled = '0011 1111 1110' : a<22:0> : Zeros(29)
2904 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) | 2903 uint64_t scaled = (static_cast<uint64_t>(0x3fe) << 52) |
2905 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29); 2904 ((static_cast<uint64_t>(a_bits) & 0x7fffff) << 29);
2906 // result_exp = 253 - UInt(a<30:23>) 2905 // result_exp = 253 - UInt(a<30:23>)
2907 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff); 2906 int32_t result_exp = 253 - ((a_bits >> 23) & 0xff);
2908 ASSERT((result_exp >= 1) && (result_exp <= 252)); 2907 ASSERT((result_exp >= 1) && (result_exp <= 252));
2909 2908
2910 double scaled_d = bit_cast<double, uint64_t>(scaled); 2909 double scaled_d = bit_cast<double, uint64_t>(scaled);
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
3719 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); 3718 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception));
3720 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); 3719 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace));
3721 buf->Longjmp(); 3720 buf->Longjmp();
3722 } 3721 }
3723 3722
3724 } // namespace dart 3723 } // namespace dart
3725 3724
3726 #endif // !defined(HOST_ARCH_ARM) 3725 #endif // !defined(HOST_ARCH_ARM)
3727 3726
3728 #endif // defined TARGET_ARCH_ARM 3727 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698