Chromium Code Reviews| Index: src/arm/simulator-arm.cc |
| =================================================================== |
| --- src/arm/simulator-arm.cc (revision 3473) |
| +++ src/arm/simulator-arm.cc (working copy) |
| @@ -421,6 +421,7 @@ |
| stack_ = reinterpret_cast<char*>(malloc(stack_size)); |
| pc_modified_ = false; |
| icount_ = 0; |
| + thumb_mode_ = false; |
| break_pc_ = NULL; |
| break_instr_ = 0; |
| @@ -2074,6 +2075,12 @@ |
| reinterpret_cast<byte*>(instr)); |
| PrintF(" 0x%08x %s\n", instr, buffer.start()); |
| } |
| + // Temporary special-casing of our particular ARM/THUMB switch |
|
Erik Corry
2009/12/17 14:05:50
I think this can be moved to where it fits (in the
|
| + if ((unsigned)instr->InstructionBits() == 0xe24ff003) { |
| + thumb_mode_ = true; |
| + set_register(pc, reinterpret_cast<int32_t>(instr) + Instr::kInstrSize); |
| + return; |
| + } |
| if (instr->ConditionField() == special_condition) { |
| DecodeUnconditional(instr); |
| } else if (ConditionallyExecute(instr)) { |
| @@ -2118,6 +2125,11 @@ |
| } |
| } |
| +void Simulator::InstructionDecode(ThumbInstr* instr) { |
| + // For now, assume all thumb instructions are an aligned switch back to ARM |
|
Erik Corry
2009/12/17 14:05:50
Please assert this is true.
|
| + set_register(pc, reinterpret_cast<int32_t>(instr) + Instr::kInstrSize); |
| + thumb_mode_ = false; |
| +} |
| void Simulator::Execute() { |
| // Get the PC to simulate. Cannot use the accessor here as we need the |
| @@ -2128,9 +2140,14 @@ |
| // Fast version of the dispatch loop without checking whether the simulator |
| // should be stopping at a particular executed instruction. |
| while (program_counter != end_sim_pc) { |
| - Instr* instr = reinterpret_cast<Instr*>(program_counter); |
| + if (thumb_mode_) { |
| + ThumbInstr* instr = reinterpret_cast<ThumbInstr*>(program_counter); |
| + InstructionDecode(instr); |
| + } else { |
| + Instr* instr = reinterpret_cast<Instr*>(program_counter); |
| + InstructionDecode(instr); |
| + } |
| icount_++; |
| - InstructionDecode(instr); |
| program_counter = get_pc(); |
| } |
| } else { |