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. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // The currently executing Simulator instance, which is associated to the | 45 // The currently executing Simulator instance, which is associated to the |
46 // current isolate | 46 // current isolate |
47 static Simulator* Current(); | 47 static Simulator* Current(); |
48 | 48 |
49 // Accessors for register state. Reading the pc value adheres to the ARM | 49 // Accessors for register state. Reading the pc value adheres to the ARM |
50 // architecture specification and is off by 8 from the currently executing | 50 // architecture specification and is off by 8 from the currently executing |
51 // instruction. | 51 // instruction. |
52 void set_register(Register reg, int32_t value); | 52 void set_register(Register reg, int32_t value); |
53 int32_t get_register(Register reg) const; | 53 int32_t get_register(Register reg) const; |
54 | 54 |
55 int32_t get_sp() const { | 55 int32_t get_sp() const { return get_register(SPREG); } |
56 return get_register(SPREG); | |
57 } | |
58 | 56 |
59 // Special case of set_register and get_register to access the raw PC value. | 57 // Special case of set_register and get_register to access the raw PC value. |
60 void set_pc(int32_t value); | 58 void set_pc(int32_t value); |
61 int32_t get_pc() const; | 59 int32_t get_pc() const; |
62 | 60 |
63 // Accessors for VFP register state. | 61 // Accessors for VFP register state. |
64 void set_sregister(SRegister reg, float value); | 62 void set_sregister(SRegister reg, float value); |
65 float get_sregister(SRegister reg) const; | 63 float get_sregister(SRegister reg) const; |
66 void set_dregister(DRegister reg, double value); | 64 void set_dregister(DRegister reg, double value); |
67 double get_dregister(DRegister reg) const; | 65 double get_dregister(DRegister reg) const; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 uint64_t icount_; | 168 uint64_t icount_; |
171 static int32_t flag_stop_sim_at_; | 169 static int32_t flag_stop_sim_at_; |
172 SimulatorSetjmpBuffer* last_setjmp_buffer_; | 170 SimulatorSetjmpBuffer* last_setjmp_buffer_; |
173 uword top_exit_frame_info_; | 171 uword top_exit_frame_info_; |
174 | 172 |
175 // Registered breakpoints. | 173 // Registered breakpoints. |
176 Instr* break_pc_; | 174 Instr* break_pc_; |
177 int32_t break_instr_; | 175 int32_t break_instr_; |
178 | 176 |
179 // Illegal memory access support. | 177 // Illegal memory access support. |
180 static bool IsIllegalAddress(uword addr) { | 178 static bool IsIllegalAddress(uword addr) { return addr < 64 * 1024; } |
181 return addr < 64*1024; | |
182 } | |
183 void HandleIllegalAccess(uword addr, Instr* instr); | 179 void HandleIllegalAccess(uword addr, Instr* instr); |
184 | 180 |
185 // Handles a legal instruction that the simulator does not implement. | 181 // Handles a legal instruction that the simulator does not implement. |
186 void UnimplementedInstruction(Instr* instr); | 182 void UnimplementedInstruction(Instr* instr); |
187 | 183 |
188 // Unsupported instructions use Format to print an error and stop execution. | 184 // Unsupported instructions use Format to print an error and stop execution. |
189 void Format(Instr* instr, const char* format); | 185 void Format(Instr* instr, const char* format); |
190 | 186 |
191 // Checks if the current instruction should be executed based on its | 187 // Checks if the current instruction should be executed based on its |
192 // condition bits. | 188 // condition bits. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // Executes one instruction. | 262 // Executes one instruction. |
267 void InstructionDecode(Instr* instr); | 263 void InstructionDecode(Instr* instr); |
268 | 264 |
269 // Executes ARM instructions until the PC reaches kEndSimulatingPC. | 265 // Executes ARM instructions until the PC reaches kEndSimulatingPC. |
270 void Execute(); | 266 void Execute(); |
271 | 267 |
272 // Returns true if tracing of executed instructions is enabled. | 268 // Returns true if tracing of executed instructions is enabled. |
273 bool IsTracingExecution() const; | 269 bool IsTracingExecution() const; |
274 | 270 |
275 // Longjmp support for exceptions. | 271 // Longjmp support for exceptions. |
276 SimulatorSetjmpBuffer* last_setjmp_buffer() { | 272 SimulatorSetjmpBuffer* last_setjmp_buffer() { return last_setjmp_buffer_; } |
277 return last_setjmp_buffer_; | |
278 } | |
279 void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) { | 273 void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) { |
280 last_setjmp_buffer_ = buffer; | 274 last_setjmp_buffer_ = buffer; |
281 } | 275 } |
282 | 276 |
283 friend class SimulatorDebugger; | 277 friend class SimulatorDebugger; |
284 friend class SimulatorSetjmpBuffer; | 278 friend class SimulatorSetjmpBuffer; |
285 DISALLOW_COPY_AND_ASSIGN(Simulator); | 279 DISALLOW_COPY_AND_ASSIGN(Simulator); |
286 }; | 280 }; |
287 | 281 |
288 } // namespace dart | 282 } // namespace dart |
289 | 283 |
290 #endif // RUNTIME_VM_SIMULATOR_ARM_H_ | 284 #endif // RUNTIME_VM_SIMULATOR_ARM_H_ |
OLD | NEW |