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

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

Issue 3003583002: [VM, Precompiler] PoC Obfuscator (Closed)
Patch Set: address comments and fix stuff Created 3 years, 3 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 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // 133 //
134 #define ISOLATE_FLAG_LIST(V) \ 134 #define ISOLATE_FLAG_LIST(V) \
135 V(type_checks, EnableTypeChecks, enable_type_checks, \ 135 V(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(asserts, EnableAsserts, enable_asserts, FLAG_enable_asserts) \
138 V(error_on_bad_type, ErrorOnBadType, enable_error_on_bad_type, \ 138 V(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(error_on_bad_override, ErrorOnBadOverride, enable_error_on_bad_override, \
141 FLAG_error_on_bad_override) \ 141 FLAG_error_on_bad_override) \
142 V(use_field_guards, UseFieldGuards, use_field_guards, FLAG_use_field_guards) \ 142 V(use_field_guards, UseFieldGuards, use_field_guards, FLAG_use_field_guards) \
143 V(use_osr, UseOsr, use_osr, FLAG_use_osr) 143 V(use_osr, UseOsr, use_osr, FLAG_use_osr) \
144 V(obfuscate, Obfuscate, obfuscate, false_by_default)
144 145
145 class Isolate : public BaseIsolate { 146 class Isolate : public BaseIsolate {
146 public: 147 public:
147 // Keep both these enums in sync with isolate_patch.dart. 148 // Keep both these enums in sync with isolate_patch.dart.
148 // The different Isolate API message types. 149 // The different Isolate API message types.
149 enum LibMsgId { 150 enum LibMsgId {
150 kPauseMsg = 1, 151 kPauseMsg = 1,
151 kResumeMsg = 2, 152 kResumeMsg = 2,
152 kPingMsg = 3, 153 kPingMsg = 3,
153 kKillMsg = 4, 154 kKillMsg = 4,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 const char* root_script_url = NULL, 289 const char* root_script_url = NULL,
289 const char* packages_url = NULL, 290 const char* packages_url = NULL,
290 bool dont_delete_reload_context = false); 291 bool dont_delete_reload_context = false);
291 292
292 bool MakeRunnable(); 293 bool MakeRunnable();
293 void Run(); 294 void Run();
294 295
295 MessageHandler* message_handler() const { return message_handler_; } 296 MessageHandler* message_handler() const { return message_handler_; }
296 void set_message_handler(MessageHandler* value) { message_handler_ = value; } 297 void set_message_handler(MessageHandler* value) { message_handler_ = value; }
297 298
298 bool is_runnable() const { return RunnableBit::decode(isolate_flags_); } 299 bool is_runnable() const { return IsRunnableBit::decode(isolate_flags_); }
299 void set_is_runnable(bool value) { 300 void set_is_runnable(bool value) {
300 isolate_flags_ = RunnableBit::update(value, isolate_flags_); 301 isolate_flags_ = IsRunnableBit::update(value, isolate_flags_);
301 #if !defined(PRODUCT) 302 #if !defined(PRODUCT)
302 if (is_runnable()) { 303 if (is_runnable()) {
303 set_last_resume_timestamp(); 304 set_last_resume_timestamp();
304 } 305 }
305 #endif 306 #endif
306 } 307 }
307 308
308 IsolateSpawnState* spawn_state() const { return spawn_state_; } 309 IsolateSpawnState* spawn_state() const { return spawn_state_; }
309 void set_spawn_state(IsolateSpawnState* value) { spawn_state_ = value; } 310 void set_spawn_state(IsolateSpawnState* value) { spawn_state_ = value; }
310 311
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 void PauseEventHandler(); 679 void PauseEventHandler();
679 #endif 680 #endif
680 681
681 void AddClosureFunction(const Function& function) const; 682 void AddClosureFunction(const Function& function) const;
682 RawFunction* LookupClosureFunction(const Function& parent, 683 RawFunction* LookupClosureFunction(const Function& parent,
683 TokenPosition token_pos) const; 684 TokenPosition token_pos) const;
684 intptr_t FindClosureIndex(const Function& needle) const; 685 intptr_t FindClosureIndex(const Function& needle) const;
685 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const; 686 RawFunction* ClosureFunctionFromIndex(intptr_t idx) const;
686 687
687 bool is_service_isolate() const { 688 bool is_service_isolate() const {
688 return ServiceIsolateBit::decode(isolate_flags_); 689 return IsServiceIsolateBit::decode(isolate_flags_);
689 } 690 }
690 void set_is_service_isolate(bool value) { 691 void set_is_service_isolate(bool value) {
691 isolate_flags_ = ServiceIsolateBit::update(value, isolate_flags_); 692 isolate_flags_ = IsServiceIsolateBit::update(value, isolate_flags_);
692 } 693 }
693 694
695 Dart_QualifiedFunctionName* embedder_entry_points() const {
696 return embedder_entry_points_;
697 }
698
699 void set_obfuscation_map(const char** map) { obfuscation_map_ = map; }
700 const char** obfuscation_map() const { return obfuscation_map_; }
701
694 // Isolate-specific flag handling. 702 // Isolate-specific flag handling.
695 static void FlagsInitialize(Dart_IsolateFlags* api_flags); 703 static void FlagsInitialize(Dart_IsolateFlags* api_flags);
696 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const; 704 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const;
697 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags); 705 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags);
698 706
699 #if defined(PRODUCT) 707 #if defined(PRODUCT)
700 #define DECLARE_GETTER(name, bitname, isolate_flag_name, flag_name) \ 708 #define DECLARE_GETTER(name, bitname, isolate_flag_name, flag_name) \
701 bool name() const { return flag_name; } 709 bool name() const { return flag_name; }
702 ISOLATE_FLAG_LIST(DECLARE_GETTER) 710 ISOLATE_FLAG_LIST(DECLARE_GETTER)
703 #undef DECLARE_GETTER 711 #undef DECLARE_GETTER
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 StoreBuffer* store_buffer_; 806 StoreBuffer* store_buffer_;
799 Heap* heap_; 807 Heap* heap_;
800 uword user_tag_; 808 uword user_tag_;
801 RawUserTag* current_tag_; 809 RawUserTag* current_tag_;
802 RawUserTag* default_tag_; 810 RawUserTag* default_tag_;
803 RawCode* ic_miss_code_; 811 RawCode* ic_miss_code_;
804 ObjectStore* object_store_; 812 ObjectStore* object_store_;
805 ClassTable class_table_; 813 ClassTable class_table_;
806 bool single_step_; 814 bool single_step_;
807 815
816 #define ISOLATE_FLAG_BITS(V) \
817 V(ErrorsFatal) \
818 V(IsRunnable) \
819 V(IsServiceIsolate) \
820 V(CompilationAllowed) \
821 V(AllClassesFinalized) \
822 V(RemappingCids) \
823 V(ResumeRequest) \
824 V(HasAttemptedReload) \
825 V(ShouldPausePostServiceRequest) \
826 V(UseDartFrontEnd) \
827 V(EnableTypeChecks) \
828 V(EnableAsserts) \
829 V(ErrorOnBadType) \
830 V(ErrorOnBadOverride) \
831 V(UseFieldGuards) \
832 V(UseOsr) \
833 V(Obfuscate)
834
808 // Isolate specific flags. 835 // Isolate specific flags.
809 enum FlagBits { 836 enum FlagBits {
810 kErrorsFatalBit = 0, 837 #define DECLARE_BIT(Name) k##Name##Bit,
811 kIsRunnableBit = 1, 838 ISOLATE_FLAG_BITS(DECLARE_BIT)
812 kIsServiceIsolateBit = 2, 839 #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 }; 840 };
827 class ErrorsFatalBit : public BitField<uint32_t, bool, kErrorsFatalBit, 1> {}; 841
828 class RunnableBit : public BitField<uint32_t, bool, kIsRunnableBit, 1> {}; 842 #define DECLARE_BITFIELD(Name) \
829 class ServiceIsolateBit 843 class Name##Bit : public BitField<uint32_t, bool, k##Name##Bit, 1> {};
830 : public BitField<uint32_t, bool, kIsServiceIsolateBit, 1> {}; 844 ISOLATE_FLAG_BITS(DECLARE_BITFIELD)
831 class CompilationAllowedBit 845 #undef DECLARE_BITFIELD
832 : public BitField<uint32_t, bool, kCompilationAllowedBit, 1> {}; 846
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_; 847 uint32_t isolate_flags_;
858 848
859 // Background compilation. 849 // Background compilation.
860 int16_t background_compiler_disabled_depth_; 850 int16_t background_compiler_disabled_depth_;
861 BackgroundCompiler* background_compiler_; 851 BackgroundCompiler* background_compiler_;
862 852
863 // Fields that aren't needed in a product build go here with boolean flags at 853 // Fields that aren't needed in a product build go here with boolean flags at
864 // the top. 854 // the top.
865 #if !defined(PRODUCT) 855 #if !defined(PRODUCT)
866 char* debugger_name_; 856 char* debugger_name_;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 RawGrowableObjectArray* boxed_field_list_; 952 RawGrowableObjectArray* boxed_field_list_;
963 953
964 // This guards spawn_count_. An isolate cannot complete shutdown and be 954 // This guards spawn_count_. An isolate cannot complete shutdown and be
965 // destroyed while there are child isolates in the midst of a spawn. 955 // destroyed while there are child isolates in the midst of a spawn.
966 Monitor* spawn_count_monitor_; 956 Monitor* spawn_count_monitor_;
967 intptr_t spawn_count_; 957 intptr_t spawn_count_;
968 958
969 HandlerInfoCache handler_info_cache_; 959 HandlerInfoCache handler_info_cache_;
970 CatchEntryStateCache catch_entry_state_cache_; 960 CatchEntryStateCache catch_entry_state_cache_;
971 961
962 Dart_QualifiedFunctionName* embedder_entry_points_;
963 const char** obfuscation_map_;
964
972 static Dart_IsolateCreateCallback create_callback_; 965 static Dart_IsolateCreateCallback create_callback_;
973 static Dart_IsolateShutdownCallback shutdown_callback_; 966 static Dart_IsolateShutdownCallback shutdown_callback_;
974 static Dart_IsolateCleanupCallback cleanup_callback_; 967 static Dart_IsolateCleanupCallback cleanup_callback_;
975 968
976 #if !defined(PRODUCT) 969 #if !defined(PRODUCT)
977 static void WakePauseEventHandler(Dart_Isolate isolate); 970 static void WakePauseEventHandler(Dart_Isolate isolate);
978 #endif 971 #endif
979 972
980 // Manage list of existing isolates. 973 // Manage list of existing isolates.
981 static bool AddIsolateToList(Isolate* isolate); 974 static bool AddIsolateToList(Isolate* isolate);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 intptr_t* spawn_count_; 1119 intptr_t* spawn_count_;
1127 1120
1128 Dart_IsolateFlags isolate_flags_; 1121 Dart_IsolateFlags isolate_flags_;
1129 bool paused_; 1122 bool paused_;
1130 bool errors_are_fatal_; 1123 bool errors_are_fatal_;
1131 }; 1124 };
1132 1125
1133 } // namespace dart 1126 } // namespace dart
1134 1127
1135 #endif // RUNTIME_VM_ISOLATE_H_ 1128 #endif // RUNTIME_VM_ISOLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698