Chromium Code Reviews| 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. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 ~Simulator(); | 28 ~Simulator(); |
| 29 | 29 |
| 30 // The currently executing Simulator instance, which is associated to the | 30 // The currently executing Simulator instance, which is associated to the |
| 31 // current isolate | 31 // current isolate |
| 32 static Simulator* Current(); | 32 static Simulator* Current(); |
| 33 | 33 |
| 34 // Accessors for register state. | 34 // Accessors for register state. |
| 35 void set_register(Register reg, int32_t value); | 35 void set_register(Register reg, int32_t value); |
| 36 int32_t get_register(Register reg) const; | 36 int32_t get_register(Register reg) const; |
| 37 | 37 |
| 38 // Accessors for hi, lo registers | |
|
regis
2013/03/08 21:09:03
period
| |
| 39 void set_hi_register(int32_t value) { hi_reg_ = value; } | |
| 40 void set_lo_register(int32_t value) { lo_reg_ = value; } | |
| 41 int32_t get_hi_register() const { return hi_reg_; } | |
| 42 int32_t get_lo_register() const { return lo_reg_; } | |
| 43 | |
| 38 // Accessor to the internal simulator stack top. | 44 // Accessor to the internal simulator stack top. |
| 39 uword StackTop() const; | 45 uword StackTop() const; |
| 40 | 46 |
| 41 // Call on program start. | 47 // Call on program start. |
| 42 static void InitOnce(); | 48 static void InitOnce(); |
| 43 | 49 |
| 44 // Dart generally calls into generated code with 5 parameters. This is a | 50 // Dart generally calls into generated code with 5 parameters. This is a |
| 45 // convenience function, which sets up the simulator state and grabs the | 51 // convenience function, which sets up the simulator state and grabs the |
| 46 // result on return. | 52 // result on return. |
| 47 int64_t Call(int32_t entry, | 53 int64_t Call(int32_t entry, |
| 48 int32_t parameter0, | 54 int32_t parameter0, |
| 49 int32_t parameter1, | 55 int32_t parameter1, |
| 50 int32_t parameter2, | 56 int32_t parameter2, |
| 51 int32_t parameter3); | 57 int32_t parameter3); |
| 52 | 58 |
| 53 private: | 59 private: |
| 54 // A pc value used to signal the simulator to stop execution. Generally | 60 // A pc value used to signal the simulator to stop execution. Generally |
| 55 // the ra is set to this value on transition from native C code to | 61 // the ra is set to this value on transition from native C code to |
| 56 // simulated execution, so that the simulator can "return" to the native | 62 // simulated execution, so that the simulator can "return" to the native |
| 57 // C code. | 63 // C code. |
| 58 static const uword kEndSimulatingPC = -1; | 64 static const uword kEndSimulatingPC = -1; |
| 59 | 65 |
| 66 // special registers for the results of div, divu. | |
|
regis
2013/03/08 21:09:03
// Special ...
| |
| 67 int32_t hi_reg_; | |
| 68 int32_t lo_reg_; | |
| 69 | |
| 60 int32_t registers_[kNumberOfCpuRegisters]; | 70 int32_t registers_[kNumberOfCpuRegisters]; |
| 61 uword pc_; | 71 uword pc_; |
| 62 | 72 |
| 63 // Simulator support. | 73 // Simulator support. |
| 64 char* stack_; | 74 char* stack_; |
| 65 int icount_; | 75 int icount_; |
| 66 bool delay_slot_; | 76 bool delay_slot_; |
| 67 | 77 |
| 68 void set_pc(uword value) { pc_ = value; } | 78 void set_pc(uword value) { pc_ = value; } |
| 69 | 79 |
| 70 void Format(Instr* instr, const char* format); | 80 void Format(Instr* instr, const char* format); |
| 71 | 81 |
| 72 void DecodeSpecial(Instr* instr); | 82 void DecodeSpecial(Instr* instr); |
| 83 void DecodeSpecial2(Instr* instr); | |
| 73 void InstructionDecode(Instr* instr); | 84 void InstructionDecode(Instr* instr); |
| 74 | 85 |
| 75 void Execute(); | 86 void Execute(); |
| 76 void ExecuteDelaySlot(); | 87 void ExecuteDelaySlot(); |
| 77 }; | 88 }; |
| 78 | 89 |
| 79 } // namespace dart | 90 } // namespace dart |
| 80 | 91 |
| 81 #endif // VM_SIMULATOR_MIPS_H_ | 92 #endif // VM_SIMULATOR_MIPS_H_ |
| OLD | NEW |