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 "vm/globals.h" | 9 #include "vm/globals.h" |
9 #include "vm/handles.h" | 10 #include "vm/handles.h" |
10 #include "vm/os_thread.h" | 11 #include "vm/os_thread.h" |
11 #include "vm/store_buffer.h" | 12 #include "vm/store_buffer.h" |
12 #include "vm/runtime_entry_list.h" | 13 #include "vm/runtime_entry_list.h" |
13 | 14 |
14 namespace dart { | 15 namespace dart { |
15 | 16 |
16 class AbstractType; | 17 class AbstractType; |
| 18 class ApiLocalScope; |
17 class Array; | 19 class Array; |
18 class CHA; | 20 class CHA; |
19 class Class; | 21 class Class; |
20 class Code; | 22 class Code; |
21 class Error; | 23 class Error; |
22 class ExceptionHandlers; | 24 class ExceptionHandlers; |
23 class Field; | 25 class Field; |
24 class Function; | 26 class Function; |
25 class GrowableObjectArray; | 27 class GrowableObjectArray; |
26 class HandleScope; | 28 class HandleScope; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 131 |
130 // OSThread corresponding to this thread. | 132 // OSThread corresponding to this thread. |
131 OSThread* os_thread() const { return os_thread_; } | 133 OSThread* os_thread() const { return os_thread_; } |
132 void set_os_thread(OSThread* os_thread) { | 134 void set_os_thread(OSThread* os_thread) { |
133 os_thread_ = os_thread; | 135 os_thread_ = os_thread; |
134 } | 136 } |
135 | 137 |
136 // The topmost zone used for allocation in this thread. | 138 // The topmost zone used for allocation in this thread. |
137 Zone* zone() const { return zone_; } | 139 Zone* zone() const { return zone_; } |
138 | 140 |
| 141 // The reusable api local scope for this thread. |
| 142 ApiLocalScope* api_reusable_scope() const { return api_reusable_scope_; } |
| 143 void set_api_reusable_scope(ApiLocalScope* value) { |
| 144 ASSERT(value == NULL || api_reusable_scope_ == NULL); |
| 145 api_reusable_scope_ = value; |
| 146 } |
| 147 |
| 148 // The api local scope for this thread, this where all local handles |
| 149 // are allocated. |
| 150 ApiLocalScope* api_top_scope() const { return api_top_scope_; } |
| 151 void set_api_top_scope(ApiLocalScope* value) { api_top_scope_ = value; } |
| 152 |
139 // The isolate that this thread is operating on, or NULL if none. | 153 // The isolate that this thread is operating on, or NULL if none. |
140 Isolate* isolate() const { return isolate_; } | 154 Isolate* isolate() const { return isolate_; } |
141 static intptr_t isolate_offset() { | 155 static intptr_t isolate_offset() { |
142 return OFFSET_OF(Thread, isolate_); | 156 return OFFSET_OF(Thread, isolate_); |
143 } | 157 } |
144 bool IsMutatorThread() const; | 158 bool IsMutatorThread() const; |
145 | 159 |
146 // Is |this| executing Dart code? | 160 // Is |this| executing Dart code? |
147 bool IsExecutingDartCode() const; | 161 bool IsExecutingDartCode() const; |
148 | 162 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 369 |
356 #define REUSABLE_HANDLE(object) \ | 370 #define REUSABLE_HANDLE(object) \ |
357 object& object##Handle() const { \ | 371 object& object##Handle() const { \ |
358 return *object##_handle_; \ | 372 return *object##_handle_; \ |
359 } | 373 } |
360 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE) | 374 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE) |
361 #undef REUSABLE_HANDLE | 375 #undef REUSABLE_HANDLE |
362 | 376 |
363 RawGrowableObjectArray* pending_functions(); | 377 RawGrowableObjectArray* pending_functions(); |
364 | 378 |
| 379 // Visit all object pointers. |
365 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 380 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 381 |
| 382 bool IsValidLocalHandle(Dart_Handle object) const; |
| 383 int CountLocalHandles() const; |
| 384 int ZoneSizeInBytes() const; |
| 385 void UnwindScopes(uword stack_marker); |
| 386 |
366 void InitVMConstants(); | 387 void InitVMConstants(); |
367 | 388 |
368 private: | 389 private: |
369 template<class T> T* AllocateReusableHandle(); | 390 template<class T> T* AllocateReusableHandle(); |
370 | 391 |
371 OSThread* os_thread_; | 392 OSThread* os_thread_; |
372 Isolate* isolate_; | 393 Isolate* isolate_; |
373 Heap* heap_; | 394 Heap* heap_; |
374 Zone* zone_; | 395 Zone* zone_; |
| 396 ApiLocalScope* api_reusable_scope_; |
| 397 ApiLocalScope* api_top_scope_; |
375 uword top_exit_frame_info_; | 398 uword top_exit_frame_info_; |
376 StackResource* top_resource_; | 399 StackResource* top_resource_; |
377 LongJumpScope* long_jump_base_; | 400 LongJumpScope* long_jump_base_; |
378 StoreBufferBlock* store_buffer_block_; | 401 StoreBufferBlock* store_buffer_block_; |
379 int32_t no_callback_scope_depth_; | 402 int32_t no_callback_scope_depth_; |
380 #if defined(DEBUG) | 403 #if defined(DEBUG) |
381 HandleScope* top_handle_scope_; | 404 HandleScope* top_handle_scope_; |
382 intptr_t no_handle_scope_depth_; | 405 intptr_t no_handle_scope_depth_; |
383 int32_t no_safepoint_scope_depth_; | 406 int32_t no_safepoint_scope_depth_; |
384 #endif | 407 #endif |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 // Disable thread interrupts. | 486 // Disable thread interrupts. |
464 class DisableThreadInterruptsScope : public StackResource { | 487 class DisableThreadInterruptsScope : public StackResource { |
465 public: | 488 public: |
466 explicit DisableThreadInterruptsScope(Thread* thread); | 489 explicit DisableThreadInterruptsScope(Thread* thread); |
467 ~DisableThreadInterruptsScope(); | 490 ~DisableThreadInterruptsScope(); |
468 }; | 491 }; |
469 | 492 |
470 } // namespace dart | 493 } // namespace dart |
471 | 494 |
472 #endif // VM_THREAD_H_ | 495 #endif // VM_THREAD_H_ |
OLD | NEW |