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

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

Issue 2497673004: Rehash canonical constants table for each class that can be affected by the 'become' operation (Closed)
Patch Set: Created 4 years, 1 month 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/isolate_reload.h ('k') | runtime/vm/verifier.cc » ('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/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 const GrowableObjectArray& saved_libs = 1149 const GrowableObjectArray& saved_libs =
1150 GrowableObjectArray::Handle(saved_libraries()); 1150 GrowableObjectArray::Handle(saved_libraries());
1151 const GrowableObjectArray& libs = 1151 const GrowableObjectArray& libs =
1152 GrowableObjectArray::Handle(I->object_store()->libraries()); 1152 GrowableObjectArray::Handle(I->object_store()->libraries());
1153 if (saved_libs.Length() != libs.Length()) { 1153 if (saved_libs.Length() != libs.Length()) {
1154 TIR_Print("Identity reload failed! B#L=%" Pd " A#L=%" Pd "\n", 1154 TIR_Print("Identity reload failed! B#L=%" Pd " A#L=%" Pd "\n",
1155 saved_libs.Length(), libs.Length()); 1155 saved_libs.Length(), libs.Length());
1156 } 1156 }
1157 } 1157 }
1158 1158
1159 // Rehash constants map for all new classes and the closure class. 1159 // Rehash constants map for all classes.
1160 Class& cls = Class::Handle(zone_); 1160 RehashConstants();
1161 cls = I->class_table()->At(kClosureCid);
1162 cls.RehashConstants(zone_);
1163 {
1164 ASSERT(class_map_storage_ != Array::null());
1165 UnorderedHashMap<ClassMapTraits> map(class_map_storage_);
1166 UnorderedHashMap<ClassMapTraits>::Iterator it(&map);
1167 while (it.MoveNext()) {
1168 const intptr_t entry = it.Current();
1169 cls = Class::RawCast(map.GetKey(entry));
1170 cls.RehashConstants(zone_);
1171 }
1172 map.Release();
1173 }
1174 1161
1175 #ifdef DEBUG 1162 #ifdef DEBUG
1176 // Verify that all canonical instances are correctly setup in the 1163 // Verify that all canonical instances are correctly setup in the
1177 // corresponding canonical tables. 1164 // corresponding canonical tables.
1178 Thread* thread = Thread::Current(); 1165 Thread* thread = Thread::Current();
1179 I->heap()->CollectAllGarbage(); 1166 I->heap()->CollectAllGarbage();
1180 VerifyCanonicalVisitor check_canonical(thread); 1167 VerifyCanonicalVisitor check_canonical(thread);
1181 I->heap()->IterateObjects(&check_canonical); 1168 I->heap()->IterateObjects(&check_canonical);
1182 #endif // DEBUG 1169 #endif // DEBUG
1183 } 1170 }
1184 1171
1185 1172
1173 void IsolateReloadContext::RehashConstants() {
1174 ClassTable* class_table = I->class_table();
1175 Class& cls = Class::Handle(zone_);
1176 const intptr_t top = class_table->NumCids();
1177 for (intptr_t cid = kInstanceCid; cid < top; cid++) {
siva 2016/11/15 22:58:22 Should this be (kNumPredefinedCids + 1)
rmacnak 2016/11/15 23:13:33 No, we still need to rehash array, growable array,
1178 if (!class_table->IsValidIndex(cid) || !class_table->HasValidClassAt(cid)) {
siva 2016/11/15 22:58:22 IsValidIndex(cid) is implicit right with the check
1179 // Skip invalid classes.
1180 continue;
1181 }
1182 if (RawObject::IsNumberClassId(cid) || RawObject::IsStringClassId(cid)) {
1183 // Skip classes that cannot be affected by the 'become' operation.
1184 continue;
1185 }
siva 2016/11/15 22:58:22 By running from kNumPredefinedCids this check for
1186 // Rehash constants.
1187 cls = class_table->At(cid);
1188 VTIR_Print("Rehashing constants in class `%s`\n", cls.ToCString());
1189 cls.RehashConstants(zone_);
1190 }
1191 }
1192
1193
1186 bool IsolateReloadContext::IsDirty(const Library& lib) { 1194 bool IsolateReloadContext::IsDirty(const Library& lib) {
1187 const intptr_t index = lib.index(); 1195 const intptr_t index = lib.index();
1188 if (index == static_cast<classid_t>(-1)) { 1196 if (index == static_cast<classid_t>(-1)) {
1189 // Treat deleted libraries as dirty. 1197 // Treat deleted libraries as dirty.
1190 return true; 1198 return true;
1191 } 1199 }
1192 ASSERT((index >= 0) && (index < library_infos_.length())); 1200 ASSERT((index >= 0) && (index < library_infos_.length()));
1193 return library_infos_[index].dirty; 1201 return library_infos_[index].dirty;
1194 } 1202 }
1195 1203
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 ASSERT(!super_cls.IsNull()); 1703 ASSERT(!super_cls.IsNull());
1696 super_cls.AddDirectSubclass(cls); 1704 super_cls.AddDirectSubclass(cls);
1697 } 1705 }
1698 } 1706 }
1699 } 1707 }
1700 } 1708 }
1701 1709
1702 #endif // !PRODUCT 1710 #endif // !PRODUCT
1703 1711
1704 } // namespace dart 1712 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate_reload.h ('k') | runtime/vm/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698