| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Declares a Simulator for ARM instructions if we are not generating a native | 5 // Declares a Simulator for ARM instructions if we are not generating a native |
| 6 // ARM binary. This Simulator allows us to run and debug ARM code generation on | 6 // ARM binary. This Simulator allows us to run and debug ARM code generation on |
| 7 // regular desktop machines. | 7 // regular desktop machines. |
| 8 // Dart calls into generated code by "calling" the InvokeDartCode stub, | 8 // Dart calls into generated code by "calling" the InvokeDartCode stub, |
| 9 // which will start execution in the Simulator or forwards to the real entry | 9 // which will start execution in the Simulator or forwards to the real entry |
| 10 // on a ARM HW platform. | 10 // on a ARM HW platform. |
| 11 | 11 |
| 12 #ifndef VM_SIMULATOR_ARM_H_ | 12 #ifndef VM_SIMULATOR_ARM_H_ |
| 13 #define VM_SIMULATOR_ARM_H_ | 13 #define VM_SIMULATOR_ARM_H_ |
| 14 | 14 |
| 15 #ifndef VM_SIMULATOR_H_ | 15 #ifndef VM_SIMULATOR_H_ |
| 16 #error Do not include simulator_arm.h directly; use simulator.h. | 16 #error Do not include simulator_arm.h directly; use simulator.h. |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 #include "vm/allocation.h" | |
| 20 #include "vm/constants_arm.h" | 19 #include "vm/constants_arm.h" |
| 21 #include "vm/object.h" | 20 #include "vm/object.h" |
| 22 | 21 |
| 23 namespace dart { | 22 namespace dart { |
| 24 | 23 |
| 25 class Isolate; | 24 class Isolate; |
| 26 class SimulatorSetjmpBuffer; | 25 class SimulatorSetjmpBuffer; |
| 27 | 26 |
| 28 class Simulator { | 27 class Simulator { |
| 29 public: | 28 public: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 | 47 |
| 49 // Accessors for VFP register state. | 48 // Accessors for VFP register state. |
| 50 void set_sregister(SRegister reg, float value); | 49 void set_sregister(SRegister reg, float value); |
| 51 float get_sregister(SRegister reg) const; | 50 float get_sregister(SRegister reg) const; |
| 52 void set_dregister(DRegister reg, double value); | 51 void set_dregister(DRegister reg, double value); |
| 53 double get_dregister(DRegister reg) const; | 52 double get_dregister(DRegister reg) const; |
| 54 | 53 |
| 55 // Accessor to the internal simulator stack top. | 54 // Accessor to the internal simulator stack top. |
| 56 uword StackTop() const; | 55 uword StackTop() const; |
| 57 | 56 |
| 58 // Executes ARM instructions until the PC reaches end_sim_pc. | 57 // The isolate's top_exit_frame_info refers to a Dart frame in the simulator |
| 59 void Execute(); | 58 // stack. The simulator's top_exit_frame_info refers to a C++ frame in the |
| 59 // native stack. |
| 60 uword top_exit_frame_info() const { return top_exit_frame_info_; } |
| 61 void set_top_exit_frame_info(uword value) { top_exit_frame_info_ = value; } |
| 60 | 62 |
| 61 // Call on program start. | 63 // Call on program start. |
| 62 static void InitOnce(); | 64 static void InitOnce(); |
| 63 | 65 |
| 64 // Dart generally calls into generated code with 5 parameters. This is a | 66 // Dart generally calls into generated code with 5 parameters. This is a |
| 65 // convenience function, which sets up the simulator state and grabs the | 67 // convenience function, which sets up the simulator state and grabs the |
| 66 // result on return. | 68 // result on return. |
| 67 int64_t Call(int32_t entry, | 69 int64_t Call(int32_t entry, |
| 68 int32_t parameter0, | 70 int32_t parameter0, |
| 69 int32_t parameter1, | 71 int32_t parameter1, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 bool fp_z_flag_; | 114 bool fp_z_flag_; |
| 113 bool fp_c_flag_; | 115 bool fp_c_flag_; |
| 114 bool fp_v_flag_; | 116 bool fp_v_flag_; |
| 115 | 117 |
| 116 // Simulator support. | 118 // Simulator support. |
| 117 char* stack_; | 119 char* stack_; |
| 118 bool pc_modified_; | 120 bool pc_modified_; |
| 119 int icount_; | 121 int icount_; |
| 120 static int32_t flag_stop_sim_at_; | 122 static int32_t flag_stop_sim_at_; |
| 121 SimulatorSetjmpBuffer* last_setjmp_buffer_; | 123 SimulatorSetjmpBuffer* last_setjmp_buffer_; |
| 124 uword top_exit_frame_info_; |
| 122 | 125 |
| 123 // Registered breakpoints. | 126 // Registered breakpoints. |
| 124 Instr* break_pc_; | 127 Instr* break_pc_; |
| 125 int32_t break_instr_; | 128 int32_t break_instr_; |
| 126 | 129 |
| 127 // Illegal memory access support. | 130 // Illegal memory access support. |
| 128 static bool IsIllegalAddress(uword addr) { | 131 static bool IsIllegalAddress(uword addr) { |
| 129 return addr < 64*1024; | 132 return addr < 64*1024; |
| 130 } | 133 } |
| 131 void HandleIllegalAccess(uword addr, Instr* instr); | 134 void HandleIllegalAccess(uword addr, Instr* instr); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void DecodeType2(Instr* instr); | 215 void DecodeType2(Instr* instr); |
| 213 void DecodeType3(Instr* instr); | 216 void DecodeType3(Instr* instr); |
| 214 void DecodeType4(Instr* instr); | 217 void DecodeType4(Instr* instr); |
| 215 void DecodeType5(Instr* instr); | 218 void DecodeType5(Instr* instr); |
| 216 void DecodeType6(Instr* instr); | 219 void DecodeType6(Instr* instr); |
| 217 void DecodeType7(Instr* instr); | 220 void DecodeType7(Instr* instr); |
| 218 | 221 |
| 219 // Executes one instruction. | 222 // Executes one instruction. |
| 220 void InstructionDecode(Instr* instr); | 223 void InstructionDecode(Instr* instr); |
| 221 | 224 |
| 225 // Executes ARM instructions until the PC reaches kEndSimulatingPC. |
| 226 void Execute(); |
| 227 |
| 222 // Longjmp support for exceptions. | 228 // Longjmp support for exceptions. |
| 223 SimulatorSetjmpBuffer* last_setjmp_buffer() { | 229 SimulatorSetjmpBuffer* last_setjmp_buffer() { |
| 224 return last_setjmp_buffer_; | 230 return last_setjmp_buffer_; |
| 225 } | 231 } |
| 226 void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) { | 232 void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) { |
| 227 last_setjmp_buffer_ = buffer; | 233 last_setjmp_buffer_ = buffer; |
| 228 } | 234 } |
| 229 | 235 |
| 230 friend class SimulatorDebugger; | 236 friend class SimulatorDebugger; |
| 231 friend class SimulatorSetjmpBuffer; | 237 friend class SimulatorSetjmpBuffer; |
| 232 DISALLOW_COPY_AND_ASSIGN(Simulator); | 238 DISALLOW_COPY_AND_ASSIGN(Simulator); |
| 233 }; | 239 }; |
| 234 | 240 |
| 235 } // namespace dart | 241 } // namespace dart |
| 236 | 242 |
| 237 #endif // VM_SIMULATOR_ARM_H_ | 243 #endif // VM_SIMULATOR_ARM_H_ |
| OLD | NEW |