Commit 7a957510 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

[wasm] Read/Write WasmValue in LE

Use Read/WriteLittleEndianValue call to make sure
we deal with wasm values in the correct endian order
on big endian machine.

Change-Id: I7ede8226319ecfd0605cefa1823e5bbaeb0ebb6a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2752879
Commit-Queue: Junliang Yan <junyan@redhat.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73368}
parent 52ec6165
......@@ -86,20 +86,20 @@ class WasmValue {
public:
WasmValue() : type_(kWasmStmt), bit_pattern_{} {}
#define DEFINE_TYPE_SPECIFIC_METHODS(name, localtype, ctype) \
explicit WasmValue(ctype v) : type_(localtype), bit_pattern_{} { \
static_assert(sizeof(ctype) <= sizeof(bit_pattern_), \
"size too big for WasmValue"); \
base::WriteUnalignedValue<ctype>(reinterpret_cast<Address>(bit_pattern_), \
v); \
} \
ctype to_##name() const { \
DCHECK_EQ(localtype, type_); \
return to_##name##_unchecked(); \
} \
ctype to_##name##_unchecked() const { \
return base::ReadUnalignedValue<ctype>( \
reinterpret_cast<Address>(bit_pattern_)); \
#define DEFINE_TYPE_SPECIFIC_METHODS(name, localtype, ctype) \
explicit WasmValue(ctype v) : type_(localtype), bit_pattern_{} { \
static_assert(sizeof(ctype) <= sizeof(bit_pattern_), \
"size too big for WasmValue"); \
base::WriteLittleEndianValue<ctype>( \
reinterpret_cast<Address>(bit_pattern_), v); \
} \
ctype to_##name() const { \
DCHECK_EQ(localtype, type_); \
return to_##name##_unchecked(); \
} \
ctype to_##name##_unchecked() const { \
return base::ReadLittleEndianValue<ctype>( \
reinterpret_cast<Address>(bit_pattern_)); \
}
FOREACH_PRIMITIVE_WASMVAL_TYPE(DEFINE_TYPE_SPECIFIC_METHODS)
#undef DEFINE_TYPE_SPECIFIC_METHODS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment