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" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 StackResource* top_resource() const { return state_.top_resource; } | 117 StackResource* top_resource() const { return state_.top_resource; } |
118 void set_top_resource(StackResource* value) { | 118 void set_top_resource(StackResource* value) { |
119 state_.top_resource = value; | 119 state_.top_resource = value; |
120 } | 120 } |
121 static intptr_t top_resource_offset() { | 121 static intptr_t top_resource_offset() { |
122 return OFFSET_OF(Thread, state_) + OFFSET_OF(State, top_resource); | 122 return OFFSET_OF(Thread, state_) + OFFSET_OF(State, top_resource); |
123 } | 123 } |
124 | 124 |
125 void set_thread_state(InterruptableThreadState* state) { | 125 void set_thread_state(InterruptableThreadState* state) { |
126 ASSERT((thread_state() == NULL) || (state == NULL)); | 126 ASSERT((thread_state() == NULL) || (state == NULL)); |
127 state_.thread_state = state; | 127 thread_state_ = state; |
128 } | 128 } |
129 | 129 |
130 InterruptableThreadState* thread_state() const { | 130 InterruptableThreadState* thread_state() const { |
131 return state_.thread_state; | 131 return thread_state_; |
132 } | 132 } |
133 | 133 |
134 static intptr_t heap_offset() { | 134 static intptr_t heap_offset() { |
135 return OFFSET_OF(Thread, heap_); | 135 return OFFSET_OF(Thread, heap_); |
136 } | 136 } |
137 | 137 |
138 int32_t no_handle_scope_depth() const { | 138 int32_t no_handle_scope_depth() const { |
139 #if defined(DEBUG) | 139 #if defined(DEBUG) |
140 return state_.no_handle_scope_depth; | 140 return state_.no_handle_scope_depth; |
141 #else | 141 #else |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 #endif | 193 #endif |
194 } | 194 } |
195 | 195 |
196 // Collection of isolate-specific state of a thread that is saved/restored | 196 // Collection of isolate-specific state of a thread that is saved/restored |
197 // on isolate exit/re-entry. | 197 // on isolate exit/re-entry. |
198 struct State { | 198 struct State { |
199 Zone* zone; | 199 Zone* zone; |
200 uword top_exit_frame_info; | 200 uword top_exit_frame_info; |
201 StackResource* top_resource; | 201 StackResource* top_resource; |
202 TimelineEventBlock* timeline_block; | 202 TimelineEventBlock* timeline_block; |
203 // TODO(koda): Migrate individual fields of InterruptableThreadState. | |
204 InterruptableThreadState* thread_state; | |
205 LongJumpScope* long_jump_base; | 203 LongJumpScope* long_jump_base; |
206 #if defined(DEBUG) | 204 #if defined(DEBUG) |
207 HandleScope* top_handle_scope; | 205 HandleScope* top_handle_scope; |
208 intptr_t no_handle_scope_depth; | 206 intptr_t no_handle_scope_depth; |
209 int32_t no_safepoint_scope_depth; | 207 int32_t no_safepoint_scope_depth; |
210 #endif | 208 #endif |
211 }; | 209 }; |
212 | 210 |
213 #define DEFINE_OFFSET_METHOD(type_name, member_name, expr, default_init_value) \ | 211 #define DEFINE_OFFSET_METHOD(type_name, member_name, expr, default_init_value) \ |
214 static intptr_t member_name##offset() { \ | 212 static intptr_t member_name##offset() { \ |
(...skipping 18 matching lines...) Expand all Loading... |
233 state_.long_jump_base = value; | 231 state_.long_jump_base = value; |
234 } | 232 } |
235 | 233 |
236 private: | 234 private: |
237 static ThreadLocalKey thread_key_; | 235 static ThreadLocalKey thread_key_; |
238 | 236 |
239 Isolate* isolate_; | 237 Isolate* isolate_; |
240 Heap* heap_; | 238 Heap* heap_; |
241 State state_; | 239 State state_; |
242 StoreBufferBlock* store_buffer_block_; | 240 StoreBufferBlock* store_buffer_block_; |
| 241 // TODO(koda): Migrate individual fields of InterruptableThreadState. |
| 242 InterruptableThreadState* thread_state_; |
243 #define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value) \ | 243 #define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value) \ |
244 type_name member_name; | 244 type_name member_name; |
245 CACHED_CONSTANTS_LIST(DECLARE_MEMBERS) | 245 CACHED_CONSTANTS_LIST(DECLARE_MEMBERS) |
246 #undef DECLARE_MEMBERS | 246 #undef DECLARE_MEMBERS |
247 | 247 |
248 explicit Thread(bool init_vm_constants = true); | 248 explicit Thread(bool init_vm_constants = true); |
249 | 249 |
250 void InitVMConstants(); | 250 void InitVMConstants(); |
251 | 251 |
252 void ClearState() { | 252 void ClearState() { |
(...skipping 19 matching lines...) Expand all Loading... |
272 friend class ApiZone; | 272 friend class ApiZone; |
273 friend class Isolate; | 273 friend class Isolate; |
274 friend class StackZone; | 274 friend class StackZone; |
275 friend class ThreadRegistry; | 275 friend class ThreadRegistry; |
276 DISALLOW_COPY_AND_ASSIGN(Thread); | 276 DISALLOW_COPY_AND_ASSIGN(Thread); |
277 }; | 277 }; |
278 | 278 |
279 } // namespace dart | 279 } // namespace dart |
280 | 280 |
281 #endif // VM_THREAD_H_ | 281 #endif // VM_THREAD_H_ |
OLD | NEW |