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

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

Issue 3003583002: [VM, Precompiler] PoC Obfuscator (Closed)
Patch Set: Discard obfuscation map 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_);
693 }
694
695 Dart_QualifiedFunctionName* embedder_entry_points() const {
696 return embedder_entry_points_;
692 } 697 }
693 698
694 // Isolate-specific flag handling. 699 // Isolate-specific flag handling.
695 static void FlagsInitialize(Dart_IsolateFlags* api_flags); 700 static void FlagsInitialize(Dart_IsolateFlags* api_flags);
696 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const; 701 void FlagsCopyTo(Dart_IsolateFlags* api_flags) const;
697 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags); 702 void FlagsCopyFrom(const Dart_IsolateFlags& api_flags);
698 703
699 #if defined(PRODUCT) 704 #if defined(PRODUCT)
700 #define DECLARE_GETTER(name, bitname, isolate_flag_name, flag_name) \ 705 #define DECLARE_GETTER(name, bitname, isolate_flag_name, flag_name) \
701 bool name() const { return flag_name; } 706 bool name() const { return flag_name; }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 StoreBuffer* store_buffer_; 803 StoreBuffer* store_buffer_;
799 Heap* heap_; 804 Heap* heap_;
800 uword user_tag_; 805 uword user_tag_;
801 RawUserTag* current_tag_; 806 RawUserTag* current_tag_;
802 RawUserTag* default_tag_; 807 RawUserTag* default_tag_;
803 RawCode* ic_miss_code_; 808 RawCode* ic_miss_code_;
804 ObjectStore* object_store_; 809 ObjectStore* object_store_;
805 ClassTable class_table_; 810 ClassTable class_table_;
806 bool single_step_; 811 bool single_step_;
807 812
813 #define ISOLATE_FLAG_BITS(V) \
814 V(ErrorsFatal) \
815 V(IsRunnable) \
816 V(IsServiceIsolate) \
817 V(CompilationAllowed) \
818 V(AllClassesFinalized) \
819 V(RemappingCids) \
820 V(ResumeRequest) \
821 V(HasAttemptedReload) \
822 V(ShouldPausePostServiceRequest) \
823 V(UseDartFrontEnd) \
824 V(EnableTypeChecks) \
825 V(EnableAsserts) \
826 V(ErrorOnBadType) \
827 V(ErrorOnBadOverride) \
828 V(UseFieldGuards) \
829 V(UseOsr) \
830 V(Obfuscate)
831
808 // Isolate specific flags. 832 // Isolate specific flags.
809 enum FlagBits { 833 enum FlagBits {
810 kErrorsFatalBit = 0, 834 #define DECLARE_BIT(Name) k##Name##Bit,
811 kIsRunnableBit = 1, 835 ISOLATE_FLAG_BITS(DECLARE_BIT)
812 kIsServiceIsolateBit = 2, 836 #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 }; 837 };
827 class ErrorsFatalBit : public BitField<uint32_t, bool, kErrorsFatalBit, 1> {}; 838
828 class RunnableBit : public BitField<uint32_t, bool, kIsRunnableBit, 1> {}; 839 #define DECLARE_BITFIELD(Name) \
829 class ServiceIsolateBit 840 class Name##Bit : public BitField<uint32_t, bool, k##Name##Bit, 1> {};
830 : public BitField<uint32_t, bool, kIsServiceIsolateBit, 1> {}; 841 ISOLATE_FLAG_BITS(DECLARE_BITFIELD)
831 class CompilationAllowedBit 842 #undef DECLARE_BITFIELD
832 : public BitField<uint32_t, bool, kCompilationAllowedBit, 1> {}; 843
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_; 844 uint32_t isolate_flags_;
858 845
859 // Background compilation. 846 // Background compilation.
860 int16_t background_compiler_disabled_depth_; 847 int16_t background_compiler_disabled_depth_;
861 BackgroundCompiler* background_compiler_; 848 BackgroundCompiler* background_compiler_;
862 849
863 // Fields that aren't needed in a product build go here with boolean flags at 850 // Fields that aren't needed in a product build go here with boolean flags at
864 // the top. 851 // the top.
865 #if !defined(PRODUCT) 852 #if !defined(PRODUCT)
866 char* debugger_name_; 853 char* debugger_name_;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 // List of fields that became boxed and that trigger deoptimization. 948 // List of fields that became boxed and that trigger deoptimization.
962 RawGrowableObjectArray* boxed_field_list_; 949 RawGrowableObjectArray* boxed_field_list_;
963 950
964 // This guards spawn_count_. An isolate cannot complete shutdown and be 951 // This guards spawn_count_. An isolate cannot complete shutdown and be
965 // destroyed while there are child isolates in the midst of a spawn. 952 // destroyed while there are child isolates in the midst of a spawn.
966 Monitor* spawn_count_monitor_; 953 Monitor* spawn_count_monitor_;
967 intptr_t spawn_count_; 954 intptr_t spawn_count_;
968 955
969 HandlerInfoCache handler_info_cache_; 956 HandlerInfoCache handler_info_cache_;
970 CatchEntryStateCache catch_entry_state_cache_; 957 CatchEntryStateCache catch_entry_state_cache_;
958 Dart_QualifiedFunctionName* embedder_entry_points_;
971 959
972 static Dart_IsolateCreateCallback create_callback_; 960 static Dart_IsolateCreateCallback create_callback_;
973 static Dart_IsolateShutdownCallback shutdown_callback_; 961 static Dart_IsolateShutdownCallback shutdown_callback_;
974 static Dart_IsolateCleanupCallback cleanup_callback_; 962 static Dart_IsolateCleanupCallback cleanup_callback_;
975 963
976 #if !defined(PRODUCT) 964 #if !defined(PRODUCT)
977 static void WakePauseEventHandler(Dart_Isolate isolate); 965 static void WakePauseEventHandler(Dart_Isolate isolate);
978 #endif 966 #endif
979 967
980 // Manage list of existing isolates. 968 // Manage list of existing isolates.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 intptr_t* spawn_count_; 1114 intptr_t* spawn_count_;
1127 1115
1128 Dart_IsolateFlags isolate_flags_; 1116 Dart_IsolateFlags isolate_flags_;
1129 bool paused_; 1117 bool paused_;
1130 bool errors_are_fatal_; 1118 bool errors_are_fatal_;
1131 }; 1119 };
1132 1120
1133 } // namespace dart 1121 } // namespace dart
1134 1122
1135 #endif // RUNTIME_VM_ISOLATE_H_ 1123 #endif // RUNTIME_VM_ISOLATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698