| Index: runtime/bin/main.cc
|
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
|
| index 07365e18362baeeef432dcae4c7b90c0fa55bd52..ab45b95aac2ca35fcc0f081b7f3860c5e5b1647f 100644
|
| --- a/runtime/bin/main.cc
|
| +++ b/runtime/bin/main.cc
|
| @@ -52,10 +52,16 @@ extern const uint8_t* isolate_snapshot_buffer;
|
| * - 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_full_snapshot_after_run = false;
|
| -static bool run_full_snapshot = false;
|
| +static bool run_app_snapshot = false;
|
| static const char* snapshot_filename = NULL;
|
| +enum SnapshotKind {
|
| + kNone,
|
| + kScript,
|
| + kAppAOT,
|
| + kAppJITAfterRun,
|
| + kAppAfterRun,
|
| +};
|
| +static SnapshotKind gen_snapshot_kind = kNone;
|
|
|
| // Value of the --package-root flag.
|
| // (This pointer points into an argv buffer and does not need to be
|
| @@ -73,29 +79,11 @@ static const char* commandline_packages_file = NULL;
|
| 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 gen_precompiled_snapshot = false;
|
| -static bool gen_precompiled_jit_snapshot = false;
|
| -
|
| -
|
| -// Global flag that is used to indicate that we want to run from a precompiled
|
| -// snapshot.
|
| -static bool run_precompiled_snapshot = false;
|
| -static bool run_precompiled_jit_snapshot = false;
|
| -
|
| -
|
| // Global flag that is used to indicate that we want to use blobs/mmap instead
|
| // of assembly/shared libraries for precompilation.
|
| static bool use_blobs = false;
|
|
|
|
|
| -// Value of the --gen/run_precompiled_snapshot flag.
|
| -// (This pointer points into an argv buffer and does not need to be
|
| -// free'd.)
|
| -static const char* precompiled_snapshot_directory = NULL;
|
| -
|
| -
|
| // Global flag that is used to indicate that we want to compile everything in
|
| // the same way as precompilation before main, then continue running in the
|
| // same process.
|
| @@ -110,14 +98,13 @@ static const bool is_noopt = false;
|
| extern const char* kPrecompiledLibraryName;
|
| extern const char* kPrecompiledInstructionsSymbolName;
|
| extern const char* kPrecompiledDataSymbolName;
|
| -static const char* kPrecompiledVmIsolateName = "precompiled.vmisolate";
|
| -static const char* kPrecompiledIsolateName = "precompiled.isolate";
|
| -static const char* kPrecompiledAssemblyName = "precompiled.S";
|
| -static const char* kPrecompiledInstructionsBlobName =
|
| - "precompiled.instructions";
|
| -static const char* kPrecompiledRodataBlobName = "precompiled.rodata";
|
| -static const char* kVMIsolateSuffix = "vmisolate";
|
| -static const char* kIsolateSuffix = "isolate";
|
| +
|
| +static const char* kVMIsolateSuffix = "snapshot.vmisolate";
|
| +static const char* kIsolateSuffix = "snapshot.isolate";
|
| +static const char* kAssemblySuffix = "snapshot.S";
|
| +static const char* kInstructionsSuffix = "snapshot.instructions";
|
| +static const char* kRODataSuffix = "snapshot.rodata";
|
| +
|
|
|
| // Global flag that is used to indicate that we want to trace resolution of
|
| // URIs and the loading of libraries, parts and scripts.
|
| @@ -347,125 +334,43 @@ static bool ProcessUseBlobsOption(const char* arg,
|
| }
|
|
|
|
|
| -static bool ProcessGenPrecompiledSnapshotOption(
|
| - const char* arg,
|
| - CommandLineOptions* vm_options) {
|
| -#if !defined(DART_PRECOMPILER)
|
| - Log::PrintErr("Precompiled snapshots must be generated with "
|
| - "dart_bootstrap.\n");
|
| - return false;
|
| -#else // defined(DART_PRECOMPILER)
|
| - ASSERT(arg != NULL);
|
| - if ((arg[0] == '=') || (arg[0] == ':')) {
|
| - precompiled_snapshot_directory = &arg[1];
|
| - } else {
|
| - precompiled_snapshot_directory = arg;
|
| - }
|
| - gen_precompiled_snapshot = true;
|
| - vm_options->AddArgument("--precompilation");
|
| - return true;
|
| -#endif // defined(DART_PRECOMPILER)
|
| -}
|
| -
|
| -
|
| -static bool ProcessGenPrecompiledJITSnapshotOption(
|
| - const char* arg,
|
| - CommandLineOptions* vm_options) {
|
| - ASSERT(arg != NULL);
|
| - if ((arg[0] == '=') || (arg[0] == ':')) {
|
| - precompiled_snapshot_directory = &arg[1];
|
| - } else {
|
| - precompiled_snapshot_directory = arg;
|
| - }
|
| - gen_precompiled_jit_snapshot = true;
|
| - return true;
|
| -}
|
| -
|
| -
|
| -static bool ProcessRunPrecompiledSnapshotOption(
|
| - const char* arg,
|
| - CommandLineOptions* vm_options) {
|
| - ASSERT(arg != NULL);
|
| - precompiled_snapshot_directory = arg;
|
| - if ((precompiled_snapshot_directory[0] == '=') ||
|
| - (precompiled_snapshot_directory[0] == ':')) {
|
| - precompiled_snapshot_directory = &precompiled_snapshot_directory[1];
|
| - }
|
| - run_precompiled_snapshot = true;
|
| - vm_options->AddArgument("--precompilation");
|
| - return true;
|
| -}
|
| -
|
| -
|
| -static bool ProcessRunPrecompiledJITSnapshotOption(
|
| - const char* arg,
|
| - CommandLineOptions* vm_options) {
|
| - ASSERT(arg != NULL);
|
| - precompiled_snapshot_directory = arg;
|
| - if ((precompiled_snapshot_directory[0] == '=') ||
|
| - (precompiled_snapshot_directory[0] == ':')) {
|
| - precompiled_snapshot_directory = &precompiled_snapshot_directory[1];
|
| - }
|
| - run_precompiled_jit_snapshot = true;
|
| - return true;
|
| -}
|
| -
|
| -
|
| -static bool ProcessSnapshotOptionHelper(const char* filename,
|
| - bool* snapshot_option) {
|
| - ASSERT((filename != NULL) && (strlen(filename) != 0));
|
| +static bool ProcessSnapshotFilenameOption(const char* filename,
|
| + CommandLineOptions* vm_options) {
|
| 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;
|
| + if (gen_snapshot_kind == kNone) {
|
| + gen_snapshot_kind = kScript; // Default behavior.
|
| }
|
| return true;
|
| }
|
|
|
|
|
| -static bool ProcessScriptSnapshotOption(const char* filename,
|
| - CommandLineOptions* vm_options) {
|
| - 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_bootstrap'.
|
| - if (isolate_snapshot_buffer != NULL) {
|
| - Log::PrintErr("Full Application snapshots must be generated with"
|
| - " dart_bootstrap\n");
|
| - return false;
|
| +static bool ProcessSnapshotKindOption(const char* kind,
|
| + CommandLineOptions* vm_options) {
|
| + if (strcmp(kind, "script") == 0) {
|
| + gen_snapshot_kind = kScript;
|
| + return true;
|
| + } else if (strcmp(kind, "app-aot") == 0) {
|
| + gen_snapshot_kind = kAppAOT;
|
| + return true;
|
| + } else if (strcmp(kind, "app-jit-after-run") == 0) {
|
| + gen_snapshot_kind = kAppJITAfterRun;
|
| + return true;
|
| + } else if (strcmp(kind, "app-after-run") == 0) {
|
| + gen_snapshot_kind = kAppAfterRun;
|
| + return true;
|
| }
|
| - return ProcessSnapshotOptionHelper(filename,
|
| - &generate_full_snapshot_after_run);
|
| + Log::PrintErr("Unrecognized snapshot kind: '%s'\nValid kinds are: "
|
| + "script, app-aot, app-jit-after-run, app-after-run\n", kind);
|
| + return false;
|
| }
|
|
|
|
|
| -static bool ProcessRunFullSnapshotOption(
|
| +static bool ProcessRunAppSnapshotOption(
|
| const char* filename, CommandLineOptions* vm_options) {
|
| -#if !defined(PRODUCT)
|
| - Log::PrintErr("Full Application snapshots can only be be run with"
|
| - " product mode\n");
|
| - return false;
|
| -#else
|
| - return ProcessSnapshotOptionHelper(filename, &run_full_snapshot);
|
| -#endif // defined(PRODUCT)
|
| + ASSERT(filename != NULL);
|
| + snapshot_filename = filename;
|
| + run_app_snapshot = true;
|
| + return true;
|
| }
|
|
|
|
|
| @@ -562,17 +467,13 @@ static struct {
|
|
|
| // VM specific options to the standalone dart program.
|
| { "--compile_all", ProcessCompileAllOption },
|
| - { "--use_blobs", ProcessUseBlobsOption },
|
| { "--enable-vm-service", ProcessEnableVmServiceOption },
|
| - { "--gen-precompiled-snapshot", ProcessGenPrecompiledSnapshotOption },
|
| - { "--gen-precompiled-jit-snapshot", ProcessGenPrecompiledJITSnapshotOption },
|
| { "--observe", ProcessObserveOption },
|
| - { "--run-precompiled-snapshot", ProcessRunPrecompiledSnapshotOption },
|
| - { "--run-precompiled-jit-snapshot", ProcessRunPrecompiledJITSnapshotOption },
|
| { "--shutdown", ProcessShutdownOption },
|
| - { "--snapshot=", ProcessScriptSnapshotOption },
|
| - { "--full-snapshot-after-run=", ProcessFullSnapshotAfterRunOption },
|
| - { "--run-full-snapshot=", ProcessRunFullSnapshotOption },
|
| + { "--snapshot=", ProcessSnapshotFilenameOption },
|
| + { "--snapshot-kind=", ProcessSnapshotKindOption },
|
| + { "--run-app-snapshot=", ProcessRunAppSnapshotOption },
|
| + { "--use-blobs", ProcessUseBlobsOption },
|
| { "--trace-loading", ProcessTraceLoadingOption },
|
| { NULL, NULL }
|
| };
|
| @@ -689,25 +590,15 @@ static int ParseArguments(int argc,
|
| "file is invalid.\n");
|
| return -1;
|
| }
|
| - if (is_noopt) {
|
| - if (gen_precompiled_snapshot) {
|
| - Log::PrintErr("Running dart_noopt with --gen_precompiled_snapshot"
|
| - " is invalid.\n");
|
| - return -1;
|
| - }
|
| - if (run_precompiled_snapshot) {
|
| - Log::PrintErr("Running dart_noopt with --run_precompiled_snapshot"
|
| - " is invalid.\n");
|
| - return -1;
|
| - }
|
| + if (is_noopt && gen_snapshot_kind != kNone) {
|
| + Log::PrintErr("Generating a snapshot with dart_noopt is invalid.\n");
|
| + return -1;
|
| }
|
| - if (run_full_snapshot && run_precompiled_snapshot) {
|
| - Log::PrintErr("Specifying --run_full_snapshot and"
|
| - " --run_precompiled_snapshot is invalid.\n");
|
| + if ((gen_snapshot_kind != kNone) && (snapshot_filename == NULL)) {
|
| + Log::PrintErr("Generating a snapshot requires a filename (--snapshot).\n");
|
| return -1;
|
| }
|
| - if ((generate_full_snapshot_after_run || gen_precompiled_snapshot) &&
|
| - (run_full_snapshot || run_precompiled_snapshot)) {
|
| + if ((gen_snapshot_kind != kNone) && run_app_snapshot) {
|
| Log::PrintErr("Specifying an option to generate a snapshot and"
|
| " run using a snapshot is invalid.\n");
|
| return -1;
|
| @@ -798,16 +689,16 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| int* exit_code) {
|
| ASSERT(script_uri != NULL);
|
|
|
| + const bool needs_load_port = !run_app_snapshot;
|
| #if defined(PRODUCT)
|
| - const bool run_service_isolate = !run_full_snapshot &&
|
| - !run_precompiled_snapshot;
|
| + const bool run_service_isolate = needs_load_port;
|
| #else
|
| - const bool run_service_isolate = !run_full_snapshot;
|
| + // Always create the service isolate in DEBUG and RELEASE modes for profiling,
|
| + // even if we don't need it for loading.
|
| + const bool run_service_isolate = true;
|
| #endif // PRODUCT
|
| if (!run_service_isolate &&
|
| (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) {
|
| - // We do not create a service isolate when running a full application
|
| - // snapshot or a precompiled snapshot in product mode.
|
| return NULL;
|
| }
|
|
|
| @@ -839,8 +730,7 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
|
|
| if (Dart_IsServiceIsolate(isolate)) {
|
| // If this is the service isolate, load embedder specific bits and return.
|
| - bool skip_library_load = run_precompiled_snapshot ||
|
| - run_precompiled_jit_snapshot;
|
| + bool skip_library_load = run_app_snapshot;
|
| if (!VmService::Setup(vm_service_server_ip,
|
| vm_service_server_port,
|
| skip_library_load)) {
|
| @@ -862,14 +752,9 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| result = DartUtils::PrepareForScriptLoading(false, trace_loading);
|
| CHECK_RESULT(result);
|
|
|
| - if (!run_precompiled_snapshot &&
|
| - !run_precompiled_jit_snapshot &&
|
| - !run_full_snapshot) {
|
| + if (needs_load_port) {
|
| // Set up the load port provided by the service isolate so that we can
|
| // load scripts.
|
| - // With a full snapshot or a precompiled snapshot in product mode, there is
|
| - // no service isolate. A precompiled snapshot in release or debug mode does
|
| - // have the service isolate, but it doesn't use it for loading.
|
| result = DartUtils::SetupServiceLoadPort();
|
| CHECK_RESULT(result);
|
| }
|
| @@ -881,9 +766,7 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| result = Dart_SetEnvironmentCallback(EnvironmentCallback);
|
| CHECK_RESULT(result);
|
|
|
| - if (run_precompiled_snapshot) {
|
| - // No setup.
|
| - } else if (run_full_snapshot || run_precompiled_jit_snapshot) {
|
| + if (run_app_snapshot) {
|
| result = DartUtils::SetupIOLibrary(script_uri);
|
| CHECK_RESULT(result);
|
| } else {
|
| @@ -1244,19 +1127,13 @@ static void* LoadLibrarySymbol(const char* snapshot_directory,
|
| qualified_libname = libname;
|
| }
|
| void* library = Extensions::LoadExtensionLibrary(qualified_libname);
|
| - if (library == NULL) {
|
| - Log::PrintErr("Error: Failed to load library '%s'\n", qualified_libname);
|
| - Platform::Exit(kErrorExitCode);
|
| - }
|
| - void* symbol = Extensions::ResolveSymbol(library, symname);
|
| - if (symbol == NULL) {
|
| - Log::PrintErr("Error: Failed to load symbol '%s'\n", symname);
|
| - Platform::Exit(kErrorExitCode);
|
| - }
|
| if (concat != NULL) {
|
| delete concat;
|
| }
|
| - return symbol;
|
| + if (library == NULL) {
|
| + return NULL;
|
| + }
|
| + return Extensions::ResolveSymbol(library, symname);
|
| }
|
|
|
|
|
| @@ -1273,19 +1150,6 @@ static void GenerateScriptSnapshot() {
|
| }
|
|
|
|
|
| -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);
|
| -}
|
| -
|
| -
|
| static void GeneratePrecompiledSnapshot() {
|
| uint8_t* vm_isolate_buffer = NULL;
|
| intptr_t vm_isolate_size = 0;
|
| @@ -1320,30 +1184,25 @@ static void GeneratePrecompiledSnapshot() {
|
| if (Dart_IsError(result)) {
|
| ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
| }
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledVmIsolateName,
|
| + WriteSnapshotFile(snapshot_filename, kVMIsolateSuffix,
|
| false,
|
| vm_isolate_buffer,
|
| vm_isolate_size);
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledIsolateName,
|
| + WriteSnapshotFile(snapshot_filename, kIsolateSuffix,
|
| false,
|
| isolate_buffer,
|
| isolate_size);
|
| if (use_blobs) {
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledInstructionsBlobName,
|
| + WriteSnapshotFile(snapshot_filename, kInstructionsSuffix,
|
| false,
|
| instructions_blob_buffer,
|
| instructions_blob_size);
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledRodataBlobName,
|
| + WriteSnapshotFile(snapshot_filename, kRODataSuffix,
|
| false,
|
| rodata_blob_buffer,
|
| rodata_blob_size);
|
| } else {
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledAssemblyName,
|
| + WriteSnapshotFile(snapshot_filename, kAssemblySuffix,
|
| false,
|
| assembly_buffer,
|
| assembly_size);
|
| @@ -1352,6 +1211,10 @@ static void GeneratePrecompiledSnapshot() {
|
|
|
|
|
| static void GeneratePrecompiledJITSnapshot() {
|
| + if (!use_blobs) {
|
| + ErrorExit(kErrorExitCode,
|
| + "Generating app JIT snapshots as assembly unimplemented\n");
|
| + }
|
| uint8_t* vm_isolate_buffer = NULL;
|
| intptr_t vm_isolate_size = 0;
|
| uint8_t* isolate_buffer = NULL;
|
| @@ -1372,23 +1235,19 @@ static void GeneratePrecompiledJITSnapshot() {
|
| if (Dart_IsError(result)) {
|
| ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
| }
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledVmIsolateName,
|
| + WriteSnapshotFile(snapshot_filename, kVMIsolateSuffix,
|
| false,
|
| vm_isolate_buffer,
|
| vm_isolate_size);
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledIsolateName,
|
| + WriteSnapshotFile(snapshot_filename, kIsolateSuffix,
|
| false,
|
| isolate_buffer,
|
| isolate_size);
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledInstructionsBlobName,
|
| + WriteSnapshotFile(snapshot_filename, kInstructionsSuffix,
|
| false,
|
| instructions_blob_buffer,
|
| instructions_blob_size);
|
| - WriteSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledRodataBlobName,
|
| + WriteSnapshotFile(snapshot_filename, kRODataSuffix,
|
| false,
|
| rodata_blob_buffer,
|
| rodata_blob_size);
|
| @@ -1402,8 +1261,6 @@ static void GenerateFullSnapshot() {
|
| 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,
|
| @@ -1413,17 +1270,13 @@ static void GenerateFullSnapshot() {
|
| ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
|
| }
|
|
|
| - // Compute snapshot file names and write out the snapshot files.
|
| - ComputeSnapshotFilenames(snapshot_filename,
|
| - &vm_snapshot_fname,
|
| - &isolate_snapshot_fname);
|
| - WriteSnapshotFile(NULL,
|
| - vm_snapshot_fname,
|
| + WriteSnapshotFile(snapshot_filename,
|
| + kVMIsolateSuffix,
|
| false,
|
| vm_isolate_buffer,
|
| vm_isolate_size);
|
| - WriteSnapshotFile(NULL,
|
| - isolate_snapshot_fname,
|
| + WriteSnapshotFile(snapshot_filename,
|
| + kIsolateSuffix,
|
| false,
|
| isolate_buffer,
|
| isolate_size);
|
| @@ -1486,7 +1339,7 @@ bool RunMainIsolate(const char* script_name,
|
|
|
| Dart_EnterScope();
|
|
|
| - if (generate_script_snapshot) {
|
| + if (gen_snapshot_kind == kScript) {
|
| GenerateScriptSnapshot();
|
| } else {
|
| // Lookup the library of the root script.
|
| @@ -1498,9 +1351,12 @@ bool RunMainIsolate(const char* script_name,
|
| result = Dart_LibraryImportLibrary(
|
| isolate_data->builtin_lib(), root_lib, Dart_Null());
|
| #if !defined(PRODUCT)
|
| - if (is_noopt || gen_precompiled_snapshot || gen_precompiled_jit_snapshot) {
|
| + if (is_noopt ||
|
| + (gen_snapshot_kind == kAppAfterRun) ||
|
| + (gen_snapshot_kind == kAppAOT) ||
|
| + (gen_snapshot_kind == kAppJITAfterRun)) {
|
| // Load the embedder's portion of the VM service's Dart code so it will
|
| - // be included in the precompiled snapshot.
|
| + // be included in the app snapshot.
|
| if (!VmService::LoadForGenPrecompiled()) {
|
| fprintf(stderr,
|
| "VM service loading failed: %s\n",
|
| @@ -1516,7 +1372,7 @@ bool RunMainIsolate(const char* script_name,
|
| CHECK_RESULT(result);
|
| }
|
|
|
| - if (is_noopt || gen_precompiled_snapshot) {
|
| + if (is_noopt || (gen_snapshot_kind == kAppAOT)) {
|
| Dart_QualifiedFunctionName standalone_entry_points[] = {
|
| { "dart:_builtin", "::", "_getMainClosure" },
|
| { "dart:_builtin", "::", "_getPrintClosure" },
|
| @@ -1551,12 +1407,12 @@ bool RunMainIsolate(const char* script_name,
|
| { NULL, NULL, NULL } // Must be terminated with NULL entries.
|
| };
|
|
|
| - const bool reset_fields = gen_precompiled_snapshot;
|
| + const bool reset_fields = gen_snapshot_kind == kAppAOT;
|
| result = Dart_Precompile(standalone_entry_points, reset_fields);
|
| CHECK_RESULT(result);
|
| }
|
|
|
| - if (gen_precompiled_snapshot) {
|
| + if (gen_snapshot_kind == kAppAOT) {
|
| GeneratePrecompiledSnapshot();
|
| } else {
|
| if (Dart_IsNull(root_lib)) {
|
| @@ -1588,11 +1444,12 @@ bool RunMainIsolate(const char* script_name,
|
|
|
| // Keep handling messages until the last active receive port is closed.
|
| result = Dart_RunLoop();
|
| - // Generate a full snapshot after execution if specified.
|
| - if (generate_full_snapshot_after_run || gen_precompiled_jit_snapshot) {
|
| + // Generate an app snapshot after execution if specified.
|
| + if ((gen_snapshot_kind == kAppAfterRun) ||
|
| + (gen_snapshot_kind == kAppJITAfterRun)) {
|
| if (!Dart_IsCompilationError(result) &&
|
| !Dart_IsVMRestartRequest(result)) {
|
| - if (generate_full_snapshot_after_run) {
|
| + if (gen_snapshot_kind == kAppAfterRun) {
|
| GenerateFullSnapshot();
|
| } else {
|
| Dart_Handle prepare_result = Dart_PrecompileJIT();
|
| @@ -1756,20 +1613,17 @@ void main(int argc, char** argv) {
|
| Platform::Exit(kErrorExitCode);
|
| }
|
|
|
| -#if !defined(PRODUCT)
|
| - // Constant true in PRODUCT mode.
|
| - if (generate_script_snapshot ||
|
| - generate_full_snapshot_after_run ||
|
| - run_full_snapshot ||
|
| - gen_precompiled_jit_snapshot ||
|
| - run_precompiled_jit_snapshot) {
|
| +#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
|
| + // Constant true if PRODUCT or DART_PRECOMPILED_RUNTIME.
|
| + if ((gen_snapshot_kind != kNone) || run_app_snapshot) {
|
| vm_options.AddArgument("--load_deferred_eagerly");
|
| }
|
| #endif
|
|
|
| -#if defined(DART_PRECOMPILER) && !defined(DART_NO_SNAPSHOT)
|
| - // Always set --precompilation with dart_noopt.
|
| - ASSERT(!gen_precompiled_snapshot && !run_precompiled_snapshot);
|
| + if ((gen_snapshot_kind == kAppAOT) || is_noopt) {
|
| + vm_options.AddArgument("--precompilation");
|
| + }
|
| +#if defined(DART_PRECOMPILED_RUNTIME)
|
| vm_options.AddArgument("--precompilation");
|
| #endif
|
|
|
| @@ -1781,43 +1635,27 @@ void main(int argc, char** argv) {
|
|
|
| const uint8_t* instructions_snapshot = NULL;
|
| const uint8_t* data_snapshot = NULL;
|
| - if (run_precompiled_snapshot || run_precompiled_jit_snapshot) {
|
| - ReadSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledVmIsolateName,
|
| + if (run_app_snapshot) {
|
| + ReadSnapshotFile(snapshot_filename, kVMIsolateSuffix,
|
| &vm_isolate_snapshot_buffer);
|
| - ReadSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledIsolateName,
|
| + ReadSnapshotFile(snapshot_filename, kIsolateSuffix,
|
| &isolate_snapshot_buffer);
|
| if (use_blobs) {
|
| - ReadExecutableSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledInstructionsBlobName,
|
| + ReadExecutableSnapshotFile(snapshot_filename,
|
| + kInstructionsSuffix,
|
| &instructions_snapshot);
|
| - ReadSnapshotFile(precompiled_snapshot_directory,
|
| - kPrecompiledRodataBlobName,
|
| + ReadSnapshotFile(snapshot_filename, kRODataSuffix,
|
| &data_snapshot);
|
| } else {
|
| instructions_snapshot = reinterpret_cast<const uint8_t*>(
|
| - LoadLibrarySymbol(precompiled_snapshot_directory,
|
| + LoadLibrarySymbol(snapshot_filename,
|
| kPrecompiledLibraryName,
|
| kPrecompiledInstructionsSymbolName));
|
| data_snapshot = reinterpret_cast<const uint8_t*>(
|
| - LoadLibrarySymbol(precompiled_snapshot_directory,
|
| + LoadLibrarySymbol(snapshot_filename,
|
| kPrecompiledLibraryName,
|
| kPrecompiledDataSymbolName));
|
| }
|
| - } 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.
|
|
|