OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_reload.h" | 5 #include "vm/isolate_reload.h" |
6 | 6 |
7 #include "vm/become.h" | 7 #include "vm/become.h" |
8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 reinterpret_cast<RawObject**>(&saved_class_table_[0]), saved_num_cids_); | 874 reinterpret_cast<RawObject**>(&saved_class_table_[0]), saved_num_cids_); |
875 } | 875 } |
876 } | 876 } |
877 | 877 |
878 | 878 |
879 ObjectStore* IsolateReloadContext::object_store() { | 879 ObjectStore* IsolateReloadContext::object_store() { |
880 return isolate_->object_store(); | 880 return isolate_->object_store(); |
881 } | 881 } |
882 | 882 |
883 | 883 |
884 static void ResetICs(const Function& function, const Code& code) { | |
885 // TODO(johnmccutchan): Relying on the function's ICData Map can miss ICDatas. | |
886 // Use the code's object pool instead. | |
887 if (function.ic_data_array() == Array::null()) { | |
888 // TODO(johnmccutchan): Even in this case, we need to scan the code's object | |
889 // pool instead. | |
890 return; // Already reset in an earlier round. | |
891 } | |
892 | |
893 Thread* thread = Thread::Current(); | |
894 Zone* zone = thread->zone(); | |
895 | |
896 ZoneGrowableArray<const ICData*>* ic_data_array = | |
897 new(zone) ZoneGrowableArray<const ICData*>(); | |
898 function.RestoreICDataMap(ic_data_array, false /* clone ic-data */); | |
899 const intptr_t ic_data_array_length = ic_data_array->length(); | |
900 if (ic_data_array_length == 0) { | |
901 return; | |
902 } | |
903 const PcDescriptors& descriptors = | |
904 PcDescriptors::Handle(code.pc_descriptors()); | |
905 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kIcCall | | |
906 RawPcDescriptors::kUnoptStaticCall); | |
907 while (iter.MoveNext()) { | |
908 const intptr_t index = iter.DeoptId(); | |
909 if (index >= ic_data_array_length) { | |
910 // TODO(johnmccutchan): Investigate how this can happen. | |
911 continue; | |
912 } | |
913 const ICData* ic_data = (*ic_data_array)[index]; | |
914 if (ic_data == NULL) { | |
915 // TODO(johnmccutchan): Investigate how this can happen. | |
916 continue; | |
917 } | |
918 bool is_static_call = iter.Kind() == RawPcDescriptors::kUnoptStaticCall; | |
919 ic_data->Reset(is_static_call); | |
920 } | |
921 } | |
922 | |
923 | |
924 void IsolateReloadContext::ResetUnoptimizedICsOnStack() { | 884 void IsolateReloadContext::ResetUnoptimizedICsOnStack() { |
925 Code& code = Code::Handle(); | 885 Code& code = Code::Handle(); |
926 Function& function = Function::Handle(); | 886 Function& function = Function::Handle(); |
927 DartFrameIterator iterator; | 887 DartFrameIterator iterator; |
928 StackFrame* frame = iterator.NextFrame(); | 888 StackFrame* frame = iterator.NextFrame(); |
929 while (frame != NULL) { | 889 while (frame != NULL) { |
930 code = frame->LookupDartCode(); | 890 code = frame->LookupDartCode(); |
931 if (code.is_optimized()) { | 891 if (code.is_optimized()) { |
932 // If this code is optimized, we need to reset the ICs in the | 892 // If this code is optimized, we need to reset the ICs in the |
933 // corresponding unoptimized code, which will be executed when the stack | 893 // corresponding unoptimized code, which will be executed when the stack |
934 // unwinds to the the optimized code. | 894 // unwinds to the the optimized code. |
935 function = code.function(); | 895 function = code.function(); |
936 code = function.unoptimized_code(); | 896 code = function.unoptimized_code(); |
937 ASSERT(!code.IsNull()); | 897 ASSERT(!code.IsNull()); |
938 ResetICs(function, code); | 898 code.ResetICDatas(function); |
939 } else { | 899 } else { |
940 function = code.function(); | 900 function = code.function(); |
941 ResetICs(function, code); | 901 code.ResetICDatas(function); |
942 } | 902 } |
943 frame = iterator.NextFrame(); | 903 frame = iterator.NextFrame(); |
944 } | 904 } |
945 } | 905 } |
946 | 906 |
947 | 907 |
948 void IsolateReloadContext::ResetMegamorphicCaches() { | 908 void IsolateReloadContext::ResetMegamorphicCaches() { |
949 object_store()->set_megamorphic_cache_table(GrowableObjectArray::Handle()); | 909 object_store()->set_megamorphic_cache_table(GrowableObjectArray::Handle()); |
950 // Since any current optimized code will not make any more calls, it may be | 910 // Since any current optimized code will not make any more calls, it may be |
951 // better to clear the table instead of clearing each of the caches, allow | 911 // better to clear the table instead of clearing each of the caches, allow |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 // Null out the ICData array and code. | 968 // Null out the ICData array and code. |
1009 func.ClearICDataArray(); | 969 func.ClearICDataArray(); |
1010 func.ClearCode(); | 970 func.ClearCode(); |
1011 func.set_was_compiled(false); | 971 func.set_was_compiled(false); |
1012 } | 972 } |
1013 | 973 |
1014 void PreserveUnoptimizedCode(const Function& func) { | 974 void PreserveUnoptimizedCode(const Function& func) { |
1015 ASSERT(!code_.IsNull()); | 975 ASSERT(!code_.IsNull()); |
1016 // We are preserving the unoptimized code, fill all ICData arrays with | 976 // We are preserving the unoptimized code, fill all ICData arrays with |
1017 // the sentinel values so that we have no stale type feedback. | 977 // the sentinel values so that we have no stale type feedback. |
1018 func.FillICDataWithSentinels(code_); | 978 code_.ResetICDatas(func); |
1019 } | 979 } |
1020 | 980 |
1021 bool IsFromDirtyLibrary(const Function& func) { | 981 bool IsFromDirtyLibrary(const Function& func) { |
1022 owning_class_ = func.Owner(); | 982 owning_class_ = func.Owner(); |
1023 owning_lib_ = owning_class_.library(); | 983 owning_lib_ = owning_class_.library(); |
1024 return reload_context_->IsDirty(owning_lib_); | 984 return reload_context_->IsDirty(owning_lib_); |
1025 } | 985 } |
1026 | 986 |
1027 Object& handle_; | 987 Object& handle_; |
1028 Class& owning_class_; | 988 Class& owning_class_; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 ASSERT(!super_cls.IsNull()); | 1142 ASSERT(!super_cls.IsNull()); |
1183 super_cls.AddDirectSubclass(cls); | 1143 super_cls.AddDirectSubclass(cls); |
1184 } | 1144 } |
1185 } | 1145 } |
1186 } | 1146 } |
1187 } | 1147 } |
1188 | 1148 |
1189 #endif // !PRODUCT | 1149 #endif // !PRODUCT |
1190 | 1150 |
1191 } // namespace dart | 1151 } // namespace dart |
OLD | NEW |