Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: runtime/vm/isolate.h

Issue 1965823002: Initial isolate reload support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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
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_depth_--;
413 if (background_compiler_disabled_depth_ < 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_depth_++;
421 }
422
423 bool is_background_compiler_disabled() const {
424 return background_compiler_disabled_depth_ > 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
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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 762
711 VMTagCounters vm_tag_counters_; 763 VMTagCounters vm_tag_counters_;
712 RawGrowableObjectArray* tag_table_; 764 RawGrowableObjectArray* tag_table_;
713 765
714 RawGrowableObjectArray* deoptimized_code_array_; 766 RawGrowableObjectArray* deoptimized_code_array_;
715 767
716 RawError* sticky_error_; 768 RawError* sticky_error_;
717 769
718 // Background compilation. 770 // Background compilation.
719 BackgroundCompiler* background_compiler_; 771 BackgroundCompiler* background_compiler_;
772 intptr_t background_compiler_disabled_depth_;
720 773
721 // We use 6 list entries for each pending service extension calls. 774 // We use 6 list entries for each pending service extension calls.
722 enum { 775 enum {
723 kPendingHandlerIndex = 0, 776 kPendingHandlerIndex = 0,
724 kPendingMethodNameIndex, 777 kPendingMethodNameIndex,
725 kPendingKeysIndex, 778 kPendingKeysIndex,
726 kPendingValuesIndex, 779 kPendingValuesIndex,
727 kPendingReplyPortIndex, 780 kPendingReplyPortIndex,
728 kPendingIdIndex, 781 kPendingIdIndex,
729 kPendingEntrySize 782 kPendingEntrySize
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 RawGrowableObjectArray* boxed_field_list_; 815 RawGrowableObjectArray* boxed_field_list_;
763 // List of fields that were disabling code while background compiler 816 // List of fields that were disabling code while background compiler
764 // was running. 817 // was running.
765 RawGrowableObjectArray* disabling_field_list_; 818 RawGrowableObjectArray* disabling_field_list_;
766 819
767 // This guards spawn_count_. An isolate cannot complete shutdown and be 820 // This guards spawn_count_. An isolate cannot complete shutdown and be
768 // destroyed while there are child isolates in the midst of a spawn. 821 // destroyed while there are child isolates in the midst of a spawn.
769 Monitor* spawn_count_monitor_; 822 Monitor* spawn_count_monitor_;
770 intptr_t spawn_count_; 823 intptr_t spawn_count_;
771 824
825 // Has a reload ever been attempted?
826 bool has_attempted_reload_;
827 intptr_t no_reload_scope_depth_; // we can only reload when this is 0.
828 IsolateReloadContext* reload_context_;
829
772 #define ISOLATE_METRIC_VARIABLE(type, variable, name, unit) \ 830 #define ISOLATE_METRIC_VARIABLE(type, variable, name, unit) \
773 type metric_##variable##_; 831 type metric_##variable##_;
774 ISOLATE_METRIC_LIST(ISOLATE_METRIC_VARIABLE); 832 ISOLATE_METRIC_LIST(ISOLATE_METRIC_VARIABLE);
775 #undef ISOLATE_METRIC_VARIABLE 833 #undef ISOLATE_METRIC_VARIABLE
776 834
777 835
778 static Dart_IsolateCreateCallback create_callback_; 836 static Dart_IsolateCreateCallback create_callback_;
779 static Dart_IsolateShutdownCallback shutdown_callback_; 837 static Dart_IsolateShutdownCallback shutdown_callback_;
780 static Dart_IsolateInterruptCallback vmstats_callback_; 838 static Dart_IsolateInterruptCallback vmstats_callback_;
781 839
782 static void WakePauseEventHandler(Dart_Isolate isolate); 840 static void WakePauseEventHandler(Dart_Isolate isolate);
783 841
784 // Manage list of existing isolates. 842 // Manage list of existing isolates.
785 static bool AddIsolateToList(Isolate* isolate); 843 static bool AddIsolateToList(Isolate* isolate);
786 static void RemoveIsolateFromList(Isolate* isolate); 844 static void RemoveIsolateFromList(Isolate* isolate);
787 845
788 // This monitor protects isolates_list_head_, and creation_enabled_. 846 // This monitor protects isolates_list_head_, and creation_enabled_.
789 static Monitor* isolates_list_monitor_; 847 static Monitor* isolates_list_monitor_;
790 static Isolate* isolates_list_head_; 848 static Isolate* isolates_list_head_;
791 static bool creation_enabled_; 849 static bool creation_enabled_;
792 850
793 #define REUSABLE_FRIEND_DECLARATION(name) \ 851 #define REUSABLE_FRIEND_DECLARATION(name) \
794 friend class Reusable##name##HandleScope; 852 friend class Reusable##name##HandleScope;
795 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) 853 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION)
796 #undef REUSABLE_FRIEND_DECLARATION 854 #undef REUSABLE_FRIEND_DECLARATION
797 855
856 friend class Become; // VisitObjectPointers
798 friend class GCMarker; // VisitObjectPointers 857 friend class GCMarker; // VisitObjectPointers
799 friend class SafepointHandler; 858 friend class SafepointHandler;
800 friend class Scavenger; // VisitObjectPointers 859 friend class Scavenger; // VisitObjectPointers
801 friend class ServiceIsolate; 860 friend class ServiceIsolate;
802 friend class Thread; 861 friend class Thread;
803 friend class Timeline; 862 friend class Timeline;
863 friend class NoReloadScope; // reload_block
864
804 865
805 DISALLOW_COPY_AND_ASSIGN(Isolate); 866 DISALLOW_COPY_AND_ASSIGN(Isolate);
806 }; 867 };
807 868
808 869
809 // When we need to execute code in an isolate, we use the 870 // When we need to execute code in an isolate, we use the
810 // StartIsolateScope. 871 // StartIsolateScope.
811 class StartIsolateScope { 872 class StartIsolateScope {
812 public: 873 public:
813 explicit StartIsolateScope(Isolate* new_isolate) 874 explicit StartIsolateScope(Isolate* new_isolate)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 intptr_t* spawn_count_; 989 intptr_t* spawn_count_;
929 990
930 Dart_IsolateFlags isolate_flags_; 991 Dart_IsolateFlags isolate_flags_;
931 bool paused_; 992 bool paused_;
932 bool errors_are_fatal_; 993 bool errors_are_fatal_;
933 }; 994 };
934 995
935 } // namespace dart 996 } // namespace dart
936 997
937 #endif // VM_ISOLATE_H_ 998 #endif // VM_ISOLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698