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 ARM instructions if we are not generating a native | 5 // Declares a Simulator for ARM instructions if we are not generating a native |
6 // ARM binary. This Simulator allows us to run and debug ARM code generation on | 6 // ARM binary. This Simulator allows us to run and debug ARM code generation on |
7 // regular desktop machines. | 7 // 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 ARM HW platform. | 10 // on a ARM HW platform. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // If fp_args is true, the parameters0-3 are placed in S0-3. Otherwise, they | 87 // If fp_args is true, the parameters0-3 are placed in S0-3. Otherwise, they |
88 // are placed in R0-3. | 88 // are placed in R0-3. |
89 int64_t Call(int32_t entry, | 89 int64_t Call(int32_t entry, |
90 int32_t parameter0, | 90 int32_t parameter0, |
91 int32_t parameter1, | 91 int32_t parameter1, |
92 int32_t parameter2, | 92 int32_t parameter2, |
93 int32_t parameter3, | 93 int32_t parameter3, |
94 bool fp_return = false, | 94 bool fp_return = false, |
95 bool fp_args = false); | 95 bool fp_args = false); |
96 | 96 |
97 // Implementation of atomic compare and exchange in the same synchronization | |
98 // domain as other synchronization primitive instructions (e.g. ldrex, strex). | |
99 static uword CompareExchange(uword* address, | |
100 uword compare_value, | |
101 uword new_value); | |
102 | 97 |
103 // Runtime and native call support. | 98 // Runtime and native call support. |
104 enum CallKind { | 99 enum CallKind { |
105 kRuntimeCall, | 100 kRuntimeCall, |
106 kLeafRuntimeCall, | 101 kLeafRuntimeCall, |
107 kLeafFloatRuntimeCall, | 102 kLeafFloatRuntimeCall, |
108 kBootstrapNativeCall, | 103 kBootstrapNativeCall, |
109 kNativeCall | 104 kNativeCall |
110 }; | 105 }; |
111 static uword RedirectExternalReference(uword function, | 106 static uword RedirectExternalReference(uword function, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 inline int8_t ReadB(uword addr); | 196 inline int8_t ReadB(uword addr); |
202 inline void WriteB(uword addr, uint8_t value); | 197 inline void WriteB(uword addr, uint8_t value); |
203 | 198 |
204 inline uint16_t ReadHU(uword addr, Instr* instr); | 199 inline uint16_t ReadHU(uword addr, Instr* instr); |
205 inline int16_t ReadH(uword addr, Instr* instr); | 200 inline int16_t ReadH(uword addr, Instr* instr); |
206 inline void WriteH(uword addr, uint16_t value, Instr* instr); | 201 inline void WriteH(uword addr, uint16_t value, Instr* instr); |
207 | 202 |
208 inline intptr_t ReadW(uword addr, Instr* instr); | 203 inline intptr_t ReadW(uword addr, Instr* instr); |
209 inline void WriteW(uword addr, intptr_t value, Instr* instr); | 204 inline void WriteW(uword addr, intptr_t value, Instr* instr); |
210 | 205 |
211 // Synchronization primitives support. | |
212 void ClearExclusive(); | |
213 intptr_t ReadExclusiveW(uword addr, Instr* instr); | |
214 intptr_t WriteExclusiveW(uword addr, intptr_t value, Instr* instr); | |
215 | |
216 // TODO(regis): Remove exclusive access support machinery if not needed. | |
217 // In Dart, there is at most one thread per isolate. | |
218 // We keep track of 16 exclusive access address tags across all isolates. | |
219 // Since we cannot simulate a native context switch, which clears | |
220 // the exclusive access state of the local monitor (using the CLREX | |
221 // instruction), we associate the isolate requesting exclusive access to the | |
222 // address tag. Multiple isolates requesting exclusive access (using the LDREX | |
223 // instruction) to the same address will result in multiple address tags being | |
224 // created for the same address, one per isolate. | |
225 // At any given time, each isolate is associated to at most one address tag. | |
226 static Mutex* exclusive_access_lock_; | |
227 static const int kNumAddressTags = 16; | |
228 static struct AddressTag { | |
229 Isolate* isolate; | |
230 uword addr; | |
231 } exclusive_access_state_[kNumAddressTags]; | |
232 static int next_address_tag_; | |
233 | |
234 // Set access to given address to 'exclusive state' for current isolate. | |
235 static void SetExclusiveAccess(uword addr); | |
236 | |
237 // Returns true if the current isolate has exclusive access to given address, | |
238 // returns false otherwise. In either case, set access to given address to | |
239 // 'open state' for all isolates. | |
240 // If given addr is NULL, set access to 'open state' for current | |
241 // isolate (CLREX). | |
242 static bool HasExclusiveAccessAndOpen(uword addr); | |
243 | |
244 // Executing is handled based on the instruction type. | 206 // Executing is handled based on the instruction type. |
245 void DecodeType01(Instr* instr); // Both type 0 and type 1 rolled into one. | 207 void DecodeType01(Instr* instr); // Both type 0 and type 1 rolled into one. |
246 void DecodeType2(Instr* instr); | 208 void DecodeType2(Instr* instr); |
247 void DecodeType3(Instr* instr); | 209 void DecodeType3(Instr* instr); |
248 void DecodeType4(Instr* instr); | 210 void DecodeType4(Instr* instr); |
249 void DecodeType5(Instr* instr); | 211 void DecodeType5(Instr* instr); |
250 void DecodeType6(Instr* instr); | 212 void DecodeType6(Instr* instr); |
251 void DecodeType7(Instr* instr); | 213 void DecodeType7(Instr* instr); |
252 void DecodeSIMDDataProcessing(Instr* instr); | 214 void DecodeSIMDDataProcessing(Instr* instr); |
253 | 215 |
(...skipping 12 matching lines...) Expand all Loading... |
266 } | 228 } |
267 | 229 |
268 friend class SimulatorDebugger; | 230 friend class SimulatorDebugger; |
269 friend class SimulatorSetjmpBuffer; | 231 friend class SimulatorSetjmpBuffer; |
270 DISALLOW_COPY_AND_ASSIGN(Simulator); | 232 DISALLOW_COPY_AND_ASSIGN(Simulator); |
271 }; | 233 }; |
272 | 234 |
273 } // namespace dart | 235 } // namespace dart |
274 | 236 |
275 #endif // VM_SIMULATOR_ARM_H_ | 237 #endif // VM_SIMULATOR_ARM_H_ |
OLD | NEW |