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

Unified Diff: runtime/vm/kernel_reader.cc

Issue 2786083002: Read platform.dill in the VM. (Closed)
Patch Set: Incorporate review comments and merge. 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/vm/kernel_reader.h ('k') | runtime/vm/kernel_to_il.cc » ('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 1099c1b69a7aef45dc58a0f7e324004f1e7fa258..0b1d9b000a71b8440225320f03ee866637173ff8 100644
--- a/runtime/vm/kernel_reader.cc
+++ b/runtime/vm/kernel_reader.cc
@@ -157,12 +157,34 @@ Object& KernelReader::ReadProgram() {
if (ClassFinalizer::ProcessPendingClasses(/*from_kernel=*/true)) {
CanonicalName* main = program_->main_method();
- dart::Library& library = LookupLibrary(H.EnclosingName(main));
+ if (main == NULL) {
+ 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.
Object& main_obj = Object::Handle(
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)));
+
return library;
}
}
@@ -233,7 +255,7 @@ void KernelReader::ReadLibrary(Library* kernel_library) {
toplevel_class.SetFunctions(Array::Handle(MakeFunctionsArray()));
const GrowableObjectArray& classes =
- GrowableObjectArray::Handle(I->object_store()->pending_classes());
+ GrowableObjectArray::Handle(Z, I->object_store()->pending_classes());
// Load all classes.
for (intptr_t i = 0; i < kernel_library->classes().length(); i++) {
« no previous file with comments | « runtime/vm/kernel_reader.h ('k') | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698