Chromium Code Reviews| Index: src/arm/simulator-arm.cc |
| diff --git a/src/arm/simulator-arm.cc b/src/arm/simulator-arm.cc |
| index 91df404f9af3a00a191d8d232d4c5858e4d3155b..0b8e096810b720d96ff79f04cd4cc41b977ba644 100644 |
| --- a/src/arm/simulator-arm.cc |
| +++ b/src/arm/simulator-arm.cc |
| @@ -1066,111 +1066,101 @@ void Simulator::TrashCallerSaveRegisters() { |
| int Simulator::ReadW(int32_t addr, Instruction* instr) { |
| -#if V8_TARGET_CAN_READ_UNALIGNED |
| - intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
| - return *ptr; |
| -#else |
| - if ((addr & 3) == 0) { |
| + if (FLAG_enable_unaligned_accesses) { |
| intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
| return *ptr; |
| + } else if ((addr & 3) == 0) { |
|
JF
2012/10/10 10:35:08
Why not fold this into the previous block?
if (FL
ulan
2012/10/10 12:13:28
Done, thanks.
|
| + intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
| + return *ptr; |
| + } else { |
| + PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| + addr, |
| + reinterpret_cast<intptr_t>(instr)); |
| + UNIMPLEMENTED(); |
| + return 0; |
| } |
| - PrintF("Unaligned read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| - addr, |
| - reinterpret_cast<intptr_t>(instr)); |
| - UNIMPLEMENTED(); |
| - return 0; |
| -#endif |
| } |
| void Simulator::WriteW(int32_t addr, int value, Instruction* instr) { |
| -#if V8_TARGET_CAN_READ_UNALIGNED |
| - intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
| - *ptr = value; |
| - return; |
| -#else |
| - if ((addr & 3) == 0) { |
| + if (FLAG_enable_unaligned_accesses) { |
| + intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
| + *ptr = value; |
| + } else if ((addr & 3) == 0) { |
| intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |
| *ptr = value; |
| - return; |
| + } else { |
| + PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| + addr, |
| + reinterpret_cast<intptr_t>(instr)); |
| + UNIMPLEMENTED(); |
| } |
| - PrintF("Unaligned write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| - addr, |
| - reinterpret_cast<intptr_t>(instr)); |
| - UNIMPLEMENTED(); |
| -#endif |
| } |
| uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { |
| -#if V8_TARGET_CAN_READ_UNALIGNED |
| - uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
| - return *ptr; |
| -#else |
| - if ((addr & 1) == 0) { |
| + if (FLAG_enable_unaligned_accesses) { |
| uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
| return *ptr; |
| + } else if ((addr & 1) == 0) { |
| + uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
| + return *ptr; |
| + } else { |
| + PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" |
| + V8PRIxPTR "\n", |
| + addr, |
| + reinterpret_cast<intptr_t>(instr)); |
| + UNIMPLEMENTED(); |
| + return 0; |
| } |
| - PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| - addr, |
| - reinterpret_cast<intptr_t>(instr)); |
| - UNIMPLEMENTED(); |
| - return 0; |
| -#endif |
| } |
| int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { |
| -#if V8_TARGET_CAN_READ_UNALIGNED |
| - int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
| - return *ptr; |
| -#else |
| - if ((addr & 1) == 0) { |
| + if (FLAG_enable_unaligned_accesses) { |
| + int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
| + return *ptr; |
| + } else if ((addr & 1) == 0) { |
| int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
| return *ptr; |
| + } else { |
| + PrintF("Unaligned signed halfword read at 0x%08x\n", addr); |
| + UNIMPLEMENTED(); |
| + return 0; |
| } |
| - PrintF("Unaligned signed halfword read at 0x%08x\n", addr); |
| - UNIMPLEMENTED(); |
| - return 0; |
| -#endif |
| } |
| void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { |
| -#if V8_TARGET_CAN_READ_UNALIGNED |
| - uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
| - *ptr = value; |
| - return; |
| -#else |
| - if ((addr & 1) == 0) { |
| + if (FLAG_enable_unaligned_accesses) { |
| + uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
| + *ptr = value; |
| + } else if ((addr & 1) == 0) { |
| uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |
| *ptr = value; |
| - return; |
| + } else { |
| + PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" |
| + V8PRIxPTR "\n", |
| + addr, |
| + reinterpret_cast<intptr_t>(instr)); |
| + UNIMPLEMENTED(); |
| } |
| - PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| - addr, |
| - reinterpret_cast<intptr_t>(instr)); |
| - UNIMPLEMENTED(); |
| -#endif |
| } |
| void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { |
| -#if V8_TARGET_CAN_READ_UNALIGNED |
| - int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
| - *ptr = value; |
| - return; |
| -#else |
| - if ((addr & 1) == 0) { |
| + if (FLAG_enable_unaligned_accesses) { |
| + int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
| + *ptr = value; |
| + } else if ((addr & 1) == 0) { |
| int16_t* ptr = reinterpret_cast<int16_t*>(addr); |
| *ptr = value; |
| - return; |
| + } else { |
| + PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| + addr, |
| + reinterpret_cast<intptr_t>(instr)); |
| + UNIMPLEMENTED(); |
| } |
| - PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", |
| - addr, |
| - reinterpret_cast<intptr_t>(instr)); |
| - UNIMPLEMENTED(); |
| -#endif |
| } |
| @@ -1199,37 +1189,33 @@ void Simulator::WriteB(int32_t addr, int8_t value) { |
| int32_t* Simulator::ReadDW(int32_t addr) { |
| -#if V8_TARGET_CAN_READ_UNALIGNED |
| - int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
| - return ptr; |
| -#else |
| - if ((addr & 3) == 0) { |
| + if (FLAG_enable_unaligned_accesses) { |
| + int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
| + return ptr; |
| + } else if ((addr & 3) == 0) { |
| int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
| return ptr; |
| + } else { |
| + PrintF("Unaligned read at 0x%08x\n", addr); |
| + UNIMPLEMENTED(); |
| + return 0; |
| } |
| - PrintF("Unaligned read at 0x%08x\n", addr); |
| - UNIMPLEMENTED(); |
| - return 0; |
| -#endif |
| } |
| void Simulator::WriteDW(int32_t addr, int32_t value1, int32_t value2) { |
| -#if V8_TARGET_CAN_READ_UNALIGNED |
| - int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
| - *ptr++ = value1; |
| - *ptr = value2; |
| - return; |
| -#else |
| - if ((addr & 3) == 0) { |
| + if (FLAG_enable_unaligned_accesses) { |
| + int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
| + *ptr++ = value1; |
| + *ptr = value2; |
| + } else if ((addr & 3) == 0) { |
| int32_t* ptr = reinterpret_cast<int32_t*>(addr); |
| *ptr++ = value1; |
| *ptr = value2; |
| - return; |
| + } else { |
| + PrintF("Unaligned write at 0x%08x\n", addr); |
| + UNIMPLEMENTED(); |
| } |
| - PrintF("Unaligned write at 0x%08x\n", addr); |
| - UNIMPLEMENTED(); |
| -#endif |
| } |