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

Unified Diff: src/utils.h

Issue 1423373004: MIPS: Fix unaligned read of bytecodes in interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 1 month 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/interpreter/bytecodes.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | 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 0426ce51cb7dd1ea5e49663fb4c71dcc1a6a8b2f..1fe6a3213c776251dd96121f242ef363d49f0c60 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1734,6 +1734,42 @@ static inline void WriteDoubleValue(void* p, double value) {
#endif // V8_TARGET_ARCH_MIPS
}
+
+static inline uint16_t ReadUnalignedUInt16(const void* p) {
+#if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64)
+ return *reinterpret_cast<const uint16_t*>(p);
+#else // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
+ // Prevent compiler from using load-half (mips lh) on (possibly)
+ // non-16-bit aligned address.
+ union conversion {
+ uint16_t h;
+ uint8_t b[2];
+ } c;
+ const uint8_t* ptr = reinterpret_cast<const uint8_t*>(p);
+ c.b[0] = *ptr;
+ c.b[1] = *(ptr + 1);
+ return c.h;
+#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
+}
+
+
+static inline void WriteUnalignedUInt16(void* p, uint16_t value) {
+#if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64)
+ *(reinterpret_cast<uint16_t*>(p)) = value;
+#else // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
+ // Prevent compiler from using store-half (mips sh) on (possibly)
+ // non-16-bit aligned address.
+ union conversion {
+ uint16_t h;
+ uint8_t b[2];
+ } c;
+ c.h = value;
+ uint8_t* ptr = reinterpret_cast<uint8_t*>(p);
+ *ptr = c.b[0];
+ *(ptr + 1) = c.b[1];
+#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698