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 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 | 1701 |
1702 // Returns current value of top of the stack. Works correctly with ASAN. | 1702 // Returns current value of top of the stack. Works correctly with ASAN. |
1703 DISABLE_ASAN | 1703 DISABLE_ASAN |
1704 inline uintptr_t GetCurrentStackPosition() { | 1704 inline uintptr_t GetCurrentStackPosition() { |
1705 // Takes the address of the limit variable in order to find out where | 1705 // Takes the address of the limit variable in order to find out where |
1706 // the top of stack is right now. | 1706 // the top of stack is right now. |
1707 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); | 1707 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); |
1708 return limit; | 1708 return limit; |
1709 } | 1709 } |
1710 | 1710 |
| 1711 static inline double ReadDoubleValue(const void* p) { |
| 1712 #ifndef V8_TARGET_ARCH_MIPS |
| 1713 return *reinterpret_cast<const double*>(p); |
| 1714 #else // V8_TARGET_ARCH_MIPS |
| 1715 // Prevent compiler from using load-double (mips ldc1) on (possibly) |
| 1716 // non-64-bit aligned address. |
| 1717 union conversion { |
| 1718 double d; |
| 1719 uint32_t u[2]; |
| 1720 } c; |
| 1721 const uint32_t* ptr = reinterpret_cast<const uint32_t*>(p); |
| 1722 c.u[0] = *ptr; |
| 1723 c.u[1] = *(ptr + 1); |
| 1724 return c.d; |
| 1725 #endif // V8_TARGET_ARCH_MIPS |
| 1726 } |
| 1727 |
| 1728 |
| 1729 static inline void WriteDoubleValue(void* p, double value) { |
| 1730 #ifndef V8_TARGET_ARCH_MIPS |
| 1731 *(reinterpret_cast<double*>(p)) = value; |
| 1732 #else // V8_TARGET_ARCH_MIPS |
| 1733 // Prevent compiler from using load-double (mips sdc1) on (possibly) |
| 1734 // non-64-bit aligned address. |
| 1735 union conversion { |
| 1736 double d; |
| 1737 uint32_t u[2]; |
| 1738 } c; |
| 1739 c.d = value; |
| 1740 uint32_t* ptr = reinterpret_cast<uint32_t*>(p); |
| 1741 *ptr = c.u[0]; |
| 1742 *(ptr + 1) = c.u[1]; |
| 1743 #endif // V8_TARGET_ARCH_MIPS |
| 1744 } |
| 1745 |
1711 } // namespace internal | 1746 } // namespace internal |
1712 } // namespace v8 | 1747 } // namespace v8 |
1713 | 1748 |
1714 #endif // V8_UTILS_H_ | 1749 #endif // V8_UTILS_H_ |
OLD | NEW |