Chromium Code Reviews| Index: runtime/vm/object.h |
| diff --git a/runtime/vm/object.h b/runtime/vm/object.h |
| index 8138adba3c072b30673499a82b309e0e05b0caf1..8d3e64de6af5797346433b72203b56c31a03ecc9 100644 |
| --- a/runtime/vm/object.h |
| +++ b/runtime/vm/object.h |
| @@ -7933,11 +7933,13 @@ class TypedData : public Instance { |
| #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)); \ |
|
zra
2016/11/01 21:46:01
Should we specialize this by architecture?
Cutch
2016/11/01 21:48:21
+1 We should avoid calling memmove on architecture
|
| + 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)); \ |
| } |
| TYPED_GETTER_SETTER(Int8, int8_t) |
| TYPED_GETTER_SETTER(Uint8, uint8_t) |