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

Unified Diff: src/wasm/decoder.h

Issue 2034093002: Implement WASM big-endian support (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Small fixes. Rebase to master Created 4 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/utils.h ('k') | src/wasm/encoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/decoder.h
diff --git a/src/wasm/decoder.h b/src/wasm/decoder.h
index 9136fa511d4e3bb562e50612dc944c444d74a3ca..cc8024c82fe050061decb70dff226107bfaad0e3 100644
--- a/src/wasm/decoder.h
+++ b/src/wasm/decoder.h
@@ -26,12 +26,6 @@ namespace wasm {
#define TRACE(...)
#endif
-#if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_ARM)
-#define UNALIGNED_ACCESS_OK 1
-#else
-#define UNALIGNED_ACCESS_OK 0
-#endif
-
// A helper utility to decode bytes, integers, fields, varints, etc, from
// a buffer of bytes.
class Decoder {
@@ -122,47 +116,19 @@ class Decoder {
// Reads a single 16-bit unsigned integer (little endian).
inline uint16_t read_u16(const byte* ptr) {
DCHECK(ptr >= start_ && (ptr + 2) <= end_);
-#if V8_TARGET_LITTLE_ENDIAN && UNALIGNED_ACCESS_OK
- return *reinterpret_cast<const uint16_t*>(ptr);
-#else
- uint16_t b0 = ptr[0];
- uint16_t b1 = ptr[1];
- return (b1 << 8) | b0;
-#endif
+ return ReadLittleEndianValue<uint16_t>(ptr);
}
// Reads a single 32-bit unsigned integer (little endian).
inline uint32_t read_u32(const byte* ptr) {
DCHECK(ptr >= start_ && (ptr + 4) <= end_);
-#if V8_TARGET_LITTLE_ENDIAN && UNALIGNED_ACCESS_OK
- return *reinterpret_cast<const uint32_t*>(ptr);
-#else
- uint32_t b0 = ptr[0];
- uint32_t b1 = ptr[1];
- uint32_t b2 = ptr[2];
- uint32_t b3 = ptr[3];
- return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
-#endif
+ return ReadLittleEndianValue<uint32_t>(ptr);
}
// Reads a single 64-bit unsigned integer (little endian).
inline uint64_t read_u64(const byte* ptr) {
DCHECK(ptr >= start_ && (ptr + 8) <= end_);
-#if V8_TARGET_LITTLE_ENDIAN && UNALIGNED_ACCESS_OK
- return *reinterpret_cast<const uint64_t*>(ptr);
-#else
- uint32_t b0 = ptr[0];
- uint32_t b1 = ptr[1];
- uint32_t b2 = ptr[2];
- uint32_t b3 = ptr[3];
- uint32_t low = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
- uint32_t b4 = ptr[4];
- uint32_t b5 = ptr[5];
- uint32_t b6 = ptr[6];
- uint32_t b7 = ptr[7];
- uint64_t high = (b7 << 24) | (b6 << 16) | (b5 << 8) | b4;
- return (high << 32) | low;
-#endif
+ return ReadLittleEndianValue<uint64_t>(ptr);
}
// Reads a 8-bit unsigned integer (byte) and advances {pc_}.
« no previous file with comments | « src/utils.h ('k') | src/wasm/encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698