149 bool Reload(
bool force_reload,
150 const char* root_script_url =
nullptr,
151 const char* packages_url =
nullptr,
152 const uint8_t* kernel_buffer =
nullptr,
153 intptr_t kernel_buffer_size = 0);
161 ErrorPtr
error()
const;
166 return file_modified_callback_;
174 bool HasReasonsForCancelling()
const {
175 return !reasons_to_cancel_reload_.is_empty();
182 void ReportReasonsForCancelling();
185 void ReportOnJSON(JSONStream* stream, intptr_t final_library_count);
190 InstanceMorpher* instance_morpher);
193 bool HasInstanceMorphers()
const {
return !instance_morphers_.is_empty(); }
196 void CommonFinalizeTail(intptr_t final_library_count);
199 void ReportError(
const Error&
error);
200 void ReportSuccess();
202 void VisitObjectPointers(ObjectPointerVisitor* visitor);
204 void GetRootLibUrl(
const char* root_script_url);
205 char* CompileToKernel(
bool force_reload,
206 const char* packages_url,
207 const uint8_t** kernel_buffer,
208 intptr_t* kernel_buffer_size);
209 void BuildModifiedLibrariesClosure(BitVector* modified_libs);
210 void FindModifiedSources(
bool force_reload,
213 const char* packages_url);
214 bool ScriptModifiedSince(
const Script& script, int64_t since);
216 void MorphInstancesPhase1Allocate(
ObjectLocator* locator, Become* become);
217 void MorphInstancesPhase2Become(Become* become);
225 ClassTable* class_table_;
227 int64_t start_time_micros_ = -1;
228 int64_t reload_timestamp_ = -1;
229 bool reload_skipped_ =
false;
230 bool reload_finalized_ =
false;
232 intptr_t num_old_libs_ = -1;
234 intptr_t num_received_libs_ = -1;
235 intptr_t bytes_received_libs_ = -1;
236 intptr_t num_received_classes_ = -1;
237 intptr_t num_received_procedures_ = -1;
238 intptr_t num_saved_libs_ = -1;
241 struct MorpherTrait {
242 typedef InstanceMorpher*
Value;
243 typedef intptr_t
Key;
244 typedef InstanceMorpher*
Pair;
246 static Key KeyOf(
Pair kv) {
return kv->cid(); }
247 static Value ValueOf(
Pair kv) {
return kv; }
249 static bool IsKeyEqual(
Pair kv,
Key key) {
return kv->cid() ==
key; }
253 GrowableArray<InstanceMorpher*> instance_morphers_;
256 GrowableArray<ReasonForCancelling*> reasons_to_cancel_reload_;
259 DirectChainedHashMap<MorpherTrait> instance_morpher_by_cid_;
262 BitVector* modified_libs_ =
nullptr;
266 BitVector* modified_libs_transitive_ =
nullptr;
270 BitVector* saved_libs_transitive_updated_ =
nullptr;
272 String& root_lib_url_;
273 ObjectPtr* from() {
return reinterpret_cast<ObjectPtr*
>(&root_url_prefix_); }
274 StringPtr root_url_prefix_;
275 StringPtr old_root_url_prefix_;
277 return reinterpret_cast<ObjectPtr*
>(&old_root_url_prefix_);
302 return group_reload_context_.get();
309 bool IsDirty(
const Library& lib);
311 void RegisterClass(
const Class& new_cls);
315 StringPtr FindLibraryPrivateKey(
const Library& replacement_or_new);
319 IsolateGroup* isolate_group() {
return isolate_group_; }
320 ObjectStore* object_store();
322 void EnsuredUnoptimizedCodeForStack();
323 void DeoptimizeDependentCode();
325 void ReloadPhase1AllocateStorageMapsAndCheckpoint();
326 void CheckpointClasses();
327 ObjectPtr ReloadPhase2LoadKernel(kernel::Program* program,
328 const String& root_lib_url);
329 void ReloadPhase3FinalizeLoading();
330 void ReloadPhase4CommitPrepare();
331 void ReloadPhase4CommitFinish();
332 void ReloadPhase4Rollback();
334 void CheckpointLibraries();
336 void RollbackLibraries();
342 void CommitBeforeInstanceMorphing();
343 void CommitAfterInstanceMorphing();
346 void RunInvalidationVisitors();
347 void InvalidateKernelInfos(
349 const GrowableArray<const KernelProgramInfo*>& kernel_infos);
350 void InvalidateFunctions(Zone*
zone,
351 const GrowableArray<const Function*>& functions);
352 void InvalidateSuspendStates(
354 const GrowableArray<const SuspendState*>& suspend_states);
355 void InvalidateFields(Zone*
zone,
356 const GrowableArray<const Field*>& fields,
357 const GrowableArray<const Instance*>& instances);
358 void ResetUnoptimizedICsOnStack();
359 void ResetMegamorphicCaches();
360 void InvalidateWorld();
368 std::shared_ptr<IsolateGroupReloadContext> group_reload_context_;
370 MallocGrowableArray<LibraryInfo> library_infos_;
372 ClassPtr OldClassOrNull(
const Class& replacement_or_new);
373 LibraryPtr OldLibraryOrNull(
const Library& replacement_or_new);
374 LibraryPtr OldLibraryOrNullBaseMoved(
const Library& replacement_or_new);
376 void BuildLibraryMapping();
377 void BuildRemovedClassesSet();
378 void ValidateReload();
380 void AddClassMapping(
const Class& replacement_or_new,
const Class& original);
381 void AddLibraryMapping(
const Library& replacement_or_new,
383 void AddStaticFieldMapping(
const Field& old_field,
const Field& new_field);
384 void AddBecomeMapping(
const Object& old,
const Object& neu);
385 void RebuildDirectSubclasses();
390 return reinterpret_cast<ObjectPtr*
>(&old_classes_set_storage_);
392 ArrayPtr old_classes_set_storage_;
393 ArrayPtr class_map_storage_;
394 ArrayPtr removed_class_set_storage_;
395 ArrayPtr old_libraries_set_storage_;
396 ArrayPtr library_map_storage_;
397 LibraryPtr saved_root_library_;
398 GrowableObjectArrayPtr saved_libraries_;
399 ObjectPtr* to() {
return reinterpret_cast<ObjectPtr*
>(&saved_libraries_); }
friend class ObjectLocator
static Dart_FileModifiedCallback file_modified_callback()
static void SetFileModifiedCallback(Dart_FileModifiedCallback callback)
IsolateGroup * isolate_group() const
bool reload_skipped() const
int64_t reload_timestamp() const
bool reload_aborted() const
friend class ReasonForCancelling
int64_t start_time_micros() const
friend class IsolateGroup
~IsolateGroupReloadContext()
bool Reload(bool force_reload, const char *root_script_url=nullptr, const char *packages_url=nullptr, const uint8_t *kernel_buffer=nullptr, intptr_t kernel_buffer_size=0)
static bool IsSameLibrary(const Library &a_lib, const Library &b_lib)
static bool IsSameClass(const Class &a, const Class &b)
friend class IsolateGroup
IsolateGroupReloadContext * group_reload_context()