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

Unified Diff: runtime/vm/kernel_reader.cc

Issue 2772803002: Revert "Use canonical names for some name-based lookup." (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/kernel_reader.h ('k') | runtime/vm/kernel_to_il.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_reader.cc
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc
index 6e04260cfad0c142c1515f7bde4eb4c601782136..1377f7ca66e62c2ceb00cec41d9d45fd27945c9a 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -84,13 +84,12 @@ class SimpleExpressionConverter : public ExpressionVisitor {
RawLibrary* BuildingTranslationHelper::LookupLibraryByKernelLibrary(
- CanonicalName* library) {
+ Library* library) {
return reader_->LookupLibrary(library).raw();
}
-RawClass* BuildingTranslationHelper::LookupClassByKernelClass(
- CanonicalName* klass) {
+RawClass* BuildingTranslationHelper::LookupClassByKernelClass(Class* klass) {
return reader_->LookupClass(klass).raw();
}
@@ -111,6 +110,9 @@ KernelReader::KernelReader(Program* program)
Object& KernelReader::ReadProgram() {
LongJumpScope jump;
if (setjmp(*jump.Set()) == 0) {
+ Procedure* main = program_->main_method();
+ Library* kernel_main_library = Library::Cast(main->parent());
+
intptr_t length = program_->libraries().length();
for (intptr_t i = 0; i < length; i++) {
Library* kernel_library = program_->libraries()[i];
@@ -118,16 +120,12 @@ Object& KernelReader::ReadProgram() {
}
for (intptr_t i = 0; i < length; i++) {
- dart::Library& library =
- LookupLibrary(program_->libraries()[i]->canonical_name());
+ dart::Library& library = LookupLibrary(program_->libraries()[i]);
if (!library.Loaded()) library.SetLoaded();
}
if (ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) {
- Procedure* main = program_->main_method();
- Library* kernel_main_library = Library::Cast(main->parent());
- dart::Library& library =
- LookupLibrary(kernel_main_library->canonical_name());
+ dart::Library& library = LookupLibrary(kernel_main_library);
// Sanity check that we can find the main entrypoint.
Object& main_obj = Object::Handle(
@@ -147,7 +145,7 @@ Object& KernelReader::ReadProgram() {
void KernelReader::ReadLibrary(Library* kernel_library) {
- dart::Library& library = LookupLibrary(kernel_library->canonical_name());
+ dart::Library& library = LookupLibrary(kernel_library);
if (library.Loaded()) return;
// The bootstrapper will take care of creating the native wrapper classes, but
@@ -285,20 +283,8 @@ void KernelReader::ReadPreliminaryClass(dart::Class* klass,
dart::Class& KernelReader::ReadClass(const dart::Library& library,
const dart::Class& toplevel_class,
Class* kernel_klass) {
- dart::Class& klass = LookupClass(kernel_klass->canonical_name());
-
- // The class needs to have a script because all the functions in the class
- // will inherit it. The predicate Function::IsOptimizable uses the absence of
- // a script to detect test functions that should not be optimized.
- if (klass.script() == Script::null()) {
- klass.set_script(ScriptAt(kernel_klass->source_uri_index()));
- }
- if (klass.token_pos() == TokenPosition::kNoSource) {
- klass.set_token_pos(kernel_klass->position());
- }
- if (!klass.is_cycle_free()) {
- ReadPreliminaryClass(&klass, kernel_klass);
- }
+ // This will trigger a call to [ReadPreliminaryClass] if not already done.
+ dart::Class& klass = LookupClass(kernel_klass);
ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass);
@@ -757,10 +743,10 @@ void KernelReader::SetupFieldAccessorFunction(const dart::Class& klass,
}
}
-dart::Library& KernelReader::LookupLibrary(CanonicalName* library) {
+dart::Library& KernelReader::LookupLibrary(Library* library) {
dart::Library* handle = NULL;
if (!libraries_.Lookup(library, &handle)) {
- const dart::String& url = H.DartSymbol(library->name());
+ const dart::String& url = H.DartSymbol(library->import_uri());
handle =
&dart::Library::Handle(Z, dart::Library::LookupLibrary(thread_, url));
if (handle->IsNull()) {
@@ -774,21 +760,34 @@ dart::Library& KernelReader::LookupLibrary(CanonicalName* library) {
return *handle;
}
-dart::Class& KernelReader::LookupClass(CanonicalName* klass) {
+dart::Class& KernelReader::LookupClass(Class* klass) {
dart::Class* handle = NULL;
if (!classes_.Lookup(klass, &handle)) {
dart::Library& library = LookupLibrary(klass->parent());
const dart::String& name = H.DartClassName(klass);
handle = &dart::Class::Handle(Z, library.LookupClass(name));
if (handle->IsNull()) {
- *handle = dart::Class::New(library, name, Script::Handle(Z),
- TokenPosition::kNoSource);
+ // The class needs to have a script because all the functions in the class
+ // will inherit it. The predicate Function::IsOptimizable uses the
+ // absence of a script to detect test functions that should not be
+ // optimized.
+ Script& script = ScriptAt(klass->source_uri_index());
+ handle = &dart::Class::Handle(
+ Z, dart::Class::New(library, name, script, klass->position()));
library.AddClass(*handle);
+ } else if (handle->script() == Script::null()) {
+ // When bootstrapping we can encounter classes that do not yet have a
+ // dummy script.
+ Script& script = ScriptAt(klass->source_uri_index());
+ handle->set_script(script);
}
// Insert the class in the cache before calling ReadPreliminaryClass so
// we do not risk allocating the class again by calling LookupClass
// recursively from ReadPreliminaryClass for the same class.
classes_.Insert(klass, handle);
+ if (!handle->is_cycle_free()) {
+ ReadPreliminaryClass(handle, klass);
+ }
}
return *handle;
}
« no previous file with comments | « runtime/vm/kernel_reader.h ('k') | runtime/vm/kernel_to_il.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698