| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef V8_UTILS_H_ | 5 #ifndef V8_UTILS_H_ | 
| 6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ | 
| 7 | 7 | 
| 8 #include <limits.h> | 8 #include <limits.h> | 
| 9 #include <stdlib.h> | 9 #include <stdlib.h> | 
| 10 #include <string.h> | 10 #include <string.h> | 
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 193 | 193 | 
| 194 | 194 | 
| 195 // Floor(-0.0) == 0.0 | 195 // Floor(-0.0) == 0.0 | 
| 196 inline double Floor(double x) { | 196 inline double Floor(double x) { | 
| 197 #if V8_CC_MSVC | 197 #if V8_CC_MSVC | 
| 198   if (x == 0) return x;  // Fix for issue 3477. | 198   if (x == 0) return x;  // Fix for issue 3477. | 
| 199 #endif | 199 #endif | 
| 200   return std::floor(x); | 200   return std::floor(x); | 
| 201 } | 201 } | 
| 202 | 202 | 
| 203 // Implements the ES5 SameValue operation for floating point types. |  | 
| 204 // http://www.ecma-international.org/ecma-262/6.0/#sec-samevalue |  | 
| 205 template <typename T> |  | 
| 206 bool SameValue(T x, T y) { |  | 
| 207   // SameValue(NaN, NaN) is true. |  | 
| 208   if (x != y) return std::isnan(x) && std::isnan(y); |  | 
| 209   // SameValue(0, -0) is false. |  | 
| 210   if (std::signbit(x) != std::signbit(y)) return false; |  | 
| 211   return true; |  | 
| 212 } |  | 
| 213 |  | 
| 214 |  | 
| 215 // Implements the ES6 SameValueZero operation for floating point types. |  | 
| 216 // http://www.ecma-international.org/ecma-262/6.0/#sec-samevaluezero |  | 
| 217 template <typename T> |  | 
| 218 bool SameValueZero(T x, T y) { |  | 
| 219   if (x != y) return std::isnan(x) && std::isnan(y); |  | 
| 220   // SameValueZero doesn't distinguish between 0 and -0. |  | 
| 221   return true; |  | 
| 222 } |  | 
| 223 |  | 
| 224 | 203 | 
| 225 // TODO(svenpanne) Clean up the whole power-of-2 mess. | 204 // TODO(svenpanne) Clean up the whole power-of-2 mess. | 
| 226 inline int32_t WhichPowerOf2Abs(int32_t x) { | 205 inline int32_t WhichPowerOf2Abs(int32_t x) { | 
| 227   return (x == kMinInt) ? 31 : WhichPowerOf2(Abs(x)); | 206   return (x == kMinInt) ? 31 : WhichPowerOf2(Abs(x)); | 
| 228 } | 207 } | 
| 229 | 208 | 
| 230 | 209 | 
| 231 // Obtains the unsigned type corresponding to T | 210 // Obtains the unsigned type corresponding to T | 
| 232 // available in C++11 as std::make_unsigned | 211 // available in C++11 as std::make_unsigned | 
| 233 template<typename T> | 212 template<typename T> | 
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1769   uint32_t* ptr = reinterpret_cast<uint32_t*>(p); | 1748   uint32_t* ptr = reinterpret_cast<uint32_t*>(p); | 
| 1770   *ptr = c.u[0]; | 1749   *ptr = c.u[0]; | 
| 1771   *(ptr + 1) = c.u[1]; | 1750   *(ptr + 1) = c.u[1]; | 
| 1772 #endif  // V8_TARGET_ARCH_MIPS | 1751 #endif  // V8_TARGET_ARCH_MIPS | 
| 1773 } | 1752 } | 
| 1774 | 1753 | 
| 1775 }  // namespace internal | 1754 }  // namespace internal | 
| 1776 }  // namespace v8 | 1755 }  // namespace v8 | 
| 1777 | 1756 | 
| 1778 #endif  // V8_UTILS_H_ | 1757 #endif  // V8_UTILS_H_ | 
| OLD | NEW | 
|---|