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

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

Issue 2637193002: Support spawnUri in app snapshots. (Closed)
Patch Set: Created 3 years, 11 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 | runtime/bin/snapshot_empty.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) 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 22 matching lines...) Expand all
33 33
34 namespace dart { 34 namespace dart {
35 namespace bin { 35 namespace bin {
36 36
37 // vm_isolate_snapshot_buffer points to a snapshot for the vm isolate if we 37 // vm_isolate_snapshot_buffer points to a snapshot for the vm isolate if we
38 // link in a snapshot otherwise it is initialized to NULL. 38 // link in a snapshot otherwise it is initialized to NULL.
39 extern const uint8_t* vm_isolate_snapshot_buffer; 39 extern const uint8_t* vm_isolate_snapshot_buffer;
40 40
41 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a 41 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a
42 // snapshot otherwise it is initialized to NULL. 42 // snapshot otherwise it is initialized to NULL.
43 extern const uint8_t* isolate_snapshot_buffer; 43 extern const uint8_t* core_isolate_snapshot_buffer;
44
44 45
45 /** 46 /**
46 * Global state used to control and store generation of application snapshots 47 * Global state used to control and store generation of application snapshots
47 * An application snapshot can be generated and run using the following 48 * An application snapshot can be generated and run using the following
48 * command 49 * command
49 * dart --snapshot-kind=app-jit --snapshot=<app_snapshot_filename> 50 * dart --snapshot-kind=app-jit --snapshot=<app_snapshot_filename>
50 * <script_uri> [<script_options>] 51 * <script_uri> [<script_options>]
51 * To Run the application snapshot generated above, use : 52 * To Run the application snapshot generated above, use :
52 * dart <app_snapshot_filename> [<script_options>] 53 * dart <app_snapshot_filename> [<script_options>]
53 */ 54 */
54 static bool run_app_snapshot = false; 55 static bool vm_run_app_snapshot = false;
55 static const char* snapshot_filename = NULL; 56 static const char* snapshot_filename = NULL;
56 enum SnapshotKind { 57 enum SnapshotKind {
57 kNone, 58 kNone,
58 kScript, 59 kScript,
59 kAppAOT, 60 kAppAOT,
60 kAppJIT, 61 kAppJIT,
61 }; 62 };
62 static SnapshotKind gen_snapshot_kind = kNone; 63 static SnapshotKind gen_snapshot_kind = kNone;
63 64
64 static bool use_dart_frontend = false; 65 static bool use_dart_frontend = false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 extern const char* kPrecompiledIsolateSymbolName; 102 extern const char* kPrecompiledIsolateSymbolName;
102 extern const char* kPrecompiledInstructionsSymbolName; 103 extern const char* kPrecompiledInstructionsSymbolName;
103 extern const char* kPrecompiledDataSymbolName; 104 extern const char* kPrecompiledDataSymbolName;
104 105
105 106
106 // Global flag that is used to indicate that we want to trace resolution of 107 // Global flag that is used to indicate that we want to trace resolution of
107 // URIs and the loading of libraries, parts and scripts. 108 // URIs and the loading of libraries, parts and scripts.
108 static bool trace_loading = false; 109 static bool trace_loading = false;
109 110
110 111
112 static char* app_script_uri = NULL;
113 static const uint8_t* app_isolate_snapshot_buffer = NULL;
114
115
111 static Dart_Isolate main_isolate = NULL; 116 static Dart_Isolate main_isolate = NULL;
112 117
113 118
114 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "localhost"; 119 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "localhost";
115 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; 120 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181;
116 // VM Service options. 121 // VM Service options.
117 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; 122 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP;
118 // The 0 port is a magic value which results in the first available port 123 // The 0 port is a magic value which results in the first available port
119 // being allocated. 124 // being allocated.
120 static int vm_service_server_port = -1; 125 static int vm_service_server_port = -1;
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 } 721 }
717 if ((commandline_packages_file != NULL) && 722 if ((commandline_packages_file != NULL) &&
718 (strlen(commandline_packages_file) == 0)) { 723 (strlen(commandline_packages_file) == 0)) {
719 Log::PrintErr("Empty package file name specified.\n"); 724 Log::PrintErr("Empty package file name specified.\n");
720 return -1; 725 return -1;
721 } 726 }
722 if ((gen_snapshot_kind != kNone) && (snapshot_filename == NULL)) { 727 if ((gen_snapshot_kind != kNone) && (snapshot_filename == NULL)) {
723 Log::PrintErr("Generating a snapshot requires a filename (--snapshot).\n"); 728 Log::PrintErr("Generating a snapshot requires a filename (--snapshot).\n");
724 return -1; 729 return -1;
725 } 730 }
726 if ((gen_snapshot_kind != kNone) && run_app_snapshot) { 731 if ((gen_snapshot_kind != kNone) && vm_run_app_snapshot) {
727 Log::PrintErr( 732 Log::PrintErr(
728 "Specifying an option to generate a snapshot and" 733 "Specifying an option to generate a snapshot and"
729 " run using a snapshot is invalid.\n"); 734 " run using a snapshot is invalid.\n");
730 return -1; 735 return -1;
731 } 736 }
732 737
733 return 0; 738 return 0;
734 } 739 }
735 740
736 741
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 Dart_ExitScope(); \ 805 Dart_ExitScope(); \
801 Dart_ShutdownIsolate(); \ 806 Dart_ShutdownIsolate(); \
802 return NULL; \ 807 return NULL; \
803 } 808 }
804 809
805 810
806 static void SnapshotOnExitHook(int64_t exit_code); 811 static void SnapshotOnExitHook(int64_t exit_code);
807 812
808 813
809 // Returns true on success, false on failure. 814 // Returns true on success, false on failure.
810 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, 815 static Dart_Isolate CreateIsolateAndSetupHelper(bool is_main_isolate,
816 const char* script_uri,
811 const char* main, 817 const char* main,
812 const char* package_root, 818 const char* package_root,
813 const char* packages_config, 819 const char* packages_config,
814 Dart_IsolateFlags* flags, 820 Dart_IsolateFlags* flags,
815 char** error, 821 char** error,
816 int* exit_code) { 822 int* exit_code) {
817 ASSERT(script_uri != NULL); 823 ASSERT(script_uri != NULL);
818 if (strcmp(script_uri, DART_KERNEL_ISOLATE_NAME) == 0) { 824 if (strcmp(script_uri, DART_KERNEL_ISOLATE_NAME) == 0) {
819 if (!use_dart_frontend) { 825 if (!use_dart_frontend) {
820 *error = strdup("Kernel isolate not supported."); 826 *error = strdup("Kernel isolate not supported.");
821 return NULL; 827 return NULL;
822 } else { 828 } else {
823 if (packages_config == NULL) { 829 if (packages_config == NULL) {
824 packages_config = commandline_packages_file; 830 packages_config = commandline_packages_file;
825 } 831 }
826 } 832 }
827 } 833 }
828 834
835 #if defined(DART_PRECOMPILED_RUNTIME)
836 // AOT: All isolates start from the app snapshot.
837 bool isolate_run_app_snapshot = true;
838 const uint8_t* isolate_snapshot_buffer = app_isolate_snapshot_buffer;
839 #else
840 // JIT: Main isolate starts from the app snapshot, if any. Other use the
841 // core libraries snapshot.
842 bool isolate_run_app_snapshot = false;
843 const uint8_t* isolate_snapshot_buffer = core_isolate_snapshot_buffer;
844 if ((app_isolate_snapshot_buffer != NULL) &&
845 (is_main_isolate || ((app_script_uri != NULL) &&
846 (strcmp(script_uri, app_script_uri) == 0)))) {
847 isolate_run_app_snapshot = true;
848 isolate_snapshot_buffer = app_isolate_snapshot_buffer;
849 }
850 #endif
851
829 // If the script is a Kernel binary, then we will try to bootstrap from the 852 // If the script is a Kernel binary, then we will try to bootstrap from the
830 // script. 853 // script.
831 const uint8_t* kernel_file = NULL; 854 const uint8_t* kernel_file = NULL;
832 intptr_t kernel_length = -1; 855 intptr_t kernel_length = -1;
833 const bool is_kernel = 856 const bool is_kernel =
834 !run_app_snapshot && 857 !isolate_run_app_snapshot &&
835 TryReadKernel(script_uri, &kernel_file, &kernel_length); 858 TryReadKernel(script_uri, &kernel_file, &kernel_length);
836 859
837 void* kernel_program = NULL; 860 void* kernel_program = NULL;
838 if (is_kernel) { 861 if (is_kernel) {
839 kernel_program = Dart_ReadKernelBinary(kernel_file, kernel_length); 862 kernel_program = Dart_ReadKernelBinary(kernel_file, kernel_length);
840 free(const_cast<uint8_t*>(kernel_file)); 863 free(const_cast<uint8_t*>(kernel_file));
841 } 864 }
842 865
843 IsolateData* isolate_data = 866 IsolateData* isolate_data =
844 new IsolateData(script_uri, package_root, packages_config); 867 new IsolateData(script_uri, package_root, packages_config);
(...skipping 15 matching lines...) Expand all
860 883
861 if (is_kernel) { 884 if (is_kernel) {
862 Dart_Handle result = Dart_LoadKernel(kernel_program); 885 Dart_Handle result = Dart_LoadKernel(kernel_program);
863 CHECK_RESULT(result); 886 CHECK_RESULT(result);
864 } 887 }
865 if (is_kernel || (isolate_snapshot_buffer != NULL)) { 888 if (is_kernel || (isolate_snapshot_buffer != NULL)) {
866 // Setup the native resolver as the snapshot does not carry it. 889 // Setup the native resolver as the snapshot does not carry it.
867 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 890 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
868 Builtin::SetNativeResolver(Builtin::kIOLibrary); 891 Builtin::SetNativeResolver(Builtin::kIOLibrary);
869 } 892 }
870 if (run_app_snapshot) { 893 if (isolate_run_app_snapshot) {
871 Dart_Handle result = Loader::ReloadNativeExtensions(); 894 Dart_Handle result = Loader::ReloadNativeExtensions();
872 CHECK_RESULT(result); 895 CHECK_RESULT(result);
873 } 896 }
874 897
875 if (Dart_IsServiceIsolate(isolate)) { 898 if (Dart_IsServiceIsolate(isolate)) {
876 // If this is the service isolate, load embedder specific bits and return. 899 // If this is the service isolate, load embedder specific bits and return.
877 bool skip_library_load = run_app_snapshot; 900 bool skip_library_load = isolate_run_app_snapshot;
878 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port, 901 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port,
879 skip_library_load, vm_service_dev_mode)) { 902 skip_library_load, vm_service_dev_mode)) {
880 *error = strdup(VmService::GetErrorMessage()); 903 *error = strdup(VmService::GetErrorMessage());
881 return NULL; 904 return NULL;
882 } 905 }
883 if (compile_all) { 906 if (compile_all) {
884 result = Dart_CompileAll(); 907 result = Dart_CompileAll();
885 CHECK_RESULT(result); 908 CHECK_RESULT(result);
886 } 909 }
887 result = Dart_SetEnvironmentCallback(EnvironmentCallback); 910 result = Dart_SetEnvironmentCallback(EnvironmentCallback);
(...skipping 28 matching lines...) Expand all
916 if (!Dart_IsKernelIsolate(isolate) && use_dart_frontend) { 939 if (!Dart_IsKernelIsolate(isolate) && use_dart_frontend) {
917 // This must be the main script to be loaded. Wait for Kernel isolate 940 // This must be the main script to be loaded. Wait for Kernel isolate
918 // to finish initialization. 941 // to finish initialization.
919 Dart_Port port = Dart_ServiceWaitForKernelPort(); 942 Dart_Port port = Dart_ServiceWaitForKernelPort();
920 if (port == ILLEGAL_PORT) { 943 if (port == ILLEGAL_PORT) {
921 *error = strdup("Error while initializing Kernel isolate"); 944 *error = strdup("Error while initializing Kernel isolate");
922 return NULL; 945 return NULL;
923 } 946 }
924 } 947 }
925 948
926 if (run_app_snapshot) { 949 if (isolate_run_app_snapshot) {
927 result = DartUtils::SetupIOLibrary(script_uri); 950 result = DartUtils::SetupIOLibrary(script_uri);
928 CHECK_RESULT(result); 951 CHECK_RESULT(result);
929 Loader::InitForSnapshot(script_uri); 952 Loader::InitForSnapshot(script_uri);
953 #if !defined(DART_PRECOMPILED_RUNTIME)
954 if (is_main_isolate) {
955 // Find the canonical uri of the app snapshot. We'll use this to decide if
956 // other isolates should use the app snapshot or the core snapshot.
957 const char* resolved_script_uri = NULL;
958 result = Dart_StringToCString(
959 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)),
960 &resolved_script_uri);
961 CHECK_RESULT(result);
962 ASSERT(app_script_uri == NULL);
963 app_script_uri = strdup(resolved_script_uri);
964 }
965 #endif // !defined(DART_PRECOMPILED_RUNTIME)
930 } else { 966 } else {
931 // Load the specified application script into the newly created isolate. 967 // Load the specified application script into the newly created isolate.
932 Dart_Handle uri = 968 Dart_Handle uri =
933 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)); 969 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri));
934 CHECK_RESULT(uri); 970 CHECK_RESULT(uri);
935 if (!is_kernel) { 971 if (!is_kernel) {
936 result = Loader::LibraryTagHandler(Dart_kScriptTag, Dart_Null(), uri); 972 result = Loader::LibraryTagHandler(Dart_kScriptTag, Dart_Null(), uri);
937 CHECK_RESULT(result); 973 CHECK_RESULT(result);
938 } 974 }
939 975
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 // The VM should never call the isolate helper with a NULL flags. 1008 // The VM should never call the isolate helper with a NULL flags.
973 ASSERT(flags != NULL); 1009 ASSERT(flags != NULL);
974 ASSERT(flags->version == DART_FLAGS_CURRENT_VERSION); 1010 ASSERT(flags->version == DART_FLAGS_CURRENT_VERSION);
975 if ((package_root != NULL) && (package_config != NULL)) { 1011 if ((package_root != NULL) && (package_config != NULL)) {
976 *error = strdup( 1012 *error = strdup(
977 "Invalid arguments - Cannot simultaneously specify " 1013 "Invalid arguments - Cannot simultaneously specify "
978 "package root and package map."); 1014 "package root and package map.");
979 return NULL; 1015 return NULL;
980 } 1016 }
981 1017
1018 bool is_main_isolate = false;
982 int exit_code = 0; 1019 int exit_code = 0;
983 return CreateIsolateAndSetupHelper(script_uri, main, package_root, 1020 return CreateIsolateAndSetupHelper(is_main_isolate, script_uri, main,
984 package_config, flags, error, &exit_code); 1021 package_root, package_config, flags, error,
1022 &exit_code);
985 } 1023 }
986 1024
987 1025
988 static void PrintVersion() { 1026 static void PrintVersion() {
989 Log::PrintErr("Dart VM version: %s\n", Dart_VersionString()); 1027 Log::PrintErr("Dart VM version: %s\n", Dart_VersionString());
990 } 1028 }
991 1029
992 1030
993 // clang-format off 1031 // clang-format off
994 static void PrintUsage() { 1032 static void PrintUsage() {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 &isolate_buffer, &isolate_size, &instructions_blob_buffer, 1554 &isolate_buffer, &isolate_size, &instructions_blob_buffer,
1517 &instructions_blob_size, &rodata_blob_buffer, &rodata_blob_size); 1555 &instructions_blob_size, &rodata_blob_buffer, &rodata_blob_size);
1518 if (Dart_IsError(result)) { 1556 if (Dart_IsError(result)) {
1519 ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result)); 1557 ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
1520 } 1558 }
1521 WriteAppSnapshot(snapshot_filename, vm_isolate_buffer, vm_isolate_size, 1559 WriteAppSnapshot(snapshot_filename, vm_isolate_buffer, vm_isolate_size,
1522 isolate_buffer, isolate_size, instructions_blob_buffer, 1560 isolate_buffer, isolate_size, instructions_blob_buffer,
1523 instructions_blob_size, rodata_blob_buffer, 1561 instructions_blob_size, rodata_blob_buffer,
1524 rodata_blob_size); 1562 rodata_blob_size);
1525 #else 1563 #else
1526 uint8_t* vm_isolate_buffer = NULL;
rmacnak 2017/01/17 18:42:21 Rewriting the vm isolate here created a mismatch b
1527 intptr_t vm_isolate_size = 0;
1528 uint8_t* isolate_buffer = NULL; 1564 uint8_t* isolate_buffer = NULL;
1529 intptr_t isolate_size = 0; 1565 intptr_t isolate_size = 0;
1530 1566
1531 Dart_Handle result = Dart_CreateSnapshot(&vm_isolate_buffer, &vm_isolate_size, 1567 Dart_Handle result =
1532 &isolate_buffer, &isolate_size); 1568 Dart_CreateSnapshot(NULL, NULL, &isolate_buffer, &isolate_size);
1533 if (Dart_IsError(result)) { 1569 if (Dart_IsError(result)) {
1534 ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result)); 1570 ErrorExit(kErrorExitCode, "%s\n", Dart_GetError(result));
1535 } 1571 }
1536 1572
1537 WriteAppSnapshot(snapshot_filename, vm_isolate_buffer, vm_isolate_size, 1573 WriteAppSnapshot(snapshot_filename, NULL, 0, isolate_buffer, isolate_size,
1538 isolate_buffer, isolate_size, NULL, 0, NULL, 0); 1574 NULL, 0, NULL, 0);
1539 #endif // defined(TARGET_ARCH_X64) 1575 #endif // defined(TARGET_ARCH_X64)
1540 } 1576 }
1541 1577
1542 1578
1543 #define CHECK_RESULT(result) \ 1579 #define CHECK_RESULT(result) \
1544 if (Dart_IsError(result)) { \ 1580 if (Dart_IsError(result)) { \
1545 if (Dart_IsVMRestartRequest(result)) { \ 1581 if (Dart_IsVMRestartRequest(result)) { \
1546 Dart_ExitScope(); \ 1582 Dart_ExitScope(); \
1547 Dart_ShutdownIsolate(); \ 1583 Dart_ShutdownIsolate(); \
1548 return true; \ 1584 return true; \
(...skipping 16 matching lines...) Expand all
1565 if (exit_code == 0) { 1601 if (exit_code == 0) {
1566 GenerateAppJITSnapshot(); 1602 GenerateAppJITSnapshot();
1567 } 1603 }
1568 } 1604 }
1569 1605
1570 1606
1571 bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) { 1607 bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
1572 // Call CreateIsolateAndSetup which creates an isolate and loads up 1608 // Call CreateIsolateAndSetup which creates an isolate and loads up
1573 // the specified application script. 1609 // the specified application script.
1574 char* error = NULL; 1610 char* error = NULL;
1611 bool is_main_isolate = true;
1575 int exit_code = 0; 1612 int exit_code = 0;
1576 char* isolate_name = BuildIsolateName(script_name, "main"); 1613 char* isolate_name = BuildIsolateName(script_name, "main");
1577 Dart_Isolate isolate = CreateIsolateAndSetupHelper( 1614 Dart_Isolate isolate = CreateIsolateAndSetupHelper(
1578 script_name, "main", commandline_package_root, commandline_packages_file, 1615 is_main_isolate, script_name, "main", commandline_package_root,
1579 NULL, &error, &exit_code); 1616 commandline_packages_file, NULL, &error, &exit_code);
1580 if (isolate == NULL) { 1617 if (isolate == NULL) {
1581 delete[] isolate_name; 1618 delete[] isolate_name;
1582 if (exit_code == kRestartRequestExitCode) { 1619 if (exit_code == kRestartRequestExitCode) {
1583 free(error); 1620 free(error);
1584 return true; 1621 return true;
1585 } 1622 }
1586 Log::PrintErr("%s\n", error); 1623 Log::PrintErr("%s\n", error);
1587 free(error); 1624 free(error);
1588 error = NULL; 1625 error = NULL;
1589 Process::TerminateExitCodeHandler(); 1626 Process::TerminateExitCodeHandler();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 Loader::InitOnce(); 1932 Loader::InitOnce();
1896 1933
1897 if (!DartUtils::SetOriginalWorkingDirectory()) { 1934 if (!DartUtils::SetOriginalWorkingDirectory()) {
1898 OSError err; 1935 OSError err;
1899 Log::PrintErr("Error determining current directory: %s\n", err.message()); 1936 Log::PrintErr("Error determining current directory: %s\n", err.message());
1900 Platform::Exit(kErrorExitCode); 1937 Platform::Exit(kErrorExitCode);
1901 } 1938 }
1902 1939
1903 const uint8_t* instructions_snapshot = NULL; 1940 const uint8_t* instructions_snapshot = NULL;
1904 const uint8_t* data_snapshot = NULL; 1941 const uint8_t* data_snapshot = NULL;
1905
1906 if (ReadAppSnapshot(script_name, &vm_isolate_snapshot_buffer, 1942 if (ReadAppSnapshot(script_name, &vm_isolate_snapshot_buffer,
1907 &isolate_snapshot_buffer, &instructions_snapshot, 1943 &app_isolate_snapshot_buffer, &instructions_snapshot,
1908 &data_snapshot)) { 1944 &data_snapshot)) {
1909 run_app_snapshot = true; 1945 vm_run_app_snapshot = true;
1910 } 1946 }
1911 1947
1912 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) 1948 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
1913 // Constant true if PRODUCT or DART_PRECOMPILED_RUNTIME. 1949 // Constant true if PRODUCT or DART_PRECOMPILED_RUNTIME.
1914 if ((gen_snapshot_kind != kNone) || run_app_snapshot) { 1950 if ((gen_snapshot_kind != kNone) || vm_run_app_snapshot) {
1915 vm_options.AddArgument("--load_deferred_eagerly"); 1951 vm_options.AddArgument("--load_deferred_eagerly");
1916 } 1952 }
1917 #endif 1953 #endif
1918 1954
1919 if (gen_snapshot_kind == kAppJIT) { 1955 if (gen_snapshot_kind == kAppJIT) {
1920 vm_options.AddArgument("--fields_may_be_reset"); 1956 vm_options.AddArgument("--fields_may_be_reset");
1921 #if !defined(PRODUCT) 1957 #if !defined(PRODUCT)
1922 vm_options.AddArgument("--collect_code=false"); 1958 vm_options.AddArgument("--collect_code=false");
1923 #endif 1959 #endif
1924 } 1960 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 // Terminate process exit-code handler. 2012 // Terminate process exit-code handler.
1977 Process::TerminateExitCodeHandler(); 2013 Process::TerminateExitCodeHandler();
1978 2014
1979 error = Dart_Cleanup(); 2015 error = Dart_Cleanup();
1980 if (error != NULL) { 2016 if (error != NULL) {
1981 Log::PrintErr("VM cleanup failed: %s\n", error); 2017 Log::PrintErr("VM cleanup failed: %s\n", error);
1982 free(error); 2018 free(error);
1983 } 2019 }
1984 EventHandler::Stop(); 2020 EventHandler::Stop();
1985 2021
2022 free(app_script_uri);
2023
1986 // Free copied argument strings if converted. 2024 // Free copied argument strings if converted.
1987 if (argv_converted) { 2025 if (argv_converted) {
1988 for (int i = 0; i < argc; i++) { 2026 for (int i = 0; i < argc; i++) {
1989 free(argv[i]); 2027 free(argv[i]);
1990 } 2028 }
1991 } 2029 }
1992 2030
1993 // Free environment if any. 2031 // Free environment if any.
1994 if (environment != NULL) { 2032 if (environment != NULL) {
1995 for (HashMap::Entry* p = environment->Start(); p != NULL; 2033 for (HashMap::Entry* p = environment->Start(); p != NULL;
1996 p = environment->Next(p)) { 2034 p = environment->Next(p)) {
1997 free(p->key); 2035 free(p->key);
1998 free(p->value); 2036 free(p->value);
1999 } 2037 }
2000 delete environment; 2038 delete environment;
2001 } 2039 }
2002 2040
2003 Platform::Exit(Process::GlobalExitCode()); 2041 Platform::Exit(Process::GlobalExitCode());
2004 } 2042 }
2005 2043
2006 } // namespace bin 2044 } // namespace bin
2007 } // namespace dart 2045 } // namespace dart
2008 2046
2009 int main(int argc, char** argv) { 2047 int main(int argc, char** argv) {
2010 dart::bin::main(argc, argv); 2048 dart::bin::main(argc, argv);
2011 UNREACHABLE(); 2049 UNREACHABLE();
2012 } 2050 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/snapshot_empty.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698