Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1092)

Unified Diff: runtime/platform/globals.h

Issue 2947783002: Avoid unaligned access fault in Int32x4/Float32x4::value() on ARM. (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/globals.h
diff --git a/runtime/platform/globals.h b/runtime/platform/globals.h
index a18bc8764edef5aefb9fd13b31045cec54d3c514..30491f2e9626cb958efa79ba29086509fb4aba60 100644
--- a/runtime/platform/globals.h
+++ b/runtime/platform/globals.h
@@ -663,6 +663,8 @@ inline D bit_copy(const S& source) {
}
+#if defined(HOST_ARCH_ARM) || defined(HOST_ARCH_MIPS) || \
+ defined(HOST_ARCH_ARM64)
// Similar to bit_copy and bit_cast, but does take the type from the argument.
template <typename T>
static inline T ReadUnaligned(const T* ptr) {
@@ -672,6 +674,27 @@ static inline T ReadUnaligned(const T* ptr) {
}
+// Similar to bit_copy and bit_cast, but does take the type from the argument.
+template <typename T>
+static inline void StoreUnaligned(T* ptr, T value) {
+ memcpy(ptr, &value, sizeof(value));
+}
+#else // !(HOST_ARCH_ARM || HOST_ARCH_MIPS || HOST_ARCH_ARM64)
+// Similar to bit_copy and bit_cast, but does take the type from the argument.
+template <typename T>
+static inline T ReadUnaligned(const T* ptr) {
+ return *ptr;
+}
+
+
+// Similar to bit_copy and bit_cast, but does take the type from the argument.
+template <typename T>
+static inline void StoreUnaligned(T* ptr, T value) {
+ *ptr = value;
+}
+#endif // !(HOST_ARCH_ARM || HOST_ARCH_MIPS || HOST_ARCH_ARM64)
+
+
// On Windows the reentrent version of strtok is called
// strtok_s. Unify on the posix name strtok_r.
#if defined(HOST_OS_WINDOWS)
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698