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

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

Issue 1037453002: Split Thread/Isolate instances, but still maintain 1:1 relationship. (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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 #ifndef VM_THREAD_H_ 5 #ifndef VM_THREAD_H_
6 #define VM_THREAD_H_ 6 #define VM_THREAD_H_
7 7
8 #include "vm/isolate.h" 8 #include "vm/base_isolate.h"
9 #include "vm/globals.h"
10 #include "vm/os_thread.h"
9 11
10 namespace dart { 12 namespace dart {
11 13
14 class CHA;
15 class Isolate;
16
12 // A VM thread; may be executing Dart code or performing helper tasks like 17 // A VM thread; may be executing Dart code or performing helper tasks like
13 // garbage collection or compilation. 18 // garbage collection or compilation.
14 class Thread { 19 class Thread {
15 public: 20 public:
21 explicit Thread(Isolate* isolate)
22 : isolate_(isolate),
23 cha_(NULL) {}
24
25 static void InitOnce();
26
16 static Thread* Current() { 27 static Thread* Current() {
17 // For now, there is still just one thread per isolate, and the Thread 28 return reinterpret_cast<Thread*>(OSThread::GetThreadLocal(thread_key));
18 // class just aliases the Isolate*. Once all interfaces and uses have been
19 // updated to distinguish between isolates and threads, Thread will get its
20 // own thread-local storage key and fields.
21 return reinterpret_cast<Thread*>(Isolate::Current());
22 } 29 }
23 // TODO(koda): Remove after pivoting to Thread* in native/runtime entries. 30 static void SetCurrent(Thread* current);
24 static Thread* CurrentFromCurrentIsolate(BaseIsolate* isolate) {
25 ASSERT(Isolate::Current() == isolate);
26 return reinterpret_cast<Thread*>(isolate);
27 }
28 31
29 // The topmost zone used for allocation in this thread. 32 // The topmost zone used for allocation in this thread.
30 Zone* zone() { 33 Zone* zone() {
31 return reinterpret_cast<BaseIsolate*>(this)->current_zone(); 34 return reinterpret_cast<BaseIsolate*>(isolate())->current_zone();
32 } 35 }
33 36
34 // The isolate that this thread is operating on. 37 // The isolate that this thread is operating on, or NULL if none.
35 Isolate* isolate() { return reinterpret_cast<Isolate*>(this); } 38 Isolate* isolate() const { return isolate_; }
36 const Isolate* isolate() const {
37 return reinterpret_cast<const Isolate*>(this);
38 }
39
40 // The log for this thread.
41 class Log* Log() {
42 return reinterpret_cast<Isolate*>(this)->Log();
43 }
44 39
45 // The (topmost) CHA for the compilation in this thread. 40 // The (topmost) CHA for the compilation in this thread.
46 CHA* cha() const { return isolate()->cha(); } 41 CHA* cha() const { return cha_; }
47 void set_cha(CHA* value) { isolate()->set_cha(value); } 42 void set_cha(CHA* value) { cha_ = value; }
48 43
49 private: 44 private:
45 static ThreadLocalKey thread_key;
Ivan Posva 2015/03/26 14:36:52 thread_key_
46
47 Isolate* isolate_;
48 CHA* cha_;
49
50 DISALLOW_COPY_AND_ASSIGN(Thread); 50 DISALLOW_COPY_AND_ASSIGN(Thread);
51 }; 51 };
52 52
53 } // namespace dart 53 } // namespace dart
54 54
55 #endif // VM_THREAD_H_ 55 #endif // VM_THREAD_H_
OLDNEW
« runtime/vm/isolate.h ('K') | « runtime/vm/runtime_entry.h ('k') | runtime/vm/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698