Index: src/a64/simulator-a64.cc |
diff --git a/src/a64/simulator-a64.cc b/src/a64/simulator-a64.cc |
index e0a0d62a02a695128f50cbc2821c2c776e89401e..f015603ae964fdeedcd16def8f69eddfdf642a1f 100644 |
--- a/src/a64/simulator-a64.cc |
+++ b/src/a64/simulator-a64.cc |
@@ -139,7 +139,7 @@ void Simulator::CallVoid(byte* entry, CallArgument* args) { |
char * stack = reinterpret_cast<char*>(entry_stack); |
std::vector<int64_t>::const_iterator it; |
for (it = stack_args.begin(); it != stack_args.end(); it++) { |
- memcpy(stack, &(*it), sizeof(*it)); |
jbramley
2014/02/19 10:12:22
This copy might not be free because the address ne
|
+ *reinterpret_cast<int64_t*>(stack) = *it; |
stack += sizeof(*it); |
} |
@@ -1469,7 +1469,17 @@ uint64_t Simulator::MemoryRead(uint8_t* address, unsigned num_bytes) { |
ASSERT(address != NULL); |
ASSERT((num_bytes > 0) && (num_bytes <= sizeof(uint64_t))); |
uint64_t read = 0; |
- memcpy(&read, address, num_bytes); |
jbramley
2014/02/19 10:12:22
Again, the size is variable so this copy can't be
|
+ if (num_bytes == 8) { |
+ read = *reinterpret_cast<uint64_t*>(address); |
+ } else if (num_bytes == 4) { |
+ read = *reinterpret_cast<uint32_t*>(address); |
+ } else if (num_bytes == 2) { |
+ read = *reinterpret_cast<uint16_t*>(address); |
+ } else if (num_bytes == 1) { |
+ read = *reinterpret_cast<uint8_t*>(address); |
+ } else { |
+ UNREACHABLE(); |
+ } |
return read; |
} |
@@ -1511,7 +1521,17 @@ void Simulator::MemoryWrite(uint8_t* address, |
ASSERT((num_bytes > 0) && (num_bytes <= sizeof(uint64_t))); |
LogWrite(address, value, num_bytes); |
- memcpy(address, &value, num_bytes); |
jbramley
2014/02/19 10:12:22
Ditto.
|
+ if (num_bytes == 8) { |
+ *reinterpret_cast<uint64_t*>(address) = static_cast<uint64_t>(value); |
+ } else if (num_bytes == 4) { |
+ *reinterpret_cast<uint32_t*>(address) = static_cast<uint32_t>(value); |
+ } else if (num_bytes == 2) { |
+ *reinterpret_cast<uint16_t*>(address) = static_cast<uint16_t>(value); |
+ } else if (num_bytes == 1) { |
+ *reinterpret_cast<uint8_t*>(address) = static_cast<uint8_t>(value); |
+ } else { |
+ UNREACHABLE(); |
+ } |
} |