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

Unified Diff: runtime/vm/kernel_reader.cc

Issue 2933603002: 1. Dynamic compute the main closure that needs to be run by the main isolate (Closed)
Patch Set: Remove redundant check. Created 3 years, 6 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
Index: runtime/vm/kernel_reader.cc
diff --git a/runtime/vm/kernel_reader.cc b/runtime/vm/kernel_reader.cc
index 1ddd641c9155bb545659bbdd721b26338da307e9..583d7db52dae3d2d369315a838d91570d05a113d 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -176,50 +176,18 @@ 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.
+ // If 'main' is not found return a null library, this is the case
+ // when bootstrapping is in progress.
NameIndex main = program_->main_method();
if (main == -1) {
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);
- }
-
NameIndex 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(
- Z, library.LookupObjectAllowPrivate(H.DartSymbol("main")));
- ASSERT(!main_obj.IsNull());
-
- Function& to_patch = Function::Handle(
- Z, builtin_library.LookupFunctionAllowPrivate(
- dart::String::Handle(dart::String::New("_getMainClosure"))));
-
- Procedure* procedure =
- reinterpret_cast<Procedure*>(to_patch.kernel_function());
- // If dart:_builtin was not compiled from Kernel at all it does not need
- // to be patched.
- if (procedure != NULL) {
- // We will handle the StaticGet specially and will not use the name.
- // Note that we pass "true" in cannot_stream to avoid trying to stream
- // a non-existing part of the binary.
- //
- // TODO(kmillikin): we are leaking the new function body. Find a way to
- // deallocate it.
- procedure->function()->ReplaceBody(
- new ReturnStatement(new StaticGet(NameIndex(), false), false));
- }
+ ASSERT(library.LookupObjectAllowPrivate(H.DartSymbol("main")) !=
+ Object::null());
return library;
}
}

Powered by Google App Engine
This is Rietveld 408576698