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/atomic.h" | 10 #include "vm/atomic.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 class Capability; | 28 class Capability; |
29 class CodeIndexTable; | 29 class CodeIndexTable; |
30 class CompilerStats; | 30 class CompilerStats; |
31 class Debugger; | 31 class Debugger; |
32 class DeoptContext; | 32 class DeoptContext; |
33 class HandleScope; | 33 class HandleScope; |
34 class HandleVisitor; | 34 class HandleVisitor; |
35 class Heap; | 35 class Heap; |
36 class ICData; | 36 class ICData; |
37 class IsolateProfilerData; | 37 class IsolateProfilerData; |
38 class IsolateReloadContext; | |
38 class IsolateSpawnState; | 39 class IsolateSpawnState; |
39 class Log; | 40 class Log; |
40 class MessageHandler; | 41 class MessageHandler; |
41 class Mutex; | 42 class Mutex; |
42 class Object; | 43 class Object; |
43 class ObjectIdRing; | 44 class ObjectIdRing; |
44 class ObjectPointerVisitor; | 45 class ObjectPointerVisitor; |
45 class ObjectStore; | 46 class ObjectStore; |
46 class RawInstance; | 47 class RawInstance; |
47 class RawArray; | 48 class RawArray; |
48 class RawContext; | 49 class RawContext; |
49 class RawDouble; | 50 class RawDouble; |
51 class RawError; | |
52 class RawField; | |
50 class RawGrowableObjectArray; | 53 class RawGrowableObjectArray; |
51 class RawMint; | 54 class RawMint; |
52 class RawObject; | 55 class RawObject; |
53 class RawInteger; | 56 class RawInteger; |
54 class RawError; | |
55 class RawField; | |
56 class RawFloat32x4; | 57 class RawFloat32x4; |
57 class RawInt32x4; | 58 class RawInt32x4; |
58 class RawUserTag; | 59 class RawUserTag; |
59 class SafepointHandler; | 60 class SafepointHandler; |
60 class SampleBuffer; | 61 class SampleBuffer; |
61 class SendPort; | 62 class SendPort; |
62 class ServiceIdZone; | 63 class ServiceIdZone; |
63 class Simulator; | 64 class Simulator; |
64 class StackResource; | 65 class StackResource; |
65 class StackZone; | 66 class StackZone; |
(...skipping 18 matching lines...) Expand all Loading... | |
84 // Disallow OOB message handling within this scope. | 85 // Disallow OOB message handling within this scope. |
85 class NoOOBMessageScope : public StackResource { | 86 class NoOOBMessageScope : public StackResource { |
86 public: | 87 public: |
87 explicit NoOOBMessageScope(Thread* thread); | 88 explicit NoOOBMessageScope(Thread* thread); |
88 ~NoOOBMessageScope(); | 89 ~NoOOBMessageScope(); |
89 private: | 90 private: |
90 DISALLOW_COPY_AND_ASSIGN(NoOOBMessageScope); | 91 DISALLOW_COPY_AND_ASSIGN(NoOOBMessageScope); |
91 }; | 92 }; |
92 | 93 |
93 | 94 |
95 // Disallow isolate reload. | |
96 class NoReloadScope : public StackResource { | |
97 public: | |
98 NoReloadScope(Isolate* isolate, Thread* thread); | |
99 ~NoReloadScope(); | |
100 | |
101 private: | |
102 Isolate* isolate_; | |
103 DISALLOW_COPY_AND_ASSIGN(NoReloadScope); | |
104 }; | |
105 | |
106 | |
94 class Isolate : public BaseIsolate { | 107 class Isolate : public BaseIsolate { |
95 public: | 108 public: |
96 // Keep both these enums in sync with isolate_patch.dart. | 109 // Keep both these enums in sync with isolate_patch.dart. |
97 // The different Isolate API message types. | 110 // The different Isolate API message types. |
98 enum LibMsgId { | 111 enum LibMsgId { |
99 kPauseMsg = 1, | 112 kPauseMsg = 1, |
100 kResumeMsg = 2, | 113 kResumeMsg = 2, |
101 kPingMsg = 3, | 114 kPingMsg = 3, |
102 kKillMsg = 4, | 115 kKillMsg = 4, |
103 kAddExitMsg = 5, | 116 kAddExitMsg = 5, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 StoreBuffer* store_buffer() { return store_buffer_; } | 156 StoreBuffer* store_buffer() { return store_buffer_; } |
144 | 157 |
145 ThreadRegistry* thread_registry() const { return thread_registry_; } | 158 ThreadRegistry* thread_registry() const { return thread_registry_; } |
146 SafepointHandler* safepoint_handler() const { return safepoint_handler_; } | 159 SafepointHandler* safepoint_handler() const { return safepoint_handler_; } |
147 | 160 |
148 ClassTable* class_table() { return &class_table_; } | 161 ClassTable* class_table() { return &class_table_; } |
149 static intptr_t class_table_offset() { | 162 static intptr_t class_table_offset() { |
150 return OFFSET_OF(Isolate, class_table_); | 163 return OFFSET_OF(Isolate, class_table_); |
151 } | 164 } |
152 | 165 |
166 // Prefers old classes when we are in the middle of a reload. | |
167 RawClass* GetClassForHeapWalkAt(intptr_t cid); | |
168 | |
153 static intptr_t ic_miss_code_offset() { | 169 static intptr_t ic_miss_code_offset() { |
154 return OFFSET_OF(Isolate, ic_miss_code_); | 170 return OFFSET_OF(Isolate, ic_miss_code_); |
155 } | 171 } |
156 | 172 |
157 Dart_MessageNotifyCallback message_notify_callback() const { | 173 Dart_MessageNotifyCallback message_notify_callback() const { |
158 return message_notify_callback_; | 174 return message_notify_callback_; |
159 } | 175 } |
160 void set_message_notify_callback(Dart_MessageNotifyCallback value) { | 176 void set_message_notify_callback(Dart_MessageNotifyCallback value) { |
161 message_notify_callback_ = value; | 177 message_notify_callback_ = value; |
162 } | 178 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 | 246 |
231 void SetupInstructionsSnapshotPage( | 247 void SetupInstructionsSnapshotPage( |
232 const uint8_t* instructions_snapshot_buffer); | 248 const uint8_t* instructions_snapshot_buffer); |
233 void SetupDataSnapshotPage( | 249 void SetupDataSnapshotPage( |
234 const uint8_t* instructions_snapshot_buffer); | 250 const uint8_t* instructions_snapshot_buffer); |
235 | 251 |
236 void ScheduleMessageInterrupts(); | 252 void ScheduleMessageInterrupts(); |
237 | 253 |
238 // Marks all libraries as loaded. | 254 // Marks all libraries as loaded. |
239 void DoneLoading(); | 255 void DoneLoading(); |
256 void DoneFinalizing(); | |
257 | |
258 void OnStackReload(); | |
259 void ReloadSources(bool test_mode = false); | |
240 | 260 |
241 bool MakeRunnable(); | 261 bool MakeRunnable(); |
242 void Run(); | 262 void Run(); |
243 | 263 |
244 MessageHandler* message_handler() const { return message_handler_; } | 264 MessageHandler* message_handler() const { return message_handler_; } |
245 void set_message_handler(MessageHandler* value) { message_handler_ = value; } | 265 void set_message_handler(MessageHandler* value) { message_handler_ = value; } |
246 | 266 |
247 bool is_runnable() const { return is_runnable_; } | 267 bool is_runnable() const { return is_runnable_; } |
248 void set_is_runnable(bool value) { | 268 void set_is_runnable(bool value) { |
249 is_runnable_ = value; | 269 is_runnable_ = value; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 | 401 |
382 BackgroundCompiler* background_compiler() const { | 402 BackgroundCompiler* background_compiler() const { |
383 return background_compiler_; | 403 return background_compiler_; |
384 } | 404 } |
385 void set_background_compiler(BackgroundCompiler* value) { | 405 void set_background_compiler(BackgroundCompiler* value) { |
386 // Do not overwrite a background compiler (memory leak). | 406 // Do not overwrite a background compiler (memory leak). |
387 ASSERT((value == NULL) || (background_compiler_ == NULL)); | 407 ASSERT((value == NULL) || (background_compiler_ == NULL)); |
388 background_compiler_ = value; | 408 background_compiler_ = value; |
389 } | 409 } |
390 | 410 |
411 void enable_background_compiler() { | |
412 background_compiler_disabled_count_--; | |
413 if (background_compiler_disabled_count_ < 0) { | |
414 FATAL("Mismatched number of calls to disable_background_compiler and " | |
415 "enable_background_compiler."); | |
416 } | |
417 } | |
418 | |
419 void disable_background_compiler() { | |
420 background_compiler_disabled_count_++; | |
421 } | |
422 | |
423 bool is_background_compiler_disabled() const { | |
424 return background_compiler_disabled_count_ > 0; | |
425 } | |
426 | |
391 void UpdateLastAllocationProfileAccumulatorResetTimestamp() { | 427 void UpdateLastAllocationProfileAccumulatorResetTimestamp() { |
392 last_allocationprofile_accumulator_reset_timestamp_ = | 428 last_allocationprofile_accumulator_reset_timestamp_ = |
393 OS::GetCurrentTimeMillis(); | 429 OS::GetCurrentTimeMillis(); |
394 } | 430 } |
395 | 431 |
396 int64_t last_allocationprofile_accumulator_reset_timestamp() const { | 432 int64_t last_allocationprofile_accumulator_reset_timestamp() const { |
397 return last_allocationprofile_accumulator_reset_timestamp_; | 433 return last_allocationprofile_accumulator_reset_timestamp_; |
398 } | 434 } |
399 | 435 |
400 void UpdateLastAllocationProfileGCTimestamp() { | 436 void UpdateLastAllocationProfileGCTimestamp() { |
(...skipping 24 matching lines...) Expand all Loading... | |
425 // Mutator thread is used to aggregate compiler stats. | 461 // Mutator thread is used to aggregate compiler stats. |
426 CompilerStats* aggregate_compiler_stats() { | 462 CompilerStats* aggregate_compiler_stats() { |
427 ASSERT(HasMutatorThread()); | 463 ASSERT(HasMutatorThread()); |
428 return mutator_thread_->compiler_stats(); | 464 return mutator_thread_->compiler_stats(); |
429 } | 465 } |
430 | 466 |
431 VMTagCounters* vm_tag_counters() { | 467 VMTagCounters* vm_tag_counters() { |
432 return &vm_tag_counters_; | 468 return &vm_tag_counters_; |
433 } | 469 } |
434 | 470 |
471 bool IsReloading() const { | |
472 return reload_context_ != NULL; | |
473 } | |
474 | |
475 IsolateReloadContext* reload_context() { | |
476 return reload_context_; | |
477 } | |
478 | |
479 bool HasAttemptedReload() const { | |
480 return has_attempted_reload_; | |
481 } | |
482 | |
483 bool CanReload() const; | |
484 | |
485 void ReportReloadError(const Error& error); | |
486 | |
435 uword user_tag() const { | 487 uword user_tag() const { |
436 return user_tag_; | 488 return user_tag_; |
437 } | 489 } |
438 static intptr_t user_tag_offset() { | 490 static intptr_t user_tag_offset() { |
439 return OFFSET_OF(Isolate, user_tag_); | 491 return OFFSET_OF(Isolate, user_tag_); |
440 } | 492 } |
441 static intptr_t current_tag_offset() { | 493 static intptr_t current_tag_offset() { |
442 return OFFSET_OF(Isolate, current_tag_); | 494 return OFFSET_OF(Isolate, current_tag_); |
443 } | 495 } |
444 static intptr_t default_tag_offset() { | 496 static intptr_t default_tag_offset() { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 void Shutdown(); | 659 void Shutdown(); |
608 | 660 |
609 void BuildName(const char* name_prefix); | 661 void BuildName(const char* name_prefix); |
610 | 662 |
611 void ProfileIdle(); | 663 void ProfileIdle(); |
612 | 664 |
613 // Visit all object pointers. Caller must ensure concurrent sweeper is not | 665 // Visit all object pointers. Caller must ensure concurrent sweeper is not |
614 // running, and the visitor must not allocate. | 666 // running, and the visitor must not allocate. |
615 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); | 667 void VisitObjectPointers(ObjectPointerVisitor* visitor, bool validate_frames); |
616 | 668 |
669 | |
Ivan Posva
2016/05/16 20:58:59
Extra empty line.
Cutch
2016/05/17 18:03:52
Done.
| |
617 void set_user_tag(uword tag) { | 670 void set_user_tag(uword tag) { |
618 user_tag_ = tag; | 671 user_tag_ = tag; |
619 } | 672 } |
620 | 673 |
621 RawGrowableObjectArray* GetAndClearPendingServiceExtensionCalls(); | 674 RawGrowableObjectArray* GetAndClearPendingServiceExtensionCalls(); |
622 RawGrowableObjectArray* pending_service_extension_calls() const { | 675 RawGrowableObjectArray* pending_service_extension_calls() const { |
623 return pending_service_extension_calls_; | 676 return pending_service_extension_calls_; |
624 } | 677 } |
625 void set_pending_service_extension_calls(const GrowableObjectArray& value); | 678 void set_pending_service_extension_calls(const GrowableObjectArray& value); |
626 RawGrowableObjectArray* registered_service_extension_handlers() const { | 679 RawGrowableObjectArray* registered_service_extension_handlers() const { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 | 763 |
711 VMTagCounters vm_tag_counters_; | 764 VMTagCounters vm_tag_counters_; |
712 RawGrowableObjectArray* tag_table_; | 765 RawGrowableObjectArray* tag_table_; |
713 | 766 |
714 RawGrowableObjectArray* deoptimized_code_array_; | 767 RawGrowableObjectArray* deoptimized_code_array_; |
715 | 768 |
716 RawError* sticky_error_; | 769 RawError* sticky_error_; |
717 | 770 |
718 // Background compilation. | 771 // Background compilation. |
719 BackgroundCompiler* background_compiler_; | 772 BackgroundCompiler* background_compiler_; |
773 intptr_t background_compiler_disabled_count_; | |
720 | 774 |
721 // We use 6 list entries for each pending service extension calls. | 775 // We use 6 list entries for each pending service extension calls. |
722 enum { | 776 enum { |
723 kPendingHandlerIndex = 0, | 777 kPendingHandlerIndex = 0, |
724 kPendingMethodNameIndex, | 778 kPendingMethodNameIndex, |
725 kPendingKeysIndex, | 779 kPendingKeysIndex, |
726 kPendingValuesIndex, | 780 kPendingValuesIndex, |
727 kPendingReplyPortIndex, | 781 kPendingReplyPortIndex, |
728 kPendingIdIndex, | 782 kPendingIdIndex, |
729 kPendingEntrySize | 783 kPendingEntrySize |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 RawGrowableObjectArray* boxed_field_list_; | 816 RawGrowableObjectArray* boxed_field_list_; |
763 // List of fields that were disabling code while background compiler | 817 // List of fields that were disabling code while background compiler |
764 // was running. | 818 // was running. |
765 RawGrowableObjectArray* disabling_field_list_; | 819 RawGrowableObjectArray* disabling_field_list_; |
766 | 820 |
767 // This guards spawn_count_. An isolate cannot complete shutdown and be | 821 // This guards spawn_count_. An isolate cannot complete shutdown and be |
768 // destroyed while there are child isolates in the midst of a spawn. | 822 // destroyed while there are child isolates in the midst of a spawn. |
769 Monitor* spawn_count_monitor_; | 823 Monitor* spawn_count_monitor_; |
770 intptr_t spawn_count_; | 824 intptr_t spawn_count_; |
771 | 825 |
826 // Has a reload ever been attempted? | |
827 bool has_attempted_reload_; | |
828 intptr_t no_reload_scope_depth_; // we can only reload when this is 0. | |
829 IsolateReloadContext* reload_context_; | |
830 | |
772 #define ISOLATE_METRIC_VARIABLE(type, variable, name, unit) \ | 831 #define ISOLATE_METRIC_VARIABLE(type, variable, name, unit) \ |
773 type metric_##variable##_; | 832 type metric_##variable##_; |
774 ISOLATE_METRIC_LIST(ISOLATE_METRIC_VARIABLE); | 833 ISOLATE_METRIC_LIST(ISOLATE_METRIC_VARIABLE); |
775 #undef ISOLATE_METRIC_VARIABLE | 834 #undef ISOLATE_METRIC_VARIABLE |
776 | 835 |
777 | 836 |
778 static Dart_IsolateCreateCallback create_callback_; | 837 static Dart_IsolateCreateCallback create_callback_; |
779 static Dart_IsolateShutdownCallback shutdown_callback_; | 838 static Dart_IsolateShutdownCallback shutdown_callback_; |
780 static Dart_IsolateInterruptCallback vmstats_callback_; | 839 static Dart_IsolateInterruptCallback vmstats_callback_; |
781 | 840 |
782 static void WakePauseEventHandler(Dart_Isolate isolate); | 841 static void WakePauseEventHandler(Dart_Isolate isolate); |
783 | 842 |
784 // Manage list of existing isolates. | 843 // Manage list of existing isolates. |
785 static bool AddIsolateToList(Isolate* isolate); | 844 static bool AddIsolateToList(Isolate* isolate); |
786 static void RemoveIsolateFromList(Isolate* isolate); | 845 static void RemoveIsolateFromList(Isolate* isolate); |
787 | 846 |
788 // This monitor protects isolates_list_head_, and creation_enabled_. | 847 // This monitor protects isolates_list_head_, and creation_enabled_. |
789 static Monitor* isolates_list_monitor_; | 848 static Monitor* isolates_list_monitor_; |
790 static Isolate* isolates_list_head_; | 849 static Isolate* isolates_list_head_; |
791 static bool creation_enabled_; | 850 static bool creation_enabled_; |
792 | 851 |
793 #define REUSABLE_FRIEND_DECLARATION(name) \ | 852 #define REUSABLE_FRIEND_DECLARATION(name) \ |
794 friend class Reusable##name##HandleScope; | 853 friend class Reusable##name##HandleScope; |
795 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) | 854 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) |
796 #undef REUSABLE_FRIEND_DECLARATION | 855 #undef REUSABLE_FRIEND_DECLARATION |
797 | 856 |
857 friend class Become; // VisitObjectPointers | |
798 friend class GCMarker; // VisitObjectPointers | 858 friend class GCMarker; // VisitObjectPointers |
799 friend class SafepointHandler; | 859 friend class SafepointHandler; |
800 friend class Scavenger; // VisitObjectPointers | 860 friend class Scavenger; // VisitObjectPointers |
801 friend class ServiceIsolate; | 861 friend class ServiceIsolate; |
802 friend class Thread; | 862 friend class Thread; |
803 friend class Timeline; | 863 friend class Timeline; |
864 friend class NoReloadScope; // reload_block | |
865 | |
804 | 866 |
805 DISALLOW_COPY_AND_ASSIGN(Isolate); | 867 DISALLOW_COPY_AND_ASSIGN(Isolate); |
806 }; | 868 }; |
807 | 869 |
808 | 870 |
809 // When we need to execute code in an isolate, we use the | 871 // When we need to execute code in an isolate, we use the |
810 // StartIsolateScope. | 872 // StartIsolateScope. |
811 class StartIsolateScope { | 873 class StartIsolateScope { |
812 public: | 874 public: |
813 explicit StartIsolateScope(Isolate* new_isolate) | 875 explicit StartIsolateScope(Isolate* new_isolate) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 intptr_t* spawn_count_; | 990 intptr_t* spawn_count_; |
929 | 991 |
930 Dart_IsolateFlags isolate_flags_; | 992 Dart_IsolateFlags isolate_flags_; |
931 bool paused_; | 993 bool paused_; |
932 bool errors_are_fatal_; | 994 bool errors_are_fatal_; |
933 }; | 995 }; |
934 | 996 |
935 } // namespace dart | 997 } // namespace dart |
936 | 998 |
937 #endif // VM_ISOLATE_H_ | 999 #endif // VM_ISOLATE_H_ |
OLD | NEW |