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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Generate a snapshot file after loading all the scripts specified on the 5 // Generate a snapshot file after loading all the scripts specified on the
6 // command line. 6 // command line.
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) { 480 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
481 // First resolve the specified script uri with respect to the original 481 // First resolve the specified script uri with respect to the original
482 // working directory. 482 // working directory.
483 Dart_Handle resolved_uri = ResolveUriInWorkingDirectory(script_name); 483 Dart_Handle resolved_uri = ResolveUriInWorkingDirectory(script_name);
484 if (Dart_IsError(resolved_uri)) { 484 if (Dart_IsError(resolved_uri)) {
485 return resolved_uri; 485 return resolved_uri;
486 } 486 }
487 // Now load the contents of the specified uri. 487 // Now load the contents of the specified uri.
488 const char* resolved_uri_string = DartUtils::GetStringValue(resolved_uri); 488 const char* resolved_uri_string = DartUtils::GetStringValue(resolved_uri);
489 Dart_Handle source = LoadUrlContents(resolved_uri_string); 489 Dart_Handle source = LoadUrlContents(resolved_uri_string);
490
490 if (Dart_IsError(source)) { 491 if (Dart_IsError(source)) {
491 return source; 492 return source;
492 } 493 }
493 if (IsSnapshottingForPrecompilation()) { 494 if (IsSnapshottingForPrecompilation()) {
494 return Dart_LoadScript(resolved_uri, Dart_Null(), source, 0, 0); 495 return Dart_LoadScript(resolved_uri, Dart_Null(), source, 0, 0);
495 } else { 496 } else {
496 return Dart_LoadLibrary(resolved_uri, Dart_Null(), source, 0, 0); 497 return Dart_LoadLibrary(resolved_uri, Dart_Null(), source, 0, 0);
497 } 498 }
498 } 499 }
499 500
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 CHECK_RESULT(result); 1314 CHECK_RESULT(result);
1314 1315
1315 // Set up the library tag handler in such a manner that it will use the 1316 // Set up the library tag handler in such a manner that it will use the
1316 // URL mapping specified on the command line to load the libraries. 1317 // URL mapping specified on the command line to load the libraries.
1317 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler); 1318 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler);
1318 CHECK_RESULT(result); 1319 CHECK_RESULT(result);
1319 1320
1320 Dart_QualifiedFunctionName* entry_points = 1321 Dart_QualifiedFunctionName* entry_points =
1321 ParseEntryPointsManifestIfPresent(); 1322 ParseEntryPointsManifestIfPresent();
1322 1323
1324 intptr_t payload_bytes = 0;
1325 const uint8_t* payload = NULL;
1326 const bool is_kernel_file =
1327 TryReadKernel(app_script_name, &payload, &payload_bytes);
1328
1329 if (is_kernel_file) {
1330 Dart_Handle library = Dart_LoadKernel(payload, payload_bytes);
1331 free(const_cast<uint8_t*>(payload));
1332 if (Dart_IsError(library)) FATAL("Failed to load app from Kernel IR");
1333 } else {
1334 // Set up the library tag handler in such a manner that it will use the
1335 // URL mapping specified on the command line to load the libraries.
1336 result = Dart_SetLibraryTagHandler(CreateSnapshotLibraryTagHandler);
1337 CHECK_RESULT(result);
1338 }
1339
1323 SetupStubNativeResolversForPrecompilation(entry_points); 1340 SetupStubNativeResolversForPrecompilation(entry_points);
1324 1341
1325 // Load the specified script. 1342 if (!is_kernel_file) {
1326 library = LoadSnapshotCreationScript(app_script_name); 1343 // Load the specified script.
1327 VerifyLoaded(library); 1344 library = LoadSnapshotCreationScript(app_script_name);
1345 VerifyLoaded(library);
1328 1346
1329 ImportNativeEntryPointLibrariesIntoRoot(entry_points); 1347 ImportNativeEntryPointLibrariesIntoRoot(entry_points);
1348 }
1330 1349
1331 // Ensure that we mark all libraries as loaded. 1350 // Ensure that we mark all libraries as loaded.
1332 result = Dart_FinalizeLoading(false); 1351 result = Dart_FinalizeLoading(false);
1333 CHECK_RESULT(result); 1352 CHECK_RESULT(result);
1334 1353
1335 if (!IsSnapshottingForPrecompilation()) { 1354 if (!IsSnapshottingForPrecompilation()) {
1336 CreateAndWriteSnapshot(); 1355 CreateAndWriteSnapshot();
1337 } else { 1356 } else {
1338 CreateAndWritePrecompiledSnapshot(entry_points); 1357 CreateAndWritePrecompiledSnapshot(entry_points);
1339 } 1358 }
(...skipping 14 matching lines...) Expand all
1354 EventHandler::Stop(); 1373 EventHandler::Stop();
1355 return 0; 1374 return 0;
1356 } 1375 }
1357 1376
1358 } // namespace bin 1377 } // namespace bin
1359 } // namespace dart 1378 } // namespace dart
1360 1379
1361 int main(int argc, char** argv) { 1380 int main(int argc, char** argv) {
1362 return dart::bin::main(argc, argv); 1381 return dart::bin::main(argc, argv);
1363 } 1382 }
OLDNEW
« 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