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

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
« no previous file with comments | « runtime/vm/runtime_entry_test.cc ('k') | runtime/vm/simulator_arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // The default value for R31Type has to be R31IsSP because get_register is
39 int64_t get_register(Register reg, R31Type r31t = R31IsUndef) const; 40 // accessed from architecture independent code through SPREG without
40 void set_wregister(Register reg, int32_t value, R31Type r31t = R31IsUndef); 41 // specifying the type. We also can't translate a dummy value for SPREG into
41 int32_t get_wregister(Register reg, R31Type r31t = R31IsUndef) const; 42 // a real value because the architecture independent code expects SPREG to
43 // be a real register value.
44 void set_register(Register reg, int64_t value, R31Type r31t = R31IsSP);
45 int64_t get_register(Register reg, R31Type r31t = R31IsSP) const;
46 void set_wregister(Register reg, int32_t value, R31Type r31t = R31IsSP);
47 int32_t get_wregister(Register reg, R31Type r31t = R31IsSP) const;
42 48
43 int64_t get_pc() const; 49 int64_t get_pc() const;
50 int64_t get_last_pc() const;
44 void set_pc(int64_t pc); 51 void set_pc(int64_t pc);
45 52
46 // Accessor to the internal simulator stack top. 53 // Accessor to the internal simulator stack top.
47 uword StackTop() const; 54 uword StackTop() const;
48 55
49 // The isolate's top_exit_frame_info refers to a Dart frame in the simulator 56 // 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 57 // stack. The simulator's top_exit_frame_info refers to a C++ frame in the
51 // native stack. 58 // native stack.
52 uword top_exit_frame_info() const { return top_exit_frame_info_; } 59 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; } 60 void set_top_exit_frame_info(uword value) { top_exit_frame_info_ = value; }
54 61
55 // Call on program start. 62 // Call on program start.
56 static void InitOnce() {} 63 static void InitOnce() {}
57 64
58 // Dart generally calls into generated code with 5 parameters. This is a 65 // Dart generally calls into generated code with 5 parameters. This is a
59 // convenience function, which sets up the simulator state and grabs the 66 // 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 67 // result on return. The return value is R0. The parameters are placed in
61 // R0-3. 68 // R0-3.
62 int64_t Call(int64_t entry, 69 int64_t Call(int64_t entry,
63 int64_t parameter0, 70 int64_t parameter0,
64 int64_t parameter1, 71 int64_t parameter1,
65 int64_t parameter2, 72 int64_t parameter2,
66 int64_t parameter3); 73 int64_t parameter3);
67 74
75 // Runtime and native call support.
76 enum CallKind {
77 kRuntimeCall,
78 kLeafRuntimeCall,
79 kLeafFloatRuntimeCall,
80 kBootstrapNativeCall,
81 kNativeCall
82 };
83 static uword RedirectExternalReference(uword function,
84 CallKind call_kind,
85 int argument_count);
86
68 void Longjmp(uword pc, 87 void Longjmp(uword pc,
69 uword sp, 88 uword sp,
70 uword fp, 89 uword fp,
71 RawObject* raw_exception, 90 RawObject* raw_exception,
72 RawObject* raw_stacktrace) { 91 RawObject* raw_stacktrace) {
73 UNIMPLEMENTED(); 92 UNIMPLEMENTED();
74 } 93 }
75 94
76 private: 95 private:
77 // Known bad pc value to ensure that the simulator does not execute 96 // Known bad pc value to ensure that the simulator does not execute
78 // without being properly setup. 97 // without being properly setup.
79 static const uword kBadLR = -1; 98 static const uword kBadLR = -1;
80 // A pc value used to signal the simulator to stop execution. Generally 99 // 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 100 // 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 101 // simulated execution, so that the simulator can "return" to the native
83 // C code. 102 // C code.
84 static const uword kEndSimulatingPC = -2; 103 static const uword kEndSimulatingPC = -2;
85 104
86 // CPU state. 105 // CPU state.
87 int64_t registers_[kNumberOfCpuRegisters]; 106 int64_t registers_[kNumberOfCpuRegisters];
88 bool n_flag_; 107 bool n_flag_;
89 bool z_flag_; 108 bool z_flag_;
90 bool c_flag_; 109 bool c_flag_;
91 bool v_flag_; 110 bool v_flag_;
92 111
93 // Simulator support. 112 // Simulator support.
113 int64_t last_pc_;
94 int64_t pc_; 114 int64_t pc_;
95 char* stack_; 115 char* stack_;
96 bool pc_modified_; 116 bool pc_modified_;
97 intptr_t icount_; 117 intptr_t icount_;
98 static int64_t flag_stop_sim_at_; 118 static int64_t flag_stop_sim_at_;
119 SimulatorSetjmpBuffer* last_setjmp_buffer_;
99 uword top_exit_frame_info_; 120 uword top_exit_frame_info_;
100 121
101 // Registered breakpoints. 122 // Registered breakpoints.
102 Instr* break_pc_; 123 Instr* break_pc_;
103 int64_t break_instr_; 124 int64_t break_instr_;
104 125
105 // Illegal memory access support. 126 // Illegal memory access support.
106 static bool IsIllegalAddress(uword addr) { 127 static bool IsIllegalAddress(uword addr) {
107 return addr < 64*1024; 128 return addr < 64*1024;
108 } 129 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 176
156 int64_t ExtendOperand(uint8_t reg_size, 177 int64_t ExtendOperand(uint8_t reg_size,
157 int64_t value, 178 int64_t value,
158 Extend extend_type, 179 Extend extend_type,
159 uint8_t amount); 180 uint8_t amount);
160 181
161 int64_t DecodeShiftExtendOperand(Instr* instr); 182 int64_t DecodeShiftExtendOperand(Instr* instr);
162 183
163 bool ConditionallyExecute(Instr* instr); 184 bool ConditionallyExecute(Instr* instr);
164 185
186 void DoRedirectedCall(Instr* instr);
187
165 // Decode instructions. 188 // Decode instructions.
166 void InstructionDecode(Instr* instr); 189 void InstructionDecode(Instr* instr);
167 #define DECODE_OP(op) \ 190 #define DECODE_OP(op) \
168 void Decode##op(Instr* instr); 191 void Decode##op(Instr* instr);
169 APPLY_OP_LIST(DECODE_OP) 192 APPLY_OP_LIST(DECODE_OP)
170 #undef DECODE_OP 193 #undef DECODE_OP
171 194
172 // Executes ARM64 instructions until the PC reaches kEndSimulatingPC. 195 // Executes ARM64 instructions until the PC reaches kEndSimulatingPC.
173 void Execute(); 196 void Execute();
174 197
198 // Longjmp support for exceptions.
199 SimulatorSetjmpBuffer* last_setjmp_buffer() {
200 return last_setjmp_buffer_;
201 }
202 void set_last_setjmp_buffer(SimulatorSetjmpBuffer* buffer) {
203 last_setjmp_buffer_ = buffer;
204 }
205
175 friend class SimulatorDebugger; 206 friend class SimulatorDebugger;
207 friend class SimulatorSetjmpBuffer;
176 DISALLOW_COPY_AND_ASSIGN(Simulator); 208 DISALLOW_COPY_AND_ASSIGN(Simulator);
177 }; 209 };
178 210
179 } // namespace dart 211 } // namespace dart
180 212
181 #endif // VM_SIMULATOR_ARM64_H_ 213 #endif // VM_SIMULATOR_ARM64_H_
OLDNEW
« no previous file with comments | « runtime/vm/runtime_entry_test.cc ('k') | runtime/vm/simulator_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698