| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <string.h> | 7 #include <string.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 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 return NULL; | 1040 return NULL; |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 Dart_EnterScope(); | 1043 Dart_EnterScope(); |
| 1044 | 1044 |
| 1045 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); | 1045 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); |
| 1046 CHECK_RESULT(result); | 1046 CHECK_RESULT(result); |
| 1047 | 1047 |
| 1048 #if !defined(DART_PRECOMPILED_RUNTIME) | 1048 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1049 if (dfe.UsePlatformBinary()) { | 1049 if (dfe.UsePlatformBinary()) { |
| 1050 Dart_Handle library = Dart_LoadKernel(dfe.kernel_vmservice_io()); | 1050 // Read vmservice_io kernel file independently of main thread |
| 1051 // as Dart_LoadKernel takes ownership. |
| 1052 void* kernel_vmservice_io = dfe.ReadVMServiceIO(); |
| 1053 if (kernel_vmservice_io == NULL) { |
| 1054 Log::PrintErr("Could not read dart:vmservice_io binary file."); |
| 1055 Platform::Exit(kErrorExitCode); |
| 1056 } |
| 1057 // Dart_LoadKernel takes ownership. |
| 1058 Dart_Handle library = Dart_LoadKernel(kernel_vmservice_io); |
| 1051 CHECK_RESULT_CLEANUP(library, isolate_data); | 1059 CHECK_RESULT_CLEANUP(library, isolate_data); |
| 1052 dfe.clear_kernel_vmservice_io(); // Dart_LoadKernel takes ownership. | |
| 1053 skip_library_load = true; | 1060 skip_library_load = true; |
| 1054 } | 1061 } |
| 1055 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1062 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 1056 | 1063 |
| 1057 // Load embedder specific bits and return. | 1064 // Load embedder specific bits and return. |
| 1058 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port, | 1065 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port, |
| 1059 skip_library_load, vm_service_dev_mode, | 1066 skip_library_load, vm_service_dev_mode, |
| 1060 trace_loading)) { | 1067 trace_loading)) { |
| 1061 *error = strdup(VmService::GetErrorMessage()); | 1068 *error = strdup(VmService::GetErrorMessage()); |
| 1062 return NULL; | 1069 return NULL; |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 } else { | 1458 } else { |
| 1452 // Lookup the library of the root script. | 1459 // Lookup the library of the root script. |
| 1453 Dart_Handle root_lib = Dart_RootLibrary(); | 1460 Dart_Handle root_lib = Dart_RootLibrary(); |
| 1454 // Import the root library into the builtin library so that we can easily | 1461 // Import the root library into the builtin library so that we can easily |
| 1455 // lookup the main entry point exported from the root library. | 1462 // lookup the main entry point exported from the root library. |
| 1456 IsolateData* isolate_data = | 1463 IsolateData* isolate_data = |
| 1457 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); | 1464 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); |
| 1458 result = Dart_LibraryImportLibrary(isolate_data->builtin_lib(), root_lib, | 1465 result = Dart_LibraryImportLibrary(isolate_data->builtin_lib(), root_lib, |
| 1459 Dart_Null()); | 1466 Dart_Null()); |
| 1460 if ((gen_snapshot_kind == kAppAOT) || (gen_snapshot_kind == kAppJIT)) { | 1467 if ((gen_snapshot_kind == kAppAOT) || (gen_snapshot_kind == kAppJIT)) { |
| 1461 // Load the embedder's portion of the VM service's Dart code so it will | 1468 // Load the embedder's portion of the VM service's Dart code so it will |
| 1462 // be included in the app snapshot. | 1469 // be included in the app snapshot. |
| 1463 #if defined(DART_PRECOMPILED_RUNTIME) | 1470 void* kernel_vmservice_io = NULL; |
| 1464 if (!VmService::LoadForGenPrecompiled(NULL)) { | 1471 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1465 #else | 1472 if (dfe.UsePlatformBinary()) { |
| 1466 if (!VmService::LoadForGenPrecompiled(dfe.kernel_vmservice_io())) { | 1473 // Do not cache vmservice_io kernel file as |
| 1474 // VmService::LoadForGenPrecompiled takes ownership. |
| 1475 kernel_vmservice_io = dfe.ReadVMServiceIO(); |
| 1476 if (kernel_vmservice_io == NULL) { |
| 1477 Log::PrintErr("Could not read dart:vmservice_io binary file."); |
| 1478 Platform::Exit(kErrorExitCode); |
| 1479 } |
| 1480 } |
| 1467 #endif // defined(DART_PRECOMPILED_RUNTIME) | 1481 #endif // defined(DART_PRECOMPILED_RUNTIME) |
| 1482 if (!VmService::LoadForGenPrecompiled(kernel_vmservice_io)) { |
| 1468 Log::PrintErr("VM service loading failed: %s\n", | 1483 Log::PrintErr("VM service loading failed: %s\n", |
| 1469 VmService::GetErrorMessage()); | 1484 VmService::GetErrorMessage()); |
| 1470 exit(kErrorExitCode); | 1485 Platform::Exit(kErrorExitCode); |
| 1471 } | 1486 } |
| 1472 } | 1487 } |
| 1473 | 1488 |
| 1474 if (compile_all) { | 1489 if (compile_all) { |
| 1475 result = Dart_CompileAll(); | 1490 result = Dart_CompileAll(); |
| 1476 CHECK_RESULT(result); | 1491 CHECK_RESULT(result); |
| 1477 } | 1492 } |
| 1478 | 1493 |
| 1479 if (parse_all) { | 1494 if (parse_all) { |
| 1480 result = Dart_ParseAll(); | 1495 result = Dart_ParseAll(); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 #endif | 1777 #endif |
| 1763 if (gen_snapshot_kind == kAppJIT) { | 1778 if (gen_snapshot_kind == kAppJIT) { |
| 1764 Process::SetExitHook(SnapshotOnExitHook); | 1779 Process::SetExitHook(SnapshotOnExitHook); |
| 1765 } | 1780 } |
| 1766 | 1781 |
| 1767 #if !defined(DART_PRECOMPILED_RUNTIME) | 1782 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1768 // If a kernel platform binary file is specified, read it. This | 1783 // If a kernel platform binary file is specified, read it. This |
| 1769 // step will become redundant once we have the snapshot version | 1784 // step will become redundant once we have the snapshot version |
| 1770 // of the kernel core/platform libraries. | 1785 // of the kernel core/platform libraries. |
| 1771 if (dfe.UsePlatformBinary()) { | 1786 if (dfe.UsePlatformBinary()) { |
| 1772 if (dfe.ReadPlatform() == NULL) { | 1787 void* kernel_platform = dfe.ReadPlatform(); |
| 1788 if (kernel_platform == NULL) { |
| 1773 Log::PrintErr("The platform binary is not a valid Dart Kernel file."); | 1789 Log::PrintErr("The platform binary is not a valid Dart Kernel file."); |
| 1774 Platform::Exit(kErrorExitCode); | 1790 Platform::Exit(kErrorExitCode); |
| 1775 } | 1791 } |
| 1776 if (dfe.ReadVMServiceIO() == NULL) { | 1792 dfe.set_kernel_platform(kernel_platform); |
| 1777 Log::PrintErr("Could not read dart:vmservice_io binary file."); | |
| 1778 Platform::Exit(kErrorExitCode); | |
| 1779 } | |
| 1780 } | 1793 } |
| 1781 #endif | 1794 #endif |
| 1782 | 1795 |
| 1783 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); | 1796 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); |
| 1784 | 1797 |
| 1785 // Start event handler. | 1798 // Start event handler. |
| 1786 TimerUtils::InitOnce(); | 1799 TimerUtils::InitOnce(); |
| 1787 EventHandler::Start(); | 1800 EventHandler::Start(); |
| 1788 | 1801 |
| 1789 // Initialize the Dart VM. | 1802 // Initialize the Dart VM. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 Platform::Exit(Process::GlobalExitCode()); | 1872 Platform::Exit(Process::GlobalExitCode()); |
| 1860 } | 1873 } |
| 1861 | 1874 |
| 1862 } // namespace bin | 1875 } // namespace bin |
| 1863 } // namespace dart | 1876 } // namespace dart |
| 1864 | 1877 |
| 1865 int main(int argc, char** argv) { | 1878 int main(int argc, char** argv) { |
| 1866 dart::bin::main(argc, argv); | 1879 dart::bin::main(argc, argv); |
| 1867 UNREACHABLE(); | 1880 UNREACHABLE(); |
| 1868 } | 1881 } |
| OLD | NEW |