| 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 13 matching lines...) Expand all Loading... |
| 227 | 219 |
| 228 void IsolateReloadContext::ReportSuccess() { | 220 void IsolateReloadContext::ReportSuccess() { |
| 229 ServiceEvent service_event(I, ServiceEvent::kIsolateReload); | 221 ServiceEvent service_event(I, ServiceEvent::kIsolateReload); |
| 230 Service::HandleEvent(&service_event); | 222 Service::HandleEvent(&service_event); |
| 231 } | 223 } |
| 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(); |
| 229 ASSERT(isolate() == thread->isolate()); |
| 237 | 230 |
| 238 // Grab root library before calling CheckpointBeforeReload. | 231 // Grab root library before calling CheckpointBeforeReload. |
| 239 const Library& root_lib = Library::Handle(object_store()->root_library()); | 232 const Library& root_lib = Library::Handle(object_store()->root_library()); |
| 240 ASSERT(!root_lib.IsNull()); | 233 ASSERT(!root_lib.IsNull()); |
| 241 const String& root_lib_url = String::Handle(root_lib.url()); | 234 const String& root_lib_url = String::Handle(root_lib.url()); |
| 242 | 235 |
| 236 // Preallocate storage for maps. |
| 237 old_classes_set_storage_ = |
| 238 HashTables::New<UnorderedHashSet<ClassMapTraits> >(4); |
| 239 class_map_storage_ = |
| 240 HashTables::New<UnorderedHashMap<ClassMapTraits> >(4); |
| 241 old_libraries_set_storage_ = |
| 242 HashTables::New<UnorderedHashSet<LibraryMapTraits> >(4); |
| 243 library_map_storage_ = |
| 244 HashTables::New<UnorderedHashMap<LibraryMapTraits> >(4); |
| 245 become_map_storage_ = |
| 246 HashTables::New<UnorderedHashMap<BecomeMapTraits> >(4); |
| 247 |
| 243 // Disable the background compiler while we are performing the reload. | 248 // Disable the background compiler while we are performing the reload. |
| 244 BackgroundCompiler::Disable(); | 249 BackgroundCompiler::Disable(); |
| 245 | 250 |
| 246 if (FLAG_write_protect_code) { | 251 if (FLAG_write_protect_code) { |
| 247 // Disable code page write protection while we are reloading. | 252 // Disable code page write protection while we are reloading. |
| 248 I->heap()->WriteProtectCode(false); | 253 I->heap()->WriteProtectCode(false); |
| 249 } | 254 } |
| 250 | 255 |
| 251 // Ensure all functions on the stack have unoptimized code. | 256 // Ensure all functions on the stack have unoptimized code. |
| 252 EnsuredUnoptimizedCodeForStack(); | 257 EnsuredUnoptimizedCodeForStack(); |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 ASSERT(!super_cls.IsNull()); | 1075 ASSERT(!super_cls.IsNull()); |
| 1071 super_cls.AddDirectSubclass(cls); | 1076 super_cls.AddDirectSubclass(cls); |
| 1072 } | 1077 } |
| 1073 } | 1078 } |
| 1074 } | 1079 } |
| 1075 } | 1080 } |
| 1076 | 1081 |
| 1077 #endif // !PRODUCT | 1082 #endif // !PRODUCT |
| 1078 | 1083 |
| 1079 } // namespace dart | 1084 } // namespace dart |
| OLD | NEW |