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 #include "vm/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/text_buffer.h" | 10 #include "platform/text_buffer.h" |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 } | 684 } |
685 } | 685 } |
686 #endif // !defined(PRODUCT) | 686 #endif // !defined(PRODUCT) |
687 return kError; | 687 return kError; |
688 } | 688 } |
689 } | 689 } |
690 return kOK; | 690 return kOK; |
691 } | 691 } |
692 | 692 |
693 void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) { | 693 void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) { |
694 const bool false_by_default = false; | |
695 const bool true_by_default = true; | |
696 USE(true_by_default); | |
697 USE(false_by_default); | |
698 | |
694 api_flags->version = DART_FLAGS_CURRENT_VERSION; | 699 api_flags->version = DART_FLAGS_CURRENT_VERSION; |
695 #define INIT_FROM_FLAG(name, bitname, isolate_flag, flag) \ | 700 #define INIT_FROM_FLAG(name, bitname, isolate_flag, flag) \ |
696 api_flags->isolate_flag = flag; | 701 api_flags->isolate_flag = flag; |
697 ISOLATE_FLAG_LIST(INIT_FROM_FLAG) | 702 ISOLATE_FLAG_LIST(INIT_FROM_FLAG) |
698 #undef INIT_FROM_FLAG | 703 #undef INIT_FROM_FLAG |
699 api_flags->use_dart_frontend = false; | 704 api_flags->use_dart_frontend = false; |
705 api_flags->entry_points = NULL; | |
700 } | 706 } |
701 | 707 |
702 void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const { | 708 void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const { |
703 api_flags->version = DART_FLAGS_CURRENT_VERSION; | 709 api_flags->version = DART_FLAGS_CURRENT_VERSION; |
704 #define INIT_FROM_FIELD(name, bitname, isolate_flag, flag) \ | 710 #define INIT_FROM_FIELD(name, bitname, isolate_flag, flag) \ |
705 api_flags->isolate_flag = name(); | 711 api_flags->isolate_flag = name(); |
706 ISOLATE_FLAG_LIST(INIT_FROM_FIELD) | 712 ISOLATE_FLAG_LIST(INIT_FROM_FIELD) |
707 #undef INIT_FROM_FIELD | 713 #undef INIT_FROM_FIELD |
708 api_flags->use_dart_frontend = use_dart_frontend(); | 714 api_flags->use_dart_frontend = use_dart_frontend(); |
715 api_flags->entry_points = NULL; | |
709 } | 716 } |
710 | 717 |
711 void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) { | 718 void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) { |
712 #if !defined(PRODUCT) | 719 #if !defined(PRODUCT) |
713 #define SET_FROM_FLAG(name, bitname, isolate_flag, flag) \ | 720 #define SET_FROM_FLAG(name, bitname, isolate_flag, flag) \ |
714 isolate_flags_ = bitname##Bit::update(api_flags.isolate_flag, isolate_flags_); | 721 isolate_flags_ = bitname##Bit::update(api_flags.isolate_flag, isolate_flags_); |
715 ISOLATE_FLAG_LIST(SET_FROM_FLAG) | 722 ISOLATE_FLAG_LIST(SET_FROM_FLAG) |
716 #undef SET_FROM_FLAG | 723 #undef SET_FROM_FLAG |
717 #endif // !defined(PRODUCT) | 724 #endif // !defined(PRODUCT) |
718 set_use_dart_frontend(api_flags.use_dart_frontend); | 725 set_use_dart_frontend(api_flags.use_dart_frontend); |
726 | |
727 // Copy entry points list. | |
728 ASSERT(embedder_entry_points_ == NULL); | |
729 if (api_flags.entry_points != NULL) { | |
730 intptr_t count = 0; | |
731 while (api_flags.entry_points[count].function_name != NULL) | |
732 count++; | |
733 embedder_entry_points_ = new Dart_QualifiedFunctionName[count + 1]; | |
734 for (intptr_t i = 0; i < count; i++) { | |
735 embedder_entry_points_[i].library_uri = | |
736 strdup(api_flags.entry_points[i].library_uri); | |
737 embedder_entry_points_[i].class_name = | |
738 strdup(api_flags.entry_points[i].class_name); | |
739 embedder_entry_points_[i].function_name = | |
740 strdup(api_flags.entry_points[i].function_name); | |
741 } | |
742 memset(&embedder_entry_points_[count], sizeof(Dart_QualifiedFunctionName), | |
743 0); | |
744 } | |
745 | |
719 // Leave others at defaults. | 746 // Leave others at defaults. |
720 } | 747 } |
rmacnak
2017/08/23 01:16:50
if (obfuscate) {
OS::Print("Warning: This VM has
Vyacheslav Egorov (Google)
2017/08/23 15:54:52
Done.
| |
721 | 748 |
722 #if defined(DEBUG) | 749 #if defined(DEBUG) |
723 // static | 750 // static |
724 void BaseIsolate::AssertCurrent(BaseIsolate* isolate) { | 751 void BaseIsolate::AssertCurrent(BaseIsolate* isolate) { |
725 ASSERT(isolate == Isolate::Current()); | 752 ASSERT(isolate == Isolate::Current()); |
726 } | 753 } |
727 | 754 |
728 void BaseIsolate::AssertCurrentThreadIsMutator() const { | 755 void BaseIsolate::AssertCurrentThreadIsMutator() const { |
729 ASSERT(Isolate::Current() == this); | 756 ASSERT(Isolate::Current() == this); |
730 ASSERT(Thread::Current()->IsMutatorThread()); | 757 ASSERT(Thread::Current()->IsMutatorThread()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
808 deoptimized_code_array_(GrowableObjectArray::null()), | 835 deoptimized_code_array_(GrowableObjectArray::null()), |
809 sticky_error_(Error::null()), | 836 sticky_error_(Error::null()), |
810 next_(NULL), | 837 next_(NULL), |
811 loading_invalidation_gen_(kInvalidGen), | 838 loading_invalidation_gen_(kInvalidGen), |
812 top_level_parsing_count_(0), | 839 top_level_parsing_count_(0), |
813 field_list_mutex_(new Mutex()), | 840 field_list_mutex_(new Mutex()), |
814 boxed_field_list_(GrowableObjectArray::null()), | 841 boxed_field_list_(GrowableObjectArray::null()), |
815 spawn_count_monitor_(new Monitor()), | 842 spawn_count_monitor_(new Monitor()), |
816 spawn_count_(0), | 843 spawn_count_(0), |
817 handler_info_cache_(), | 844 handler_info_cache_(), |
818 catch_entry_state_cache_() { | 845 catch_entry_state_cache_(), |
846 embedder_entry_points_(NULL) { | |
819 FlagsCopyFrom(api_flags); | 847 FlagsCopyFrom(api_flags); |
820 SetErrorsFatal(true); | 848 SetErrorsFatal(true); |
821 set_compilation_allowed(true); | 849 set_compilation_allowed(true); |
822 // TODO(asiva): A Thread is not available here, need to figure out | 850 // TODO(asiva): A Thread is not available here, need to figure out |
823 // how the vm_tag (kEmbedderTagId) can be set, these tags need to | 851 // how the vm_tag (kEmbedderTagId) can be set, these tags need to |
824 // move to the OSThread structure. | 852 // move to the OSThread structure. |
825 set_user_tag(UserTags::kDefaultUserTag); | 853 set_user_tag(UserTags::kDefaultUserTag); |
826 } | 854 } |
827 | 855 |
828 #undef REUSABLE_HANDLE_SCOPE_INIT | 856 #undef REUSABLE_HANDLE_SCOPE_INIT |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 delete message_handler_; | 891 delete message_handler_; |
864 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. | 892 message_handler_ = NULL; // Fail fast if we send messages to a dead isolate. |
865 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. | 893 ASSERT(deopt_context_ == NULL); // No deopt in progress when isolate deleted. |
866 delete spawn_state_; | 894 delete spawn_state_; |
867 delete field_list_mutex_; | 895 delete field_list_mutex_; |
868 field_list_mutex_ = NULL; | 896 field_list_mutex_ = NULL; |
869 ASSERT(spawn_count_ == 0); | 897 ASSERT(spawn_count_ == 0); |
870 delete spawn_count_monitor_; | 898 delete spawn_count_monitor_; |
871 delete safepoint_handler_; | 899 delete safepoint_handler_; |
872 delete thread_registry_; | 900 delete thread_registry_; |
901 | |
902 if (embedder_entry_points_ != NULL) { | |
903 for (intptr_t i = 0; embedder_entry_points_[i].function_name != NULL; i++) { | |
904 free(const_cast<char*>(embedder_entry_points_[i].library_uri)); | |
905 free(const_cast<char*>(embedder_entry_points_[i].class_name)); | |
906 free(const_cast<char*>(embedder_entry_points_[i].function_name)); | |
907 } | |
908 } | |
909 delete[] embedder_entry_points_; | |
873 } | 910 } |
874 | 911 |
875 void Isolate::InitOnce() { | 912 void Isolate::InitOnce() { |
876 create_callback_ = NULL; | 913 create_callback_ = NULL; |
877 isolates_list_monitor_ = new Monitor(); | 914 isolates_list_monitor_ = new Monitor(); |
878 ASSERT(isolates_list_monitor_ != NULL); | 915 ASSERT(isolates_list_monitor_ != NULL); |
879 EnableIsolateCreation(); | 916 EnableIsolateCreation(); |
880 } | 917 } |
881 | 918 |
882 Isolate* Isolate::Init(const char* name_prefix, | 919 Isolate* Isolate::Init(const char* name_prefix, |
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2832 void IsolateSpawnState::DecrementSpawnCount() { | 2869 void IsolateSpawnState::DecrementSpawnCount() { |
2833 ASSERT(spawn_count_monitor_ != NULL); | 2870 ASSERT(spawn_count_monitor_ != NULL); |
2834 ASSERT(spawn_count_ != NULL); | 2871 ASSERT(spawn_count_ != NULL); |
2835 MonitorLocker ml(spawn_count_monitor_); | 2872 MonitorLocker ml(spawn_count_monitor_); |
2836 ASSERT(*spawn_count_ > 0); | 2873 ASSERT(*spawn_count_ > 0); |
2837 *spawn_count_ = *spawn_count_ - 1; | 2874 *spawn_count_ = *spawn_count_ - 1; |
2838 ml.Notify(); | 2875 ml.Notify(); |
2839 } | 2876 } |
2840 | 2877 |
2841 } // namespace dart | 2878 } // namespace dart |
OLD | NEW |