Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Unified Diff: src/a64/simulator-a64.cc

Issue 169223004: A64: Replace memcpy with reinterpret_cast assignment in simulator and decoder. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/a64/instructions-a64.h ('K') | « src/a64/simulator-a64.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+ }
}
« src/a64/instructions-a64.h ('K') | « src/a64/simulator-a64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698