Index: runtime/vm/kernel_reader.cc |
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc |
index 0879f95ed2e713ab619368227eda0b8b03e121cf..2d51f997034edd290dd49cb0b68a640599a7b1ad 100644 |
--- a/runtime/vm/kernel_reader.cc |
+++ b/runtime/vm/kernel_reader.cc |
@@ -95,13 +95,12 @@ RawArray* KernelReader::MakeFunctionsArray() { |
RawLibrary* BuildingTranslationHelper::LookupLibraryByKernelLibrary( |
- CanonicalName* library) { |
+ intptr_t library) { |
return reader_->LookupLibrary(library).raw(); |
} |
-RawClass* BuildingTranslationHelper::LookupClassByKernelClass( |
- CanonicalName* klass) { |
+RawClass* BuildingTranslationHelper::LookupClassByKernelClass(intptr_t klass) { |
Vyacheslav Egorov (Google)
2017/05/03 06:28:48
I think we *do* need need named type for these ind
|
return reader_->LookupClass(klass).raw(); |
} |
@@ -144,8 +143,20 @@ KernelReader::KernelReader(Program* program) |
NoSafepointScope no_safepoint; |
memmove(data.DataAddr(0), reader.buffer() + reader.offset(), end_offset); |
} |
+ |
+ // Copy the canonical names into the VM's heap. Encode them as unsigned, so |
+ // the parent indexes are adjusted when extracted. |
+ reader.set_offset(program->name_table_offset()); |
+ count = reader.ReadUInt() * 2; |
+ TypedData& names = TypedData::Handle( |
+ Z, TypedData::New(kTypedDataUint32ArrayCid, count, Heap::kOld)); |
+ for (intptr_t i = 0; i < count; ++i) { |
+ names.SetUint32(i << 2, reader.ReadUInt()); |
+ } |
+ |
H.SetStringOffsets(offsets); |
H.SetStringData(data); |
+ H.SetCanonicalNames(names); |
} |
@@ -171,8 +182,8 @@ Object& KernelReader::ReadProgram() { |
// If there is no main method then we have compiled a partial Kernel file |
// and do not need to patch here. |
- CanonicalName* main = program_->main_method(); |
- if (main == NULL) { |
+ intptr_t main = program_->main_method(); |
+ if (main == -1) { |
return dart::Library::Handle(Z); |
} |
@@ -184,7 +195,7 @@ Object& KernelReader::ReadProgram() { |
return dart::Library::Handle(Z); |
} |
- CanonicalName* main_library = H.EnclosingName(main); |
+ intptr_t main_library = H.EnclosingName(main); |
dart::Library& library = LookupLibrary(main_library); |
// Sanity check that we can find the main entrypoint. |
Object& main_obj = Object::Handle( |
@@ -494,13 +505,14 @@ void KernelReader::ReadProcedure(const dart::Library& library, |
if (!annotation->IsConstructorInvocation()) continue; |
ConstructorInvocation* invocation = |
ConstructorInvocation::Cast(annotation); |
- CanonicalName* annotation_class = H.EnclosingName(invocation->target()); |
+ intptr_t annotation_class = H.EnclosingName(invocation->target()); |
ASSERT(H.IsClass(annotation_class)); |
- intptr_t class_name_index = annotation_class->name(); |
+ intptr_t class_name_index = H.CanonicalNameString(annotation_class); |
// Just compare by name, do not generate the annotation class. |
if (!H.StringEquals(class_name_index, "ExternalName")) continue; |
- ASSERT(H.IsLibrary(annotation_class->parent())); |
- intptr_t library_name_index = annotation_class->parent()->name(); |
+ ASSERT(H.IsLibrary(H.CanonicalNameParent(annotation_class))); |
+ intptr_t library_name_index = |
+ H.CanonicalNameString(H.CanonicalNameParent(annotation_class)); |
if (!H.StringEquals(library_name_index, "dart:_internal")) continue; |
is_external = false; |
@@ -634,6 +646,7 @@ Script& KernelReader::ScriptAt(intptr_t index, intptr_t import_uri) { |
RawScript::kKernelTag); |
script.set_kernel_string_offsets(H.string_offsets()); |
script.set_kernel_string_data(H.string_data()); |
+ script.set_kernel_canonical_names(H.canonical_names()); |
scripts_.SetAt(index, script); |
// Create line_starts array for the script. |
@@ -847,10 +860,10 @@ void KernelReader::SetupFieldAccessorFunction(const dart::Class& klass, |
} |
-dart::Library& KernelReader::LookupLibrary(CanonicalName* library) { |
+dart::Library& KernelReader::LookupLibrary(intptr_t library) { |
dart::Library* handle = NULL; |
if (!libraries_.Lookup(library, &handle)) { |
- const dart::String& url = H.DartSymbol(library->name()); |
+ const dart::String& url = H.DartSymbol(H.CanonicalNameString(library)); |
handle = |
&dart::Library::Handle(Z, dart::Library::LookupLibrary(thread_, url)); |
if (handle->IsNull()) { |
@@ -864,10 +877,10 @@ dart::Library& KernelReader::LookupLibrary(CanonicalName* library) { |
} |
-dart::Class& KernelReader::LookupClass(CanonicalName* klass) { |
+dart::Class& KernelReader::LookupClass(intptr_t klass) { |
dart::Class* handle = NULL; |
if (!classes_.Lookup(klass, &handle)) { |
- dart::Library& library = LookupLibrary(klass->parent()); |
+ dart::Library& library = LookupLibrary(H.CanonicalNameParent(klass)); |
const dart::String& name = H.DartClassName(klass); |
handle = &dart::Class::Handle(Z, library.LookupClass(name)); |
if (handle->IsNull()) { |