Chromium Code Reviews| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 num_saved_libs_(-1), | 183 num_saved_libs_(-1), |
| 184 script_uri_(String::null()), | 184 script_uri_(String::null()), |
| 185 error_(Error::null()), | 185 error_(Error::null()), |
| 186 old_classes_set_storage_(Array::null()), | 186 old_classes_set_storage_(Array::null()), |
| 187 class_map_storage_(Array::null()), | 187 class_map_storage_(Array::null()), |
| 188 old_libraries_set_storage_(Array::null()), | 188 old_libraries_set_storage_(Array::null()), |
| 189 library_map_storage_(Array::null()), | 189 library_map_storage_(Array::null()), |
| 190 become_map_storage_(Array::null()), | 190 become_map_storage_(Array::null()), |
| 191 saved_root_library_(Library::null()), | 191 saved_root_library_(Library::null()), |
| 192 saved_libraries_(GrowableObjectArray::null()) { | 192 saved_libraries_(GrowableObjectArray::null()) { |
| 193 // Preallocate storage for maps. | 193 // NOTE: DO NOT ALLOCATE ANY RAW OBJECTS HERE. The IsolateReloadContext is not |
| 194 old_classes_set_storage_ = | 194 // associated with the isolate yet and if a GC is triggered here the raw |
| 195 HashTables::New<UnorderedHashSet<ClassMapTraits> >(4); | 195 // objects will not be properly accounted for. |
| 196 class_map_storage_ = | |
| 197 HashTables::New<UnorderedHashMap<ClassMapTraits> >(4); | |
| 198 old_libraries_set_storage_ = | |
| 199 HashTables::New<UnorderedHashSet<LibraryMapTraits> >(4); | |
| 200 library_map_storage_ = | |
| 201 HashTables::New<UnorderedHashMap<LibraryMapTraits> >(4); | |
| 202 become_map_storage_ = | |
| 203 HashTables::New<UnorderedHashMap<BecomeMapTraits> >(4); | |
| 204 } | 196 } |
| 205 | 197 |
| 206 | 198 |
| 207 IsolateReloadContext::~IsolateReloadContext() { | 199 IsolateReloadContext::~IsolateReloadContext() { |
| 208 } | 200 } |
| 209 | 201 |
| 210 | 202 |
| 211 void IsolateReloadContext::ReportError(const Error& error) { | 203 void IsolateReloadContext::ReportError(const Error& error) { |
| 212 has_error_ = true; | 204 has_error_ = true; |
| 213 error_ = error.raw(); | 205 error_ = error.raw(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 232 | 224 |
| 233 | 225 |
| 234 void IsolateReloadContext::StartReload() { | 226 void IsolateReloadContext::StartReload() { |
| 235 TIMELINE_SCOPE(Reload); | 227 TIMELINE_SCOPE(Reload); |
| 236 Thread* thread = Thread::Current(); | 228 Thread* thread = Thread::Current(); |
| 237 | 229 |
| 238 // Grab root library before calling CheckpointBeforeReload. | 230 // Grab root library before calling CheckpointBeforeReload. |
| 239 const Library& root_lib = Library::Handle(object_store()->root_library()); | 231 const Library& root_lib = Library::Handle(object_store()->root_library()); |
| 240 ASSERT(!root_lib.IsNull()); | 232 ASSERT(!root_lib.IsNull()); |
| 241 const String& root_lib_url = String::Handle(root_lib.url()); | 233 const String& root_lib_url = String::Handle(root_lib.url()); |
| 242 | 234 |
|
siva
2016/07/12 16:23:15
Maybe add
ASSERT(isolate() == thread->isolate());
siva
2016/07/12 16:23:15
Maybe add ASSERT(isolate() == thread->isolate());
Cutch
2016/07/12 17:45:30
Done.
| |
| 235 // Preallocate storage for maps. | |
| 236 old_classes_set_storage_ = | |
| 237 HashTables::New<UnorderedHashSet<ClassMapTraits> >(4); | |
| 238 class_map_storage_ = | |
| 239 HashTables::New<UnorderedHashMap<ClassMapTraits> >(4); | |
| 240 old_libraries_set_storage_ = | |
| 241 HashTables::New<UnorderedHashSet<LibraryMapTraits> >(4); | |
| 242 library_map_storage_ = | |
| 243 HashTables::New<UnorderedHashMap<LibraryMapTraits> >(4); | |
| 244 become_map_storage_ = | |
| 245 HashTables::New<UnorderedHashMap<BecomeMapTraits> >(4); | |
| 246 | |
| 243 // Disable the background compiler while we are performing the reload. | 247 // Disable the background compiler while we are performing the reload. |
| 244 BackgroundCompiler::Disable(); | 248 BackgroundCompiler::Disable(); |
| 245 | 249 |
| 246 if (FLAG_write_protect_code) { | 250 if (FLAG_write_protect_code) { |
| 247 // Disable code page write protection while we are reloading. | 251 // Disable code page write protection while we are reloading. |
| 248 I->heap()->WriteProtectCode(false); | 252 I->heap()->WriteProtectCode(false); |
| 249 } | 253 } |
| 250 | 254 |
| 251 // Ensure all functions on the stack have unoptimized code. | 255 // Ensure all functions on the stack have unoptimized code. |
| 252 EnsuredUnoptimizedCodeForStack(); | 256 EnsuredUnoptimizedCodeForStack(); |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1070 ASSERT(!super_cls.IsNull()); | 1074 ASSERT(!super_cls.IsNull()); |
| 1071 super_cls.AddDirectSubclass(cls); | 1075 super_cls.AddDirectSubclass(cls); |
| 1072 } | 1076 } |
| 1073 } | 1077 } |
| 1074 } | 1078 } |
| 1075 } | 1079 } |
| 1076 | 1080 |
| 1077 #endif // !PRODUCT | 1081 #endif // !PRODUCT |
| 1078 | 1082 |
| 1079 } // namespace dart | 1083 } // namespace dart |
| OLD | NEW |