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 4922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4933 | 4933 |
4934 | 4934 |
4935 static float MinMaxHelper(float n, | 4935 static float MinMaxHelper(float n, |
4936 float m, | 4936 float m, |
4937 bool min, | 4937 bool min, |
4938 float quiet_nan_substitute = 0.0) { | 4938 float quiet_nan_substitute = 0.0) { |
4939 const uint64_t kFP32QuietNaNMask = 0x00400000UL; | 4939 const uint64_t kFP32QuietNaNMask = 0x00400000UL; |
4940 uint32_t raw_n = float_to_rawbits(n); | 4940 uint32_t raw_n = float_to_rawbits(n); |
4941 uint32_t raw_m = float_to_rawbits(m); | 4941 uint32_t raw_m = float_to_rawbits(m); |
4942 | 4942 |
4943 if (isnan(n) && ((raw_n & kFP32QuietNaNMask) == 0)) { | 4943 if (std::isnan(n) && ((raw_n & kFP32QuietNaNMask) == 0)) { |
4944 // n is signalling NaN. | 4944 // n is signalling NaN. |
4945 return n; | 4945 return n; |
4946 } else if (isnan(m) && ((raw_m & kFP32QuietNaNMask) == 0)) { | 4946 } else if (std::isnan(m) && ((raw_m & kFP32QuietNaNMask) == 0)) { |
4947 // m is signalling NaN. | 4947 // m is signalling NaN. |
4948 return m; | 4948 return m; |
4949 } else if (quiet_nan_substitute == 0.0) { | 4949 } else if (quiet_nan_substitute == 0.0) { |
4950 if (isnan(n)) { | 4950 if (std::isnan(n)) { |
4951 // n is quiet NaN. | 4951 // n is quiet NaN. |
4952 return n; | 4952 return n; |
4953 } else if (isnan(m)) { | 4953 } else if (std::isnan(m)) { |
4954 // m is quiet NaN. | 4954 // m is quiet NaN. |
4955 return m; | 4955 return m; |
4956 } | 4956 } |
4957 } else { | 4957 } else { |
4958 // Substitute n or m if one is quiet, but not both. | 4958 // Substitute n or m if one is quiet, but not both. |
4959 if (isnan(n) && !isnan(m)) { | 4959 if (std::isnan(n) && !std::isnan(m)) { |
4960 // n is quiet NaN: replace with substitute. | 4960 // n is quiet NaN: replace with substitute. |
4961 n = quiet_nan_substitute; | 4961 n = quiet_nan_substitute; |
4962 } else if (!isnan(n) && isnan(m)) { | 4962 } else if (!std::isnan(n) && std::isnan(m)) { |
4963 // m is quiet NaN: replace with substitute. | 4963 // m is quiet NaN: replace with substitute. |
4964 m = quiet_nan_substitute; | 4964 m = quiet_nan_substitute; |
4965 } | 4965 } |
4966 } | 4966 } |
4967 | 4967 |
4968 if ((n == 0.0) && (m == 0.0) && | 4968 if ((n == 0.0) && (m == 0.0) && |
4969 (copysign(1.0, n) != copysign(1.0, m))) { | 4969 (copysign(1.0, n) != copysign(1.0, m))) { |
4970 return min ? -0.0 : 0.0; | 4970 return min ? -0.0 : 0.0; |
4971 } | 4971 } |
4972 | 4972 |
4973 return min ? fminf(n, m) : fmaxf(n, m); | 4973 return min ? fminf(n, m) : fmaxf(n, m); |
4974 } | 4974 } |
4975 | 4975 |
4976 | 4976 |
4977 static double MinMaxHelper(double n, | 4977 static double MinMaxHelper(double n, |
4978 double m, | 4978 double m, |
4979 bool min, | 4979 bool min, |
4980 double quiet_nan_substitute = 0.0) { | 4980 double quiet_nan_substitute = 0.0) { |
4981 const uint64_t kFP64QuietNaNMask = 0x0008000000000000UL; | 4981 const uint64_t kFP64QuietNaNMask = 0x0008000000000000UL; |
4982 uint64_t raw_n = double_to_rawbits(n); | 4982 uint64_t raw_n = double_to_rawbits(n); |
4983 uint64_t raw_m = double_to_rawbits(m); | 4983 uint64_t raw_m = double_to_rawbits(m); |
4984 | 4984 |
4985 if (isnan(n) && ((raw_n & kFP64QuietNaNMask) == 0)) { | 4985 if (std::isnan(n) && ((raw_n & kFP64QuietNaNMask) == 0)) { |
4986 // n is signalling NaN. | 4986 // n is signalling NaN. |
4987 return n; | 4987 return n; |
4988 } else if (isnan(m) && ((raw_m & kFP64QuietNaNMask) == 0)) { | 4988 } else if (std::isnan(m) && ((raw_m & kFP64QuietNaNMask) == 0)) { |
4989 // m is signalling NaN. | 4989 // m is signalling NaN. |
4990 return m; | 4990 return m; |
4991 } else if (quiet_nan_substitute == 0.0) { | 4991 } else if (quiet_nan_substitute == 0.0) { |
4992 if (isnan(n)) { | 4992 if (std::isnan(n)) { |
4993 // n is quiet NaN. | 4993 // n is quiet NaN. |
4994 return n; | 4994 return n; |
4995 } else if (isnan(m)) { | 4995 } else if (std::isnan(m)) { |
4996 // m is quiet NaN. | 4996 // m is quiet NaN. |
4997 return m; | 4997 return m; |
4998 } | 4998 } |
4999 } else { | 4999 } else { |
5000 // Substitute n or m if one is quiet, but not both. | 5000 // Substitute n or m if one is quiet, but not both. |
5001 if (isnan(n) && !isnan(m)) { | 5001 if (std::isnan(n) && !std::isnan(m)) { |
5002 // n is quiet NaN: replace with substitute. | 5002 // n is quiet NaN: replace with substitute. |
5003 n = quiet_nan_substitute; | 5003 n = quiet_nan_substitute; |
5004 } else if (!isnan(n) && isnan(m)) { | 5004 } else if (!std::isnan(n) && std::isnan(m)) { |
5005 // m is quiet NaN: replace with substitute. | 5005 // m is quiet NaN: replace with substitute. |
5006 m = quiet_nan_substitute; | 5006 m = quiet_nan_substitute; |
5007 } | 5007 } |
5008 } | 5008 } |
5009 | 5009 |
5010 if ((n == 0.0) && (m == 0.0) && | 5010 if ((n == 0.0) && (m == 0.0) && |
5011 (copysign(1.0, n) != copysign(1.0, m))) { | 5011 (copysign(1.0, n) != copysign(1.0, m))) { |
5012 return min ? -0.0 : 0.0; | 5012 return min ? -0.0 : 0.0; |
5013 } | 5013 } |
5014 | 5014 |
(...skipping 4714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9729 AbsHelperX(-42); | 9729 AbsHelperX(-42); |
9730 AbsHelperX(kXMinInt); | 9730 AbsHelperX(kXMinInt); |
9731 AbsHelperX(kXMaxInt); | 9731 AbsHelperX(kXMaxInt); |
9732 | 9732 |
9733 AbsHelperW(0); | 9733 AbsHelperW(0); |
9734 AbsHelperW(42); | 9734 AbsHelperW(42); |
9735 AbsHelperW(-42); | 9735 AbsHelperW(-42); |
9736 AbsHelperW(kWMinInt); | 9736 AbsHelperW(kWMinInt); |
9737 AbsHelperW(kWMaxInt); | 9737 AbsHelperW(kWMaxInt); |
9738 } | 9738 } |
OLD | NEW |