| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_CONVERSIONS_INL_H_ | 5 #ifndef V8_CONVERSIONS_INL_H_ |
| 6 #define V8_CONVERSIONS_INL_H_ | 6 #define V8_CONVERSIONS_INL_H_ |
| 7 | 7 |
| 8 #include <limits.h> // Required for INT_MAX etc. | 8 #include <limits.h> // Required for INT_MAX etc. |
| 9 #include <float.h> // Required for DBL_MAX and on Win32 for finite() | 9 #include <float.h> // Required for DBL_MAX and on Win32 for finite() |
| 10 #include <stdarg.h> | 10 #include <stdarg.h> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 if (x < k2Pow52) { | 52 if (x < k2Pow52) { |
| 53 x += k2Pow52; | 53 x += k2Pow52; |
| 54 uint32_t result; | 54 uint32_t result; |
| 55 #ifndef V8_TARGET_BIG_ENDIAN | 55 #ifndef V8_TARGET_BIG_ENDIAN |
| 56 Address mantissa_ptr = reinterpret_cast<Address>(&x); | 56 Address mantissa_ptr = reinterpret_cast<Address>(&x); |
| 57 #else | 57 #else |
| 58 Address mantissa_ptr = reinterpret_cast<Address>(&x) + kIntSize; | 58 Address mantissa_ptr = reinterpret_cast<Address>(&x) + kIntSize; |
| 59 #endif | 59 #endif |
| 60 // Copy least significant 32 bits of mantissa. | 60 // Copy least significant 32 bits of mantissa. |
| 61 MemCopy(&result, mantissa_ptr, sizeof(result)); | 61 OS::MemCopy(&result, mantissa_ptr, sizeof(result)); |
| 62 return negative ? ~result + 1 : result; | 62 return negative ? ~result + 1 : result; |
| 63 } | 63 } |
| 64 // Large number (outside uint32 range), Infinity or NaN. | 64 // Large number (outside uint32 range), Infinity or NaN. |
| 65 return 0x80000000u; // Return integer indefinite. | 65 return 0x80000000u; // Return integer indefinite. |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 inline double DoubleToInteger(double x) { | 69 inline double DoubleToInteger(double x) { |
| 70 if (std::isnan(x)) return 0; | 70 if (std::isnan(x)) return 0; |
| 71 if (!std::isfinite(x) || x == 0) return x; | 71 if (!std::isfinite(x) || x == 0) return x; |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 SLOW_ASSERT(buffer_pos < kBufferSize); | 676 SLOW_ASSERT(buffer_pos < kBufferSize); |
| 677 buffer[buffer_pos] = '\0'; | 677 buffer[buffer_pos] = '\0'; |
| 678 | 678 |
| 679 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 679 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
| 680 return (sign == NEGATIVE) ? -converted : converted; | 680 return (sign == NEGATIVE) ? -converted : converted; |
| 681 } | 681 } |
| 682 | 682 |
| 683 } } // namespace v8::internal | 683 } } // namespace v8::internal |
| 684 | 684 |
| 685 #endif // V8_CONVERSIONS_INL_H_ | 685 #endif // V8_CONVERSIONS_INL_H_ |
| OLD | NEW |