| OLD | NEW |
| 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/base_isolate.h" | 8 #include "vm/base_isolate.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/os_thread.h" | 10 #include "vm/os_thread.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class CHA; | 14 class CHA; |
| 15 class Isolate; | 15 class Isolate; |
| 16 | 16 |
| 17 // 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 |
| 18 // garbage collection or compilation. | 18 // garbage collection or compilation. |
| 19 class Thread { | 19 class Thread { |
| 20 public: | 20 public: |
| 21 explicit Thread(Isolate* isolate) | 21 explicit Thread(Isolate* isolate) |
| 22 : isolate_(isolate), | 22 : isolate_(isolate), |
| 23 cha_(NULL) {} | 23 cha_(NULL) {} |
| 24 | 24 |
| 25 static void InitOnce(); | 25 static void InitOnce(); |
| 26 | 26 |
| 27 static Thread* Current() { | 27 static Thread* Current() { |
| 28 return reinterpret_cast<Thread*>(OSThread::GetThreadLocal(thread_key)); | 28 return reinterpret_cast<Thread*>(OSThread::GetThreadLocal(thread_key_)); |
| 29 } | 29 } |
| 30 static void SetCurrent(Thread* current); | 30 static void SetCurrent(Thread* current); |
| 31 | 31 |
| 32 // The topmost zone used for allocation in this thread. | 32 // The topmost zone used for allocation in this thread. |
| 33 Zone* zone() { | 33 Zone* zone() { |
| 34 return reinterpret_cast<BaseIsolate*>(isolate())->current_zone(); | 34 return reinterpret_cast<BaseIsolate*>(isolate())->current_zone(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 // The isolate that this thread is operating on, or NULL if none. | 37 // The isolate that this thread is operating on, or NULL if none. |
| 38 Isolate* isolate() const { return isolate_; } | 38 Isolate* isolate() const { return isolate_; } |
| 39 | 39 |
| 40 // The (topmost) CHA for the compilation in this thread. | 40 // The (topmost) CHA for the compilation in this thread. |
| 41 CHA* cha() const { return cha_; } | 41 CHA* cha() const { return cha_; } |
| 42 void set_cha(CHA* value) { cha_ = value; } | 42 void set_cha(CHA* value) { cha_ = value; } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 static ThreadLocalKey thread_key; | 45 static ThreadLocalKey thread_key_; |
| 46 | 46 |
| 47 Isolate* isolate_; | 47 Isolate* isolate_; |
| 48 CHA* cha_; | 48 CHA* cha_; |
| 49 | 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_ |
| OLD | NEW |