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

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

Issue 999983004: simMutex (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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/simulator_arm.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 20
21 namespace dart { 21 namespace dart {
22 22
23 class Isolate; 23 class Isolate;
24 class Mutex; 24 class Mutex;
25 class RawObject; 25 class RawObject;
26 class SimulatorSetjmpBuffer; 26 class SimulatorSetjmpBuffer;
27 class Thread;
27 28
28 typedef struct { 29 typedef struct {
29 union { 30 union {
30 int64_t i64[2]; 31 int64_t i64[2];
31 int32_t i32[4]; 32 int32_t i32[4];
32 } bits; 33 } bits;
33 } simd_value_t; 34 } simd_value_t;
34 35
35 class Simulator { 36 class Simulator {
36 public: 37 public:
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 inline int16_t ReadH(uword addr, Instr* instr); 179 inline int16_t ReadH(uword addr, Instr* instr);
179 inline void WriteH(uword addr, uint16_t value, Instr* instr); 180 inline void WriteH(uword addr, uint16_t value, Instr* instr);
180 181
181 inline uint32_t ReadWU(uword addr, Instr* instr); 182 inline uint32_t ReadWU(uword addr, Instr* instr);
182 inline int32_t ReadW(uword addr, Instr* instr); 183 inline int32_t ReadW(uword addr, Instr* instr);
183 inline void WriteW(uword addr, uint32_t value, Instr* instr); 184 inline void WriteW(uword addr, uint32_t value, Instr* instr);
184 185
185 inline intptr_t ReadX(uword addr, Instr* instr); 186 inline intptr_t ReadX(uword addr, Instr* instr);
186 inline void WriteX(uword addr, intptr_t value, Instr* instr); 187 inline void WriteX(uword addr, intptr_t value, Instr* instr);
187 188
188 // In Dart, there is at most one thread per isolate. 189 // We keep track of 16 exclusive access address tags across all threads.
189 // We keep track of 16 exclusive access address tags across all isolates.
190 // Since we cannot simulate a native context switch, which clears 190 // Since we cannot simulate a native context switch, which clears
191 // the exclusive access state of the local monitor (using the CLREX 191 // the exclusive access state of the local monitor (using the CLREX
192 // instruction), we associate the isolate requesting exclusive access to the 192 // instruction), we associate the thread requesting exclusive access to the
193 // address tag. Multiple isolates requesting exclusive access (using the LDREX 193 // address tag. Multiple threads requesting exclusive access (using the LDREX
194 // instruction) to the same address will result in multiple address tags being 194 // instruction) to the same address will result in multiple address tags being
195 // created for the same address, one per isolate. 195 // created for the same address, one per thread.
196 // At any given time, each isolate is associated to at most one address tag. 196 // At any given time, each thread is associated to at most one address tag.
197 static Mutex* exclusive_access_lock_; 197 static Mutex* exclusive_access_lock_;
198 static const int kNumAddressTags = 16; 198 static const int kNumAddressTags = 16;
199 static struct AddressTag { 199 static struct AddressTag {
200 Isolate* isolate; 200 Thread* thread;
201 uword addr; 201 uword addr;
202 } exclusive_access_state_[kNumAddressTags]; 202 } exclusive_access_state_[kNumAddressTags];
203 static int next_address_tag_; 203 static int next_address_tag_;
204 204
205 // Synchronization primitives support. 205 // Synchronization primitives support.
206 void ClearExclusive(); 206 void ClearExclusive();
207 intptr_t ReadExclusiveW(uword addr, Instr* instr); 207 intptr_t ReadExclusiveW(uword addr, Instr* instr);
208 intptr_t WriteExclusiveW(uword addr, intptr_t value, Instr* instr); 208 intptr_t WriteExclusiveW(uword addr, intptr_t value, Instr* instr);
209 209
210 // Set access to given address to 'exclusive state' for current isolate. 210 // Set access to given address to 'exclusive state' for current thread.
211 static void SetExclusiveAccess(uword addr); 211 static void SetExclusiveAccess(uword addr);
212 212
213 // Returns true if the current isolate has exclusive access to given address, 213 // Returns true if the current thread has exclusive access to given address,
214 // returns false otherwise. In either case, set access to given address to 214 // returns false otherwise. In either case, set access to given address to
215 // 'open state' for all isolates. 215 // 'open state' for all threads.
216 // If given addr is NULL, set access to 'open state' for current 216 // If given addr is NULL, set access to 'open state' for current
217 // isolate (CLREX). 217 // thread (CLREX).
218 static bool HasExclusiveAccessAndOpen(uword addr); 218 static bool HasExclusiveAccessAndOpen(uword addr);
219 219
220 // Helper functions to set the conditional flags in the architecture state. 220 // Helper functions to set the conditional flags in the architecture state.
221 void SetNZFlagsW(int32_t val); 221 void SetNZFlagsW(int32_t val);
222 bool CarryFromW(int32_t left, int32_t right, int32_t carry); 222 bool CarryFromW(int32_t left, int32_t right, int32_t carry);
223 bool OverflowFromW(int32_t left, int32_t right, int32_t carry); 223 bool OverflowFromW(int32_t left, int32_t right, int32_t carry);
224 224
225 void SetNZFlagsX(int64_t val); 225 void SetNZFlagsX(int64_t val);
226 bool CarryFromX(int64_t alu_out, int64_t left, int64_t right, bool addition); 226 bool CarryFromX(int64_t alu_out, int64_t left, int64_t right, bool addition);
227 bool OverflowFromX( 227 bool OverflowFromX(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
269 269
270 friend class SimulatorDebugger; 270 friend class SimulatorDebugger;
271 friend class SimulatorSetjmpBuffer; 271 friend class SimulatorSetjmpBuffer;
272 DISALLOW_COPY_AND_ASSIGN(Simulator); 272 DISALLOW_COPY_AND_ASSIGN(Simulator);
273 }; 273 };
274 274
275 } // namespace dart 275 } // namespace dart
276 276
277 #endif // VM_SIMULATOR_ARM64_H_ 277 #endif // VM_SIMULATOR_ARM64_H_
OLDNEW
« no previous file with comments | « runtime/vm/simulator_arm.cc ('k') | runtime/vm/simulator_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698