Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: runtime/vm/simulator_arm64.h

Issue 243773002: Adds Runtime call stub and Dart entry stub to ARM64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 26
26 class Simulator { 27 class Simulator {
27 public: 28 public:
28 static const uword kSimulatorStackUnderflowSize = 64; 29 static const uword kSimulatorStackUnderflowSize = 64;
29 30
30 Simulator(); 31 Simulator();
31 ~Simulator(); 32 ~Simulator();
32 33
33 // The currently executing Simulator instance, which is associated to the 34 // The currently executing Simulator instance, which is associated to the
34 // current isolate 35 // current isolate
35 static Simulator* Current(); 36 static Simulator* Current();
36 37
37 // Accessors for register state. 38 // Accessors for register state.
38 void set_register(Register reg, int64_t value, R31Type r31t = R31IsUndef); 39 void set_register(Register reg, int64_t value, R31Type r31t = R31IsUndef);
39 int64_t get_register(Register reg, R31Type r31t = R31IsUndef) const; 40 int64_t get_register(Register reg, R31Type r31t = R31IsUndef) const;
40 void set_wregister(Register reg, int32_t value, R31Type r31t = R31IsUndef); 41 void set_wregister(Register reg, int32_t value, R31Type r31t = R31IsUndef);
41 int32_t get_wregister(Register reg, R31Type r31t = R31IsUndef) const; 42 int32_t get_wregister(Register reg, R31Type r31t = R31IsUndef) const;
42 43
43 int64_t get_pc() const; 44 int64_t get_pc() const;
45 int64_t get_last_pc() const;
44 void set_pc(int64_t pc); 46 void set_pc(int64_t pc);
45 47
46 // Accessor to the internal simulator stack top. 48 // Accessor to the internal simulator stack top.
47 uword StackTop() const; 49 uword StackTop() const;
48 50
49 // The isolate's top_exit_frame_info refers to a Dart frame in the simulator 51 // The isolate's top_exit_frame_info refers to a Dart frame in the simulator
50 // stack. The simulator's top_exit_frame_info refers to a C++ frame in the 52 // stack. The simulator's top_exit_frame_info refers to a C++ frame in the
51 // native stack. 53 // native stack.
52 uword top_exit_frame_info() const { return top_exit_frame_info_; } 54 uword top_exit_frame_info() const { return top_exit_frame_info_; }
53 void set_top_exit_frame_info(uword value) { top_exit_frame_info_ = value; } 55 void set_top_exit_frame_info(uword value) { top_exit_frame_info_ = value; }
54 56
55 // Call on program start. 57 // Call on program start.
56 static void InitOnce() {} 58 static void InitOnce() {}
57 59
58 // Dart generally calls into generated code with 5 parameters. This is a 60 // Dart generally calls into generated code with 5 parameters. This is a
59 // convenience function, which sets up the simulator state and grabs the 61 // convenience function, which sets up the simulator state and grabs the
60 // result on return. The return value is R0. The parameters are placed in 62 // result on return. The return value is R0. The parameters are placed in
61 // R0-3. 63 // R0-3.
62 int64_t Call(int64_t entry, 64 int64_t Call(int64_t entry,
63 int64_t parameter0, 65 int64_t parameter0,
64 int64_t parameter1, 66 int64_t parameter1,
65 int64_t parameter2, 67 int64_t parameter2,
66 int64_t parameter3); 68 int64_t parameter3);
67 69
70 // Runtime and native call support.
71 enum CallKind {
72 kRuntimeCall,
73 kLeafRuntimeCall,
74 kLeafFloatRuntimeCall,
75 kBootstrapNativeCall,
76 kNativeCall
77 };
78 static uword RedirectExternalReference(uword function,
79 CallKind call_kind,
80 int argument_count);
81
68 void Longjmp(uword pc, 82 void Longjmp(uword pc,
69 uword sp, 83 uword sp,
70 uword fp, 84 uword fp,
71 RawObject* raw_exception, 85 RawObject* raw_exception,
72 RawObject* raw_stacktrace) { 86 RawObject* raw_stacktrace) {
73 UNIMPLEMENTED(); 87 UNIMPLEMENTED();
74 } 88 }
75 89
76 private: 90 private:
77 // Known bad pc value to ensure that the simulator does not execute 91 // Known bad pc value to ensure that the simulator does not execute
78 // without being properly setup. 92 // without being properly setup.
79 static const uword kBadLR = -1; 93 static const uword kBadLR = -1;
80 // A pc value used to signal the simulator to stop execution. Generally 94 // A pc value used to signal the simulator to stop execution. Generally
81 // the lr is set to this value on transition from native C code to 95 // the lr is set to this value on transition from native C code to
82 // simulated execution, so that the simulator can "return" to the native 96 // simulated execution, so that the simulator can "return" to the native
83 // C code. 97 // C code.
84 static const uword kEndSimulatingPC = -2; 98 static const uword kEndSimulatingPC = -2;
85 99
86 // CPU state. 100 // CPU state.
87 int64_t registers_[kNumberOfCpuRegisters]; 101 int64_t registers_[kNumberOfCpuRegisters];
88 bool n_flag_; 102 bool n_flag_;
89 bool z_flag_; 103 bool z_flag_;
90 bool c_flag_; 104 bool c_flag_;
91 bool v_flag_; 105 bool v_flag_;
92 106
93 // Simulator support. 107 // Simulator support.
108 int64_t last_pc_;
94 int64_t pc_; 109 int64_t pc_;
95 char* stack_; 110 char* stack_;
96 bool pc_modified_; 111 bool pc_modified_;
97 intptr_t icount_; 112 intptr_t icount_;
98 static int64_t flag_stop_sim_at_; 113 static int64_t flag_stop_sim_at_;
114 SimulatorSetjmpBuffer* last_setjmp_buffer_;
99 uword top_exit_frame_info_; 115 uword top_exit_frame_info_;
100 116
101 // Registered breakpoints. 117 // Registered breakpoints.
102 Instr* break_pc_; 118 Instr* break_pc_;
103 int64_t break_instr_; 119 int64_t break_instr_;
104 120
105 // Illegal memory access support. 121 // Illegal memory access support.
106 static bool IsIllegalAddress(uword addr) { 122 static bool IsIllegalAddress(uword addr) {
107 return addr < 64*1024; 123 return addr < 64*1024;
108 } 124 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 171
156 int64_t ExtendOperand(uint8_t reg_size, 172 int64_t ExtendOperand(uint8_t reg_size,
157 int64_t value, 173 int64_t value,
158 Extend extend_type, 174 Extend extend_type,
159 uint8_t amount); 175 uint8_t amount);
160 176
161 int64_t DecodeShiftExtendOperand(Instr* instr); 177 int64_t DecodeShiftExtendOperand(Instr* instr);
162 178
163 bool ConditionallyExecute(Instr* instr); 179 bool ConditionallyExecute(Instr* instr);
164 180
181 void DoRedirectedCall(Instr* instr);
182
165 // Decode instructions. 183 // Decode instructions.
166 void InstructionDecode(Instr* instr); 184 void InstructionDecode(Instr* instr);
167 #define DECODE_OP(op) \ 185 #define DECODE_OP(op) \
168 void Decode##op(Instr* instr); 186 void Decode##op(Instr* instr);
169 APPLY_OP_LIST(DECODE_OP) 187 APPLY_OP_LIST(DECODE_OP)
170 #undef DECODE_OP 188 #undef DECODE_OP
171 189
172 // Executes ARM64 instructions until the PC reaches kEndSimulatingPC. 190 // Executes ARM64 instructions until the PC reaches kEndSimulatingPC.
173 void Execute(); 191 void Execute();
174 192
193 // Longjmp support for exceptions.
194 SimulatorSetjmpBuffer* last_setjmp_buffer() {
195 return last_setjmp_buffer_;
196 }
197 void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) {
198 last_setjmp_buffer_ = buffer;
199 }
200
175 friend class SimulatorDebugger; 201 friend class SimulatorDebugger;
202 friend class SimulatorSetjmpBuffer;
176 DISALLOW_COPY_AND_ASSIGN(Simulator); 203 DISALLOW_COPY_AND_ASSIGN(Simulator);
177 }; 204 };
178 205
179 } // namespace dart 206 } // namespace dart
180 207
181 #endif // VM_SIMULATOR_ARM64_H_ 208 #endif // VM_SIMULATOR_ARM64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698