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

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 2411823003: VM support for running Kernel binaries. (Closed)
Patch Set: Address comments Created 4 years, 2 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/dartutils.cc ('k') | runtime/bin/loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/gen_snapshot.cc
diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc
index 319a322d4d1a8e7302ca2fe41849088ae4d687e8..6856b4632b6f8fe6af153f11b4f7dac8ce6ff6d7 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -487,6 +487,7 @@ static Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
// Now load the contents of the specified uri.
const char* resolved_uri_string = DartUtils::GetStringValue(resolved_uri);
Dart_Handle source = LoadUrlContents(resolved_uri_string);
+
if (Dart_IsError(source)) {
return source;
}
@@ -1320,13 +1321,31 @@ int main(int argc, char** argv) {
Dart_QualifiedFunctionName* entry_points =
ParseEntryPointsManifestIfPresent();
+ intptr_t payload_bytes = 0;
+ const uint8_t* payload = NULL;
+ const bool is_kernel_file =
+ TryReadKernel(app_script_name, &payload, &payload_bytes);
+
+ if (is_kernel_file) {
+ Dart_Handle library = Dart_LoadKernel(payload, payload_bytes);
+ free(const_cast<uint8_t*>(payload));
+ if (Dart_IsError(library)) FATAL("Failed to load app from Kernel IR");
+ } else {
+ // Set up the library tag handler in such a manner that it will use the
+ // URL mapping specified on the command line to load the libraries.
+ result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler);
+ CHECK_RESULT(result);
+ }
+
SetupStubNativeResolversForPrecompilation(entry_points);
- // Load the specified script.
- library = LoadSnapshotCreationScript(app_script_name);
- VerifyLoaded(library);
+ if (!is_kernel_file) {
+ // Load the specified script.
+ library = LoadSnapshotCreationScript(app_script_name);
+ VerifyLoaded(library);
- ImportNativeEntryPointLibrariesIntoRoot(entry_points);
+ ImportNativeEntryPointLibrariesIntoRoot(entry_points);
+ }
// Ensure that we mark all libraries as loaded.
result = Dart_FinalizeLoading(false);
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698