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" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 typedef FixedCache<intptr_t, ExceptionHandlerInfo, 16> HandlerInfoCache; | 125 typedef FixedCache<intptr_t, ExceptionHandlerInfo, 16> HandlerInfoCache; |
126 // Fixed cache for catch entry state lookup. | 126 // Fixed cache for catch entry state lookup. |
127 typedef FixedCache<intptr_t, CatchEntryState, 16> CatchEntryStateCache; | 127 typedef FixedCache<intptr_t, CatchEntryState, 16> CatchEntryStateCache; |
128 | 128 |
129 // List of Isolate flags with corresponding members of Dart_IsolateFlags and | 129 // List of Isolate flags with corresponding members of Dart_IsolateFlags and |
130 // corresponding global command line flags. | 130 // corresponding global command line flags. |
131 // | 131 // |
132 // V(name, Dart_IsolateFlags-member-name, command-line-flag-name) | 132 // V(name, Dart_IsolateFlags-member-name, command-line-flag-name) |
133 // | 133 // |
134 #define ISOLATE_FLAG_LIST(V) \ | 134 #define ISOLATE_FLAG_LIST(V) \ |
135 V(type_checks, EnableTypeChecks, enable_type_checks, \ | 135 V(NONPRODUCT, type_checks, EnableTypeChecks, enable_type_checks, \ |
136 FLAG_enable_type_checks) \ | 136 FLAG_enable_type_checks) \ |
137 V(asserts, EnableAsserts, enable_asserts, FLAG_enable_asserts) \ | 137 V(NONPRODUCT, asserts, EnableAsserts, enable_asserts, FLAG_enable_asserts) \ |
138 V(error_on_bad_type, ErrorOnBadType, enable_error_on_bad_type, \ | 138 V(NONPRODUCT, error_on_bad_type, ErrorOnBadType, enable_error_on_bad_type, \ |
139 FLAG_error_on_bad_type) \ | 139 FLAG_error_on_bad_type) \ |
140 V(error_on_bad_override, ErrorOnBadOverride, enable_error_on_bad_override, \ | 140 V(NONPRODUCT, error_on_bad_override, ErrorOnBadOverride, \ |
141 FLAG_error_on_bad_override) \ | 141 enable_error_on_bad_override, FLAG_error_on_bad_override) \ |
142 V(use_field_guards, UseFieldGuards, use_field_guards, FLAG_use_field_guards) \ | 142 V(NONPRODUCT, use_field_guards, UseFieldGuards, use_field_guards, \ |
143 V(use_osr, UseOsr, use_osr, FLAG_use_osr) | 143 FLAG_use_field_guards) \ |
| 144 V(NONPRODUCT, use_osr, UseOsr, use_osr, FLAG_use_osr) \ |
| 145 V(PRECOMPILER, obfuscate, Obfuscate, obfuscate, false_by_default) |
144 | 146 |
145 class Isolate : public BaseIsolate { | 147 class Isolate : public BaseIsolate { |
146 public: | 148 public: |
147 // Keep both these enums in sync with isolate_patch.dart. | 149 // Keep both these enums in sync with isolate_patch.dart. |
148 // The different Isolate API message types. | 150 // The different Isolate API message types. |
149 enum LibMsgId { | 151 enum LibMsgId { |
150 kPauseMsg = 1, | 152 kPauseMsg = 1, |
151 kResumeMsg = 2, | 153 kResumeMsg = 2, |
152 kPingMsg = 3, | 154 kPingMsg = 3, |
153 kKillMsg = 4, | 155 kKillMsg = 4, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 const char* root_script_url = NULL, | 290 const char* root_script_url = NULL, |
289 const char* packages_url = NULL, | 291 const char* packages_url = NULL, |
290 bool dont_delete_reload_context = false); | 292 bool dont_delete_reload_context = false); |
291 | 293 |
292 bool MakeRunnable(); | 294 bool MakeRunnable(); |
293 void Run(); | 295 void Run(); |
294 | 296 |
295 MessageHandler* message_handler() const { return message_handler_; } | 297 MessageHandler* message_handler() const { return message_handler_; } |
296 void set_message_handler(MessageHandler* value) { message_handler_ = value; } | 298 void set_message_handler(MessageHandler* value) { message_handler_ = value; } |
297 | 299 |
298 bool is_runnable() const { return RunnableBit::decode(isolate_flags_); } | 300 bool is_runnable() const { return IsRunnableBit::decode(isolate_flags_); } |
299 void set_is_runnable(bool value) { | 301 void set_is_runnable(bool value) { |
300 isolate_flags_ = RunnableBit::update(value, isolate_flags_); | 302 isolate_flags_ = IsRunnableBit::update(value, isolate_flags_); |
301 #if !defined(PRODUCT) | 303 #if !defined(PRODUCT) |
302 if (is_runnable()) { | 304 if (is_runnable()) { |
303 set_last_resume_timestamp(); | 305 set_last_resume_timestamp(); |
304 } | 306 } |
305 #endif | 307 #endif |
306 } | 308 } |
307 | 309 |
308 IsolateSpawnState* spawn_state() const { return spawn_state_; } | 310 IsolateSpawnState* spawn_state() const { return spawn_state_; } |
309 void set_spawn_state(IsolateSpawnState* value) { spawn_state_ = value; } | 311 void set_spawn_state(IsolateSpawnState* value) { spawn_state_ = value; } |
310 | 312 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 void PauseEventHandler(); | 680 void PauseEventHandler(); |
679 #endif | 681 #endif |
680 | 682 |
681 void AddClosureFunction(const Function& function) const; | 683 void AddClosureFunction(const Function& function) const; |
682 RawFunction* LookupClosureFunction(const Function& parent, | 684 RawFunction* LookupClosureFunction(const Function& parent, |
683 TokenPosition token_pos) const; | 685 TokenPosition token_pos) const; |
684 intptr_t FindClosureIndex(const Function& needle) const; | 686 intptr_t FindClosureIndex(const Function& needle) const; |
685 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const; | 687 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const; |
686 | 688 |
687 bool is_service_isolate() const { | 689 bool is_service_isolate() const { |
688 return ServiceIsolateBit::decode(isolate_flags_); | 690 return IsServiceIsolateBit::decode(isolate_flags_); |
689 } | 691 } |
690 void set_is_service_isolate(bool value) { | 692 void set_is_service_isolate(bool value) { |
691 isolate_flags_ = ServiceIsolateBit::update(value, isolate_flags_); | 693 isolate_flags_ = IsServiceIsolateBit::update(value, isolate_flags_); |
692 } | 694 } |
693 | 695 |
| 696 Dart_QualifiedFunctionName* embedder_entry_points() const { |
| 697 return embedder_entry_points_; |
| 698 } |
| 699 |
| 700 void set_obfuscation_map(const char** map) { obfuscation_map_ = map; } |
| 701 const char** obfuscation_map() const { return obfuscation_map_; } |
| 702 |
694 // Isolate-specific flag handling. | 703 // Isolate-specific flag handling. |
695 static void FlagsInitialize(Dart_IsolateFlags* api_flags); | 704 static void FlagsInitialize(Dart_IsolateFlags* api_flags); |
696 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const; | 705 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const; |
697 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags); | 706 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags); |
698 | 707 |
| 708 #if defined(DART_PRECOMPILER) |
| 709 #define FLAG_FOR_PRECOMPILER(from_field, from_flag) (from_field) |
| 710 #else |
| 711 #define FLAG_FOR_PRECOMPILER(from_field, from_flag) (from_flag) |
| 712 #endif |
| 713 |
| 714 #if !defined(PRODUCT) |
| 715 #define FLAG_FOR_NONPRODUCT(from_field, from_flag) (from_field) |
| 716 #else |
| 717 #define FLAG_FOR_NONPRODUCT(from_field, from_flag) (from_flag) |
| 718 #endif |
| 719 |
| 720 #define DECLARE_GETTER(when, name, bitname, isolate_flag_name, flag_name) \ |
| 721 bool name() const { \ |
| 722 const bool false_by_default = false; \ |
| 723 USE(false_by_default); \ |
| 724 return FLAG_FOR_##when(bitname##Bit::decode(isolate_flags_), flag_name); \ |
| 725 } |
| 726 ISOLATE_FLAG_LIST(DECLARE_GETTER) |
| 727 #undef FLAG_FOR_NONPRODUCT |
| 728 #undef FLAG_FOR_PRECOMPILER |
| 729 #undef DECLARE_GETTER |
| 730 |
699 #if defined(PRODUCT) | 731 #if defined(PRODUCT) |
700 #define DECLARE_GETTER(name, bitname, isolate_flag_name, flag_name) \ | |
701 bool name() const { return flag_name; } | |
702 ISOLATE_FLAG_LIST(DECLARE_GETTER) | |
703 #undef DECLARE_GETTER | |
704 void set_use_osr(bool use_osr) { ASSERT(!use_osr); } | 732 void set_use_osr(bool use_osr) { ASSERT(!use_osr); } |
705 #else // defined(PRODUCT) | 733 #else // defined(PRODUCT) |
706 #define DECLARE_GETTER(name, bitname, isolate_flag_name, flag_name) \ | |
707 bool name() const { return bitname##Bit::decode(isolate_flags_); } | |
708 ISOLATE_FLAG_LIST(DECLARE_GETTER) | |
709 #undef DECLARE_GETTER | |
710 void set_use_osr(bool use_osr) { | 734 void set_use_osr(bool use_osr) { |
711 isolate_flags_ = UseOsrBit::update(use_osr, isolate_flags_); | 735 isolate_flags_ = UseOsrBit::update(use_osr, isolate_flags_); |
712 } | 736 } |
713 #endif // defined(PRODUCT) | 737 #endif // defined(PRODUCT) |
714 | 738 |
715 static void KillAllIsolates(LibMsgId msg_id); | 739 static void KillAllIsolates(LibMsgId msg_id); |
716 static void KillIfExists(Isolate* isolate, LibMsgId msg_id); | 740 static void KillIfExists(Isolate* isolate, LibMsgId msg_id); |
717 | 741 |
718 static void DisableIsolateCreation(); | 742 static void DisableIsolateCreation(); |
719 static void EnableIsolateCreation(); | 743 static void EnableIsolateCreation(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 StoreBuffer* store_buffer_; | 822 StoreBuffer* store_buffer_; |
799 Heap* heap_; | 823 Heap* heap_; |
800 uword user_tag_; | 824 uword user_tag_; |
801 RawUserTag* current_tag_; | 825 RawUserTag* current_tag_; |
802 RawUserTag* default_tag_; | 826 RawUserTag* default_tag_; |
803 RawCode* ic_miss_code_; | 827 RawCode* ic_miss_code_; |
804 ObjectStore* object_store_; | 828 ObjectStore* object_store_; |
805 ClassTable class_table_; | 829 ClassTable class_table_; |
806 bool single_step_; | 830 bool single_step_; |
807 | 831 |
| 832 #define ISOLATE_FLAG_BITS(V) \ |
| 833 V(ErrorsFatal) \ |
| 834 V(IsRunnable) \ |
| 835 V(IsServiceIsolate) \ |
| 836 V(CompilationAllowed) \ |
| 837 V(AllClassesFinalized) \ |
| 838 V(RemappingCids) \ |
| 839 V(ResumeRequest) \ |
| 840 V(HasAttemptedReload) \ |
| 841 V(ShouldPausePostServiceRequest) \ |
| 842 V(UseDartFrontEnd) \ |
| 843 V(EnableTypeChecks) \ |
| 844 V(EnableAsserts) \ |
| 845 V(ErrorOnBadType) \ |
| 846 V(ErrorOnBadOverride) \ |
| 847 V(UseFieldGuards) \ |
| 848 V(UseOsr) \ |
| 849 V(Obfuscate) |
| 850 |
808 // Isolate specific flags. | 851 // Isolate specific flags. |
809 enum FlagBits { | 852 enum FlagBits { |
810 kErrorsFatalBit = 0, | 853 #define DECLARE_BIT(Name) k##Name##Bit, |
811 kIsRunnableBit = 1, | 854 ISOLATE_FLAG_BITS(DECLARE_BIT) |
812 kIsServiceIsolateBit = 2, | 855 #undef DECLARE_BIT |
813 kCompilationAllowedBit = 3, | |
814 kAllClassesFinalizedBit = 4, | |
815 kRemappingCidsBit = 5, | |
816 kResumeRequestBit = 6, | |
817 kHasAttemptedReloadBit = 7, | |
818 kShouldPausePostServiceRequestBit = 8, | |
819 kUseDartFrontEndBit = 9, | |
820 kEnableTypeChecksBit = 10, | |
821 kEnableAssertsBit = 11, | |
822 kErrorOnBadTypeBit = 12, | |
823 kErrorOnBadOverrideBit = 13, | |
824 kUseFieldGuardsBit = 14, | |
825 kUseOsrBit = 15, | |
826 }; | 856 }; |
827 class ErrorsFatalBit : public BitField<uint32_t, bool, kErrorsFatalBit, 1> {}; | 857 |
828 class RunnableBit : public BitField<uint32_t, bool, kIsRunnableBit, 1> {}; | 858 #define DECLARE_BITFIELD(Name) \ |
829 class ServiceIsolateBit | 859 class Name##Bit : public BitField<uint32_t, bool, k##Name##Bit, 1> {}; |
830 : public BitField<uint32_t, bool, kIsServiceIsolateBit, 1> {}; | 860 ISOLATE_FLAG_BITS(DECLARE_BITFIELD) |
831 class CompilationAllowedBit | 861 #undef DECLARE_BITFIELD |
832 : public BitField<uint32_t, bool, kCompilationAllowedBit, 1> {}; | 862 |
833 class AllClassesFinalizedBit | |
834 : public BitField<uint32_t, bool, kAllClassesFinalizedBit, 1> {}; | |
835 class RemappingCidsBit | |
836 : public BitField<uint32_t, bool, kRemappingCidsBit, 1> {}; | |
837 class ResumeRequestBit | |
838 : public BitField<uint32_t, bool, kResumeRequestBit, 1> {}; | |
839 class HasAttemptedReloadBit | |
840 : public BitField<uint32_t, bool, kHasAttemptedReloadBit, 1> {}; | |
841 class ShouldPausePostServiceRequestBit | |
842 : public BitField<uint32_t, bool, kShouldPausePostServiceRequestBit, 1> { | |
843 }; | |
844 class UseDartFrontEndBit | |
845 : public BitField<uint32_t, bool, kUseDartFrontEndBit, 1> {}; | |
846 class EnableTypeChecksBit | |
847 : public BitField<uint32_t, bool, kEnableTypeChecksBit, 1> {}; | |
848 class EnableAssertsBit | |
849 : public BitField<uint32_t, bool, kEnableAssertsBit, 1> {}; | |
850 class ErrorOnBadTypeBit | |
851 : public BitField<uint32_t, bool, kErrorOnBadTypeBit, 1> {}; | |
852 class ErrorOnBadOverrideBit | |
853 : public BitField<uint32_t, bool, kErrorOnBadOverrideBit, 1> {}; | |
854 class UseFieldGuardsBit | |
855 : public BitField<uint32_t, bool, kUseFieldGuardsBit, 1> {}; | |
856 class UseOsrBit : public BitField<uint32_t, bool, kUseOsrBit, 1> {}; | |
857 uint32_t isolate_flags_; | 863 uint32_t isolate_flags_; |
858 | 864 |
859 // Background compilation. | 865 // Background compilation. |
860 int16_t background_compiler_disabled_depth_; | 866 int16_t background_compiler_disabled_depth_; |
861 BackgroundCompiler* background_compiler_; | 867 BackgroundCompiler* background_compiler_; |
862 | 868 |
863 // Fields that aren't needed in a product build go here with boolean flags at | 869 // Fields that aren't needed in a product build go here with boolean flags at |
864 // the top. | 870 // the top. |
865 #if !defined(PRODUCT) | 871 #if !defined(PRODUCT) |
866 char* debugger_name_; | 872 char* debugger_name_; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 RawGrowableObjectArray* boxed_field_list_; | 968 RawGrowableObjectArray* boxed_field_list_; |
963 | 969 |
964 // This guards spawn_count_. An isolate cannot complete shutdown and be | 970 // This guards spawn_count_. An isolate cannot complete shutdown and be |
965 // destroyed while there are child isolates in the midst of a spawn. | 971 // destroyed while there are child isolates in the midst of a spawn. |
966 Monitor* spawn_count_monitor_; | 972 Monitor* spawn_count_monitor_; |
967 intptr_t spawn_count_; | 973 intptr_t spawn_count_; |
968 | 974 |
969 HandlerInfoCache handler_info_cache_; | 975 HandlerInfoCache handler_info_cache_; |
970 CatchEntryStateCache catch_entry_state_cache_; | 976 CatchEntryStateCache catch_entry_state_cache_; |
971 | 977 |
| 978 Dart_QualifiedFunctionName* embedder_entry_points_; |
| 979 const char** obfuscation_map_; |
| 980 |
972 static Dart_IsolateCreateCallback create_callback_; | 981 static Dart_IsolateCreateCallback create_callback_; |
973 static Dart_IsolateShutdownCallback shutdown_callback_; | 982 static Dart_IsolateShutdownCallback shutdown_callback_; |
974 static Dart_IsolateCleanupCallback cleanup_callback_; | 983 static Dart_IsolateCleanupCallback cleanup_callback_; |
975 | 984 |
976 #if !defined(PRODUCT) | 985 #if !defined(PRODUCT) |
977 static void WakePauseEventHandler(Dart_Isolate isolate); | 986 static void WakePauseEventHandler(Dart_Isolate isolate); |
978 #endif | 987 #endif |
979 | 988 |
980 // Manage list of existing isolates. | 989 // Manage list of existing isolates. |
981 static bool AddIsolateToList(Isolate* isolate); | 990 static bool AddIsolateToList(Isolate* isolate); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 intptr_t* spawn_count_; | 1135 intptr_t* spawn_count_; |
1127 | 1136 |
1128 Dart_IsolateFlags isolate_flags_; | 1137 Dart_IsolateFlags isolate_flags_; |
1129 bool paused_; | 1138 bool paused_; |
1130 bool errors_are_fatal_; | 1139 bool errors_are_fatal_; |
1131 }; | 1140 }; |
1132 | 1141 |
1133 } // namespace dart | 1142 } // namespace dart |
1134 | 1143 |
1135 #endif // RUNTIME_VM_ISOLATE_H_ | 1144 #endif // RUNTIME_VM_ISOLATE_H_ |
OLD | NEW |