[VM] Fix for crash when changing root script uri during reload.

Change-Id: I3eec560c94022e536f6cc3623cf47cb791a9a159
Reviewed-on: https://dart-review.googlesource.com/46401
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Ben Konyi 2018-03-14 23:25:32 +00:00 committed by commit-bot@chromium.org
parent 217e3e56fa
commit 0ff7eb02cf
2 changed files with 14 additions and 1 deletions

View file

@ -662,7 +662,7 @@ void KernelLoader::walk_incremental_kernel(BitVector* modified_libs) {
builder_.SetOffset(kernel_offset);
LibraryHelper library_helper(&builder_);
library_helper.ReadUntilIncluding(LibraryHelper::kCanonicalName);
dart::Library& lib = LookupLibrary(library_helper.canonical_name_);
dart::Library& lib = LookupLibraryOrNull(library_helper.canonical_name_);
if (!lib.IsNull() && !lib.is_dart_scheme()) {
// This is a library that already exists so mark it as being modified.
modified_libs->Add(lib.index());
@ -1604,6 +1604,18 @@ void KernelLoader::SetupFieldAccessorFunction(const Class& klass,
}
}
Library& KernelLoader::LookupLibraryOrNull(NameIndex library) {
Library* handle = NULL;
if (!libraries_.Lookup(library, &handle)) {
const String& url = H.DartString(H.CanonicalNameString(library));
handle = &Library::Handle(Z, Library::LookupLibrary(thread_, url));
if (!handle->IsNull()) {
libraries_.Insert(library, handle);
}
}
return *handle;
}
Library& KernelLoader::LookupLibrary(NameIndex library) {
Library* handle = NULL;
if (!libraries_.Lookup(library, &handle)) {

View file

@ -234,6 +234,7 @@ class KernelLoader {
void LoadLibraryImportsAndExports(Library* library);
Library& LookupLibraryOrNull(NameIndex library);
Library& LookupLibrary(NameIndex library);
Class& LookupClass(NameIndex klass);