Index: src/utils.h |
diff --git a/src/utils.h b/src/utils.h |
index 9b94a2feb1de6a7e9fcc8910ec3008e93f4a3bca..8e5ddf8896c7956f0f53f3511297bf8e568f06e8 100644 |
--- a/src/utils.h |
+++ b/src/utils.h |
@@ -1506,22 +1506,22 @@ inline uintptr_t GetCurrentStackPosition() { |
template <typename V> |
static inline V ReadUnalignedValue(const void* p) { |
-#if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64) |
+#if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM) |
return *reinterpret_cast<const V*>(p); |
-#else |
+#else // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM |
V r; |
memmove(&r, p, sizeof(V)); |
return r; |
-#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
+#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM |
} |
template <typename V> |
static inline void WriteUnalignedValue(void* p, V value) { |
-#if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64) |
+#if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM) |
*(reinterpret_cast<V*>(p)) = value; |
-#else // V8_TARGET_ARCH_MIPS |
+#else // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM |
memmove(p, &value, sizeof(V)); |
-#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
+#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM |
} |
static inline double ReadFloatValue(const void* p) { |
@@ -1552,6 +1552,33 @@ static inline void WriteUnalignedUInt32(void* p, uint32_t value) { |
WriteUnalignedValue(p, value); |
} |
+template <typename V> |
+static inline V ReadLittleEndianValue(const void* p) { |
+#if defined(V8_TARGET_LITTLE_ENDIAN) |
+ return ReadUnalignedValue<V>(p); |
+#elif defined(V8_TARGET_BIG_ENDIAN) |
+ V ret = 0; |
+ const byte* src = reinterpret_cast<const byte*>(p); |
+ byte* dst = reinterpret_cast<byte*>(&ret); |
+ for (size_t i = 0; i < sizeof(V); i++) { |
+ dst[i] = src[sizeof(V) - i - 1]; |
+ } |
+ return ret; |
+#endif // V8_TARGET_LITTLE_ENDIAN |
+} |
+ |
+template <typename V> |
+static inline void WriteLittleEndianValue(void* p, V value) { |
+#if defined(V8_TARGET_LITTLE_ENDIAN) |
+ WriteUnalignedValue<V>(p, value); |
+#elif defined(V8_TARGET_BIG_ENDIAN) |
+ byte* src = reinterpret_cast<byte*>(&value); |
+ byte* dst = reinterpret_cast<byte*>(p); |
+ for (size_t i = 0; i < sizeof(V); i++) { |
+ dst[i] = src[sizeof(V) - i - 1]; |
+ } |
+#endif // V8_TARGET_LITTLE_ENDIAN |
+} |
} // namespace internal |
} // namespace v8 |