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

Side by Side Diff: runtime/vm/isolate_reload.cc

Issue 2062983002: Revert "Remember inside an ICData if it is for a static call or an instance call" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
884 void IsolateReloadContext::ResetUnoptimizedICsOnStack() { 924 void IsolateReloadContext::ResetUnoptimizedICsOnStack() {
885 Code& code = Code::Handle(); 925 Code& code = Code::Handle();
886 Function& function = Function::Handle(); 926 Function& function = Function::Handle();
887 DartFrameIterator iterator; 927 DartFrameIterator iterator;
888 StackFrame* frame = iterator.NextFrame(); 928 StackFrame* frame = iterator.NextFrame();
889 while (frame != NULL) { 929 while (frame != NULL) {
890 code = frame->LookupDartCode(); 930 code = frame->LookupDartCode();
891 if (code.is_optimized()) { 931 if (code.is_optimized()) {
892 // If this code is optimized, we need to reset the ICs in the 932 // If this code is optimized, we need to reset the ICs in the
893 // corresponding unoptimized code, which will be executed when the stack 933 // corresponding unoptimized code, which will be executed when the stack
894 // unwinds to the the optimized code. 934 // unwinds to the the optimized code.
895 function = code.function(); 935 function = code.function();
896 code = function.unoptimized_code(); 936 code = function.unoptimized_code();
897 ASSERT(!code.IsNull()); 937 ASSERT(!code.IsNull());
898 code.ResetICDatas(function); 938 ResetICs(function, code);
899 } else { 939 } else {
900 function = code.function(); 940 function = code.function();
901 code.ResetICDatas(function); 941 ResetICs(function, code);
902 } 942 }
903 frame = iterator.NextFrame(); 943 frame = iterator.NextFrame();
904 } 944 }
905 } 945 }
906 946
907 947
908 void IsolateReloadContext::ResetMegamorphicCaches() { 948 void IsolateReloadContext::ResetMegamorphicCaches() {
909 object_store()->set_megamorphic_cache_table(GrowableObjectArray::Handle()); 949 object_store()->set_megamorphic_cache_table(GrowableObjectArray::Handle());
910 // Since any current optimized code will not make any more calls, it may be 950 // Since any current optimized code will not make any more calls, it may be
911 // better to clear the table instead of clearing each of the caches, allow 951 // 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
968 // Null out the ICData array and code. 1008 // Null out the ICData array and code.
969 func.ClearICDataArray(); 1009 func.ClearICDataArray();
970 func.ClearCode(); 1010 func.ClearCode();
971 func.set_was_compiled(false); 1011 func.set_was_compiled(false);
972 } 1012 }
973 1013
974 void PreserveUnoptimizedCode(const Function& func) { 1014 void PreserveUnoptimizedCode(const Function& func) {
975 ASSERT(!code_.IsNull()); 1015 ASSERT(!code_.IsNull());
976 // We are preserving the unoptimized code, fill all ICData arrays with 1016 // We are preserving the unoptimized code, fill all ICData arrays with
977 // the sentinel values so that we have no stale type feedback. 1017 // the sentinel values so that we have no stale type feedback.
978 code_.ResetICDatas(func); 1018 func.FillICDataWithSentinels(code_);
979 } 1019 }
980 1020
981 bool IsFromDirtyLibrary(const Function& func) { 1021 bool IsFromDirtyLibrary(const Function& func) {
982 owning_class_ = func.Owner(); 1022 owning_class_ = func.Owner();
983 owning_lib_ = owning_class_.library(); 1023 owning_lib_ = owning_class_.library();
984 return reload_context_->IsDirty(owning_lib_); 1024 return reload_context_->IsDirty(owning_lib_);
985 } 1025 }
986 1026
987 Object& handle_; 1027 Object& handle_;
988 Class& owning_class_; 1028 Class& owning_class_;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 ASSERT(!super_cls.IsNull()); 1197 ASSERT(!super_cls.IsNull());
1158 super_cls.AddDirectSubclass(cls); 1198 super_cls.AddDirectSubclass(cls);
1159 } 1199 }
1160 } 1200 }
1161 } 1201 }
1162 } 1202 }
1163 1203
1164 #endif // !PRODUCT 1204 #endif // !PRODUCT
1165 1205
1166 } // namespace dart 1206 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698