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

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

Issue 2209513003: More reload status and bug fixes (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | tests/lib/lib.status » ('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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // Grab root library before calling CheckpointBeforeReload. 434 // Grab root library before calling CheckpointBeforeReload.
435 const Library& root_lib = Library::Handle(object_store()->root_library()); 435 const Library& root_lib = Library::Handle(object_store()->root_library());
436 ASSERT(!root_lib.IsNull()); 436 ASSERT(!root_lib.IsNull());
437 const String& root_lib_url = String::Handle(root_lib.url()); 437 const String& root_lib_url = String::Handle(root_lib.url());
438 438
439 // Check to see which libraries have been modified. 439 // Check to see which libraries have been modified.
440 modified_libs_ = FindModifiedLibraries(force_reload); 440 modified_libs_ = FindModifiedLibraries(force_reload);
441 if (!modified_libs_->Contains(root_lib.index())) { 441 if (!modified_libs_->Contains(root_lib.index())) {
442 ASSERT(modified_libs_->IsEmpty()); 442 ASSERT(modified_libs_->IsEmpty());
443 reload_skipped_ = true; 443 reload_skipped_ = true;
444 TIR_Print("Skipping reload. No libraries were modified\n"); 444 TIR_Print("---- SKIPPING RELOAD (No libraries were modified)\n");
445 return; 445 return;
446 } 446 }
447 447
448 TIR_Print("---- STARTING RELOAD\n");
449
448 // Preallocate storage for maps. 450 // Preallocate storage for maps.
449 old_classes_set_storage_ = 451 old_classes_set_storage_ =
450 HashTables::New<UnorderedHashSet<ClassMapTraits> >(4); 452 HashTables::New<UnorderedHashSet<ClassMapTraits> >(4);
451 class_map_storage_ = 453 class_map_storage_ =
452 HashTables::New<UnorderedHashMap<ClassMapTraits> >(4); 454 HashTables::New<UnorderedHashMap<ClassMapTraits> >(4);
453 old_libraries_set_storage_ = 455 old_libraries_set_storage_ =
454 HashTables::New<UnorderedHashSet<LibraryMapTraits> >(4); 456 HashTables::New<UnorderedHashSet<LibraryMapTraits> >(4);
455 library_map_storage_ = 457 library_map_storage_ =
456 HashTables::New<UnorderedHashMap<LibraryMapTraits> >(4); 458 HashTables::New<UnorderedHashMap<LibraryMapTraits> >(4);
457 become_map_storage_ = 459 become_map_storage_ =
(...skipping 18 matching lines...) Expand all
476 { 478 {
477 TransitionVMToNative transition(thread); 479 TransitionVMToNative transition(thread);
478 Api::Scope api_scope(thread); 480 Api::Scope api_scope(thread);
479 481
480 Dart_Handle retval = 482 Dart_Handle retval =
481 (I->library_tag_handler())(Dart_kScriptTag, 483 (I->library_tag_handler())(Dart_kScriptTag,
482 Api::NewHandle(thread, Library::null()), 484 Api::NewHandle(thread, Library::null()),
483 Api::NewHandle(thread, root_lib_url.raw())); 485 Api::NewHandle(thread, root_lib_url.raw()));
484 result = Api::UnwrapHandle(retval); 486 result = Api::UnwrapHandle(retval);
485 } 487 }
488
489 BackgroundCompiler::Enable();
490
486 if (result.IsUnwindError()) { 491 if (result.IsUnwindError()) {
487 // Ignore an unwind error because the isolate is dead. 492 // Ignore an unwind error because the isolate is dead.
488 return; 493 return;
489 } 494 }
495
490 if (result.IsError()) { 496 if (result.IsError()) {
491 FinalizeFailedLoad(Error::Cast(result)); 497 FinalizeFailedLoad(Error::Cast(result));
492 } 498 }
493 } 499 }
494 500
495 501
496 void IsolateReloadContext::RegisterClass(const Class& new_cls) { 502 void IsolateReloadContext::RegisterClass(const Class& new_cls) {
497 const Class& old_cls = Class::Handle(OldClassOrNull(new_cls)); 503 const Class& old_cls = Class::Handle(OldClassOrNull(new_cls));
498 if (old_cls.IsNull()) { 504 if (old_cls.IsNull()) {
499 I->class_table()->Register(new_cls); 505 I->class_table()->Register(new_cls);
(...skipping 19 matching lines...) Expand all
519 } 525 }
520 526
521 527
522 // FinalizeLoading will be called *before* Reload() returns but will not be 528 // FinalizeLoading will be called *before* Reload() returns but will not be
523 // called if the embedder fails to load sources. 529 // called if the embedder fails to load sources.
524 void IsolateReloadContext::FinalizeLoading() { 530 void IsolateReloadContext::FinalizeLoading() {
525 if (reload_skipped_) { 531 if (reload_skipped_) {
526 return; 532 return;
527 } 533 }
528 BuildLibraryMapping(); 534 BuildLibraryMapping();
529 TIR_Print("---- DONE FINALIZING\n"); 535 TIR_Print("---- LOAD SUCCEEDED\n");
530 if (ValidateReload()) { 536 if (ValidateReload()) {
531 Commit(); 537 Commit();
532 PostCommit(); 538 PostCommit();
533 isolate()->set_last_reload_timestamp(reload_timestamp_); 539 isolate()->set_last_reload_timestamp(reload_timestamp_);
534 } else { 540 } else {
535 ReportReasonsForCancelling(); 541 ReportReasonsForCancelling();
536 Rollback(); 542 Rollback();
537 } 543 }
538 // ValidateReload mutates the direct subclass information and does 544 // ValidateReload mutates the direct subclass information and does
539 // not remove dead subclasses. Rebuild the direct subclass 545 // not remove dead subclasses. Rebuild the direct subclass
540 // information from scratch. 546 // information from scratch.
541 RebuildDirectSubclasses(); 547 RebuildDirectSubclasses();
542 548
543 CommonFinalizeTail(); 549 CommonFinalizeTail();
544 } 550 }
545 551
546 552
547 // FinalizeFailedLoad will be called *before* Reload() returns and will only 553 // FinalizeFailedLoad will be called *before* Reload() returns and will only
548 // be called if the embedder fails to load sources. 554 // be called if the embedder fails to load sources.
549 void IsolateReloadContext::FinalizeFailedLoad(const Error& error) { 555 void IsolateReloadContext::FinalizeFailedLoad(const Error& error) {
556 TIR_Print("---- LOAD FAILED, ABORTING RELOAD\n");
550 AddReasonForCancelling(new Aborted(zone_, error)); 557 AddReasonForCancelling(new Aborted(zone_, error));
551 ReportReasonsForCancelling(); 558 ReportReasonsForCancelling();
552 Rollback(); 559 Rollback();
553 CommonFinalizeTail(); 560 CommonFinalizeTail();
554 } 561 }
555 562
556 563
557 void IsolateReloadContext::CommonFinalizeTail() { 564 void IsolateReloadContext::CommonFinalizeTail() {
558 BackgroundCompiler::Enable();
559 ReportOnJSON(js_); 565 ReportOnJSON(js_);
560 } 566 }
561 567
568
562 void IsolateReloadContext::ReportOnJSON(JSONStream* stream) { 569 void IsolateReloadContext::ReportOnJSON(JSONStream* stream) {
563 JSONObject jsobj(stream); 570 JSONObject jsobj(stream);
564 jsobj.AddProperty("type", "ReloadReport"); 571 jsobj.AddProperty("type", "ReloadReport");
565 jsobj.AddProperty("success", !HasReasonsForCancelling()); 572 jsobj.AddProperty("success", !HasReasonsForCancelling());
566 { 573 {
567 JSONObject details(&jsobj, "details"); 574 JSONObject details(&jsobj, "details");
568 if (HasReasonsForCancelling()) { 575 if (HasReasonsForCancelling()) {
569 // Reload was rejected. 576 // Reload was rejected.
570 JSONArray array(&jsobj, "notices"); 577 JSONArray array(&jsobj, "notices");
571 for (intptr_t i = 0; i < reasons_to_cancel_reload_.length(); i++) { 578 for (intptr_t i = 0; i < reasons_to_cancel_reload_.length(); i++) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 813 }
807 } 814 }
808 } 815 }
809 816
810 return modified_libs; 817 return modified_libs;
811 } 818 }
812 819
813 820
814 void IsolateReloadContext::CheckpointLibraries() { 821 void IsolateReloadContext::CheckpointLibraries() {
815 TIMELINE_SCOPE(CheckpointLibraries); 822 TIMELINE_SCOPE(CheckpointLibraries);
816 823 TIR_Print("---- CHECKPOINTING LIBRARIES\n");
817 // Save the root library in case we abort the reload. 824 // Save the root library in case we abort the reload.
818 const Library& root_lib = 825 const Library& root_lib =
819 Library::Handle(object_store()->root_library()); 826 Library::Handle(object_store()->root_library());
820 set_saved_root_library(root_lib); 827 set_saved_root_library(root_lib);
821 828
822 // Save the old libraries array in case we abort the reload. 829 // Save the old libraries array in case we abort the reload.
823 const GrowableObjectArray& libs = 830 const GrowableObjectArray& libs =
824 GrowableObjectArray::Handle(object_store()->libraries()); 831 GrowableObjectArray::Handle(object_store()->libraries());
825 set_saved_libraries(libs); 832 set_saved_libraries(libs);
826 833
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 if (!saved_root_lib.IsNull()) { 913 if (!saved_root_lib.IsNull()) {
907 object_store()->set_root_library(saved_root_lib); 914 object_store()->set_root_library(saved_root_lib);
908 } 915 }
909 916
910 set_saved_root_library(Library::Handle()); 917 set_saved_root_library(Library::Handle());
911 set_saved_libraries(GrowableObjectArray::Handle()); 918 set_saved_libraries(GrowableObjectArray::Handle());
912 } 919 }
913 920
914 921
915 void IsolateReloadContext::Rollback() { 922 void IsolateReloadContext::Rollback() {
923 TIR_Print("---- ROLLING BACK");
916 RollbackClasses(); 924 RollbackClasses();
917 RollbackLibraries(); 925 RollbackLibraries();
918 } 926 }
919 927
920 928
921 #ifdef DEBUG 929 #ifdef DEBUG
922 void IsolateReloadContext::VerifyMaps() { 930 void IsolateReloadContext::VerifyMaps() {
923 TIMELINE_SCOPE(VerifyMaps); 931 TIMELINE_SCOPE(VerifyMaps);
924 Class& cls = Class::Handle(); 932 Class& cls = Class::Handle();
925 Class& new_cls = Class::Handle(); 933 Class& new_cls = Class::Handle();
(...skipping 23 matching lines...) Expand all
949 } 957 }
950 } 958 }
951 class_map.Release(); 959 class_map.Release();
952 reverse_class_map.Release(); 960 reverse_class_map.Release();
953 } 961 }
954 #endif 962 #endif
955 963
956 964
957 void IsolateReloadContext::Commit() { 965 void IsolateReloadContext::Commit() {
958 TIMELINE_SCOPE(Commit); 966 TIMELINE_SCOPE(Commit);
959 TIR_Print("---- COMMITTING REVERSE MAP\n"); 967 TIR_Print("---- COMMITTING RELOAD\n");
960 968
961 // Note that the object heap contains before and after instances 969 // Note that the object heap contains before and after instances
962 // used for morphing. It is therefore important that morphing takes 970 // used for morphing. It is therefore important that morphing takes
963 // place prior to any heap walking. 971 // place prior to any heap walking.
964 // So please keep this code at the top of Commit(). 972 // So please keep this code at the top of Commit().
965 if (HasInstanceMorphers()) { 973 if (HasInstanceMorphers()) {
966 // Perform shape shifting of instances if necessary. 974 // Perform shape shifting of instances if necessary.
967 MorphInstances(); 975 MorphInstances();
968 } 976 }
969 977
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 free(saved_class_table_); 1227 free(saved_class_table_);
1220 saved_class_table_ = NULL; 1228 saved_class_table_ = NULL;
1221 Become::ElementsForwardIdentity(before, after); 1229 Become::ElementsForwardIdentity(before, after);
1222 } 1230 }
1223 1231
1224 1232
1225 bool IsolateReloadContext::ValidateReload() { 1233 bool IsolateReloadContext::ValidateReload() {
1226 TIMELINE_SCOPE(ValidateReload); 1234 TIMELINE_SCOPE(ValidateReload);
1227 if (reload_aborted()) return false; 1235 if (reload_aborted()) return false;
1228 1236
1237 TIR_Print("---- VALIDATING RELOAD\n");
1238
1229 // Validate libraries. 1239 // Validate libraries.
1230 { 1240 {
1231 ASSERT(library_map_storage_ != Array::null()); 1241 ASSERT(library_map_storage_ != Array::null());
1232 UnorderedHashMap<LibraryMapTraits> map(library_map_storage_); 1242 UnorderedHashMap<LibraryMapTraits> map(library_map_storage_);
1233 UnorderedHashMap<LibraryMapTraits>::Iterator it(&map); 1243 UnorderedHashMap<LibraryMapTraits>::Iterator it(&map);
1234 Library& lib = Library::Handle(); 1244 Library& lib = Library::Handle();
1235 Library& new_lib = Library::Handle(); 1245 Library& new_lib = Library::Handle();
1236 while (it.MoveNext()) { 1246 while (it.MoveNext()) {
1237 const intptr_t entry = it.Current(); 1247 const intptr_t entry = it.Current();
1238 new_lib = Library::RawCast(map.GetKey(entry)); 1248 new_lib = Library::RawCast(map.GetKey(entry));
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 ASSERT(!super_cls.IsNull()); 1613 ASSERT(!super_cls.IsNull());
1604 super_cls.AddDirectSubclass(cls); 1614 super_cls.AddDirectSubclass(cls);
1605 } 1615 }
1606 } 1616 }
1607 } 1617 }
1608 } 1618 }
1609 1619
1610 #endif // !PRODUCT 1620 #endif // !PRODUCT
1611 1621
1612 } // namespace dart 1622 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698