| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 | 108 |
| 109 // Global flag that is used to indicate that we want to trace resolution of | 109 // Global flag that is used to indicate that we want to trace resolution of |
| 110 // URIs and the loading of libraries, parts and scripts. | 110 // URIs and the loading of libraries, parts and scripts. |
| 111 static bool trace_loading = false; | 111 static bool trace_loading = false; |
| 112 | 112 |
| 113 | 113 |
| 114 static char* app_script_uri = NULL; | 114 static char* app_script_uri = NULL; |
| 115 static const uint8_t* app_isolate_snapshot_data = NULL; | 115 static const uint8_t* app_isolate_snapshot_data = NULL; |
| 116 static const uint8_t* app_isolate_snapshot_instructions = NULL; | 116 static const uint8_t* app_isolate_snapshot_instructions = NULL; |
| 117 static AppSnapshot* app_snapshot = NULL; | |
| 118 | 117 |
| 119 | 118 |
| 120 static Dart_Isolate main_isolate = NULL; | 119 static Dart_Isolate main_isolate = NULL; |
| 121 | 120 |
| 122 | 121 |
| 123 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "localhost"; | 122 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "localhost"; |
| 124 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; | 123 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; |
| 125 // VM Service options. | 124 // VM Service options. |
| 126 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; | 125 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; |
| 127 // The 0 port is a magic value which results in the first available port | 126 // The 0 port is a magic value which results in the first available port |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 if (!use_dart_frontend) { | 829 if (!use_dart_frontend) { |
| 831 *error = strdup("Kernel isolate not supported."); | 830 *error = strdup("Kernel isolate not supported."); |
| 832 return NULL; | 831 return NULL; |
| 833 } | 832 } |
| 834 script_uri = frontend_filename; | 833 script_uri = frontend_filename; |
| 835 if (packages_config == NULL) { | 834 if (packages_config == NULL) { |
| 836 packages_config = commandline_packages_file; | 835 packages_config = commandline_packages_file; |
| 837 } | 836 } |
| 838 } | 837 } |
| 839 | 838 |
| 839 void* kernel_platform = NULL; |
| 840 void* kernel_program = NULL; |
| 841 AppSnapshot* app_snapshot = NULL; |
| 842 |
| 840 #if defined(DART_PRECOMPILED_RUNTIME) | 843 #if defined(DART_PRECOMPILED_RUNTIME) |
| 841 // AOT: All isolates start from the app snapshot. | 844 // AOT: All isolates start from the app snapshot. |
| 842 bool isolate_run_app_snapshot = true; | 845 bool isolate_run_app_snapshot = true; |
| 843 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data; | 846 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data; |
| 844 const uint8_t* isolate_snapshot_instructions = | 847 const uint8_t* isolate_snapshot_instructions = |
| 845 app_isolate_snapshot_instructions; | 848 app_isolate_snapshot_instructions; |
| 846 AppSnapshot* app_snapshot = NULL; | |
| 847 #else | 849 #else |
| 848 // JIT: Main isolate starts from the app snapshot, if any. Other isolates | 850 // JIT: Main isolate starts from the app snapshot, if any. Other isolates |
| 849 // use the core libraries snapshot. | 851 // use the core libraries snapshot. |
| 850 bool isolate_run_app_snapshot = false; | 852 bool isolate_run_app_snapshot = false; |
| 851 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; | 853 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; |
| 852 const uint8_t* isolate_snapshot_instructions = | 854 const uint8_t* isolate_snapshot_instructions = |
| 853 core_isolate_snapshot_instructions; | 855 core_isolate_snapshot_instructions; |
| 854 AppSnapshot* app_snapshot = NULL; | |
| 855 if ((app_isolate_snapshot_data != NULL) && | 856 if ((app_isolate_snapshot_data != NULL) && |
| 856 (is_main_isolate || ((app_script_uri != NULL) && | 857 (is_main_isolate || ((app_script_uri != NULL) && |
| 857 (strcmp(script_uri, app_script_uri) == 0)))) { | 858 (strcmp(script_uri, app_script_uri) == 0)))) { |
| 858 isolate_run_app_snapshot = true; | 859 isolate_run_app_snapshot = true; |
| 859 isolate_snapshot_data = app_isolate_snapshot_data; | 860 isolate_snapshot_data = app_isolate_snapshot_data; |
| 860 isolate_snapshot_instructions = app_isolate_snapshot_instructions; | 861 isolate_snapshot_instructions = app_isolate_snapshot_instructions; |
| 861 } else if (!is_main_isolate) { | 862 } else if (!is_main_isolate) { |
| 862 app_snapshot = Snapshot::TryReadAppSnapshot(script_uri); | 863 app_snapshot = Snapshot::TryReadAppSnapshot(script_uri); |
| 863 if (app_snapshot != NULL) { | 864 if (app_snapshot != NULL) { |
| 864 isolate_run_app_snapshot = true; | 865 isolate_run_app_snapshot = true; |
| 865 const uint8_t* ignore_vm_snapshot_data; | 866 const uint8_t* ignore_vm_snapshot_data; |
| 866 const uint8_t* ignore_vm_snapshot_instructions; | 867 const uint8_t* ignore_vm_snapshot_instructions; |
| 867 app_snapshot->SetBuffers( | 868 app_snapshot->SetBuffers( |
| 868 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions, | 869 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions, |
| 869 &isolate_snapshot_data, &isolate_snapshot_instructions); | 870 &isolate_snapshot_data, &isolate_snapshot_instructions); |
| 870 } | 871 } |
| 871 } | 872 } |
| 872 #endif | |
| 873 | |
| 874 void* kernel_platform = NULL; | |
| 875 void* kernel_program = NULL; | |
| 876 #if !defined(DART_PRECOMPILED_RUNTIME) | |
| 877 const bool is_service_isolate = | 873 const bool is_service_isolate = |
| 878 strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0; | 874 strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0; |
| 879 if (!is_kernel_isolate && !is_service_isolate) { | 875 if (!is_kernel_isolate && !is_service_isolate) { |
| 880 const uint8_t* platform_file = NULL; | 876 const uint8_t* platform_file = NULL; |
| 881 if (use_platform_binary) { | 877 if (use_platform_binary) { |
| 882 intptr_t platform_length = -1; | 878 intptr_t platform_length = -1; |
| 883 bool success = TryReadKernel(platform_binary_filename, &platform_file, | 879 bool success = TryReadKernel(platform_binary_filename, &platform_file, |
| 884 &platform_length); | 880 &platform_length); |
| 885 if (!success) { | 881 if (!success) { |
| 886 *error = strdup("The platform binary is not a valid Dart Kernel file."); | 882 *error = strdup("The platform binary is not a valid Dart Kernel file."); |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 Thread::InitOnce(); | 1647 Thread::InitOnce(); |
| 1652 | 1648 |
| 1653 Loader::InitOnce(); | 1649 Loader::InitOnce(); |
| 1654 | 1650 |
| 1655 if (!DartUtils::SetOriginalWorkingDirectory()) { | 1651 if (!DartUtils::SetOriginalWorkingDirectory()) { |
| 1656 OSError err; | 1652 OSError err; |
| 1657 Log::PrintErr("Error determining current directory: %s\n", err.message()); | 1653 Log::PrintErr("Error determining current directory: %s\n", err.message()); |
| 1658 Platform::Exit(kErrorExitCode); | 1654 Platform::Exit(kErrorExitCode); |
| 1659 } | 1655 } |
| 1660 | 1656 |
| 1661 app_snapshot = Snapshot::TryReadAppSnapshot(script_name); | 1657 AppSnapshot* app_snapshot = Snapshot::TryReadAppSnapshot(script_name); |
| 1662 if (app_snapshot != NULL) { | 1658 if (app_snapshot != NULL) { |
| 1663 vm_run_app_snapshot = true; | 1659 vm_run_app_snapshot = true; |
| 1664 app_snapshot->SetBuffers(&vm_snapshot_data, &vm_snapshot_instructions, | 1660 app_snapshot->SetBuffers(&vm_snapshot_data, &vm_snapshot_instructions, |
| 1665 &app_isolate_snapshot_data, | 1661 &app_isolate_snapshot_data, |
| 1666 &app_isolate_snapshot_instructions); | 1662 &app_isolate_snapshot_instructions); |
| 1667 } | 1663 } |
| 1668 | 1664 |
| 1669 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) | 1665 #if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME) |
| 1670 // Constant true if PRODUCT or DART_PRECOMPILED_RUNTIME. | 1666 // Constant true if PRODUCT or DART_PRECOMPILED_RUNTIME. |
| 1671 if ((gen_snapshot_kind != kNone) || vm_run_app_snapshot) { | 1667 if ((gen_snapshot_kind != kNone) || vm_run_app_snapshot) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 Platform::Exit(Process::GlobalExitCode()); | 1758 Platform::Exit(Process::GlobalExitCode()); |
| 1763 } | 1759 } |
| 1764 | 1760 |
| 1765 } // namespace bin | 1761 } // namespace bin |
| 1766 } // namespace dart | 1762 } // namespace dart |
| 1767 | 1763 |
| 1768 int main(int argc, char** argv) { | 1764 int main(int argc, char** argv) { |
| 1769 dart::bin::main(argc, argv); | 1765 dart::bin::main(argc, argv); |
| 1770 UNREACHABLE(); | 1766 UNREACHABLE(); |
| 1771 } | 1767 } |
| OLD | NEW |