| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 if (exit_code == 0) { | 1603 if (exit_code == 0) { |
| 1566 GenerateAppJITSnapshot(); | 1604 GenerateAppJITSnapshot(); |
| 1567 } | 1605 } |
| 1568 } | 1606 } |
| 1569 | 1607 |
| 1570 | 1608 |
| 1571 bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) { | 1609 bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) { |
| 1572 // Call CreateIsolateAndSetup which creates an isolate and loads up | 1610 // Call CreateIsolateAndSetup which creates an isolate and loads up |
| 1573 // the specified application script. | 1611 // the specified application script. |
| 1574 char* error = NULL; | 1612 char* error = NULL; |
| 1613 bool is_main_isolate = true; |
| 1575 int exit_code = 0; | 1614 int exit_code = 0; |
| 1576 char* isolate_name = BuildIsolateName(script_name, "main"); | 1615 char* isolate_name = BuildIsolateName(script_name, "main"); |
| 1577 Dart_Isolate isolate = CreateIsolateAndSetupHelper( | 1616 Dart_Isolate isolate = CreateIsolateAndSetupHelper( |
| 1578 script_name, "main", commandline_package_root, commandline_packages_file, | 1617 is_main_isolate, script_name, "main", commandline_package_root, |
| 1579 NULL, &error, &exit_code); | 1618 commandline_packages_file, NULL, &error, &exit_code); |
| 1580 if (isolate == NULL) { | 1619 if (isolate == NULL) { |
| 1581 delete[] isolate_name; | 1620 delete[] isolate_name; |
| 1582 if (exit_code == kRestartRequestExitCode) { | 1621 if (exit_code == kRestartRequestExitCode) { |
| 1583 free(error); | 1622 free(error); |
| 1584 return true; | 1623 return true; |
| 1585 } | 1624 } |
| 1586 Log::PrintErr("%s\n", error); | 1625 Log::PrintErr("%s\n", error); |
| 1587 free(error); | 1626 free(error); |
| 1588 error = NULL; | 1627 error = NULL; |
| 1589 Process::TerminateExitCodeHandler(); | 1628 Process::TerminateExitCodeHandler(); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 Loader::InitOnce(); | 1934 Loader::InitOnce(); |
| 1896 | 1935 |
| 1897 if (!DartUtils::SetOriginalWorkingDirectory()) { | 1936 if (!DartUtils::SetOriginalWorkingDirectory()) { |
| 1898 OSError err; | 1937 OSError err; |
| 1899 Log::PrintErr("Error determining current directory: %s\n", err.message()); | 1938 Log::PrintErr("Error determining current directory: %s\n", err.message()); |
| 1900 Platform::Exit(kErrorExitCode); | 1939 Platform::Exit(kErrorExitCode); |
| 1901 } | 1940 } |
| 1902 | 1941 |
| 1903 const uint8_t* instructions_snapshot = NULL; | 1942 const uint8_t* instructions_snapshot = NULL; |
| 1904 const uint8_t* data_snapshot = NULL; | 1943 const uint8_t* data_snapshot = NULL; |
| 1905 | |
| 1906 if (ReadAppSnapshot(script_name, &vm_isolate_snapshot_buffer, | 1944 if (ReadAppSnapshot(script_name, &vm_isolate_snapshot_buffer, |
| 1907 &isolate_snapshot_buffer, &instructions_snapshot, | 1945 &app_isolate_snapshot_buffer, &instructions_snapshot, |
| 1908 &data_snapshot)) { | 1946 &data_snapshot)) { |
| 1909 run_app_snapshot = true; | 1947 vm_run_app_snapshot = true; |
| 1910 } | 1948 } |
| 1911 | 1949 |
| 1912 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) | 1950 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
| 1913 // Constant true if PRODUCT or DART_PRECOMPILED_RUNTIME. | 1951 // Constant true if PRODUCT or DART_PRECOMPILED_RUNTIME. |
| 1914 if ((gen_snapshot_kind != kNone) || run_app_snapshot) { | 1952 if ((gen_snapshot_kind != kNone) || vm_run_app_snapshot) { |
| 1915 vm_options.AddArgument("--load_deferred_eagerly"); | 1953 vm_options.AddArgument("--load_deferred_eagerly"); |
| 1916 } | 1954 } |
| 1917 #endif | 1955 #endif |
| 1918 | 1956 |
| 1919 if (gen_snapshot_kind == kAppJIT) { | 1957 if (gen_snapshot_kind == kAppJIT) { |
| 1920 vm_options.AddArgument("--fields_may_be_reset"); | 1958 vm_options.AddArgument("--fields_may_be_reset"); |
| 1921 #if !defined(PRODUCT) | 1959 #if !defined(PRODUCT) |
| 1922 vm_options.AddArgument("--collect_code=false"); | 1960 vm_options.AddArgument("--collect_code=false"); |
| 1923 #endif | 1961 #endif |
| 1924 } | 1962 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 // Terminate process exit-code handler. | 2014 // Terminate process exit-code handler. |
| 1977 Process::TerminateExitCodeHandler(); | 2015 Process::TerminateExitCodeHandler(); |
| 1978 | 2016 |
| 1979 error = Dart_Cleanup(); | 2017 error = Dart_Cleanup(); |
| 1980 if (error != NULL) { | 2018 if (error != NULL) { |
| 1981 Log::PrintErr("VM cleanup failed: %s\n", error); | 2019 Log::PrintErr("VM cleanup failed: %s\n", error); |
| 1982 free(error); | 2020 free(error); |
| 1983 } | 2021 } |
| 1984 EventHandler::Stop(); | 2022 EventHandler::Stop(); |
| 1985 | 2023 |
| 2024 free(app_script_uri); |
| 2025 |
| 1986 // Free copied argument strings if converted. | 2026 // Free copied argument strings if converted. |
| 1987 if (argv_converted) { | 2027 if (argv_converted) { |
| 1988 for (int i = 0; i < argc; i++) { | 2028 for (int i = 0; i < argc; i++) { |
| 1989 free(argv[i]); | 2029 free(argv[i]); |
| 1990 } | 2030 } |
| 1991 } | 2031 } |
| 1992 | 2032 |
| 1993 // Free environment if any. | 2033 // Free environment if any. |
| 1994 if (environment != NULL) { | 2034 if (environment != NULL) { |
| 1995 for (HashMap::Entry* p = environment->Start(); p != NULL; | 2035 for (HashMap::Entry* p = environment->Start(); p != NULL; |
| 1996 p = environment->Next(p)) { | 2036 p = environment->Next(p)) { |
| 1997 free(p->key); | 2037 free(p->key); |
| 1998 free(p->value); | 2038 free(p->value); |
| 1999 } | 2039 } |
| 2000 delete environment; | 2040 delete environment; |
| 2001 } | 2041 } |
| 2002 | 2042 |
| 2003 Platform::Exit(Process::GlobalExitCode()); | 2043 Platform::Exit(Process::GlobalExitCode()); |
| 2004 } | 2044 } |
| 2005 | 2045 |
| 2006 } // namespace bin | 2046 } // namespace bin |
| 2007 } // namespace dart | 2047 } // namespace dart |
| 2008 | 2048 |
| 2009 int main(int argc, char** argv) { | 2049 int main(int argc, char** argv) { |
| 2010 dart::bin::main(argc, argv); | 2050 dart::bin::main(argc, argv); |
| 2011 UNREACHABLE(); | 2051 UNREACHABLE(); |
| 2012 } | 2052 } |
| OLD | NEW |