Chromium Code Reviews| Index: runtime/bin/main.cc |
| diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc |
| index 07365e18362baeeef432dcae4c7b90c0fa55bd52..9b5ca4506b3ceebbb5ad3983710a9b41bcffbf9f 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 const char* snapshot_filename = NULL; |
| +enum SnapshotKind { |
| + kNone, |
| + kScript, |
| + kPrecompiled, |
| + kPrecompiledJIT, |
| + kFullAfterRun, |
| +}; |
| +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,41 @@ 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, "precompiled") == 0) { |
| + gen_snapshot_kind = kPrecompiled; |
| + return true; |
| + } else if (strcmp(kind, "precompiled-jit") == 0) { |
| + gen_snapshot_kind = kPrecompiledJIT; |
| + return true; |
| + } else if (strcmp(kind, "full-after-run") == 0) { |
| + gen_snapshot_kind = kFullAfterRun; |
| + return true; |
| } |
|
siva
2016/05/05 22:38:43
As discussed offline, I am wondering if this list
rmacnak
2016/05/06 00:19:46
Updated the names and changed --run-full-snapshot
|
| - return ProcessSnapshotOptionHelper(filename, |
| - &generate_full_snapshot_after_run); |
| + return false; |
| } |
| static bool ProcessRunFullSnapshotOption( |
| 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_full_snapshot = true; |
| + return true; |
| } |
| @@ -562,17 +465,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 }, |
| + { "--snapshot=", ProcessSnapshotFilenameOption }, |
| + { "--snapshot-kind=", ProcessSnapshotKindOption }, |
| { "--run-full-snapshot=", ProcessRunFullSnapshotOption }, |
| + { "--use-blobs", ProcessUseBlobsOption }, |
| { "--trace-loading", ProcessTraceLoadingOption }, |
| { NULL, NULL } |
| }; |
| @@ -689,25 +588,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_full_snapshot) { |
| Log::PrintErr("Specifying an option to generate a snapshot and" |
| " run using a snapshot is invalid.\n"); |
| return -1; |
| @@ -798,16 +687,16 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| int* exit_code) { |
| ASSERT(script_uri != NULL); |
| + const bool needs_load_port = !run_full_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 +728,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_full_snapshot; |
| if (!VmService::Setup(vm_service_server_ip, |
| vm_service_server_port, |
| skip_library_load)) { |
| @@ -862,9 +750,7 @@ 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 |
| @@ -881,9 +767,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_full_snapshot) { |
| result = DartUtils::SetupIOLibrary(script_uri); |
| CHECK_RESULT(result); |
| } else { |
| @@ -1244,17 +1128,15 @@ static void* LoadLibrarySymbol(const char* snapshot_directory, |
| qualified_libname = libname; |
| } |
| void* library = Extensions::LoadExtensionLibrary(qualified_libname); |
| + if (concat != NULL) { |
| + delete concat; |
| + } |
| if (library == NULL) { |
| - Log::PrintErr("Error: Failed to load library '%s'\n", qualified_libname); |
| - Platform::Exit(kErrorExitCode); |
| + return NULL; |
| } |
| 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 NULL; |
| } |
| return symbol; |
|
siva
2016/05/05 22:38:43
why do you have the NULL check and return NULL why
rmacnak
2016/05/06 00:19:46
Done.
|
| } |
| @@ -1273,19 +1155,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 +1189,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); |
| @@ -1372,23 +1236,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 +1262,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 +1271,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 +1340,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,7 +1352,10 @@ 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 == kFullAfterRun) || |
| + (gen_snapshot_kind == kPrecompiled) || |
| + (gen_snapshot_kind == kPrecompiledJIT)) { |
| // Load the embedder's portion of the VM service's Dart code so it will |
| // be included in the precompiled snapshot. |
|
siva
2016/05/05 22:38:44
the comment says precompiled snapshot but should p
rmacnak
2016/05/06 00:19:46
Changed to 'app snapshot'
|
| if (!VmService::LoadForGenPrecompiled()) { |
| @@ -1516,7 +1373,7 @@ bool RunMainIsolate(const char* script_name, |
| CHECK_RESULT(result); |
| } |
| - if (is_noopt || gen_precompiled_snapshot) { |
| + if (is_noopt || (gen_snapshot_kind == kPrecompiled)) { |
| Dart_QualifiedFunctionName standalone_entry_points[] = { |
| { "dart:_builtin", "::", "_getMainClosure" }, |
| { "dart:_builtin", "::", "_getPrintClosure" }, |
| @@ -1551,12 +1408,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 == kPrecompiled; |
| result = Dart_Precompile(standalone_entry_points, reset_fields); |
| CHECK_RESULT(result); |
| } |
| - if (gen_precompiled_snapshot) { |
| + if (gen_snapshot_kind == kPrecompiled) { |
| GeneratePrecompiledSnapshot(); |
| } else { |
| if (Dart_IsNull(root_lib)) { |
| @@ -1589,10 +1446,11 @@ 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) { |
| + if ((gen_snapshot_kind == kFullAfterRun) || |
| + (gen_snapshot_kind == kPrecompiledJIT)) { |
| if (!Dart_IsCompilationError(result) && |
| !Dart_IsVMRestartRequest(result)) { |
| - if (generate_full_snapshot_after_run) { |
| + if (gen_snapshot_kind == kFullAfterRun) { |
| GenerateFullSnapshot(); |
| } else { |
| Dart_Handle prepare_result = Dart_PrecompileJIT(); |
| @@ -1756,20 +1614,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_full_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 == kPrecompiled) || is_noopt) { |
| + vm_options.AddArgument("--precompilation"); |
| + } |
| +#if defined(DART_PRECOMPILED_RUNTIME) |
| vm_options.AddArgument("--precompilation"); |
| #endif |
| @@ -1781,43 +1636,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_full_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. |