| 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/globals.h" | 8 #include "vm/globals.h" |
| 9 #include "vm/os_thread.h" | 9 #include "vm/os_thread.h" |
| 10 #include "vm/store_buffer.h" | 10 #include "vm/store_buffer.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 class CHA; | 14 class CHA; |
| 15 class HandleScope; | 15 class HandleScope; |
| 16 class Heap; | 16 class Heap; |
| 17 class InterruptableThreadState; |
| 17 class Isolate; | 18 class Isolate; |
| 18 class Object; | 19 class Object; |
| 19 class RawBool; | 20 class RawBool; |
| 20 class RawObject; | 21 class RawObject; |
| 21 class StackResource; | 22 class StackResource; |
| 22 class Zone; | 23 class Zone; |
| 23 | 24 |
| 24 | 25 |
| 25 // List of VM-global objects/addresses cached in each Thread object. | 26 // List of VM-global objects/addresses cached in each Thread object. |
| 26 #define CACHED_VM_OBJECTS_LIST(V) \ | 27 #define CACHED_VM_OBJECTS_LIST(V) \ |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 113 } |
| 113 | 114 |
| 114 StackResource* top_resource() const { return state_.top_resource; } | 115 StackResource* top_resource() const { return state_.top_resource; } |
| 115 void set_top_resource(StackResource* value) { | 116 void set_top_resource(StackResource* value) { |
| 116 state_.top_resource = value; | 117 state_.top_resource = value; |
| 117 } | 118 } |
| 118 static intptr_t top_resource_offset() { | 119 static intptr_t top_resource_offset() { |
| 119 return OFFSET_OF(Thread, state_) + OFFSET_OF(State, top_resource); | 120 return OFFSET_OF(Thread, state_) + OFFSET_OF(State, top_resource); |
| 120 } | 121 } |
| 121 | 122 |
| 123 void set_thread_state(InterruptableThreadState* state) { |
| 124 ASSERT((thread_state() == NULL) || (state == NULL)); |
| 125 state_.thread_state = state; |
| 126 } |
| 127 |
| 128 InterruptableThreadState* thread_state() const { |
| 129 return state_.thread_state; |
| 130 } |
| 131 |
| 122 static intptr_t heap_offset() { | 132 static intptr_t heap_offset() { |
| 123 return OFFSET_OF(Thread, heap_); | 133 return OFFSET_OF(Thread, heap_); |
| 124 } | 134 } |
| 125 | 135 |
| 126 int32_t no_handle_scope_depth() const { | 136 int32_t no_handle_scope_depth() const { |
| 127 #if defined(DEBUG) | 137 #if defined(DEBUG) |
| 128 return state_.no_handle_scope_depth; | 138 return state_.no_handle_scope_depth; |
| 129 #else | 139 #else |
| 130 return 0; | 140 return 0; |
| 131 #endif | 141 #endif |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 state_.no_safepoint_scope_depth -= 1; | 190 state_.no_safepoint_scope_depth -= 1; |
| 181 #endif | 191 #endif |
| 182 } | 192 } |
| 183 | 193 |
| 184 // Collection of isolate-specific state of a thread that is saved/restored | 194 // Collection of isolate-specific state of a thread that is saved/restored |
| 185 // on isolate exit/re-entry. | 195 // on isolate exit/re-entry. |
| 186 struct State { | 196 struct State { |
| 187 Zone* zone; | 197 Zone* zone; |
| 188 uword top_exit_frame_info; | 198 uword top_exit_frame_info; |
| 189 StackResource* top_resource; | 199 StackResource* top_resource; |
| 200 // TODO(koda): Migrate individual fields of InterruptableThreadState. |
| 201 InterruptableThreadState* thread_state; |
| 190 #if defined(DEBUG) | 202 #if defined(DEBUG) |
| 191 HandleScope* top_handle_scope; | 203 HandleScope* top_handle_scope; |
| 192 intptr_t no_handle_scope_depth; | 204 intptr_t no_handle_scope_depth; |
| 193 int32_t no_safepoint_scope_depth; | 205 int32_t no_safepoint_scope_depth; |
| 194 #endif | 206 #endif |
| 195 }; | 207 }; |
| 196 | 208 |
| 197 #define DEFINE_OFFSET_METHOD(type_name, member_name, expr, default_init_value) \ | 209 #define DEFINE_OFFSET_METHOD(type_name, member_name, expr, default_init_value) \ |
| 198 static intptr_t member_name##offset() { \ | 210 static intptr_t member_name##offset() { \ |
| 199 return OFFSET_OF(Thread, member_name); \ | 211 return OFFSET_OF(Thread, member_name); \ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 251 |
| 240 friend class ApiZone; | 252 friend class ApiZone; |
| 241 friend class Isolate; | 253 friend class Isolate; |
| 242 friend class StackZone; | 254 friend class StackZone; |
| 243 DISALLOW_COPY_AND_ASSIGN(Thread); | 255 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 244 }; | 256 }; |
| 245 | 257 |
| 246 } // namespace dart | 258 } // namespace dart |
| 247 | 259 |
| 248 #endif // VM_THREAD_H_ | 260 #endif // VM_THREAD_H_ |
| OLD | NEW |