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/handles.h" | 9 #include "vm/handles.h" |
10 #include "vm/os_thread.h" | 10 #include "vm/os_thread.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 ThreadId id() const { | 375 ThreadId id() const { |
376 ASSERT(id_ != OSThread::kInvalidThreadId); | 376 ASSERT(id_ != OSThread::kInvalidThreadId); |
377 return id_; | 377 return id_; |
378 } | 378 } |
379 | 379 |
380 ThreadId join_id() const { | 380 ThreadId join_id() const { |
381 ASSERT(join_id_ != OSThread::kInvalidThreadJoinId); | 381 ASSERT(join_id_ != OSThread::kInvalidThreadJoinId); |
382 return join_id_; | 382 return join_id_; |
383 } | 383 } |
384 | 384 |
| 385 ThreadId trace_id() const { |
| 386 ASSERT(trace_id_ != OSThread::kInvalidThreadJoinId); |
| 387 return trace_id_; |
| 388 } |
| 389 |
| 390 const char* name() const { |
| 391 return name_; |
| 392 } |
| 393 |
| 394 void set_name(const char* name) { |
| 395 ASSERT(Thread::Current() == this); |
| 396 ASSERT(name_ == NULL); |
| 397 name_ = name; |
| 398 } |
| 399 |
385 // Used to temporarily disable or enable thread interrupts. | 400 // Used to temporarily disable or enable thread interrupts. |
386 void DisableThreadInterrupts(); | 401 void DisableThreadInterrupts(); |
387 void EnableThreadInterrupts(); | 402 void EnableThreadInterrupts(); |
388 bool ThreadInterruptsEnabled(); | 403 bool ThreadInterruptsEnabled(); |
389 | 404 |
390 #if defined(DEBUG) | 405 #if defined(DEBUG) |
391 #define REUSABLE_HANDLE_SCOPE_ACCESSORS(object) \ | 406 #define REUSABLE_HANDLE_SCOPE_ACCESSORS(object) \ |
392 void set_reusable_##object##_handle_scope_active(bool value) { \ | 407 void set_reusable_##object##_handle_scope_active(bool value) { \ |
393 reusable_##object##_handle_scope_active_ = value; \ | 408 reusable_##object##_handle_scope_active_ = value; \ |
394 } \ | 409 } \ |
(...skipping 27 matching lines...) Expand all Loading... |
422 | 437 |
423 static bool IsThreadInList(ThreadId join_id); | 438 static bool IsThreadInList(ThreadId join_id); |
424 | 439 |
425 private: | 440 private: |
426 template<class T> T* AllocateReusableHandle(); | 441 template<class T> T* AllocateReusableHandle(); |
427 | 442 |
428 static ThreadLocalKey thread_key_; | 443 static ThreadLocalKey thread_key_; |
429 | 444 |
430 const ThreadId id_; | 445 const ThreadId id_; |
431 const ThreadId join_id_; | 446 const ThreadId join_id_; |
| 447 const ThreadId trace_id_; |
432 uintptr_t thread_interrupt_disabled_; | 448 uintptr_t thread_interrupt_disabled_; |
433 Isolate* isolate_; | 449 Isolate* isolate_; |
434 Heap* heap_; | 450 Heap* heap_; |
435 State state_; | 451 State state_; |
436 Mutex timeline_block_lock_; | 452 Mutex timeline_block_lock_; |
437 TimelineEventBlock* timeline_block_; | 453 TimelineEventBlock* timeline_block_; |
438 StoreBufferBlock* store_buffer_block_; | 454 StoreBufferBlock* store_buffer_block_; |
439 class Log* log_; | 455 class Log* log_; |
440 #define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value) \ | 456 #define DECLARE_MEMBERS(type_name, member_name, expr, default_init_value) \ |
441 type_name member_name; | 457 type_name member_name; |
(...skipping 29 matching lines...) Expand all Loading... |
471 CHA* cha_; | 487 CHA* cha_; |
472 intptr_t deopt_id_; // Compilation specific counter. | 488 intptr_t deopt_id_; // Compilation specific counter. |
473 uword vm_tag_; | 489 uword vm_tag_; |
474 RawGrowableObjectArray* pending_functions_; | 490 RawGrowableObjectArray* pending_functions_; |
475 | 491 |
476 int32_t no_callback_scope_depth_; | 492 int32_t no_callback_scope_depth_; |
477 | 493 |
478 // All |Thread|s are registered in the thread list. | 494 // All |Thread|s are registered in the thread list. |
479 Thread* thread_list_next_; | 495 Thread* thread_list_next_; |
480 | 496 |
| 497 // A name for this thread. |
| 498 const char* name_; |
| 499 |
481 static Thread* thread_list_head_; | 500 static Thread* thread_list_head_; |
482 static Mutex* thread_list_lock_; | 501 static Mutex* thread_list_lock_; |
483 | 502 |
484 static void AddThreadToList(Thread* thread); | 503 static void AddThreadToList(Thread* thread); |
485 static void RemoveThreadFromList(Thread* thread); | 504 static void RemoveThreadFromList(Thread* thread); |
486 | 505 |
487 explicit Thread(bool init_vm_constants = true); | 506 explicit Thread(bool init_vm_constants = true); |
488 | 507 |
489 void InitVMConstants(); | 508 void InitVMConstants(); |
490 | 509 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 // Disable thread interrupts. | 569 // Disable thread interrupts. |
551 class DisableThreadInterruptsScope : public StackResource { | 570 class DisableThreadInterruptsScope : public StackResource { |
552 public: | 571 public: |
553 explicit DisableThreadInterruptsScope(Thread* thread); | 572 explicit DisableThreadInterruptsScope(Thread* thread); |
554 ~DisableThreadInterruptsScope(); | 573 ~DisableThreadInterruptsScope(); |
555 }; | 574 }; |
556 | 575 |
557 } // namespace dart | 576 } // namespace dart |
558 | 577 |
559 #endif // VM_THREAD_H_ | 578 #endif // VM_THREAD_H_ |
OLD | NEW |