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