Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_ISOLATE_H_ | 5 #ifndef VM_ISOLATE_H_ |
| 6 #define VM_ISOLATE_H_ | 6 #define VM_ISOLATE_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/base_isolate.h" | 10 #include "vm/base_isolate.h" |
| 11 #include "vm/class_table.h" | 11 #include "vm/class_table.h" |
| 12 #include "vm/counters.h" | 12 #include "vm/counters.h" |
| 13 #include "vm/handles.h" | 13 #include "vm/handles.h" |
| 14 #include "vm/megamorphic_cache_table.h" | 14 #include "vm/megamorphic_cache_table.h" |
| 15 #include "vm/metrics.h" | 15 #include "vm/metrics.h" |
| 16 #include "vm/random.h" | 16 #include "vm/random.h" |
| 17 #include "vm/store_buffer.h" | 17 #include "vm/store_buffer.h" |
| 18 #include "vm/tags.h" | 18 #include "vm/tags.h" |
| 19 #include "vm/thread.h" | |
| 19 #include "vm/os_thread.h" | 20 #include "vm/os_thread.h" |
| 20 #include "vm/trace_buffer.h" | 21 #include "vm/trace_buffer.h" |
| 21 #include "vm/timer.h" | 22 #include "vm/timer.h" |
| 22 | 23 |
| 23 namespace dart { | 24 namespace dart { |
| 24 | 25 |
| 25 DECLARE_FLAG(bool, enable_type_checks); | 26 DECLARE_FLAG(bool, enable_type_checks); |
| 26 DECLARE_FLAG(bool, enable_asserts); | 27 DECLARE_FLAG(bool, enable_asserts); |
| 27 DECLARE_FLAG(bool, error_on_bad_type); | 28 DECLARE_FLAG(bool, error_on_bad_type); |
| 28 DECLARE_FLAG(bool, error_on_bad_override); | 29 DECLARE_FLAG(bool, error_on_bad_override); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 V(PcDescriptors) \ | 112 V(PcDescriptors) \ |
| 112 V(String) \ | 113 V(String) \ |
| 113 V(TypeArguments) \ | 114 V(TypeArguments) \ |
| 114 V(TypeParameter) \ | 115 V(TypeParameter) \ |
| 115 | 116 |
| 116 class Isolate : public BaseIsolate { | 117 class Isolate : public BaseIsolate { |
| 117 public: | 118 public: |
| 118 ~Isolate(); | 119 ~Isolate(); |
| 119 | 120 |
| 120 static inline Isolate* Current() { | 121 static inline Isolate* Current() { |
| 121 return reinterpret_cast<Isolate*>(OSThread::GetThreadLocal(isolate_key)); | 122 Thread* thread = Thread::Current(); |
| 123 return thread == NULL ? NULL : thread->isolate(); | |
| 122 } | 124 } |
| 123 | |
| 124 static void SetCurrent(Isolate* isolate); | 125 static void SetCurrent(Isolate* isolate); |
| 125 | 126 |
| 126 static void InitOnce(); | 127 static void InitOnce(); |
| 127 static Isolate* Init(const char* name_prefix, bool is_vm_isolate = false); | 128 static Isolate* Init(const char* name_prefix, bool is_vm_isolate = false); |
| 128 void Shutdown(); | 129 void Shutdown(); |
| 129 | 130 |
| 130 Isolate* ShallowCopy(); | 131 Isolate* ShallowCopy(); |
| 131 | 132 |
| 132 // Register a newly introduced class. | 133 // Register a newly introduced class. |
| 133 void RegisterClass(const Class& cls); | 134 void RegisterClass(const Class& cls); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 158 return &megamorphic_cache_table_; | 159 return &megamorphic_cache_table_; |
| 159 } | 160 } |
| 160 | 161 |
| 161 Dart_MessageNotifyCallback message_notify_callback() const { | 162 Dart_MessageNotifyCallback message_notify_callback() const { |
| 162 return message_notify_callback_; | 163 return message_notify_callback_; |
| 163 } | 164 } |
| 164 void set_message_notify_callback(Dart_MessageNotifyCallback value) { | 165 void set_message_notify_callback(Dart_MessageNotifyCallback value) { |
| 165 message_notify_callback_ = value; | 166 message_notify_callback_ = value; |
| 166 } | 167 } |
| 167 | 168 |
| 169 // A thread that operates on this isolate and may execute Dart code. | |
| 170 // No other threads operating on this isolate may execute Dart code. | |
| 171 // TODO(koda): Remove after caching current thread in generated code. | |
| 172 Thread* main_thread() { | |
|
siva
2015/03/25 21:26:34
The name 'main_thread' is confusing because we alr
koda
2015/03/25 21:49:47
Renamed to mutator_thread.
| |
| 173 DEBUG_ASSERT(IsIsolateOf(main_thread_)); | |
| 174 return main_thread_; | |
| 175 } | |
| 176 #if defined(DEBUG) | |
| 177 bool IsIsolateOf(Thread* thread); | |
| 178 #endif // DEBUG | |
| 179 | |
| 168 const char* name() const { return name_; } | 180 const char* name() const { return name_; } |
| 181 // TODO(koda): Move to Thread. | |
| 169 class Log* Log() const; | 182 class Log* Log() const; |
| 170 | 183 |
| 171 int64_t start_time() const { return start_time_; } | 184 int64_t start_time() const { return start_time_; } |
| 172 | 185 |
| 173 Dart_Port main_port() const { return main_port_; } | 186 Dart_Port main_port() const { return main_port_; } |
| 174 void set_main_port(Dart_Port port) { | 187 void set_main_port(Dart_Port port) { |
| 175 ASSERT(main_port_ == 0); // Only set main port once. | 188 ASSERT(main_port_ == 0); // Only set main port once. |
| 176 main_port_ = port; | 189 main_port_ = port; |
| 177 } | 190 } |
| 178 Dart_Port origin_id() const { return origin_id_; } | 191 Dart_Port origin_id() const { return origin_id_; } |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 | 673 |
| 661 void BuildName(const char* name_prefix); | 674 void BuildName(const char* name_prefix); |
| 662 void PrintInvokedFunctions(); | 675 void PrintInvokedFunctions(); |
| 663 | 676 |
| 664 void ProfileIdle(); | 677 void ProfileIdle(); |
| 665 | 678 |
| 666 void set_user_tag(uword tag) { | 679 void set_user_tag(uword tag) { |
| 667 user_tag_ = tag; | 680 user_tag_ = tag; |
| 668 } | 681 } |
| 669 | 682 |
| 670 CHA* cha() const { return cha_; } | |
| 671 void set_cha(CHA* value) { cha_ = value; } | |
| 672 | |
| 673 template<class T> T* AllocateReusableHandle(); | 683 template<class T> T* AllocateReusableHandle(); |
| 674 | 684 |
| 675 static ThreadLocalKey isolate_key; | 685 Thread* main_thread_; |
| 676 | |
| 677 uword vm_tag_; | 686 uword vm_tag_; |
| 678 StoreBuffer store_buffer_; | 687 StoreBuffer store_buffer_; |
| 679 ClassTable class_table_; | 688 ClassTable class_table_; |
| 680 MegamorphicCacheTable megamorphic_cache_table_; | 689 MegamorphicCacheTable megamorphic_cache_table_; |
| 681 Dart_MessageNotifyCallback message_notify_callback_; | 690 Dart_MessageNotifyCallback message_notify_callback_; |
| 682 char* name_; | 691 char* name_; |
| 683 int64_t start_time_; | 692 int64_t start_time_; |
| 684 Dart_Port main_port_; | 693 Dart_Port main_port_; |
| 685 Dart_Port origin_id_; // Isolates created by spawnFunc have some origin id. | 694 Dart_Port origin_id_; // Isolates created by spawnFunc have some origin id. |
| 686 uint64_t pause_capability_; | 695 uint64_t pause_capability_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 class Log* log_; | 733 class Log* log_; |
| 725 | 734 |
| 726 // Status support. | 735 // Status support. |
| 727 char* stacktrace_; | 736 char* stacktrace_; |
| 728 intptr_t stack_frame_index_; | 737 intptr_t stack_frame_index_; |
| 729 | 738 |
| 730 // Timestamps of last operation via service. | 739 // Timestamps of last operation via service. |
| 731 int64_t last_allocationprofile_accumulator_reset_timestamp_; | 740 int64_t last_allocationprofile_accumulator_reset_timestamp_; |
| 732 int64_t last_allocationprofile_gc_timestamp_; | 741 int64_t last_allocationprofile_gc_timestamp_; |
| 733 | 742 |
| 734 CHA* cha_; | |
| 735 | |
| 736 // Ring buffer of objects assigned an id. | 743 // Ring buffer of objects assigned an id. |
| 737 ObjectIdRing* object_id_ring_; | 744 ObjectIdRing* object_id_ring_; |
| 738 | 745 |
| 739 // Trace buffer support. | 746 // Trace buffer support. |
| 740 TraceBuffer* trace_buffer_; | 747 TraceBuffer* trace_buffer_; |
| 741 | 748 |
| 742 IsolateProfilerData* profiler_data_; | 749 IsolateProfilerData* profiler_data_; |
| 743 Mutex profiler_data_mutex_; | 750 Mutex profiler_data_mutex_; |
| 744 InterruptableThreadState* thread_state_; | 751 InterruptableThreadState* thread_state_; |
| 745 | 752 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 uint8_t* serialized_args_; | 929 uint8_t* serialized_args_; |
| 923 intptr_t serialized_args_len_; | 930 intptr_t serialized_args_len_; |
| 924 uint8_t* serialized_message_; | 931 uint8_t* serialized_message_; |
| 925 intptr_t serialized_message_len_; | 932 intptr_t serialized_message_len_; |
| 926 bool paused_; | 933 bool paused_; |
| 927 }; | 934 }; |
| 928 | 935 |
| 929 } // namespace dart | 936 } // namespace dart |
| 930 | 937 |
| 931 #endif // VM_ISOLATE_H_ | 938 #endif // VM_ISOLATE_H_ |
| OLD | NEW |