Chromium Code Reviews| Index: src/IceAssembler.h |
| diff --git a/src/IceAssembler.h b/src/IceAssembler.h |
| index 7f5d909ed30215e46ac81595e035a203a478d047..b007325e7f45053f286d8c3d1cb968cafab460f7 100644 |
| --- a/src/IceAssembler.h |
| +++ b/src/IceAssembler.h |
| @@ -100,20 +100,22 @@ public: |
| /// Basic support for emitting, loading, and storing. |
| template <typename T> void emit(T Value) { |
| assert(hasEnsuredCapacity()); |
| - *reinterpret_cast<T *>(Cursor) = Value; |
| + memcpy(reinterpret_cast<void *>(Cursor), &Value, sizeof(T)); |
|
Jim Stichnoth
2015/09/04 21:32:48
Have you checked the effect of this patch on assem
ascull
2015/09/05 00:00:48
The binary produces is the same before and after t
Jim Stichnoth
2015/09/05 01:03:22
OK, thanks for checking.
|
| Cursor += sizeof(T); |
| } |
| template <typename T> T load(intptr_t Position) const { |
| assert(Position >= 0 && |
| Position <= (size() - static_cast<intptr_t>(sizeof(T)))); |
| - return *reinterpret_cast<T *>(Contents + Position); |
| + T Value; |
| + memcpy(&Value, reinterpret_cast<void *>(Contents + Position), sizeof(T)); |
| + return Value; |
| } |
| template <typename T> void store(intptr_t Position, T Value) { |
| assert(Position >= 0 && |
| Position <= (size() - static_cast<intptr_t>(sizeof(T)))); |
| - *reinterpret_cast<T *>(Contents + Position) = Value; |
| + memcpy(reinterpret_cast<void *>(Contents + Position), &Value, sizeof(T)); |
| } |
| /// Emit a fixup at the current location. |