| 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 | 736 |
| 737 // Returns true on success, false on failure. | 737 // Returns true on success, false on failure. |
| 738 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, | 738 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| 739 const char* main, | 739 const char* main, |
| 740 const char* package_root, | 740 const char* package_root, |
| 741 const char* packages_config, | 741 const char* packages_config, |
| 742 Dart_IsolateFlags* flags, | 742 Dart_IsolateFlags* flags, |
| 743 char** error, | 743 char** error, |
| 744 int* exit_code) { | 744 int* exit_code) { |
| 745 ASSERT(script_uri != NULL); | 745 ASSERT(script_uri != NULL); |
| 746 |
| 746 #if defined(DART_PRODUCT_BINARY) | 747 #if defined(DART_PRODUCT_BINARY) |
| 747 if (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0) { | 748 const bool run_service_isolate = false; |
| 748 // No service isolate support. | 749 #elif defined(PRODUCT) |
| 750 const bool run_service_isolate = !run_full_snapshot && |
| 751 !run_precompiled_snapshot; |
| 752 #else |
| 753 const bool run_service_isolate = !run_full_snapshot; |
| 754 #endif |
| 755 if (!run_service_isolate && |
| 756 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) { |
| 757 // We do not create a service isolate when running a full application |
| 758 // snapshot or a precompiled snapshot in product mode. |
| 749 return NULL; | 759 return NULL; |
| 750 } | 760 } |
| 751 #endif // defined(DART_PRODUCT_BINARY) | |
| 752 | 761 |
| 753 if (run_full_snapshot && | |
| 754 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) { | |
| 755 // We do not create a service isolate when running a full application | |
| 756 // snapshot. | |
| 757 return NULL; | |
| 758 } | |
| 759 IsolateData* isolate_data = new IsolateData(script_uri, | 762 IsolateData* isolate_data = new IsolateData(script_uri, |
| 760 package_root, | 763 package_root, |
| 761 packages_config); | 764 packages_config); |
| 762 Dart_Isolate isolate = NULL; | 765 Dart_Isolate isolate = Dart_CreateIsolate(script_uri, |
| 763 | 766 main, |
| 764 isolate = Dart_CreateIsolate(script_uri, | 767 isolate_snapshot_buffer, |
| 765 main, | 768 flags, |
| 766 isolate_snapshot_buffer, | 769 isolate_data, |
| 767 flags, | 770 error); |
| 768 isolate_data, | |
| 769 error); | |
| 770 | |
| 771 if (isolate == NULL) { | 771 if (isolate == NULL) { |
| 772 delete isolate_data; | 772 delete isolate_data; |
| 773 return NULL; | 773 return NULL; |
| 774 } | 774 } |
| 775 | 775 |
| 776 Dart_EnterScope(); | 776 Dart_EnterScope(); |
| 777 | 777 |
| 778 if (isolate_snapshot_buffer != NULL) { | 778 if (isolate_snapshot_buffer != NULL) { |
| 779 // Setup the native resolver as the snapshot does not carry it. | 779 // Setup the native resolver as the snapshot does not carry it. |
| 780 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); | 780 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 805 return isolate; | 805 return isolate; |
| 806 } | 806 } |
| 807 #endif // defined(DART_PRODUCT_BINARY) | 807 #endif // defined(DART_PRODUCT_BINARY) |
| 808 | 808 |
| 809 // Prepare builtin and other core libraries for use to resolve URIs. | 809 // Prepare builtin and other core libraries for use to resolve URIs. |
| 810 // Set up various closures, e.g: printing, timers etc. | 810 // Set up various closures, e.g: printing, timers etc. |
| 811 // Set up 'package root' for URI resolution. | 811 // Set up 'package root' for URI resolution. |
| 812 result = DartUtils::PrepareForScriptLoading(false, trace_loading); | 812 result = DartUtils::PrepareForScriptLoading(false, trace_loading); |
| 813 CHECK_RESULT(result); | 813 CHECK_RESULT(result); |
| 814 | 814 |
| 815 if (!run_full_snapshot) { | 815 if (run_service_isolate) { |
| 816 // Set up the load port provided by the service isolate so that we can | 816 // Set up the load port provided by the service isolate so that we can |
| 817 // load scripts. | 817 // load scripts. |
| 818 result = DartUtils::SetupServiceLoadPort(); | 818 result = DartUtils::SetupServiceLoadPort(); |
| 819 CHECK_RESULT(result); | 819 CHECK_RESULT(result); |
| 820 } | 820 } |
| 821 | 821 |
| 822 // Setup package root if specified. | 822 // Setup package root if specified. |
| 823 result = DartUtils::SetupPackageRoot(package_root, packages_config); | 823 result = DartUtils::SetupPackageRoot(package_root, packages_config); |
| 824 CHECK_RESULT(result); | 824 CHECK_RESULT(result); |
| 825 | 825 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 GenerateScriptSnapshot(); | 1292 GenerateScriptSnapshot(); |
| 1293 } else { | 1293 } else { |
| 1294 // Lookup the library of the root script. | 1294 // Lookup the library of the root script. |
| 1295 Dart_Handle root_lib = Dart_RootLibrary(); | 1295 Dart_Handle root_lib = Dart_RootLibrary(); |
| 1296 // Import the root library into the builtin library so that we can easily | 1296 // Import the root library into the builtin library so that we can easily |
| 1297 // lookup the main entry point exported from the root library. | 1297 // lookup the main entry point exported from the root library. |
| 1298 IsolateData* isolate_data = | 1298 IsolateData* isolate_data = |
| 1299 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); | 1299 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); |
| 1300 result = Dart_LibraryImportLibrary( | 1300 result = Dart_LibraryImportLibrary( |
| 1301 isolate_data->builtin_lib(), root_lib, Dart_Null()); | 1301 isolate_data->builtin_lib(), root_lib, Dart_Null()); |
| 1302 #ifndef DART_PRODUCT_BINARY | 1302 #if !defined(DART_PRODUCT_BINARY) && !defined(PRODUCT) |
| 1303 if (is_noopt || gen_precompiled_snapshot) { | 1303 if (is_noopt || gen_precompiled_snapshot) { |
| 1304 // Load the embedder's portion of the VM service's Dart code so it will | 1304 // Load the embedder's portion of the VM service's Dart code so it will |
| 1305 // be included in the precompiled snapshot. | 1305 // be included in the precompiled snapshot. |
| 1306 if (!VmService::LoadForGenPrecompiled()) { | 1306 if (!VmService::LoadForGenPrecompiled()) { |
| 1307 fprintf(stderr, | 1307 fprintf(stderr, |
| 1308 "VM service loading failed: %s\n", | 1308 "VM service loading failed: %s\n", |
| 1309 VmService::GetErrorMessage()); | 1309 VmService::GetErrorMessage()); |
| 1310 fflush(stderr); | 1310 fflush(stderr); |
| 1311 exit(kErrorExitCode); | 1311 exit(kErrorExitCode); |
| 1312 } | 1312 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1340 { "dart:io", "Link", "Link." }, | 1340 { "dart:io", "Link", "Link." }, |
| 1341 { "dart:io", "OSError", "OSError." }, | 1341 { "dart:io", "OSError", "OSError." }, |
| 1342 { "dart:io", "TlsException", "TlsException." }, | 1342 { "dart:io", "TlsException", "TlsException." }, |
| 1343 { "dart:io", "X509Certificate", "X509Certificate._" }, | 1343 { "dart:io", "X509Certificate", "X509Certificate._" }, |
| 1344 { "dart:io", "_ExternalBuffer", "set:data" }, | 1344 { "dart:io", "_ExternalBuffer", "set:data" }, |
| 1345 { "dart:io", "_Platform", "set:_nativeScript" }, | 1345 { "dart:io", "_Platform", "set:_nativeScript" }, |
| 1346 { "dart:io", "_ProcessStartStatus", "set:_errorCode" }, | 1346 { "dart:io", "_ProcessStartStatus", "set:_errorCode" }, |
| 1347 { "dart:io", "_ProcessStartStatus", "set:_errorMessage" }, | 1347 { "dart:io", "_ProcessStartStatus", "set:_errorMessage" }, |
| 1348 { "dart:io", "_SecureFilterImpl", "get:ENCRYPTED_SIZE" }, | 1348 { "dart:io", "_SecureFilterImpl", "get:ENCRYPTED_SIZE" }, |
| 1349 { "dart:io", "_SecureFilterImpl", "get:SIZE" }, | 1349 { "dart:io", "_SecureFilterImpl", "get:SIZE" }, |
| 1350 #if !defined(PRODUCT) |
| 1350 { "dart:vmservice_io", "::", "main" }, | 1351 { "dart:vmservice_io", "::", "main" }, |
| 1352 #endif // !PRODUCT |
| 1351 { NULL, NULL, NULL } // Must be terminated with NULL entries. | 1353 { NULL, NULL, NULL } // Must be terminated with NULL entries. |
| 1352 }; | 1354 }; |
| 1353 | 1355 |
| 1354 const bool reset_fields = gen_precompiled_snapshot; | 1356 const bool reset_fields = gen_precompiled_snapshot; |
| 1355 result = Dart_Precompile(standalone_entry_points, reset_fields); | 1357 result = Dart_Precompile(standalone_entry_points, reset_fields); |
| 1356 CHECK_RESULT(result); | 1358 CHECK_RESULT(result); |
| 1357 } | 1359 } |
| 1358 | 1360 |
| 1359 if (gen_precompiled_snapshot) { | 1361 if (gen_precompiled_snapshot) { |
| 1360 uint8_t* vm_isolate_buffer = NULL; | 1362 uint8_t* vm_isolate_buffer = NULL; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 Platform::Exit(Process::GlobalExitCode()); | 1697 Platform::Exit(Process::GlobalExitCode()); |
| 1696 } | 1698 } |
| 1697 | 1699 |
| 1698 } // namespace bin | 1700 } // namespace bin |
| 1699 } // namespace dart | 1701 } // namespace dart |
| 1700 | 1702 |
| 1701 int main(int argc, char** argv) { | 1703 int main(int argc, char** argv) { |
| 1702 dart::bin::main(argc, argv); | 1704 dart::bin::main(argc, argv); |
| 1703 UNREACHABLE(); | 1705 UNREACHABLE(); |
| 1704 } | 1706 } |
| OLD | NEW |