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

Unified Diff: src/utils.h

Issue 1193433002: MIPS: Fix unaligned memory access. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moved to utils.h Created 5 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 | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index 8b2f1137e0fa708a0701440a048120aedf8ec2d8..dfdf384587e6293b3c316f90c5db4f01feb37428 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1708,6 +1708,41 @@ inline uintptr_t GetCurrentStackPosition() {
return limit;
}
+static inline double ReadDoubleValue(const void* p) {
+#ifndef V8_TARGET_ARCH_MIPS
+ return *reinterpret_cast<const double*>(p);
+#else // V8_TARGET_ARCH_MIPS
+ // Prevent compiler from using load-double (mips ldc1) on (possibly)
+ // non-64-bit aligned address.
+ union conversion {
+ double d;
+ uint32_t u[2];
+ } c;
+ const uint32_t* ptr = reinterpret_cast<const uint32_t*>(p);
+ c.u[0] = *ptr;
+ c.u[1] = *(ptr + 1);
+ return c.d;
+#endif // V8_TARGET_ARCH_MIPS
+}
+
+
+static inline void WriteDoubleValue(void* p, double value) {
+#ifndef V8_TARGET_ARCH_MIPS
+ *(reinterpret_cast<double*>(p)) = value;
+#else // V8_TARGET_ARCH_MIPS
+ // Prevent compiler from using load-double (mips sdc1) on (possibly)
+ // non-64-bit aligned address.
+ union conversion {
+ double d;
+ uint32_t u[2];
+ } c;
+ c.d = value;
+ uint32_t* ptr = reinterpret_cast<uint32_t*>(p);
+ *ptr = c.u[0];
+ *(ptr + 1) = c.u[1];
+#endif // V8_TARGET_ARCH_MIPS
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698