| 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 "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/handles.h" | 10 #include "vm/handles.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // The currently executing thread, or NULL if not yet initialized. | 115 // The currently executing thread, or NULL if not yet initialized. |
| 116 static Thread* Current() { | 116 static Thread* Current() { |
| 117 BaseThread* thread = OSThread::GetCurrentTLS(); | 117 BaseThread* thread = OSThread::GetCurrentTLS(); |
| 118 if (thread == NULL || thread->is_os_thread()) { | 118 if (thread == NULL || thread->is_os_thread()) { |
| 119 return NULL; | 119 return NULL; |
| 120 } | 120 } |
| 121 return reinterpret_cast<Thread*>(thread); | 121 return reinterpret_cast<Thread*>(thread); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Makes the current thread enter 'isolate'. | 124 // Makes the current thread enter 'isolate'. |
| 125 static void EnterIsolate(Isolate* isolate); | 125 static bool EnterIsolate(Isolate* isolate); |
| 126 // Makes the current thread exit its isolate. | 126 // Makes the current thread exit its isolate. |
| 127 static void ExitIsolate(); | 127 static void ExitIsolate(); |
| 128 | 128 |
| 129 // A VM thread other than the main mutator thread can enter an isolate as a | 129 // A VM thread other than the main mutator thread can enter an isolate as a |
| 130 // "helper" to gain limited concurrent access to the isolate. One example is | 130 // "helper" to gain limited concurrent access to the isolate. One example is |
| 131 // SweeperTask (which uses the class table, which is copy-on-write). | 131 // SweeperTask (which uses the class table, which is copy-on-write). |
| 132 // TODO(koda): Properly synchronize heap access to expand allowed operations. | 132 // TODO(koda): Properly synchronize heap access to expand allowed operations. |
| 133 static void EnterIsolateAsHelper(Isolate* isolate, | 133 static bool EnterIsolateAsHelper(Isolate* isolate, |
| 134 bool bypass_safepoint = false); | 134 bool bypass_safepoint = false); |
| 135 static void ExitIsolateAsHelper(bool bypass_safepoint = false); | 135 static void ExitIsolateAsHelper(bool bypass_safepoint = false); |
| 136 | 136 |
| 137 // Called when the current thread transitions from mutator to collector. | 137 // Called when the current thread transitions from mutator to collector. |
| 138 // Empties the store buffer block into the isolate. | 138 // Empties the store buffer block into the isolate. |
| 139 // TODO(koda): Always run GC in separate thread. | 139 // TODO(koda): Always run GC in separate thread. |
| 140 static void PrepareForGC(); | 140 static void PrepareForGC(); |
| 141 | 141 |
| 142 // OSThread corresponding to this thread. | 142 // OSThread corresponding to this thread. |
| 143 OSThread* os_thread() const { return os_thread_; } | 143 OSThread* os_thread() const { return os_thread_; } |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 // Disable thread interrupts. | 498 // Disable thread interrupts. |
| 499 class DisableThreadInterruptsScope : public StackResource { | 499 class DisableThreadInterruptsScope : public StackResource { |
| 500 public: | 500 public: |
| 501 explicit DisableThreadInterruptsScope(Thread* thread); | 501 explicit DisableThreadInterruptsScope(Thread* thread); |
| 502 ~DisableThreadInterruptsScope(); | 502 ~DisableThreadInterruptsScope(); |
| 503 }; | 503 }; |
| 504 | 504 |
| 505 } // namespace dart | 505 } // namespace dart |
| 506 | 506 |
| 507 #endif // VM_THREAD_H_ | 507 #endif // VM_THREAD_H_ |
| OLD | NEW |