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

Unified Diff: runtime/vm/kernel_reader.cc

Issue 2842913002: Fix the front end compiler tests. (Closed)
Patch Set: Created 3 years, 8 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/bin/main.cc ('k') | no next file » | 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 0b1d9b000a71b8440225320f03ee866637173ff8..d9c9d20912588965b18e5a1170c5cf5bac352108 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -156,11 +156,25 @@ Object& KernelReader::ReadProgram() {
}
if (ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) {
+ // There is a function _getMainClosure in dart:_builtin that returns the
+ // main procedure. Since the platform libraries are compiled before the
+ // program script, this function might need to be patched here.
+
+ // 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) {
return dart::Library::Handle(Z);
}
+ // If the builtin library is not set in the object store, then we are
+ // bootstrapping and do not need to patch here.
+ dart::Library& builtin_library =
+ dart::Library::Handle(Z, I->object_store()->builtin_library());
+ if (builtin_library.IsNull()) {
+ return dart::Library::Handle(Z);
+ }
+
CanonicalName* main_library = H.EnclosingName(main);
dart::Library& library = LookupLibrary(main_library);
// Sanity check that we can find the main entrypoint.
@@ -168,23 +182,22 @@ Object& KernelReader::ReadProgram() {
Z, library.LookupObjectAllowPrivate(H.DartSymbol("main")));
ASSERT(!main_obj.IsNull());
- // There is a function _getMainClosure in dart:_builtin that returns the
- // main procedure. Since the platform libraries are compiled before the
- // program script, this function is patched here.
- //
- // TODO(kmillikin): we are leaking the function body. Find a way to
- // deallocate it.
- dart::Library& builtin_library =
- dart::Library::Handle(Z, I->object_store()->builtin_library());
Function& to_patch = Function::Handle(
Z, builtin_library.LookupFunctionAllowPrivate(
dart::String::Handle(dart::String::New("_getMainClosure"))));
- // We will handle the StaticGet specially and will not use the name.
Procedure* procedure =
reinterpret_cast<Procedure*>(to_patch.kernel_function());
- procedure->function()->set_body(new ReturnStatement(new StaticGet(NULL)));
-
+ // If dart:_builtin was not compiled from Kernel at all or if it was
+ // linked with a script, it does not need to be patched.
+ if ((procedure != NULL) && (procedure->function()->body() == NULL)) {
+ // We will handle the StaticGet specially and will not use the name.
+ //
+ // TODO(kmillikin): we are leaking the function body. Find a way to
+ // deallocate it.
+ procedure->function()->set_body(
+ new ReturnStatement(new StaticGet(NULL)));
+ }
return library;
}
}
« no previous file with comments | « runtime/bin/main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698