OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2853 default: UNIMPLEMENTED(); | 2853 default: UNIMPLEMENTED(); |
2854 } | 2854 } |
2855 } | 2855 } |
2856 | 2856 |
2857 | 2857 |
2858 template <typename T> | 2858 template <typename T> |
2859 T Simulator::FPAdd(T op1, T op2) { | 2859 T Simulator::FPAdd(T op1, T op2) { |
2860 // NaNs should be handled elsewhere. | 2860 // NaNs should be handled elsewhere. |
2861 ASSERT(!std::isnan(op1) && !std::isnan(op2)); | 2861 ASSERT(!std::isnan(op1) && !std::isnan(op2)); |
2862 | 2862 |
2863 if (isinf(op1) && isinf(op2) && (op1 != op2)) { | 2863 if (std::isinf(op1) && std::isinf(op2) && (op1 != op2)) { |
2864 // inf + -inf returns the default NaN. | 2864 // inf + -inf returns the default NaN. |
2865 return FPDefaultNaN<T>(); | 2865 return FPDefaultNaN<T>(); |
2866 } else { | 2866 } else { |
2867 // Other cases should be handled by standard arithmetic. | 2867 // Other cases should be handled by standard arithmetic. |
2868 return op1 + op2; | 2868 return op1 + op2; |
2869 } | 2869 } |
2870 } | 2870 } |
2871 | 2871 |
2872 | 2872 |
2873 template <typename T> | 2873 template <typename T> |
2874 T Simulator::FPDiv(T op1, T op2) { | 2874 T Simulator::FPDiv(T op1, T op2) { |
2875 // NaNs should be handled elsewhere. | 2875 // NaNs should be handled elsewhere. |
2876 ASSERT(!std::isnan(op1) && !std::isnan(op2)); | 2876 ASSERT(!std::isnan(op1) && !std::isnan(op2)); |
2877 | 2877 |
2878 if ((isinf(op1) && isinf(op2)) || ((op1 == 0.0) && (op2 == 0.0))) { | 2878 if ((std::isinf(op1) && std::isinf(op2)) || ((op1 == 0.0) && (op2 == 0.0))) { |
2879 // inf / inf and 0.0 / 0.0 return the default NaN. | 2879 // inf / inf and 0.0 / 0.0 return the default NaN. |
2880 return FPDefaultNaN<T>(); | 2880 return FPDefaultNaN<T>(); |
2881 } else { | 2881 } else { |
2882 // Other cases should be handled by standard arithmetic. | 2882 // Other cases should be handled by standard arithmetic. |
2883 return op1 / op2; | 2883 return op1 / op2; |
2884 } | 2884 } |
2885 } | 2885 } |
2886 | 2886 |
2887 | 2887 |
2888 template <typename T> | 2888 template <typename T> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2929 | 2929 |
2930 template <typename T> | 2930 template <typename T> |
2931 T Simulator::FPMinNM(T a, T b) { | 2931 T Simulator::FPMinNM(T a, T b) { |
2932 if (IsQuietNaN(a) && !IsQuietNaN(b)) { | 2932 if (IsQuietNaN(a) && !IsQuietNaN(b)) { |
2933 a = kFP64PositiveInfinity; | 2933 a = kFP64PositiveInfinity; |
2934 } else if (!IsQuietNaN(a) && IsQuietNaN(b)) { | 2934 } else if (!IsQuietNaN(a) && IsQuietNaN(b)) { |
2935 b = kFP64PositiveInfinity; | 2935 b = kFP64PositiveInfinity; |
2936 } | 2936 } |
2937 | 2937 |
2938 T result = FPProcessNaNs(a, b); | 2938 T result = FPProcessNaNs(a, b); |
2939 return isnan(result) ? result : FPMin(a, b); | 2939 return std::isnan(result) ? result : FPMin(a, b); |
2940 } | 2940 } |
2941 | 2941 |
2942 | 2942 |
2943 template <typename T> | 2943 template <typename T> |
2944 T Simulator::FPMul(T op1, T op2) { | 2944 T Simulator::FPMul(T op1, T op2) { |
2945 // NaNs should be handled elsewhere. | 2945 // NaNs should be handled elsewhere. |
2946 ASSERT(!std::isnan(op1) && !std::isnan(op2)); | 2946 ASSERT(!std::isnan(op1) && !std::isnan(op2)); |
2947 | 2947 |
2948 if ((isinf(op1) && (op2 == 0.0)) || (isinf(op2) && (op1 == 0.0))) { | 2948 if ((std::isinf(op1) && (op2 == 0.0)) || (std::isinf(op2) && (op1 == 0.0))) { |
2949 // inf * 0.0 returns the default NaN. | 2949 // inf * 0.0 returns the default NaN. |
2950 return FPDefaultNaN<T>(); | 2950 return FPDefaultNaN<T>(); |
2951 } else { | 2951 } else { |
2952 // Other cases should be handled by standard arithmetic. | 2952 // Other cases should be handled by standard arithmetic. |
2953 return op1 * op2; | 2953 return op1 * op2; |
2954 } | 2954 } |
2955 } | 2955 } |
2956 | 2956 |
2957 | 2957 |
2958 template<typename T> | 2958 template<typename T> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3010 return std::sqrt(op); | 3010 return std::sqrt(op); |
3011 } | 3011 } |
3012 } | 3012 } |
3013 | 3013 |
3014 | 3014 |
3015 template <typename T> | 3015 template <typename T> |
3016 T Simulator::FPSub(T op1, T op2) { | 3016 T Simulator::FPSub(T op1, T op2) { |
3017 // NaNs should be handled elsewhere. | 3017 // NaNs should be handled elsewhere. |
3018 ASSERT(!std::isnan(op1) && !std::isnan(op2)); | 3018 ASSERT(!std::isnan(op1) && !std::isnan(op2)); |
3019 | 3019 |
3020 if (isinf(op1) && isinf(op2) && (op1 == op2)) { | 3020 if (std::isinf(op1) && std::isinf(op2) && (op1 == op2)) { |
3021 // inf - inf returns the default NaN. | 3021 // inf - inf returns the default NaN. |
3022 return FPDefaultNaN<T>(); | 3022 return FPDefaultNaN<T>(); |
3023 } else { | 3023 } else { |
3024 // Other cases should be handled by standard arithmetic. | 3024 // Other cases should be handled by standard arithmetic. |
3025 return op1 - op2; | 3025 return op1 - op2; |
3026 } | 3026 } |
3027 } | 3027 } |
3028 | 3028 |
3029 | 3029 |
3030 template <typename T> | 3030 template <typename T> |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3637 default: | 3637 default: |
3638 UNIMPLEMENTED(); | 3638 UNIMPLEMENTED(); |
3639 } | 3639 } |
3640 } | 3640 } |
3641 | 3641 |
3642 #endif // USE_SIMULATOR | 3642 #endif // USE_SIMULATOR |
3643 | 3643 |
3644 } } // namespace v8::internal | 3644 } } // namespace v8::internal |
3645 | 3645 |
3646 #endif // V8_TARGET_ARCH_ARM64 | 3646 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |