OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 ARM64 instructions if we are not generating a native | 5 // Declares a Simulator for ARM64 instructions if we are not generating a native |
6 // ARM64 binary. This Simulator allows us to run and debug ARM64 code generation | 6 // ARM64 binary. This Simulator allows us to run and debug ARM64 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 ARM64 HW platform. | 10 // on a ARM64 HW platform. |
11 | 11 |
12 #ifndef VM_SIMULATOR_ARM64_H_ | 12 #ifndef VM_SIMULATOR_ARM64_H_ |
13 #define VM_SIMULATOR_ARM64_H_ | 13 #define VM_SIMULATOR_ARM64_H_ |
14 | 14 |
15 #ifndef VM_SIMULATOR_H_ | 15 #ifndef VM_SIMULATOR_H_ |
16 #error Do not include simulator_arm64.h directly; use simulator.h. | 16 #error Do not include simulator_arm64.h directly; use simulator.h. |
17 #endif | 17 #endif |
18 | 18 |
19 #include "vm/constants_arm64.h" | 19 #include "vm/constants_arm64.h" |
20 #include "vm/object.h" | 20 #include "vm/object.h" |
21 | 21 |
22 namespace dart { | 22 namespace dart { |
23 | 23 |
24 class Isolate; | 24 class Isolate; |
25 class SimulatorSetjmpBuffer; | 25 class SimulatorSetjmpBuffer; |
26 | 26 |
| 27 typedef struct { |
| 28 int64_t lo; |
| 29 int64_t hi; |
| 30 } simd_value_t; |
| 31 |
27 class Simulator { | 32 class Simulator { |
28 public: | 33 public: |
29 static const uword kSimulatorStackUnderflowSize = 64; | 34 static const uword kSimulatorStackUnderflowSize = 64; |
30 | 35 |
31 Simulator(); | 36 Simulator(); |
32 ~Simulator(); | 37 ~Simulator(); |
33 | 38 |
34 // The currently executing Simulator instance, which is associated to the | 39 // The currently executing Simulator instance, which is associated to the |
35 // current isolate | 40 // current isolate |
36 static Simulator* Current(); | 41 static Simulator* Current(); |
37 | 42 |
38 // Accessors for register state. | 43 // Accessors for register state. |
39 // The default value for R31Type has to be R31IsSP because get_register is | 44 // The default value for R31Type has to be R31IsSP because get_register is |
40 // accessed from architecture independent code through SPREG without | 45 // accessed from architecture independent code through SPREG without |
41 // specifying the type. We also can't translate a dummy value for SPREG into | 46 // specifying the type. We also can't translate a dummy value for SPREG into |
42 // a real value because the architecture independent code expects SPREG to | 47 // a real value because the architecture independent code expects SPREG to |
43 // be a real register value. | 48 // be a real register value. |
44 void set_register(Register reg, int64_t value, R31Type r31t = R31IsSP); | 49 void set_register(Register reg, int64_t value, R31Type r31t = R31IsSP); |
45 int64_t get_register(Register reg, R31Type r31t = R31IsSP) const; | 50 int64_t get_register(Register reg, R31Type r31t = R31IsSP) const; |
46 void set_wregister(Register reg, int32_t value, R31Type r31t = R31IsSP); | 51 void set_wregister(Register reg, int32_t value, R31Type r31t = R31IsSP); |
47 int32_t get_wregister(Register reg, R31Type r31t = R31IsSP) const; | 52 int32_t get_wregister(Register reg, R31Type r31t = R31IsSP) const; |
48 | 53 |
| 54 // Get and set a V register in double ('d') mode. Setting clears the high |
| 55 // 64 bits of the V register. Getting ignores the high 64 bits. |
| 56 int64_t get_vregisterd(VRegister reg); |
| 57 void set_vregisterd(VRegister reg, int64_t value); |
| 58 |
49 int64_t get_pc() const; | 59 int64_t get_pc() const; |
50 int64_t get_last_pc() const; | 60 int64_t get_last_pc() const; |
51 void set_pc(int64_t pc); | 61 void set_pc(int64_t pc); |
52 | 62 |
53 // Accessor to the internal simulator stack top. | 63 // Accessor to the internal simulator stack top. |
54 uword StackTop() const; | 64 uword StackTop() const; |
55 | 65 |
56 // The isolate's top_exit_frame_info refers to a Dart frame in the simulator | 66 // The isolate's top_exit_frame_info refers to a Dart frame in the simulator |
57 // stack. The simulator's top_exit_frame_info refers to a C++ frame in the | 67 // stack. The simulator's top_exit_frame_info refers to a C++ frame in the |
58 // native stack. | 68 // native stack. |
59 uword top_exit_frame_info() const { return top_exit_frame_info_; } | 69 uword top_exit_frame_info() const { return top_exit_frame_info_; } |
60 void set_top_exit_frame_info(uword value) { top_exit_frame_info_ = value; } | 70 void set_top_exit_frame_info(uword value) { top_exit_frame_info_ = value; } |
61 | 71 |
62 // Call on program start. | 72 // Call on program start. |
63 static void InitOnce() {} | 73 static void InitOnce() {} |
64 | 74 |
65 // Dart generally calls into generated code with 5 parameters. This is a | 75 // Dart generally calls into generated code with 5 parameters. This is a |
66 // convenience function, which sets up the simulator state and grabs the | 76 // convenience function, which sets up the simulator state and grabs the |
67 // result on return. The return value is R0. The parameters are placed in | 77 // result on return. The return value is R0. The parameters are placed in |
68 // R0-3. | 78 // R0-3. |
69 int64_t Call(int64_t entry, | 79 int64_t Call(int64_t entry, |
70 int64_t parameter0, | 80 int64_t parameter0, |
71 int64_t parameter1, | 81 int64_t parameter1, |
72 int64_t parameter2, | 82 int64_t parameter2, |
73 int64_t parameter3); | 83 int64_t parameter3, |
| 84 bool fp_return = false, |
| 85 bool fp_args = false); |
74 | 86 |
75 // Runtime and native call support. | 87 // Runtime and native call support. |
76 enum CallKind { | 88 enum CallKind { |
77 kRuntimeCall, | 89 kRuntimeCall, |
78 kLeafRuntimeCall, | 90 kLeafRuntimeCall, |
79 kLeafFloatRuntimeCall, | 91 kLeafFloatRuntimeCall, |
80 kBootstrapNativeCall, | 92 kBootstrapNativeCall, |
81 kNativeCall | 93 kNativeCall |
82 }; | 94 }; |
83 static uword RedirectExternalReference(uword function, | 95 static uword RedirectExternalReference(uword function, |
(...skipping 16 matching lines...) Expand all Loading... |
100 // C code. | 112 // C code. |
101 static const uword kEndSimulatingPC = -2; | 113 static const uword kEndSimulatingPC = -2; |
102 | 114 |
103 // CPU state. | 115 // CPU state. |
104 int64_t registers_[kNumberOfCpuRegisters]; | 116 int64_t registers_[kNumberOfCpuRegisters]; |
105 bool n_flag_; | 117 bool n_flag_; |
106 bool z_flag_; | 118 bool z_flag_; |
107 bool c_flag_; | 119 bool c_flag_; |
108 bool v_flag_; | 120 bool v_flag_; |
109 | 121 |
| 122 simd_value_t vregisters_[kNumberOfVRegisters]; |
| 123 bool fp_n_flag_; |
| 124 bool fp_z_flag_; |
| 125 bool fp_c_flag_; |
| 126 bool fp_v_flag_; |
| 127 |
110 // Simulator support. | 128 // Simulator support. |
111 int64_t last_pc_; | 129 int64_t last_pc_; |
112 int64_t pc_; | 130 int64_t pc_; |
113 char* stack_; | 131 char* stack_; |
114 bool pc_modified_; | 132 bool pc_modified_; |
115 intptr_t icount_; | 133 intptr_t icount_; |
116 static int64_t flag_stop_sim_at_; | 134 static int64_t flag_stop_sim_at_; |
117 SimulatorSetjmpBuffer* last_setjmp_buffer_; | 135 SimulatorSetjmpBuffer* last_setjmp_buffer_; |
118 uword top_exit_frame_info_; | 136 uword top_exit_frame_info_; |
119 | 137 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 220 } |
203 | 221 |
204 friend class SimulatorDebugger; | 222 friend class SimulatorDebugger; |
205 friend class SimulatorSetjmpBuffer; | 223 friend class SimulatorSetjmpBuffer; |
206 DISALLOW_COPY_AND_ASSIGN(Simulator); | 224 DISALLOW_COPY_AND_ASSIGN(Simulator); |
207 }; | 225 }; |
208 | 226 |
209 } // namespace dart | 227 } // namespace dart |
210 | 228 |
211 #endif // VM_SIMULATOR_ARM64_H_ | 229 #endif // VM_SIMULATOR_ARM64_H_ |
OLD | NEW |