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 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1727 double d; | 1727 double d; |
1728 uint32_t u[2]; | 1728 uint32_t u[2]; |
1729 } c; | 1729 } c; |
1730 c.d = value; | 1730 c.d = value; |
1731 uint32_t* ptr = reinterpret_cast<uint32_t*>(p); | 1731 uint32_t* ptr = reinterpret_cast<uint32_t*>(p); |
1732 *ptr = c.u[0]; | 1732 *ptr = c.u[0]; |
1733 *(ptr + 1) = c.u[1]; | 1733 *(ptr + 1) = c.u[1]; |
1734 #endif // V8_TARGET_ARCH_MIPS | 1734 #endif // V8_TARGET_ARCH_MIPS |
1735 } | 1735 } |
1736 | 1736 |
1737 | |
1738 static inline uint16_t ReadShortValue(const void* p) { | |
1739 #ifndef V8_TARGET_ARCH_MIPS | |
paul.l...
2015/10/30 17:40:32
This needs to be done for MIPS64 also (unlike the
akos.palfi.imgtec
2015/10/30 22:26:32
Done.
| |
1740 return *reinterpret_cast<uint6_t*>(p); | |
1741 #else // V8_TARGET_ARCH_MIPS | |
1742 // Prevent compiler from using load-half (mips lh) on (possibly) | |
1743 // non-16-bit aligned address. | |
1744 union conversion { | |
1745 uint16_t d; | |
1746 uint8_t u[2]; | |
paul.l...
2015/10/30 17:40:32
the field names should be h and b (for half-word a
akos.palfi.imgtec
2015/10/30 22:26:32
Done.
| |
1747 } c; | |
1748 const uint8_t* ptr = reinterpret_cast<const uint8_t*>(p); | |
1749 c.u[0] = *ptr; | |
1750 c.u[1] = *(ptr + 1); | |
1751 return c.d; | |
1752 #endif // V8_TARGET_ARCH_MIPS | |
1753 } | |
1754 | |
1755 | |
1756 static inline void WriteShortValue(void* p, uint16_t value) { | |
1757 #ifndef V8_TARGET_ARCH_MIPS | |
1758 *(reinterpret_cast<uint16_t*>(p)) = value; | |
1759 #else // V8_TARGET_ARCH_MIPS | |
1760 // Prevent compiler from using store-half (mips sh) on (possibly) | |
1761 // non-16-bit aligned address. | |
1762 union conversion { | |
1763 uint16_t d; | |
1764 uint8_t u[2]; | |
1765 } c; | |
1766 c.d = value; | |
1767 uint8_t* ptr = reinterpret_cast<uint8_t*>(p); | |
1768 *ptr = c.u[0]; | |
1769 *(ptr + 1) = c.u[1]; | |
1770 #endif // V8_TARGET_ARCH_MIPS | |
1771 } | |
1772 | |
1737 } // namespace internal | 1773 } // namespace internal |
1738 } // namespace v8 | 1774 } // namespace v8 |
1739 | 1775 |
1740 #endif // V8_UTILS_H_ | 1776 #endif // V8_UTILS_H_ |
OLD | NEW |