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

Side by Side Diff: runtime/bin/main.cc

Issue 1689953003: Fixes for running a full application snapshot: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename); 1102 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename);
1103 concat = new char[len + 1]; 1103 concat = new char[len + 1];
1104 snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename); 1104 snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename);
1105 qualified_filename = concat; 1105 qualified_filename = concat;
1106 } else { 1106 } else {
1107 qualified_filename = filename; 1107 qualified_filename = filename;
1108 } 1108 }
1109 1109
1110 void* file = DartUtils::OpenFile(qualified_filename, false); 1110 void* file = DartUtils::OpenFile(qualified_filename, false);
1111 if (file == NULL) { 1111 if (file == NULL) {
1112 ErrorExit(kErrorExitCode, 1112 fprintf(stderr,
1113 "Error: Unable to open file %s for reading snapshot\n", 1113 "Error: Unable to open file %s for reading snapshot\n",
1114 qualified_filename); 1114 qualified_filename);
1115 fflush(stderr);
1116 Platform::Exit(kErrorExitCode);
1115 } 1117 }
1116 intptr_t len = -1; 1118 intptr_t len = -1;
1117 DartUtils::ReadFile(buffer, &len, file); 1119 DartUtils::ReadFile(buffer, &len, file);
1118 if (*buffer == NULL || len == -1) { 1120 if (*buffer == NULL || len == -1) {
1119 ErrorExit(kErrorExitCode, 1121 fprintf(stderr,
1120 "Error: Unable to read snapshot file %s\n", qualified_filename); 1122 "Error: Unable to read snapshot file %s\n", qualified_filename);
1123 fflush(stderr);
1124 Platform::Exit(kErrorExitCode);
1121 } 1125 }
1122 DartUtils::CloseFile(file); 1126 DartUtils::CloseFile(file);
1123 if (concat != NULL) { 1127 if (concat != NULL) {
1124 delete concat; 1128 delete concat;
1125 } 1129 }
1126 } 1130 }
1127 1131
1128 1132
1129 static void* LoadLibrarySymbol(const char* libname, const char* symname) { 1133 static void* LoadLibrarySymbol(const char* libname, const char* symname) {
1130 void* library = Extensions::LoadExtensionLibrary(libname); 1134 void* library = Extensions::LoadExtensionLibrary(libname);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 1379
1376 Dart_Handle isolate_lib = 1380 Dart_Handle isolate_lib =
1377 Dart_LookupLibrary(Dart_NewStringFromCString("dart:isolate")); 1381 Dart_LookupLibrary(Dart_NewStringFromCString("dart:isolate"));
1378 result = Dart_Invoke(isolate_lib, 1382 result = Dart_Invoke(isolate_lib,
1379 Dart_NewStringFromCString("_startMainIsolate"), 1383 Dart_NewStringFromCString("_startMainIsolate"),
1380 kNumIsolateArgs, isolate_args); 1384 kNumIsolateArgs, isolate_args);
1381 CHECK_RESULT(result); 1385 CHECK_RESULT(result);
1382 1386
1383 // Keep handling messages until the last active receive port is closed. 1387 // Keep handling messages until the last active receive port is closed.
1384 result = Dart_RunLoop(); 1388 result = Dart_RunLoop();
1385 CHECK_RESULT(result);
1386
1387 // Generate a full snapshot after execution if specified. 1389 // Generate a full snapshot after execution if specified.
1388 if (generate_full_snapshot_after_run) { 1390 if (generate_full_snapshot_after_run) {
1389 GenerateFullSnapshot(); 1391 if (!Dart_IsCompilationError(result) &&
1392 !Dart_IsVMRestartRequest(result)) {
1393 GenerateFullSnapshot();
1394 }
1390 } 1395 }
1396 CHECK_RESULT(result);
1391 } 1397 }
1392 } 1398 }
1393 1399
1394 Dart_ExitScope(); 1400 Dart_ExitScope();
1395 // Shutdown the isolate. 1401 // Shutdown the isolate.
1396 Dart_ShutdownIsolate(); 1402 Dart_ShutdownIsolate();
1397 1403
1398 // No restart. 1404 // No restart.
1399 return false; 1405 return false;
1400 } 1406 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1535
1530 Thread::InitOnce(); 1536 Thread::InitOnce();
1531 1537
1532 if (!DartUtils::SetOriginalWorkingDirectory()) { 1538 if (!DartUtils::SetOriginalWorkingDirectory()) {
1533 OSError err; 1539 OSError err;
1534 fprintf(stderr, "Error determining current directory: %s\n", err.message()); 1540 fprintf(stderr, "Error determining current directory: %s\n", err.message());
1535 fflush(stderr); 1541 fflush(stderr);
1536 Platform::Exit(kErrorExitCode); 1542 Platform::Exit(kErrorExitCode);
1537 } 1543 }
1538 1544
1539 if (generate_script_snapshot || generate_full_snapshot_after_run) { 1545 if (generate_script_snapshot ||
1546 generate_full_snapshot_after_run ||
1547 run_full_snapshot) {
1540 vm_options.AddArgument("--load_deferred_eagerly"); 1548 vm_options.AddArgument("--load_deferred_eagerly");
1541 } 1549 }
1542 1550
1543 #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT) 1551 #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT)
1544 // Always set --precompilation with dart_noopt. 1552 // Always set --precompilation with dart_noopt.
1545 ASSERT(!gen_precompiled_snapshot && !run_precompiled_snapshot); 1553 ASSERT(!gen_precompiled_snapshot && !run_precompiled_snapshot);
1546 vm_options.AddArgument("--precompilation"); 1554 vm_options.AddArgument("--precompilation");
1547 #endif 1555 #endif
1548 1556
1549 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 1557 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 Platform::Exit(Process::GlobalExitCode()); 1646 Platform::Exit(Process::GlobalExitCode());
1639 } 1647 }
1640 1648
1641 } // namespace bin 1649 } // namespace bin
1642 } // namespace dart 1650 } // namespace dart
1643 1651
1644 int main(int argc, char** argv) { 1652 int main(int argc, char** argv) {
1645 dart::bin::main(argc, argv); 1653 dart::bin::main(argc, argv);
1646 UNREACHABLE(); 1654 UNREACHABLE();
1647 } 1655 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698