Chromium Code Reviews| Index: runtime/vm/object.h |
| diff --git a/runtime/vm/object.h b/runtime/vm/object.h |
| index 8138adba3c072b30673499a82b309e0e05b0caf1..4fce97ae728daea592293b9cb1d52f1400d308ff 100644 |
| --- a/runtime/vm/object.h |
| +++ b/runtime/vm/object.h |
| @@ -7930,15 +7930,32 @@ class TypedData : public Instance { |
| virtual bool CanonicalizeEquals(const Instance& other) const; |
| virtual uword ComputeCanonicalTableHash() const; |
| +#if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) |
| #define TYPED_GETTER_SETTER(name, type) \ |
| type Get##name(intptr_t byte_offset) const { \ |
| NoSafepointScope no_safepoint; \ |
| - return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ |
| + type result; \ |
| + memmove(&result, DataAddr(byte_offset), sizeof(type)); \ |
|
Cutch
2016/11/01 22:45:09
You are still calling memmove on IA32/X64.
rmacnak
2016/11/01 23:25:15
Oops, fixed.
|
| + return result; \ |
| } \ |
| void Set##name(intptr_t byte_offset, type value) const { \ |
| NoSafepointScope no_safepoint; \ |
| - *reinterpret_cast<type*>(DataAddr(byte_offset)) = value; \ |
| + memmove(DataAddr(byte_offset), &value, sizeof(type)); \ |
| + } |
| +#else // defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) |
| +#define TYPED_GETTER_SETTER(name, type) \ |
| + type Get##name(intptr_t byte_offset) const { \ |
| + NoSafepointScope no_safepoint; \ |
| + type result; \ |
| + memmove(&result, DataAddr(byte_offset), sizeof(type)); \ |
| + return result; \ |
| + } \ |
| + void Set##name(intptr_t byte_offset, type value) const { \ |
| + NoSafepointScope no_safepoint; \ |
| + memmove(DataAddr(byte_offset), &value, sizeof(type)); \ |
| } |
| +#endif // defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) |
| + |
| TYPED_GETTER_SETTER(Int8, int8_t) |
| TYPED_GETTER_SETTER(Uint8, uint8_t) |
| TYPED_GETTER_SETTER(Int16, int16_t) |