Chromium Code Reviews| 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" |
| 11 | 11 |
| 12 #include "bin/builtin.h" | 12 #include "bin/builtin.h" |
| 13 #include "bin/dartutils.h" | 13 #include "bin/dartutils.h" |
| 14 #include "bin/dfe.h" | 14 #include "bin/dfe.h" |
| 15 #include "bin/directory.h" | 15 #include "bin/directory.h" |
| 16 #include "bin/embedded_dart_io.h" | 16 #include "bin/embedded_dart_io.h" |
| 17 #include "bin/error_exit.h" | 17 #include "bin/error_exit.h" |
| 18 #include "bin/eventhandler.h" | 18 #include "bin/eventhandler.h" |
| 19 #include "bin/extensions.h" | 19 #include "bin/extensions.h" |
| 20 #include "bin/file.h" | 20 #include "bin/file.h" |
| 21 #include "bin/isolate_data.h" | 21 #include "bin/isolate_data.h" |
| 22 #include "bin/loader.h" | 22 #include "bin/loader.h" |
| 23 #include "bin/log.h" | 23 #include "bin/log.h" |
| 24 #include "bin/platform.h" | 24 #include "bin/platform.h" |
| 25 #include "bin/process.h" | 25 #include "bin/process.h" |
| 26 #include "bin/service_isolate_bindata.h" | |
| 26 #include "bin/snapshot_utils.h" | 27 #include "bin/snapshot_utils.h" |
| 27 #include "bin/thread.h" | 28 #include "bin/thread.h" |
| 28 #include "bin/utils.h" | 29 #include "bin/utils.h" |
| 29 #include "bin/vmservice_impl.h" | 30 #include "bin/vmservice_impl.h" |
| 30 #include "platform/globals.h" | 31 #include "platform/globals.h" |
| 31 #include "platform/growable_array.h" | 32 #include "platform/growable_array.h" |
| 32 #include "platform/hashmap.h" | 33 #include "platform/hashmap.h" |
| 33 #include "platform/text_buffer.h" | 34 #include "platform/text_buffer.h" |
| 34 #if !defined(DART_PRECOMPILER) | 35 #if !defined(DART_PRECOMPILER) |
| 35 #include "zlib/zlib.h" | 36 #include "zlib/zlib.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 #include "vm/kernel.h" | 39 #include "vm/kernel.h" |
| 39 | 40 |
| 40 extern "C" { | 41 extern "C" { |
| 41 extern const uint8_t kDartVmSnapshotData[]; | 42 extern const uint8_t kDartVmSnapshotData[]; |
| 42 extern const uint8_t kDartVmSnapshotInstructions[]; | 43 extern const uint8_t kDartVmSnapshotInstructions[]; |
| 43 extern const uint8_t kDartCoreIsolateSnapshotData[]; | 44 extern const uint8_t kDartCoreIsolateSnapshotData[]; |
| 44 extern const uint8_t kDartCoreIsolateSnapshotInstructions[]; | 45 extern const uint8_t kDartCoreIsolateSnapshotInstructions[]; |
| 45 } | 46 } |
| 46 | 47 |
| 47 namespace dart { | 48 namespace dart { |
| 49 | |
| 50 DECLARE_FLAG(bool, use_dart_frontend); | |
|
siva
2017/06/08 01:05:18
This is not needed you can use dfe.UseDartFrontEnd
| |
| 51 | |
| 48 namespace bin { | 52 namespace bin { |
| 49 | 53 |
| 50 // Snapshot pieces if we link in a snapshot, otherwise initialized to NULL. | 54 // Snapshot pieces if we link in a snapshot, otherwise initialized to NULL. |
| 51 #if defined(DART_NO_SNAPSHOT) | 55 #if defined(DART_NO_SNAPSHOT) |
| 52 const uint8_t* vm_snapshot_data = NULL; | 56 const uint8_t* vm_snapshot_data = NULL; |
| 53 const uint8_t* vm_snapshot_instructions = NULL; | 57 const uint8_t* vm_snapshot_instructions = NULL; |
| 54 const uint8_t* core_isolate_snapshot_data = NULL; | 58 const uint8_t* core_isolate_snapshot_data = NULL; |
| 55 const uint8_t* core_isolate_snapshot_instructions = NULL; | 59 const uint8_t* core_isolate_snapshot_instructions = NULL; |
| 56 #else | 60 #else |
| 57 const uint8_t* vm_snapshot_data = kDartVmSnapshotData; | 61 const uint8_t* vm_snapshot_data = kDartVmSnapshotData; |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 989 const char* main, | 993 const char* main, |
| 990 const char* package_root, | 994 const char* package_root, |
| 991 const char* packages_config, | 995 const char* packages_config, |
| 992 Dart_IsolateFlags* flags, | 996 Dart_IsolateFlags* flags, |
| 993 char** error, | 997 char** error, |
| 994 int* exit_code) { | 998 int* exit_code) { |
| 995 ASSERT(script_uri != NULL); | 999 ASSERT(script_uri != NULL); |
| 996 | 1000 |
| 997 #if defined(DART_PRECOMPILED_RUNTIME) | 1001 #if defined(DART_PRECOMPILED_RUNTIME) |
| 998 // AOT: All isolates start from the app snapshot. | 1002 // AOT: All isolates start from the app snapshot. |
| 999 bool isolate_run_app_snapshot = true; | 1003 bool skip_library_load = true; |
| 1000 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data; | 1004 const uint8_t* isolate_snapshot_data = app_isolate_snapshot_data; |
| 1001 const uint8_t* isolate_snapshot_instructions = | 1005 const uint8_t* isolate_snapshot_instructions = |
| 1002 app_isolate_snapshot_instructions; | 1006 app_isolate_snapshot_instructions; |
| 1003 #else | 1007 #else |
| 1004 // JIT: Service isolate uses the core libraries snapshot. | 1008 // JIT: Service isolate uses the core libraries snapshot. |
| 1005 bool isolate_run_app_snapshot = false; | 1009 bool skip_library_load = false; |
| 1006 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; | 1010 const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data; |
| 1007 const uint8_t* isolate_snapshot_instructions = | 1011 const uint8_t* isolate_snapshot_instructions = |
| 1008 core_isolate_snapshot_instructions; | 1012 core_isolate_snapshot_instructions; |
| 1009 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1013 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 1010 | 1014 |
| 1015 Dart_Isolate isolate = NULL; | |
| 1011 IsolateData* isolate_data = | 1016 IsolateData* isolate_data = |
| 1012 new IsolateData(script_uri, package_root, packages_config, NULL); | 1017 new IsolateData(script_uri, package_root, packages_config, NULL); |
| 1013 Dart_Isolate isolate = Dart_CreateIsolate( | 1018 if (FLAG_use_dart_frontend) { |
| 1014 script_uri, main, isolate_snapshot_data, isolate_snapshot_instructions, | 1019 ASSERT(service_isolate_kernel_bindata_size_ != 0); |
| 1015 flags, isolate_data, error); | 1020 void* kernel = Dart_ReadKernelBinary(service_isolate_kernel_bindata_, |
| 1021 service_isolate_kernel_bindata_size_); | |
| 1022 if (kernel == NULL) { | |
| 1023 *error = strdup("Could not load service isolate from kernel"); | |
| 1024 } else { | |
| 1025 isolate = Dart_CreateIsolateFromKernel(script_uri, NULL, kernel, flags, | |
| 1026 isolate_data, error); | |
| 1027 skip_library_load = true; | |
| 1028 } | |
| 1029 } else { | |
| 1030 isolate = Dart_CreateIsolate(script_uri, main, isolate_snapshot_data, | |
| 1031 isolate_snapshot_instructions, flags, | |
| 1032 isolate_data, error); | |
| 1033 } | |
| 1016 if (isolate == NULL) { | 1034 if (isolate == NULL) { |
| 1017 delete isolate_data; | 1035 delete isolate_data; |
| 1018 return NULL; | 1036 return NULL; |
| 1019 } | 1037 } |
| 1020 | 1038 |
| 1021 Dart_EnterScope(); | 1039 Dart_EnterScope(); |
| 1022 | 1040 |
| 1023 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); | 1041 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); |
| 1024 CHECK_RESULT(result); | 1042 CHECK_RESULT(result); |
| 1025 | 1043 |
| 1026 // Load embedder specific bits and return. | 1044 // Load embedder specific bits and return. |
| 1027 bool skip_library_load = isolate_run_app_snapshot; | |
| 1028 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port, | 1045 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port, |
| 1029 skip_library_load, vm_service_dev_mode, | 1046 skip_library_load, vm_service_dev_mode, |
| 1030 trace_loading)) { | 1047 trace_loading)) { |
| 1031 *error = strdup(VmService::GetErrorMessage()); | 1048 *error = strdup(VmService::GetErrorMessage()); |
| 1032 return NULL; | 1049 return NULL; |
| 1033 } | 1050 } |
| 1034 if (compile_all) { | 1051 if (compile_all) { |
| 1035 result = Dart_CompileAll(); | 1052 result = Dart_CompileAll(); |
| 1036 CHECK_RESULT(result); | 1053 CHECK_RESULT(result); |
| 1037 } | 1054 } |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1875 Platform::Exit(Process::GlobalExitCode()); | 1892 Platform::Exit(Process::GlobalExitCode()); |
| 1876 } | 1893 } |
| 1877 | 1894 |
| 1878 } // namespace bin | 1895 } // namespace bin |
| 1879 } // namespace dart | 1896 } // namespace dart |
| 1880 | 1897 |
| 1881 int main(int argc, char** argv) { | 1898 int main(int argc, char** argv) { |
| 1882 dart::bin::main(argc, argv); | 1899 dart::bin::main(argc, argv); |
| 1883 UNREACHABLE(); | 1900 UNREACHABLE(); |
| 1884 } | 1901 } |
| OLD | NEW |