| 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 RUNTIME_VM_ISOLATE_H_ | 5 #ifndef RUNTIME_VM_ISOLATE_H_ |
| 6 #define RUNTIME_VM_ISOLATE_H_ | 6 #define RUNTIME_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" |
| 11 #include "vm/base_isolate.h" | 11 #include "vm/base_isolate.h" |
| 12 #include "vm/class_table.h" | 12 #include "vm/class_table.h" |
| 13 #include "vm/exceptions.h" | 13 #include "vm/exceptions.h" |
| 14 #include "vm/fixed_cache.h" | 14 #include "vm/fixed_cache.h" |
| 15 #include "vm/growable_array.h" |
| 15 #include "vm/handles.h" | 16 #include "vm/handles.h" |
| 16 #include "vm/megamorphic_cache_table.h" | 17 #include "vm/megamorphic_cache_table.h" |
| 17 #include "vm/metrics.h" | 18 #include "vm/metrics.h" |
| 19 #include "vm/os_thread.h" |
| 18 #include "vm/random.h" | 20 #include "vm/random.h" |
| 19 #include "vm/tags.h" | 21 #include "vm/tags.h" |
| 20 #include "vm/thread.h" | 22 #include "vm/thread.h" |
| 21 #include "vm/os_thread.h" | |
| 22 #include "vm/timer.h" | 23 #include "vm/timer.h" |
| 23 #include "vm/token_position.h" | 24 #include "vm/token_position.h" |
| 24 #include "vm/growable_array.h" | |
| 25 | 25 |
| 26 namespace dart { | 26 namespace dart { |
| 27 | 27 |
| 28 // Forward declarations. | 28 // Forward declarations. |
| 29 class ApiState; | 29 class ApiState; |
| 30 class BackgroundCompiler; | 30 class BackgroundCompiler; |
| 31 class Capability; | 31 class Capability; |
| 32 class CodeIndexTable; | 32 class CodeIndexTable; |
| 33 class CompilerStats; | 33 class CompilerStats; |
| 34 class Debugger; | 34 class Debugger; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 class SerializedObjectBuffer; | 66 class SerializedObjectBuffer; |
| 67 class ServiceIdZone; | 67 class ServiceIdZone; |
| 68 class Simulator; | 68 class Simulator; |
| 69 class StackResource; | 69 class StackResource; |
| 70 class StackZone; | 70 class StackZone; |
| 71 class StoreBuffer; | 71 class StoreBuffer; |
| 72 class StubCode; | 72 class StubCode; |
| 73 class ThreadRegistry; | 73 class ThreadRegistry; |
| 74 class UserTag; | 74 class UserTag; |
| 75 | 75 |
| 76 | |
| 77 class PendingLazyDeopt { | 76 class PendingLazyDeopt { |
| 78 public: | 77 public: |
| 79 PendingLazyDeopt(uword fp, uword pc) : fp_(fp), pc_(pc) {} | 78 PendingLazyDeopt(uword fp, uword pc) : fp_(fp), pc_(pc) {} |
| 80 uword fp() { return fp_; } | 79 uword fp() { return fp_; } |
| 81 uword pc() { return pc_; } | 80 uword pc() { return pc_; } |
| 82 void set_pc(uword pc) { pc_ = pc; } | 81 void set_pc(uword pc) { pc_ = pc; } |
| 83 | 82 |
| 84 private: | 83 private: |
| 85 uword fp_; | 84 uword fp_; |
| 86 uword pc_; | 85 uword pc_; |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 | |
| 90 class IsolateVisitor { | 88 class IsolateVisitor { |
| 91 public: | 89 public: |
| 92 IsolateVisitor() {} | 90 IsolateVisitor() {} |
| 93 virtual ~IsolateVisitor() {} | 91 virtual ~IsolateVisitor() {} |
| 94 | 92 |
| 95 virtual void VisitIsolate(Isolate* isolate) = 0; | 93 virtual void VisitIsolate(Isolate* isolate) = 0; |
| 96 | 94 |
| 97 protected: | 95 protected: |
| 98 // Returns true if |isolate| is the VM or service isolate. | 96 // Returns true if |isolate| is the VM or service isolate. |
| 99 bool IsVMInternalIsolate(Isolate* isolate) const; | 97 bool IsVMInternalIsolate(Isolate* isolate) const; |
| 100 | 98 |
| 101 private: | 99 private: |
| 102 DISALLOW_COPY_AND_ASSIGN(IsolateVisitor); | 100 DISALLOW_COPY_AND_ASSIGN(IsolateVisitor); |
| 103 }; | 101 }; |
| 104 | 102 |
| 105 | |
| 106 // Disallow OOB message handling within this scope. | 103 // Disallow OOB message handling within this scope. |
| 107 class NoOOBMessageScope : public StackResource { | 104 class NoOOBMessageScope : public StackResource { |
| 108 public: | 105 public: |
| 109 explicit NoOOBMessageScope(Thread* thread); | 106 explicit NoOOBMessageScope(Thread* thread); |
| 110 ~NoOOBMessageScope(); | 107 ~NoOOBMessageScope(); |
| 111 | 108 |
| 112 private: | 109 private: |
| 113 DISALLOW_COPY_AND_ASSIGN(NoOOBMessageScope); | 110 DISALLOW_COPY_AND_ASSIGN(NoOOBMessageScope); |
| 114 }; | 111 }; |
| 115 | 112 |
| 116 | |
| 117 // Disallow isolate reload. | 113 // Disallow isolate reload. |
| 118 class NoReloadScope : public StackResource { | 114 class NoReloadScope : public StackResource { |
| 119 public: | 115 public: |
| 120 NoReloadScope(Isolate* isolate, Thread* thread); | 116 NoReloadScope(Isolate* isolate, Thread* thread); |
| 121 ~NoReloadScope(); | 117 ~NoReloadScope(); |
| 122 | 118 |
| 123 private: | 119 private: |
| 124 Isolate* isolate_; | 120 Isolate* isolate_; |
| 125 DISALLOW_COPY_AND_ASSIGN(NoReloadScope); | 121 DISALLOW_COPY_AND_ASSIGN(NoReloadScope); |
| 126 }; | 122 }; |
| 127 | 123 |
| 128 | |
| 129 // Fixed cache for exception handler lookup. | 124 // Fixed cache for exception handler lookup. |
| 130 typedef FixedCache<intptr_t, ExceptionHandlerInfo, 16> HandlerInfoCache; | 125 typedef FixedCache<intptr_t, ExceptionHandlerInfo, 16> HandlerInfoCache; |
| 131 // Fixed cache for catch entry state lookup. | 126 // Fixed cache for catch entry state lookup. |
| 132 typedef FixedCache<intptr_t, CatchEntryState, 16> CatchEntryStateCache; | 127 typedef FixedCache<intptr_t, CatchEntryState, 16> CatchEntryStateCache; |
| 133 | 128 |
| 134 // List of Isolate flags with corresponding members of Dart_IsolateFlags and | 129 // List of Isolate flags with corresponding members of Dart_IsolateFlags and |
| 135 // corresponding global command line flags. | 130 // corresponding global command line flags. |
| 136 // | 131 // |
| 137 // V(name, Dart_IsolateFlags-member-name, command-line-flag-name) | 132 // V(name, Dart_IsolateFlags-member-name, command-line-flag-name) |
| 138 // | 133 // |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return shutdown_callback_; | 408 return shutdown_callback_; |
| 414 } | 409 } |
| 415 | 410 |
| 416 static void SetCleanupCallback(Dart_IsolateCleanupCallback cb) { | 411 static void SetCleanupCallback(Dart_IsolateCleanupCallback cb) { |
| 417 cleanup_callback_ = cb; | 412 cleanup_callback_ = cb; |
| 418 } | 413 } |
| 419 static Dart_IsolateCleanupCallback CleanupCallback() { | 414 static Dart_IsolateCleanupCallback CleanupCallback() { |
| 420 return cleanup_callback_; | 415 return cleanup_callback_; |
| 421 } | 416 } |
| 422 | 417 |
| 423 | |
| 424 void set_object_id_ring(ObjectIdRing* ring) { object_id_ring_ = ring; } | 418 void set_object_id_ring(ObjectIdRing* ring) { object_id_ring_ = ring; } |
| 425 ObjectIdRing* object_id_ring() { return object_id_ring_; } | 419 ObjectIdRing* object_id_ring() { return object_id_ring_; } |
| 426 | 420 |
| 427 void AddPendingDeopt(uword fp, uword pc); | 421 void AddPendingDeopt(uword fp, uword pc); |
| 428 uword FindPendingDeopt(uword fp) const; | 422 uword FindPendingDeopt(uword fp) const; |
| 429 void ClearPendingDeoptsAtOrBelow(uword fp) const; | 423 void ClearPendingDeoptsAtOrBelow(uword fp) const; |
| 430 MallocGrowableArray<PendingLazyDeopt>* pending_deopts() const { | 424 MallocGrowableArray<PendingLazyDeopt>* pending_deopts() const { |
| 431 return pending_deopts_; | 425 return pending_deopts_; |
| 432 } | 426 } |
| 433 bool IsDeoptimizing() const { return deopt_context_ != NULL; } | 427 bool IsDeoptimizing() const { return deopt_context_ != NULL; } |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 static void FlagsInitialize(Dart_IsolateFlags* api_flags); | 640 static void FlagsInitialize(Dart_IsolateFlags* api_flags); |
| 647 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const; | 641 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const; |
| 648 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags); | 642 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags); |
| 649 | 643 |
| 650 #if defined(PRODUCT) | 644 #if defined(PRODUCT) |
| 651 #define DECLARE_GETTER(name, isolate_flag_name, flag_name) \ | 645 #define DECLARE_GETTER(name, isolate_flag_name, flag_name) \ |
| 652 bool name() const { return flag_name; } | 646 bool name() const { return flag_name; } |
| 653 ISOLATE_FLAG_LIST(DECLARE_GETTER) | 647 ISOLATE_FLAG_LIST(DECLARE_GETTER) |
| 654 #undef DECLARE_GETTER | 648 #undef DECLARE_GETTER |
| 655 void set_use_osr(bool use_osr) { ASSERT(!use_osr); } | 649 void set_use_osr(bool use_osr) { ASSERT(!use_osr); } |
| 656 #else // defined(PRODUCT) | 650 #else // defined(PRODUCT) |
| 657 #define DECLARE_GETTER(name, isolate_flag_name, flag_name) \ | 651 #define DECLARE_GETTER(name, isolate_flag_name, flag_name) \ |
| 658 bool name() const { return name##_; } | 652 bool name() const { return name##_; } |
| 659 ISOLATE_FLAG_LIST(DECLARE_GETTER) | 653 ISOLATE_FLAG_LIST(DECLARE_GETTER) |
| 660 #undef DECLARE_GETTER | 654 #undef DECLARE_GETTER |
| 661 void set_use_osr(bool use_osr) { use_osr_ = use_osr; } | 655 void set_use_osr(bool use_osr) { use_osr_ = use_osr; } |
| 662 #endif // defined(PRODUCT) | 656 #endif // defined(PRODUCT) |
| 663 | 657 |
| 664 static void KillAllIsolates(LibMsgId msg_id); | 658 static void KillAllIsolates(LibMsgId msg_id); |
| 665 static void KillIfExists(Isolate* isolate, LibMsgId msg_id); | 659 static void KillIfExists(Isolate* isolate, LibMsgId msg_id); |
| 666 | 660 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 static bool creation_enabled_; | 887 static bool creation_enabled_; |
| 894 | 888 |
| 895 #define REUSABLE_FRIEND_DECLARATION(name) \ | 889 #define REUSABLE_FRIEND_DECLARATION(name) \ |
| 896 friend class Reusable##name##HandleScope; | 890 friend class Reusable##name##HandleScope; |
| 897 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) | 891 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) |
| 898 #undef REUSABLE_FRIEND_DECLARATION | 892 #undef REUSABLE_FRIEND_DECLARATION |
| 899 | 893 |
| 900 friend class Become; // VisitObjectPointers | 894 friend class Become; // VisitObjectPointers |
| 901 friend class GCMarker; // VisitObjectPointers | 895 friend class GCMarker; // VisitObjectPointers |
| 902 friend class SafepointHandler; | 896 friend class SafepointHandler; |
| 903 friend class Scavenger; // VisitObjectPointers | 897 friend class Scavenger; // VisitObjectPointers |
| 904 friend class ObjectGraph; // VisitObjectPointers | 898 friend class ObjectGraph; // VisitObjectPointers |
| 905 friend class ServiceIsolate; | 899 friend class ServiceIsolate; |
| 906 friend class Thread; | 900 friend class Thread; |
| 907 friend class Timeline; | 901 friend class Timeline; |
| 908 friend class NoReloadScope; // reload_block | 902 friend class NoReloadScope; // reload_block |
| 909 | 903 |
| 910 | |
| 911 DISALLOW_COPY_AND_ASSIGN(Isolate); | 904 DISALLOW_COPY_AND_ASSIGN(Isolate); |
| 912 }; | 905 }; |
| 913 | 906 |
| 914 | |
| 915 // When we need to execute code in an isolate, we use the | 907 // When we need to execute code in an isolate, we use the |
| 916 // StartIsolateScope. | 908 // StartIsolateScope. |
| 917 class StartIsolateScope { | 909 class StartIsolateScope { |
| 918 public: | 910 public: |
| 919 explicit StartIsolateScope(Isolate* new_isolate) | 911 explicit StartIsolateScope(Isolate* new_isolate) |
| 920 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { | 912 : new_isolate_(new_isolate), saved_isolate_(Isolate::Current()) { |
| 921 // TODO(koda): Audit users; passing NULL goes against naming of this class. | 913 // TODO(koda): Audit users; passing NULL goes against naming of this class. |
| 922 if (new_isolate_ == NULL) { | 914 if (new_isolate_ == NULL) { |
| 923 ASSERT(Isolate::Current() == NULL); | 915 ASSERT(Isolate::Current() == NULL); |
| 924 // Do nothing. | 916 // Do nothing. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 946 } | 938 } |
| 947 } | 939 } |
| 948 | 940 |
| 949 private: | 941 private: |
| 950 Isolate* new_isolate_; | 942 Isolate* new_isolate_; |
| 951 Isolate* saved_isolate_; | 943 Isolate* saved_isolate_; |
| 952 | 944 |
| 953 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope); | 945 DISALLOW_COPY_AND_ASSIGN(StartIsolateScope); |
| 954 }; | 946 }; |
| 955 | 947 |
| 956 | |
| 957 class IsolateSpawnState { | 948 class IsolateSpawnState { |
| 958 public: | 949 public: |
| 959 IsolateSpawnState(Dart_Port parent_port, | 950 IsolateSpawnState(Dart_Port parent_port, |
| 960 Dart_Port origin_id, | 951 Dart_Port origin_id, |
| 961 void* init_data, | 952 void* init_data, |
| 962 const char* script_url, | 953 const char* script_url, |
| 963 const Function& func, | 954 const Function& func, |
| 964 SerializedObjectBuffer* message_buffer, | 955 SerializedObjectBuffer* message_buffer, |
| 965 Monitor* spawn_count_monitor, | 956 Monitor* spawn_count_monitor, |
| 966 intptr_t* spawn_count, | 957 intptr_t* spawn_count, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 intptr_t* spawn_count_; | 1025 intptr_t* spawn_count_; |
| 1035 | 1026 |
| 1036 Dart_IsolateFlags isolate_flags_; | 1027 Dart_IsolateFlags isolate_flags_; |
| 1037 bool paused_; | 1028 bool paused_; |
| 1038 bool errors_are_fatal_; | 1029 bool errors_are_fatal_; |
| 1039 }; | 1030 }; |
| 1040 | 1031 |
| 1041 } // namespace dart | 1032 } // namespace dart |
| 1042 | 1033 |
| 1043 #endif // RUNTIME_VM_ISOLATE_H_ | 1034 #endif // RUNTIME_VM_ISOLATE_H_ |
| OLD | NEW |