| Index: runtime/bin/main.cc
|
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
|
| index 9e4a1c3ca43b6b0d0029058a7167f3a0912fc2d8..6be11f0cc2cb8bf01044760242a257486fd10e48 100644
|
| --- a/runtime/bin/main.cc
|
| +++ b/runtime/bin/main.cc
|
| @@ -39,12 +39,22 @@ extern const uint8_t* vm_isolate_snapshot_buffer;
|
| // snapshot otherwise it is initialized to NULL.
|
| extern const uint8_t* isolate_snapshot_buffer;
|
|
|
| -// Global state that stores a pointer to the application script snapshot.
|
| +/**
|
| + * Global state used to control and store generation of application snapshots
|
| + * (script/full).
|
| + * A full application snapshot can be generated and run using the following
|
| + * commands
|
| + * - Generating a full application snapshot :
|
| + * dart_no_snapshot --full-snapshot-after-run=<filename> --package-root=<dirs>
|
| + * <script_uri> [<script_options>]
|
| + * - Running the full application snapshot generated above :
|
| + * dart --run-full-snapshot=<filename> <script_uri> [<script_options>]
|
| + */
|
| static bool generate_script_snapshot = false;
|
| -static bool generate_script_snapshot_after_run = false;
|
| +static bool generate_full_snapshot_after_run = false;
|
| +static bool run_full_snapshot = false;
|
| static const char* snapshot_filename = NULL;
|
|
|
| -
|
| // Value of the --package-root flag.
|
| // (This pointer points into an argv buffer and does not need to be
|
| // free'd.)
|
| @@ -58,17 +68,17 @@ static const char* commandline_packages_file = NULL;
|
|
|
| // Global flag that is used to indicate that we want to compile all the
|
| // dart functions and not run anything.
|
| -static bool has_compile_all = false;
|
| +static bool compile_all = false;
|
|
|
|
|
| // Global flag that is used to indicate that we want to compile all the
|
| // dart functions before running main and not compile anything thereafter.
|
| -static bool has_gen_precompiled_snapshot = false;
|
| +static bool gen_precompiled_snapshot = false;
|
|
|
|
|
| // Global flag that is used to indicate that we want to run from a precompiled
|
| // snapshot.
|
| -static bool has_run_precompiled_snapshot = false;
|
| +static bool run_precompiled_snapshot = false;
|
|
|
|
|
| // Value of the --gen/run_precompiled_snapshot flag.
|
| @@ -82,9 +92,9 @@ static const char* precompiled_snapshot_directory = NULL;
|
| // same process.
|
| // Always set this with dart_noopt.
|
| #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT)
|
| -static const bool has_noopt = true;
|
| +static const bool is_noopt = true;
|
| #else
|
| -static const bool has_noopt = false;
|
| +static const bool is_noopt = false;
|
| #endif
|
|
|
|
|
| @@ -93,11 +103,12 @@ extern const char* kPrecompiledSymbolName;
|
| static const char* kPrecompiledVmIsolateName = "precompiled.vmisolate";
|
| static const char* kPrecompiledIsolateName = "precompiled.isolate";
|
| static const char* kPrecompiledInstructionsName = "precompiled.S";
|
| -
|
| +static const char* kVMIsolateSuffix = "vmisolate";
|
| +static const char* kIsolateSuffix = "isolate";
|
|
|
| // Global flag that is used to indicate that we want to trace resolution of
|
| // URIs and the loading of libraries, parts and scripts.
|
| -static bool has_trace_loading = false;
|
| +static bool trace_loading = false;
|
|
|
|
|
| static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1";
|
| @@ -160,34 +171,34 @@ static bool IsValidFlag(const char* name,
|
| }
|
|
|
|
|
| -static bool has_version_option = false;
|
| +static bool version_option = false;
|
| static bool ProcessVersionOption(const char* arg,
|
| CommandLineOptions* vm_options) {
|
| if (*arg != '\0') {
|
| return false;
|
| }
|
| - has_version_option = true;
|
| + version_option = true;
|
| return true;
|
| }
|
|
|
|
|
| -static bool has_help_option = false;
|
| +static bool help_option = false;
|
| static bool ProcessHelpOption(const char* arg, CommandLineOptions* vm_options) {
|
| if (*arg != '\0') {
|
| return false;
|
| }
|
| - has_help_option = true;
|
| + help_option = true;
|
| return true;
|
| }
|
|
|
|
|
| -static bool has_verbose_option = false;
|
| +static bool verbose_option = false;
|
| static bool ProcessVerboseOption(const char* arg,
|
| CommandLineOptions* vm_options) {
|
| if (*arg != '\0') {
|
| return false;
|
| }
|
| - has_verbose_option = true;
|
| + verbose_option = true;
|
| return true;
|
| }
|
|
|
| @@ -307,7 +318,7 @@ static bool ProcessCompileAllOption(const char* arg,
|
| if (*arg != '\0') {
|
| return false;
|
| }
|
| - has_compile_all = true;
|
| + compile_all = true;
|
| return true;
|
| }
|
|
|
| @@ -327,7 +338,7 @@ static bool ProcessGenPrecompiledSnapshotOption(
|
| } else {
|
| precompiled_snapshot_directory = arg;
|
| }
|
| - has_gen_precompiled_snapshot = true;
|
| + gen_precompiled_snapshot = true;
|
| vm_options->AddArgument("--precompilation");
|
| return true;
|
| }
|
| @@ -342,45 +353,67 @@ static bool ProcessRunPrecompiledSnapshotOption(
|
| (precompiled_snapshot_directory[0] == ':')) {
|
| precompiled_snapshot_directory = &precompiled_snapshot_directory[1];
|
| }
|
| - has_run_precompiled_snapshot = true;
|
| + run_precompiled_snapshot = true;
|
| vm_options->AddArgument("--precompilation");
|
| return true;
|
| }
|
|
|
|
|
| -static bool ProcessScriptSnapshotOptionHelper(const char* filename,
|
| - bool* snapshot_option) {
|
| - *snapshot_option = false;
|
| - if ((filename != NULL) && (strlen(filename) != 0)) {
|
| - // Ensure that we are already running using a full snapshot.
|
| - if (isolate_snapshot_buffer == NULL) {
|
| - Log::PrintErr("Script snapshots cannot be generated in this version of"
|
| - " dart\n");
|
| - return false;
|
| - }
|
| - snapshot_filename = filename;
|
| - *snapshot_option = true;
|
| - if (generate_script_snapshot && generate_script_snapshot_after_run) {
|
| - Log::PrintErr("--snapshot and --snapshot-after-run options"
|
| - " cannot be specified at the same time\n");
|
| - return false;
|
| - }
|
| - return true;
|
| +static bool ProcessSnapshotOptionHelper(const char* filename,
|
| + bool* snapshot_option) {
|
| + ASSERT((filename != NULL) && (strlen(filename) != 0));
|
| + snapshot_filename = filename;
|
| + *snapshot_option = true;
|
| + if (generate_script_snapshot && generate_full_snapshot_after_run) {
|
| + Log::PrintErr("--snapshot and --snapshot-after-run options"
|
| + " cannot be specified at the same time\n");
|
| + *snapshot_option = false;
|
| + return false;
|
| }
|
| - return false;
|
| + return true;
|
| }
|
|
|
|
|
| static bool ProcessScriptSnapshotOption(const char* filename,
|
| CommandLineOptions* vm_options) {
|
| - return ProcessScriptSnapshotOptionHelper(filename, &generate_script_snapshot);
|
| + if ((filename == NULL) || (strlen(filename) == 0)) {
|
| + return false;
|
| + }
|
| + // Ensure that we are already running using a full snapshot.
|
| + if (isolate_snapshot_buffer == NULL) {
|
| + Log::PrintErr("Script snapshots cannot be generated in this version of"
|
| + " Dart\n");
|
| + return false;
|
| + }
|
| + return ProcessSnapshotOptionHelper(filename, &generate_script_snapshot);
|
| +}
|
| +
|
| +
|
| +static bool ProcessFullSnapshotAfterRunOption(
|
| + const char* filename, CommandLineOptions* vm_options) {
|
| + if ((filename == NULL) || (strlen(filename) == 0)) {
|
| + return false;
|
| + }
|
| + // Ensure that we are running 'dart_no_snapshot'.
|
| + if (isolate_snapshot_buffer != NULL) {
|
| + Log::PrintErr("Full Application snapshots must be generated with"
|
| + " dart_no_snapshot\n");
|
| + return false;
|
| + }
|
| + return ProcessSnapshotOptionHelper(filename,
|
| + &generate_full_snapshot_after_run);
|
| }
|
|
|
|
|
| -static bool ProcessScriptSnapshotAfterRunOption(
|
| +static bool ProcessRunFullSnapshotOption(
|
| const char* filename, CommandLineOptions* vm_options) {
|
| - return ProcessScriptSnapshotOptionHelper(filename,
|
| - &generate_script_snapshot_after_run);
|
| + // Ensure that we are not running 'dart_no_snapshot'.
|
| + if (isolate_snapshot_buffer == NULL) {
|
| + Log::PrintErr("Full Application snapshots cannot be run with"
|
| + " dart_no_snapshot\n");
|
| + return false;
|
| + }
|
| + return ProcessSnapshotOptionHelper(filename, &run_full_snapshot);
|
| }
|
|
|
|
|
| @@ -428,7 +461,7 @@ static bool ProcessTraceLoadingOption(const char* arg,
|
| if (*arg != '\0') {
|
| return false;
|
| }
|
| - has_trace_loading = true;
|
| + trace_loading = true;
|
| return true;
|
| }
|
|
|
| @@ -483,7 +516,8 @@ static struct {
|
| { "--run-precompiled-snapshot", ProcessRunPrecompiledSnapshotOption },
|
| { "--shutdown", ProcessShutdownOption },
|
| { "--snapshot=", ProcessScriptSnapshotOption },
|
| - { "--snapshot-after-run=", ProcessScriptSnapshotAfterRunOption },
|
| + { "--full-snapshot-after-run=", ProcessFullSnapshotAfterRunOption },
|
| + { "--run-full-snapshot=", ProcessRunFullSnapshotOption },
|
| { "--trace-loading", ProcessTraceLoadingOption },
|
| { NULL, NULL }
|
| };
|
| @@ -600,23 +634,29 @@ static int ParseArguments(int argc,
|
| "file is invalid.\n");
|
| return -1;
|
| }
|
| - if (has_noopt) {
|
| - if (has_gen_precompiled_snapshot) {
|
| + if (is_noopt) {
|
| + if (gen_precompiled_snapshot) {
|
| Log::PrintErr("Running dart_noopt with --gen_precompiled_snapshot"
|
| " is invalid.\n");
|
| return -1;
|
| }
|
| - if (has_run_precompiled_snapshot) {
|
| + if (run_precompiled_snapshot) {
|
| Log::PrintErr("Running dart_noopt with --run_precompiled_snapshot"
|
| " is invalid.\n");
|
| return -1;
|
| }
|
| }
|
| - if (has_gen_precompiled_snapshot && has_run_precompiled_snapshot) {
|
| - Log::PrintErr("Specifying --gen_precompiled_snapshot and"
|
| + if (run_full_snapshot && run_precompiled_snapshot) {
|
| + Log::PrintErr("Specifying --run_full_snapshot and"
|
| " --run_precompiled_snapshot is invalid.\n");
|
| return -1;
|
| }
|
| + if ((generate_full_snapshot_after_run || gen_precompiled_snapshot) &&
|
| + (run_full_snapshot || run_precompiled_snapshot)) {
|
| + Log::PrintErr("Specifying an option to generate a snapshot and"
|
| + " run using a snapshot is invalid.\n");
|
| + return -1;
|
| + }
|
|
|
| return 0;
|
| }
|
| @@ -702,6 +742,12 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| char** error,
|
| int* exit_code) {
|
| ASSERT(script_uri != NULL);
|
| + if (run_full_snapshot &&
|
| + !strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME)) {
|
| + // We do not create a service isolate when running a full application
|
| + // snapshot.
|
| + return NULL;
|
| + }
|
| IsolateData* isolate_data = new IsolateData(script_uri,
|
| package_root,
|
| packages_config);
|
| @@ -735,11 +781,11 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| // If this is the service isolate, load embedder specific bits and return.
|
| if (!VmService::Setup(vm_service_server_ip,
|
| vm_service_server_port,
|
| - has_run_precompiled_snapshot)) {
|
| + run_precompiled_snapshot)) {
|
| *error = strdup(VmService::GetErrorMessage());
|
| return NULL;
|
| }
|
| - if (has_compile_all) {
|
| + if (compile_all) {
|
| result = Dart_CompileAll();
|
| CHECK_RESULT(result);
|
| }
|
| @@ -751,13 +797,15 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| // Prepare builtin and other core libraries for use to resolve URIs.
|
| // Set up various closures, e.g: printing, timers etc.
|
| // Set up 'package root' for URI resolution.
|
| - result = DartUtils::PrepareForScriptLoading(false, has_trace_loading);
|
| + result = DartUtils::PrepareForScriptLoading(false, trace_loading);
|
| CHECK_RESULT(result);
|
|
|
| - // Set up the load port provided by the service isolate so that we can
|
| - // load scripts.
|
| - result = DartUtils::SetupServiceLoadPort();
|
| - CHECK_RESULT(result);
|
| + if (!run_full_snapshot) {
|
| + // Set up the load port provided by the service isolate so that we can
|
| + // load scripts.
|
| + result = DartUtils::SetupServiceLoadPort();
|
| + CHECK_RESULT(result);
|
| + }
|
|
|
| // Setup package root if specified.
|
| result = DartUtils::SetupPackageRoot(package_root, packages_config);
|
| @@ -766,10 +814,8 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| result = Dart_SetEnvironmentCallback(EnvironmentCallback);
|
| CHECK_RESULT(result);
|
|
|
| - if (!has_run_precompiled_snapshot) {
|
| + if (!run_precompiled_snapshot && !run_full_snapshot) {
|
| // Load the specified application script into the newly created isolate.
|
| -
|
| - // Load the script.
|
| result = DartUtils::LoadScript(script_uri);
|
| CHECK_RESULT(result);
|
|
|
| @@ -783,6 +829,9 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
|
|
| result = DartUtils::SetupIOLibrary(script_uri);
|
| CHECK_RESULT(result);
|
| + } else if (run_full_snapshot) {
|
| + result = DartUtils::SetupIOLibrary(script_uri);
|
| + CHECK_RESULT(result);
|
| }
|
|
|
| // Make the isolate runnable so that it is ready to handle messages.
|
| @@ -839,7 +888,7 @@ static void PrintUsage() {
|
| "\n"
|
| "Executes the Dart script passed as <dart-script-file>.\n"
|
| "\n");
|
| - if (!has_verbose_option) {
|
| + if (!verbose_option) {
|
| Log::PrintErr(
|
| "Common options:\n"
|
| "--checked or -c\n"
|
| @@ -1008,17 +1057,17 @@ static void ServiceStreamCancelCallback(const char* stream_id) {
|
| }
|
|
|
|
|
| -static void WritePrecompiledSnapshotFile(const char* filename,
|
| - const uint8_t* buffer,
|
| - const intptr_t size) {
|
| +static void WriteSnapshotFile(const char* snapshot_directory,
|
| + const char* filename,
|
| + bool write_magic_number,
|
| + const uint8_t* buffer,
|
| + const intptr_t size) {
|
| char* concat = NULL;
|
| const char* qualified_filename;
|
| - if (strlen(precompiled_snapshot_directory) > 0) {
|
| - intptr_t len = snprintf(NULL, 0, "%s/%s",
|
| - precompiled_snapshot_directory, filename);
|
| + if ((snapshot_directory != NULL) && strlen(snapshot_directory) > 0) {
|
| + intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename);
|
| concat = new char[len + 1];
|
| - snprintf(concat, len + 1, "%s/%s",
|
| - precompiled_snapshot_directory, filename);
|
| + snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename);
|
| qualified_filename = concat;
|
| } else {
|
| qualified_filename = filename;
|
| @@ -1026,6 +1075,12 @@ static void WritePrecompiledSnapshotFile(const char* filename,
|
|
|
| File* file = File::Open(qualified_filename, File::kWriteTruncate);
|
| ASSERT(file != NULL);
|
| +
|
| + if (write_magic_number) {
|
| + // Write the magic number to indicate file is a script snapshot.
|
| + DartUtils::WriteMagicNumber(file);
|
| + }
|
| +
|
| if (!file->WriteFully(buffer, size)) {
|
| ErrorExit(kErrorExitCode,
|
| "Unable to open file %s for writing snapshot\n",
|
| @@ -1038,16 +1093,15 @@ static void WritePrecompiledSnapshotFile(const char* filename,
|
| }
|
|
|
|
|
| -static void ReadPrecompiledSnapshotFile(const char* filename,
|
| - const uint8_t** buffer) {
|
| +static void ReadSnapshotFile(const char* snapshot_directory,
|
| + const char* filename,
|
| + const uint8_t** buffer) {
|
| char* concat = NULL;
|
| const char* qualified_filename;
|
| - if (strlen(precompiled_snapshot_directory) > 0) {
|
| - intptr_t len = snprintf(NULL, 0, "%s/%s",
|
| - precompiled_snapshot_directory, filename);
|
| + if ((snapshot_directory != NULL) && strlen(snapshot_directory) > 0) {
|
| + intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename);
|
| concat = new char[len + 1];
|
| - snprintf(concat, len + 1, "%s/%s",
|
| - precompiled_snapshot_directory, filename);
|
| + snprintf(concat, len + 1, "%s/%s", snapshot_directory, filename);
|
| qualified_filename = concat;
|
| } else {
|
| qualified_filename = filename;
|
| @@ -1096,22 +1150,54 @@ static void GenerateScriptSnapshot() {
|
| ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
| }
|
|
|
| - // Open the snapshot file.
|
| - File* snapshot_file = File::Open(snapshot_filename, File::kWriteTruncate);
|
| - if (snapshot_file == NULL) {
|
| - ErrorExit(kErrorExitCode,
|
| - "Unable to open file %s for writing the snapshot\n",
|
| - snapshot_filename);
|
| - }
|
| + WriteSnapshotFile(NULL, snapshot_filename, true, buffer, size);
|
| +}
|
| +
|
| +
|
| +static void ComputeSnapshotFilenames(const char* filename,
|
| + char** vm_snapshot_fname,
|
| + char** isolate_snapshot_fname) {
|
| + intptr_t len = snprintf(NULL, 0, "%s.%s", filename, kVMIsolateSuffix);
|
| + *vm_snapshot_fname = new char[len + 1];
|
| + snprintf(*vm_snapshot_fname, len + 1, "%s.%s", filename, kVMIsolateSuffix);
|
| +
|
| + len = snprintf(NULL, 0, "%s.%s", filename, kIsolateSuffix);
|
| + *isolate_snapshot_fname = new char[len + 1];
|
| + snprintf(*isolate_snapshot_fname, len + 1, "%s.%s", filename, kIsolateSuffix);
|
| +}
|
|
|
| - // Write the magic number to indicate file is a script snapshot.
|
| - DartUtils::WriteMagicNumber(snapshot_file);
|
| +static void GenerateFullSnapshot() {
|
| + // Create a full snapshot of the script.
|
| + Dart_Handle result;
|
| + uint8_t* vm_isolate_buffer = NULL;
|
| + intptr_t vm_isolate_size = 0;
|
| + uint8_t* isolate_buffer = NULL;
|
| + intptr_t isolate_size = 0;
|
| + char* vm_snapshot_fname = NULL;
|
| + char* isolate_snapshot_fname = NULL;
|
| +
|
| + result = Dart_CreateSnapshot(&vm_isolate_buffer,
|
| + &vm_isolate_size,
|
| + &isolate_buffer,
|
| + &isolate_size);
|
| + if (Dart_IsError(result)) {
|
| + ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
| + }
|
|
|
| - // Now write the snapshot out to specified file.
|
| - bool bytes_written = snapshot_file->WriteFully(buffer, size);
|
| - ASSERT(bytes_written);
|
| - delete snapshot_file;
|
| - snapshot_file = NULL;
|
| + // Compute snapshot file names and write out the snapshot files.
|
| + ComputeSnapshotFilenames(snapshot_filename,
|
| + &vm_snapshot_fname,
|
| + &isolate_snapshot_fname);
|
| + WriteSnapshotFile(NULL,
|
| + vm_snapshot_fname,
|
| + false,
|
| + vm_isolate_buffer,
|
| + vm_isolate_size);
|
| + WriteSnapshotFile(NULL,
|
| + isolate_snapshot_fname,
|
| + false,
|
| + isolate_buffer,
|
| + isolate_size);
|
| }
|
|
|
|
|
| @@ -1182,7 +1268,7 @@ bool RunMainIsolate(const char* script_name,
|
| reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate));
|
| result = Dart_LibraryImportLibrary(
|
| isolate_data->builtin_lib(), root_lib, Dart_Null());
|
| - if (has_noopt || has_gen_precompiled_snapshot) {
|
| + if (is_noopt || gen_precompiled_snapshot) {
|
| // Load the embedder's portion of the VM service's Dart code so it will
|
| // be included in the precompiled snapshot.
|
| if (!VmService::LoadForGenPrecompiled()) {
|
| @@ -1194,12 +1280,12 @@ bool RunMainIsolate(const char* script_name,
|
| }
|
| }
|
|
|
| - if (has_compile_all) {
|
| + if (compile_all) {
|
| result = Dart_CompileAll();
|
| CHECK_RESULT(result);
|
| }
|
|
|
| - if (has_noopt || has_gen_precompiled_snapshot) {
|
| + if (is_noopt || gen_precompiled_snapshot) {
|
| Dart_QualifiedFunctionName standalone_entry_points[] = {
|
| { "dart:_builtin", "::", "_getMainClosure" },
|
| { "dart:_builtin", "::", "_getPrintClosure" },
|
| @@ -1232,12 +1318,12 @@ bool RunMainIsolate(const char* script_name,
|
| { NULL, NULL, NULL } // Must be terminated with NULL entries.
|
| };
|
|
|
| - const bool reset_fields = has_gen_precompiled_snapshot;
|
| + const bool reset_fields = gen_precompiled_snapshot;
|
| result = Dart_Precompile(standalone_entry_points, reset_fields);
|
| CHECK_RESULT(result);
|
| }
|
|
|
| - if (has_gen_precompiled_snapshot) {
|
| + if (gen_precompiled_snapshot) {
|
| uint8_t* vm_isolate_buffer = NULL;
|
| intptr_t vm_isolate_size = 0;
|
| uint8_t* isolate_buffer = NULL;
|
| @@ -1251,15 +1337,21 @@ bool RunMainIsolate(const char* script_name,
|
| &instructions_buffer,
|
| &instructions_size);
|
| CHECK_RESULT(result);
|
| - WritePrecompiledSnapshotFile(kPrecompiledVmIsolateName,
|
| - vm_isolate_buffer,
|
| - vm_isolate_size);
|
| - WritePrecompiledSnapshotFile(kPrecompiledIsolateName,
|
| - isolate_buffer,
|
| - isolate_size);
|
| - WritePrecompiledSnapshotFile(kPrecompiledInstructionsName,
|
| - instructions_buffer,
|
| - instructions_size);
|
| + WriteSnapshotFile(precompiled_snapshot_directory,
|
| + kPrecompiledVmIsolateName,
|
| + false,
|
| + vm_isolate_buffer,
|
| + vm_isolate_size);
|
| + WriteSnapshotFile(precompiled_snapshot_directory,
|
| + kPrecompiledIsolateName,
|
| + false,
|
| + isolate_buffer,
|
| + isolate_size);
|
| + WriteSnapshotFile(precompiled_snapshot_directory,
|
| + kPrecompiledInstructionsName,
|
| + false,
|
| + instructions_buffer,
|
| + instructions_size);
|
| } else {
|
| if (Dart_IsNull(root_lib)) {
|
| ErrorExit(kErrorExitCode,
|
| @@ -1292,9 +1384,9 @@ bool RunMainIsolate(const char* script_name,
|
| result = Dart_RunLoop();
|
| CHECK_RESULT(result);
|
|
|
| - // Generate a script snapshot after execution if specified.
|
| - if (generate_script_snapshot_after_run) {
|
| - GenerateScriptSnapshot();
|
| + // Generate a full snapshot after execution if specified.
|
| + if (generate_full_snapshot_after_run) {
|
| + GenerateFullSnapshot();
|
| }
|
| }
|
| }
|
| @@ -1418,10 +1510,10 @@ void main(int argc, char** argv) {
|
| &dart_options,
|
| &print_flags_seen,
|
| &verbose_debug_seen) < 0) {
|
| - if (has_help_option) {
|
| + if (help_option) {
|
| PrintUsage();
|
| Platform::Exit(0);
|
| - } else if (has_version_option) {
|
| + } else if (version_option) {
|
| PrintVersion();
|
| Platform::Exit(0);
|
| } else if (print_flags_seen) {
|
| @@ -1444,13 +1536,13 @@ void main(int argc, char** argv) {
|
| Platform::Exit(kErrorExitCode);
|
| }
|
|
|
| - if (generate_script_snapshot) {
|
| + if (generate_script_snapshot || generate_full_snapshot_after_run) {
|
| vm_options.AddArgument("--load_deferred_eagerly");
|
| }
|
|
|
| #if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT)
|
| // Always set --precompilation with dart_noopt.
|
| - ASSERT(!has_gen_precompiled_snapshot && !has_run_precompiled_snapshot);
|
| + ASSERT(!gen_precompiled_snapshot && !run_precompiled_snapshot);
|
| vm_options.AddArgument("--precompilation");
|
| #endif
|
|
|
| @@ -1461,13 +1553,28 @@ void main(int argc, char** argv) {
|
| EventHandler::Start();
|
|
|
| const uint8_t* instructions_snapshot = NULL;
|
| - if (has_run_precompiled_snapshot) {
|
| + if (run_precompiled_snapshot) {
|
| instructions_snapshot = reinterpret_cast<const uint8_t*>(
|
| LoadLibrarySymbol(kPrecompiledLibraryName, kPrecompiledSymbolName));
|
| - ReadPrecompiledSnapshotFile(kPrecompiledVmIsolateName,
|
| - &vm_isolate_snapshot_buffer);
|
| - ReadPrecompiledSnapshotFile(kPrecompiledIsolateName,
|
| - &isolate_snapshot_buffer);
|
| + ReadSnapshotFile(precompiled_snapshot_directory,
|
| + kPrecompiledVmIsolateName,
|
| + &vm_isolate_snapshot_buffer);
|
| + ReadSnapshotFile(precompiled_snapshot_directory,
|
| + kPrecompiledIsolateName,
|
| + &isolate_snapshot_buffer);
|
| + } else if (run_full_snapshot) {
|
| + char* vm_snapshot_fname;
|
| + char* isolate_snapshot_fname;
|
| +
|
| + // Compute file names.
|
| + ComputeSnapshotFilenames(snapshot_filename,
|
| + &vm_snapshot_fname,
|
| + &isolate_snapshot_fname);
|
| +
|
| + ReadSnapshotFile(NULL, vm_snapshot_fname, &vm_isolate_snapshot_buffer);
|
| + ReadSnapshotFile(NULL, isolate_snapshot_fname, &isolate_snapshot_buffer);
|
| + delete vm_snapshot_fname;
|
| + delete isolate_snapshot_fname;
|
| }
|
|
|
| // Initialize the Dart VM.
|
|
|