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

Side by Side Diff: runtime/vm/simulator_mips.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_arm64.cc ('k') | runtime/vm/simulator_mips.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) 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 MIPS instructions if we are not generating a native 5 // Declares a Simulator for MIPS instructions if we are not generating a native
6 // MIPS binary. This Simulator allows us to run and debug MIPS code generation 6 // MIPS binary. This Simulator allows us to run and debug MIPS 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 MIPS HW platform. 10 // on a MIPS HW platform.
11 11
12 #ifndef VM_SIMULATOR_MIPS_H_ 12 #ifndef VM_SIMULATOR_MIPS_H_
13 #define VM_SIMULATOR_MIPS_H_ 13 #define VM_SIMULATOR_MIPS_H_
14 14
15 #ifndef VM_SIMULATOR_H_ 15 #ifndef VM_SIMULATOR_H_
16 #error Do not include simulator_mips.h directly; use simulator.h. 16 #error Do not include simulator_mips.h directly; use simulator.h.
17 #endif 17 #endif
18 18
19 #include "vm/constants_mips.h" 19 #include "vm/constants_mips.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 class Simulator { 29 class Simulator {
29 public: 30 public:
30 static const uword kSimulatorStackUnderflowSize = 64; 31 static const uword kSimulatorStackUnderflowSize = 64;
31 32
32 Simulator(); 33 Simulator();
33 ~Simulator(); 34 ~Simulator();
34 35
35 // The currently executing Simulator instance, which is associated to the 36 // The currently executing Simulator instance, which is associated to the
36 // current isolate 37 // current isolate
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 inline uint16_t ReadHU(uword addr, Instr *instr); 191 inline uint16_t ReadHU(uword addr, Instr *instr);
191 inline intptr_t ReadW(uword addr, Instr* instr); 192 inline intptr_t ReadW(uword addr, Instr* instr);
192 193
193 inline void WriteB(uword addr, uint8_t value); 194 inline void WriteB(uword addr, uint8_t value);
194 inline void WriteH(uword addr, uint16_t value, Instr* isntr); 195 inline void WriteH(uword addr, uint16_t value, Instr* isntr);
195 inline void WriteW(uword addr, intptr_t value, Instr* instr); 196 inline void WriteW(uword addr, intptr_t value, Instr* instr);
196 197
197 inline double ReadD(uword addr, Instr* instr); 198 inline double ReadD(uword addr, Instr* instr);
198 inline void WriteD(uword addr, double value, Instr* instr); 199 inline void WriteD(uword addr, double value, Instr* instr);
199 200
200 // In Dart, there is at most one thread per isolate. 201 // We keep track of 16 exclusive access address tags across all threads.
201 // We keep track of 16 exclusive access address tags across all isolates.
202 // Since we cannot simulate a native context switch, which clears 202 // Since we cannot simulate a native context switch, which clears
203 // the exclusive access state of the local monitor, we associate the isolate 203 // the exclusive access state of the local monitor, we associate the thread
204 // requesting exclusive access to the address tag. 204 // requesting exclusive access to the address tag.
205 // Multiple isolates requesting exclusive access (using the LL instruction) 205 // Multiple threads requesting exclusive access (using the LL instruction)
206 // to the same address will result in multiple address tags being created for 206 // to the same address will result in multiple address tags being created for
207 // the same address, one per isolate. 207 // the same address, one per thread.
208 // At any given time, each isolate is associated to at most one address tag. 208 // At any given time, each thread is associated to at most one address tag.
209 static Mutex* exclusive_access_lock_; 209 static Mutex* exclusive_access_lock_;
210 static const int kNumAddressTags = 16; 210 static const int kNumAddressTags = 16;
211 static struct AddressTag { 211 static struct AddressTag {
212 Isolate* isolate; 212 Thread* thread;
213 uword addr; 213 uword addr;
214 } exclusive_access_state_[kNumAddressTags]; 214 } exclusive_access_state_[kNumAddressTags];
215 static int next_address_tag_; 215 static int next_address_tag_;
216 216
217 // Synchronization primitives support. 217 // Synchronization primitives support.
218 void ClearExclusive(); 218 void ClearExclusive();
219 intptr_t ReadExclusiveW(uword addr, Instr* instr); 219 intptr_t ReadExclusiveW(uword addr, Instr* instr);
220 intptr_t WriteExclusiveW(uword addr, intptr_t value, Instr* instr); 220 intptr_t WriteExclusiveW(uword addr, intptr_t value, Instr* instr);
221 221
222 // Set access to given address to 'exclusive state' for current isolate. 222 // Set access to given address to 'exclusive state' for current thread.
223 static void SetExclusiveAccess(uword addr); 223 static void SetExclusiveAccess(uword addr);
224 224
225 // Returns true if the current isolate has exclusive access to given address, 225 // Returns true if the current thread has exclusive access to given address,
226 // returns false otherwise. In either case, set access to given address to 226 // returns false otherwise. In either case, set access to given address to
227 // 'open state' for all isolates. 227 // 'open state' for all threads.
228 // If given addr is NULL, set access to 'open state' for current 228 // If given addr is NULL, set access to 'open state' for current
229 // isolate (CLREX). 229 // thread (CLREX).
230 static bool HasExclusiveAccessAndOpen(uword addr); 230 static bool HasExclusiveAccessAndOpen(uword addr);
231 231
232 void DoBranch(Instr* instr, bool taken, bool likely); 232 void DoBranch(Instr* instr, bool taken, bool likely);
233 void DoBreak(Instr *instr); 233 void DoBreak(Instr *instr);
234 234
235 void DecodeSpecial(Instr* instr); 235 void DecodeSpecial(Instr* instr);
236 void DecodeSpecial2(Instr* instr); 236 void DecodeSpecial2(Instr* instr);
237 void DecodeRegImm(Instr* instr); 237 void DecodeRegImm(Instr* instr);
238 void DecodeCop1(Instr* instr); 238 void DecodeCop1(Instr* instr);
239 void InstructionDecode(Instr* instr); 239 void InstructionDecode(Instr* instr);
(...skipping 13 matching lines...) Expand all
253 } 253 }
254 254
255 friend class SimulatorDebugger; 255 friend class SimulatorDebugger;
256 friend class SimulatorSetjmpBuffer; 256 friend class SimulatorSetjmpBuffer;
257 DISALLOW_COPY_AND_ASSIGN(Simulator); 257 DISALLOW_COPY_AND_ASSIGN(Simulator);
258 }; 258 };
259 259
260 } // namespace dart 260 } // namespace dart
261 261
262 #endif // VM_SIMULATOR_MIPS_H_ 262 #endif // VM_SIMULATOR_MIPS_H_
OLDNEW
« no previous file with comments | « runtime/vm/simulator_arm64.cc ('k') | runtime/vm/simulator_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698