Chromium Code Reviews| 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 Isolate; | 17 class Isolate; |
| 18 class Object; | 18 class Object; |
| 19 class RawBool; | 19 class RawBool; |
| 20 class RawObject; | 20 class RawObject; |
| 21 class StackResource; | 21 class StackResource; |
| 22 class TimelineEventBlock; | |
| 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) \ |
| 27 V(RawObject*, object_null_, Object::null(), NULL) \ | 28 V(RawObject*, object_null_, Object::null(), NULL) \ |
| 28 V(RawBool*, bool_true_, Object::bool_true().raw(), NULL) \ | 29 V(RawBool*, bool_true_, Object::bool_true().raw(), NULL) \ |
| 29 V(RawBool*, bool_false_, Object::bool_false().raw(), NULL) \ | 30 V(RawBool*, bool_false_, Object::bool_false().raw(), NULL) \ |
| 30 | 31 |
| 31 #define CACHED_ADDRESSES_LIST(V) \ | 32 #define CACHED_ADDRESSES_LIST(V) \ |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 state_.no_safepoint_scope_depth -= 1; | 181 state_.no_safepoint_scope_depth -= 1; |
| 181 #endif | 182 #endif |
| 182 } | 183 } |
| 183 | 184 |
| 184 // Collection of isolate-specific state of a thread that is saved/restored | 185 // Collection of isolate-specific state of a thread that is saved/restored |
| 185 // on isolate exit/re-entry. | 186 // on isolate exit/re-entry. |
| 186 struct State { | 187 struct State { |
| 187 Zone* zone; | 188 Zone* zone; |
| 188 uword top_exit_frame_info; | 189 uword top_exit_frame_info; |
| 189 StackResource* top_resource; | 190 StackResource* top_resource; |
| 191 TimelineEventBlock* current_block; | |
|
koda
2015/08/07 01:09:54
Name is a bit too general; consider adding "_timel
Cutch
2015/08/07 16:47:42
Done.
| |
| 190 #if defined(DEBUG) | 192 #if defined(DEBUG) |
| 191 HandleScope* top_handle_scope; | 193 HandleScope* top_handle_scope; |
| 192 intptr_t no_handle_scope_depth; | 194 intptr_t no_handle_scope_depth; |
| 193 int32_t no_safepoint_scope_depth; | 195 int32_t no_safepoint_scope_depth; |
| 194 #endif | 196 #endif |
| 195 }; | 197 }; |
| 196 | 198 |
| 197 #define DEFINE_OFFSET_METHOD(type_name, member_name, expr, default_init_value) \ | 199 #define DEFINE_OFFSET_METHOD(type_name, member_name, expr, default_init_value) \ |
| 198 static intptr_t member_name##offset() { \ | 200 static intptr_t member_name##offset() { \ |
| 199 return OFFSET_OF(Thread, member_name); \ | 201 return OFFSET_OF(Thread, member_name); \ |
| 200 } | 202 } |
| 201 CACHED_CONSTANTS_LIST(DEFINE_OFFSET_METHOD) | 203 CACHED_CONSTANTS_LIST(DEFINE_OFFSET_METHOD) |
| 202 #undef DEFINE_OFFSET_METHOD | 204 #undef DEFINE_OFFSET_METHOD |
| 203 | 205 |
| 204 static bool CanLoadFromThread(const Object& object); | 206 static bool CanLoadFromThread(const Object& object); |
| 205 static intptr_t OffsetFromThread(const Object& object); | 207 static intptr_t OffsetFromThread(const Object& object); |
| 206 | 208 |
| 209 TimelineEventBlock* current_block() const { | |
| 210 return state_.current_block; | |
| 211 } | |
| 212 | |
| 213 void set_current_block(TimelineEventBlock* block) { | |
| 214 state_.current_block = block; | |
| 215 } | |
| 216 | |
| 207 private: | 217 private: |
| 208 static ThreadLocalKey thread_key_; | 218 static ThreadLocalKey thread_key_; |
| 209 | 219 |
| 210 Isolate* isolate_; | 220 Isolate* isolate_; |
| 211 Heap* heap_; | 221 Heap* heap_; |
| 212 State state_; | 222 State state_; |
| 213 StoreBufferBlock* store_buffer_block_; | 223 StoreBufferBlock* store_buffer_block_; |
| 214 #define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value) \ | 224 #define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value) \ |
| 215 type_name member_name; | 225 type_name member_name; |
| 216 CACHED_CONSTANTS_LIST(DECLARE_MEMBERS) | 226 CACHED_CONSTANTS_LIST(DECLARE_MEMBERS) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 228 state_.zone = zone; | 238 state_.zone = zone; |
| 229 } | 239 } |
| 230 | 240 |
| 231 void set_top_exit_frame_info(uword top_exit_frame_info) { | 241 void set_top_exit_frame_info(uword top_exit_frame_info) { |
| 232 state_.top_exit_frame_info = top_exit_frame_info; | 242 state_.top_exit_frame_info = top_exit_frame_info; |
| 233 } | 243 } |
| 234 | 244 |
| 235 static void SetCurrent(Thread* current); | 245 static void SetCurrent(Thread* current); |
| 236 | 246 |
| 237 void Schedule(Isolate* isolate); | 247 void Schedule(Isolate* isolate); |
| 248 void PostSchedule(); | |
| 238 void Unschedule(); | 249 void Unschedule(); |
| 239 | 250 |
| 240 friend class ApiZone; | 251 friend class ApiZone; |
| 241 friend class Isolate; | 252 friend class Isolate; |
| 242 friend class StackZone; | 253 friend class StackZone; |
| 243 DISALLOW_COPY_AND_ASSIGN(Thread); | 254 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 244 }; | 255 }; |
| 245 | 256 |
| 246 } // namespace dart | 257 } // namespace dart |
| 247 | 258 |
| 248 #endif // VM_THREAD_H_ | 259 #endif // VM_THREAD_H_ |
| OLD | NEW |