Index: runtime/vm/kernel_reader.cc |
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc |
index d9d767975ec4df9d6c4c2588315508368e96cf8e..28c5201abad051ee02210153eee5930fd5a59624 100644 |
--- a/runtime/vm/kernel_reader.cc |
+++ b/runtime/vm/kernel_reader.cc |
@@ -81,19 +81,18 @@ class SimpleExpressionConverter : public ExpressionVisitor { |
dart::Instance* simple_value_; |
}; |
-void BuildingTranslationHelper::SetFinalize(bool finalize) { |
- reader_->finalize_ = finalize; |
-} |
RawLibrary* BuildingTranslationHelper::LookupLibraryByKernelLibrary( |
Library* library) { |
return reader_->LookupLibrary(library).raw(); |
} |
+ |
RawClass* BuildingTranslationHelper::LookupClassByKernelClass(Class* klass) { |
return reader_->LookupClass(klass).raw(); |
} |
+ |
Object& KernelReader::ReadProgram() { |
ASSERT(!bootstrapping_); |
Program* program = ReadPrecompiledKernelFromBuffer(buffer_, buffer_length_); |
@@ -113,29 +112,13 @@ Object& KernelReader::ReadProgram() { |
ReadLibrary(kernel_library); |
} |
- // We finalize classes after we've constructed all classes since we |
- // currently don't construct them in pre-order of the class hierarchy (and |
- // finalization of a class needs all of its superclasses to be finalized). |
- dart::String& name = dart::String::Handle(Z); |
for (intptr_t i = 0; i < length; i++) { |
- Library* kernel_library = program->libraries()[i]; |
- dart::Library& library = LookupLibrary(kernel_library); |
- name = library.url(); |
- |
- // TODO(27590) unskip this library when we fix underlying issue. |
- if (name.Equals("dart:vmservice_io")) { |
- continue; |
- } |
+ dart::Library& library = LookupLibrary(program->libraries()[i]); |
+ if (!library.Loaded()) library.SetLoaded(); |
+ } |
- if (!library.Loaded()) { |
- dart::Class& klass = dart::Class::Handle(Z); |
- for (intptr_t i = 0; i < kernel_library->classes().length(); i++) { |
- klass = LookupClass(kernel_library->classes()[i]).raw(); |
- ClassFinalizer::FinalizeTypesInClass(klass); |
- ClassFinalizer::FinalizeClass(klass); |
- } |
- library.SetLoaded(); |
- } |
+ if (!ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) { |
+ FATAL("Error in class finalization during bootstrapping."); |
} |
dart::Library& library = LookupLibrary(kernel_main_library); |
@@ -161,6 +144,7 @@ Object& KernelReader::ReadProgram() { |
} |
} |
+ |
void KernelReader::ReadLibrary(Library* kernel_library) { |
dart::Library& library = LookupLibrary(kernel_library); |
if (library.Loaded()) return; |
@@ -216,13 +200,17 @@ void KernelReader::ReadLibrary(Library* kernel_library) { |
ReadProcedure(library, toplevel_class, kernel_procedure); |
} |
+ const GrowableObjectArray& classes = |
+ GrowableObjectArray::Handle(I->object_store()->pending_classes()); |
+ |
// Load all classes. |
for (intptr_t i = 0; i < kernel_library->classes().length(); i++) { |
Class* kernel_klass = kernel_library->classes()[i]; |
- ReadClass(library, kernel_klass); |
+ classes.Add(ReadClass(library, kernel_klass), Heap::kOld); |
} |
} |
+ |
void KernelReader::ReadPreliminaryClass(dart::Class* klass, |
Class* kernel_klass) { |
ASSERT(kernel_klass->IsNormalClass()); |
@@ -283,7 +271,6 @@ void KernelReader::ReadPreliminaryClass(dart::Class* klass, |
intptr_t interface_count = kernel_klass->implemented_classes().length(); |
const dart::Array& interfaces = |
dart::Array::Handle(Z, dart::Array::New(interface_count)); |
- dart::Class& interface_class = dart::Class::Handle(Z); |
for (intptr_t i = 0; i < interface_count; i++) { |
InterfaceType* kernel_interface_type = |
kernel_klass->implemented_classes()[i]; |
@@ -291,33 +278,14 @@ void KernelReader::ReadPreliminaryClass(dart::Class* klass, |
T.TranslateTypeWithoutFinalization(kernel_interface_type); |
if (type.IsMalformed()) H.ReportError("Malformed interface type."); |
interfaces.SetAt(i, type); |
- |
- // NOTE: Normally the DartVM keeps a list of pending classes and iterates |
- // through them later on using `ClassFinalizer::ProcessPendingClasses()`. |
- // This involes calling `ClassFinalizer::ResolveSuperTypeAndInterfaces()` |
- // which does a lot of error validation (e.g. cycle checks) which we don't |
- // need here. But we do need to do one thing which this resolving phase |
- // normally does for us: set the `is_implemented` boolean. |
- |
- // TODO(27590): Maybe we can do this differently once we have |
- // "bootstrapping from kernel"-support. |
- interface_class = type.type_class(); |
- interface_class.set_is_implemented(); |
} |
klass->set_interfaces(interfaces); |
if (kernel_klass->is_abstract()) klass->set_is_abstract(); |
- klass->set_is_cycle_free(); |
- |
- // When bootstrapping we should not finalize types yet because they will be |
- // finalized when the object store's pending_classes list is drained by |
- // ClassFinalizer::ProcessPendingClasses. Even when not bootstrapping we are |
- // careful not to eagerly finalize types that may introduce a circularity |
- // (such as type arguments, interface types, field types, etc.). |
- if (finalize_) ClassFinalizer::FinalizeTypesInClass(*klass); |
} |
-void KernelReader::ReadClass(const dart::Library& library, |
- Class* kernel_klass) { |
+ |
+dart::Class& KernelReader::ReadClass(const dart::Library& library, |
+ Class* kernel_klass) { |
// This will trigger a call to [ReadPreliminaryClass] if not already done. |
dart::Class& klass = LookupClass(kernel_klass); |
@@ -382,8 +350,11 @@ void KernelReader::ReadClass(const dart::Library& library, |
GrowableObjectArray::Handle(Z, I->object_store()->pending_classes()) |
.Add(klass, Heap::kOld); |
} |
+ |
+ return klass; |
} |
+ |
void KernelReader::ReadProcedure(const dart::Library& library, |
const dart::Class& owner, |
Procedure* kernel_procedure, |
@@ -523,6 +494,7 @@ void KernelReader::GenerateFieldAccessors(const dart::Class& klass, |
} |
} |
+ |
void KernelReader::SetupFunctionParameters(TranslationHelper translation_helper, |
DartTypeTranslator type_translator, |
const dart::Class& klass, |
@@ -592,6 +564,7 @@ void KernelReader::SetupFunctionParameters(TranslationHelper translation_helper, |
: return_type); |
} |
+ |
void KernelReader::SetupFieldAccessorFunction(const dart::Class& klass, |
const dart::Function& function) { |
bool is_setter = function.IsImplicitSetterFunction(); |
@@ -677,6 +650,7 @@ dart::Class& KernelReader::LookupClass(Class* klass) { |
return *handle; |
} |
+ |
RawFunction::Kind KernelReader::GetFunctionType(Procedure* kernel_procedure) { |
intptr_t lookuptable[] = { |
RawFunction::kRegularFunction, // Procedure::kMethod |
@@ -694,5 +668,6 @@ RawFunction::Kind KernelReader::GetFunctionType(Procedure* kernel_procedure) { |
} |
} |
+ |
} // namespace kernel |
} // namespace dart |