| 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 "platform/assert.h" | 9 #include "platform/assert.h" | 
| 10 #include "vm/atomic.h" | 10 #include "vm/atomic.h" | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 111   CACHED_VM_OBJECTS_LIST(V)                                                    \ | 111   CACHED_VM_OBJECTS_LIST(V)                                                    \ | 
| 112   CACHED_ADDRESSES_LIST(V)                                                     \ | 112   CACHED_ADDRESSES_LIST(V)                                                     \ | 
| 113 | 113 | 
| 114 // A VM thread; may be executing Dart code or performing helper tasks like | 114 // A VM thread; may be executing Dart code or performing helper tasks like | 
| 115 // garbage collection or compilation. The Thread structure associated with | 115 // garbage collection or compilation. The Thread structure associated with | 
| 116 // a thread is allocated by EnsureInit before entering an isolate, and destroyed | 116 // a thread is allocated by EnsureInit before entering an isolate, and destroyed | 
| 117 // automatically when the underlying OS thread exits. NOTE: On Windows, CleanUp | 117 // automatically when the underlying OS thread exits. NOTE: On Windows, CleanUp | 
| 118 // must currently be called manually (issue 23474). | 118 // must currently be called manually (issue 23474). | 
| 119 class Thread : public BaseThread { | 119 class Thread : public BaseThread { | 
| 120  public: | 120  public: | 
|  | 121   // The kind of task this thread is performing. Sampled by the profiler. | 
|  | 122   enum TaskKind { | 
|  | 123     kUnknownTask = 0x0, | 
|  | 124     kMutatorTask = 0x1, | 
|  | 125     kCompilerTask = 0x2, | 
|  | 126     kSweeperTask = 0x4, | 
|  | 127     kMarkerTask = 0x8, | 
|  | 128   }; | 
| 121   ~Thread(); | 129   ~Thread(); | 
| 122 | 130 | 
| 123   // The currently executing thread, or NULL if not yet initialized. | 131   // The currently executing thread, or NULL if not yet initialized. | 
| 124   static Thread* Current() { | 132   static Thread* Current() { | 
| 125     BaseThread* thread = OSThread::GetCurrentTLS(); | 133     BaseThread* thread = OSThread::GetCurrentTLS(); | 
| 126     if (thread == NULL || thread->is_os_thread()) { | 134     if (thread == NULL || thread->is_os_thread()) { | 
| 127       return NULL; | 135       return NULL; | 
| 128     } | 136     } | 
| 129     return reinterpret_cast<Thread*>(thread); | 137     return reinterpret_cast<Thread*>(thread); | 
| 130   } | 138   } | 
| 131 | 139 | 
| 132   // Makes the current thread enter 'isolate'. | 140   // Makes the current thread enter 'isolate'. | 
| 133   static bool EnterIsolate(Isolate* isolate); | 141   static bool EnterIsolate(Isolate* isolate); | 
| 134   // Makes the current thread exit its isolate. | 142   // Makes the current thread exit its isolate. | 
| 135   static void ExitIsolate(); | 143   static void ExitIsolate(); | 
| 136 | 144 | 
| 137   // A VM thread other than the main mutator thread can enter an isolate as a | 145   // A VM thread other than the main mutator thread can enter an isolate as a | 
| 138   // "helper" to gain limited concurrent access to the isolate. One example is | 146   // "helper" to gain limited concurrent access to the isolate. One example is | 
| 139   // SweeperTask (which uses the class table, which is copy-on-write). | 147   // SweeperTask (which uses the class table, which is copy-on-write). | 
| 140   // TODO(koda): Properly synchronize heap access to expand allowed operations. | 148   // TODO(koda): Properly synchronize heap access to expand allowed operations. | 
| 141   static bool EnterIsolateAsHelper(Isolate* isolate, | 149   static bool EnterIsolateAsHelper(Isolate* isolate, | 
|  | 150                                    TaskKind kind, | 
| 142                                    bool bypass_safepoint = false); | 151                                    bool bypass_safepoint = false); | 
| 143   static void ExitIsolateAsHelper(bool bypass_safepoint = false); | 152   static void ExitIsolateAsHelper(bool bypass_safepoint = false); | 
| 144 | 153 | 
| 145   // Empties the store buffer block into the isolate. | 154   // Empties the store buffer block into the isolate. | 
| 146   void PrepareForGC(); | 155   void PrepareForGC(); | 
| 147 | 156 | 
| 148   void SetStackLimit(uword value); | 157   void SetStackLimit(uword value); | 
| 149   void SetStackLimitFromStackBase(uword stack_base); | 158   void SetStackLimitFromStackBase(uword stack_base); | 
| 150   void ClearStackLimit(); | 159   void ClearStackLimit(); | 
| 151 | 160 | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 174     return reinterpret_cast<uword>(&stack_overflow_flags_); | 183     return reinterpret_cast<uword>(&stack_overflow_flags_); | 
| 175   } | 184   } | 
| 176   static intptr_t stack_overflow_flags_offset() { | 185   static intptr_t stack_overflow_flags_offset() { | 
| 177     return OFFSET_OF(Thread, stack_overflow_flags_); | 186     return OFFSET_OF(Thread, stack_overflow_flags_); | 
| 178   } | 187   } | 
| 179 | 188 | 
| 180   int32_t IncrementAndGetStackOverflowCount() { | 189   int32_t IncrementAndGetStackOverflowCount() { | 
| 181     return ++stack_overflow_count_; | 190     return ++stack_overflow_count_; | 
| 182   } | 191   } | 
| 183 | 192 | 
|  | 193   TaskKind task_kind() const { | 
|  | 194     return task_kind_; | 
|  | 195   } | 
|  | 196 | 
| 184   // Retrieves and clears the stack overflow flags.  These are set by | 197   // Retrieves and clears the stack overflow flags.  These are set by | 
| 185   // the generated code before the slow path runtime routine for a | 198   // the generated code before the slow path runtime routine for a | 
| 186   // stack overflow is called. | 199   // stack overflow is called. | 
| 187   uword GetAndClearStackOverflowFlags(); | 200   uword GetAndClearStackOverflowFlags(); | 
| 188 | 201 | 
| 189   // Interrupt bits. | 202   // Interrupt bits. | 
| 190   enum { | 203   enum { | 
| 191     kVMInterrupt = 0x1,  // Internal VM checks: safepoints, store buffers, etc. | 204     kVMInterrupt = 0x1,  // Internal VM checks: safepoints, store buffers, etc. | 
| 192     kMessageInterrupt = 0x2,  // An interrupt to process an out of band message. | 205     kMessageInterrupt = 0x2,  // An interrupt to process an out of band message. | 
| 193 | 206 | 
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 588   template<class T> T* AllocateReusableHandle(); | 601   template<class T> T* AllocateReusableHandle(); | 
| 589 | 602 | 
| 590   // Accessed from generated code: | 603   // Accessed from generated code: | 
| 591   uword stack_limit_; | 604   uword stack_limit_; | 
| 592   uword stack_overflow_flags_; | 605   uword stack_overflow_flags_; | 
| 593   Isolate* isolate_; | 606   Isolate* isolate_; | 
| 594   Heap* heap_; | 607   Heap* heap_; | 
| 595   uword top_exit_frame_info_; | 608   uword top_exit_frame_info_; | 
| 596   StoreBufferBlock* store_buffer_block_; | 609   StoreBufferBlock* store_buffer_block_; | 
| 597   uword vm_tag_; | 610   uword vm_tag_; | 
|  | 611   TaskKind task_kind_; | 
| 598   // State that is cached in the TLS for fast access in generated code. | 612   // State that is cached in the TLS for fast access in generated code. | 
| 599 #define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value)      \ | 613 #define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value)      \ | 
| 600   type_name member_name; | 614   type_name member_name; | 
| 601 CACHED_CONSTANTS_LIST(DECLARE_MEMBERS) | 615 CACHED_CONSTANTS_LIST(DECLARE_MEMBERS) | 
| 602 #undef DECLARE_MEMBERS | 616 #undef DECLARE_MEMBERS | 
| 603 | 617 | 
| 604 #define DECLARE_MEMBERS(name)      \ | 618 #define DECLARE_MEMBERS(name)      \ | 
| 605   uword name##_entry_point_; | 619   uword name##_entry_point_; | 
| 606 RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) | 620 RUNTIME_ENTRY_LIST(DECLARE_MEMBERS) | 
| 607 #undef DECLARE_MEMBERS | 621 #undef DECLARE_MEMBERS | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 713 // Disable thread interrupts. | 727 // Disable thread interrupts. | 
| 714 class DisableThreadInterruptsScope : public StackResource { | 728 class DisableThreadInterruptsScope : public StackResource { | 
| 715  public: | 729  public: | 
| 716   explicit DisableThreadInterruptsScope(Thread* thread); | 730   explicit DisableThreadInterruptsScope(Thread* thread); | 
| 717   ~DisableThreadInterruptsScope(); | 731   ~DisableThreadInterruptsScope(); | 
| 718 }; | 732 }; | 
| 719 | 733 | 
| 720 }  // namespace dart | 734 }  // namespace dart | 
| 721 | 735 | 
| 722 #endif  // VM_THREAD_H_ | 736 #endif  // VM_THREAD_H_ | 
| OLD | NEW | 
|---|