| 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 MIPS instructions if we are not generating a native | 5 // Declares a Simulator for MIPS instructions if we are not generating a native |
| 6 // MIPS binary. This Simulator allows us to run and debug MIPS code generation | 6 // MIPS binary. This Simulator allows us to run and debug MIPS code generation |
| 7 // on regular desktop machines. | 7 // on 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 MIPS HW platform. | 10 // on a MIPS HW platform. |
| 11 | 11 |
| 12 #ifndef VM_SIMULATOR_MIPS_H_ | 12 #ifndef VM_SIMULATOR_MIPS_H_ |
| 13 #define VM_SIMULATOR_MIPS_H_ | 13 #define VM_SIMULATOR_MIPS_H_ |
| 14 | 14 |
| 15 #ifndef VM_SIMULATOR_H_ | 15 #ifndef VM_SIMULATOR_H_ |
| 16 #error Do not include simulator_mips.h directly; use simulator.h. | 16 #error Do not include simulator_mips.h directly; use simulator.h. |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 #include "vm/constants_mips.h" |
| 20 |
| 19 namespace dart { | 21 namespace dart { |
| 20 | 22 |
| 21 class Simulator { | 23 class Simulator { |
| 22 public: | 24 public: |
| 23 static const uword kSimulatorStackUnderflowSize = 64; | 25 static const uword kSimulatorStackUnderflowSize = 64; |
| 24 | 26 |
| 25 Simulator(); | 27 Simulator(); |
| 26 ~Simulator(); | 28 ~Simulator(); |
| 27 | 29 |
| 28 // The currently executing Simulator instance, which is associated to the | 30 // The currently executing Simulator instance, which is associated to the |
| 29 // current isolate | 31 // current isolate |
| 30 static Simulator* Current(); | 32 static Simulator* Current(); |
| 31 | 33 |
| 34 // Accessors for register state. |
| 35 void set_register(Register reg, int32_t value); |
| 36 int32_t get_register(Register reg) const; |
| 37 |
| 32 // Accessor to the internal simulator stack top. | 38 // Accessor to the internal simulator stack top. |
| 33 uword StackTop() const; | 39 uword StackTop() const; |
| 34 | 40 |
| 35 // Call on program start. | 41 // Call on program start. |
| 36 static void InitOnce(); | 42 static void InitOnce(); |
| 37 | 43 |
| 38 // Dart generally calls into generated code with 5 parameters. This is a | 44 // Dart generally calls into generated code with 5 parameters. This is a |
| 39 // convenience function, which sets up the simulator state and grabs the | 45 // convenience function, which sets up the simulator state and grabs the |
| 40 // result on return. | 46 // result on return. |
| 41 int64_t Call(int32_t entry, | 47 int64_t Call(int32_t entry, |
| 42 int32_t parameter0, | 48 int32_t parameter0, |
| 43 int32_t parameter1, | 49 int32_t parameter1, |
| 44 int32_t parameter2, | 50 int32_t parameter2, |
| 45 int32_t parameter3, | 51 int32_t parameter3, |
| 46 int32_t parameter4); | 52 int32_t parameter4); |
| 47 | 53 |
| 48 private: | 54 private: |
| 49 char* stack_; | 55 char* stack_; |
| 50 }; | 56 }; |
| 51 | 57 |
| 52 } // namespace dart | 58 } // namespace dart |
| 53 | 59 |
| 54 #endif // VM_SIMULATOR_MIPS_H_ | 60 #endif // VM_SIMULATOR_MIPS_H_ |
| OLD | NEW |