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

Unified Diff: src/a64/instructions-a64.h

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
« no previous file with comments | « no previous file | src/a64/simulator-a64.h » ('j') | src/a64/simulator-a64.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/a64/instructions-a64.h
diff --git a/src/a64/instructions-a64.h b/src/a64/instructions-a64.h
index 472d4bf9fd76d367c0200f4d0b1156546f0ca34e..1d19e68a4984204b1138f719550d5e6526a6d8ea 100644
--- a/src/a64/instructions-a64.h
+++ b/src/a64/instructions-a64.h
@@ -116,13 +116,11 @@ enum Reg31Mode {
class Instruction {
public:
Instr InstructionBits() const {
- Instr bits;
- memcpy(&bits, this, sizeof(bits));
jbramley 2014/02/19 10:12:22 These simple (fixed-size) memcpy calls should be f
- return bits;
+ return *reinterpret_cast<Instr*>(const_cast<Instruction*>(this));
}
void SetInstructionBits(Instr new_instr) {
- memcpy(this, &new_instr, sizeof(new_instr));
+ *reinterpret_cast<Instr*>(this) = new_instr;
}
int Bit(int pos) const {
@@ -367,15 +365,15 @@ class Instruction {
uint32_t Literal32() {
uint32_t literal;
- memcpy(&literal, LiteralAddress(), sizeof(literal));
-
+ uint32_t* buffer = &literal;
+ *buffer = *reinterpret_cast<uint32_t*>(LiteralAddress());
return literal;
}
uint64_t Literal64() {
uint64_t literal;
- memcpy(&literal, LiteralAddress(), sizeof(literal));
-
+ uint64_t* buffer = &literal;
+ *buffer = *reinterpret_cast<uint64_t*>(LiteralAddress());
return literal;
}
« no previous file with comments | « no previous file | src/a64/simulator-a64.h » ('j') | src/a64/simulator-a64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698