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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 // Returns true on success, false on failure. | 684 // Returns true on success, false on failure. |
685 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, | 685 static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
686 const char* main, | 686 const char* main, |
687 const char* package_root, | 687 const char* package_root, |
688 const char* packages_config, | 688 const char* packages_config, |
689 Dart_IsolateFlags* flags, | 689 Dart_IsolateFlags* flags, |
690 char** error, | 690 char** error, |
691 int* exit_code) { | 691 int* exit_code) { |
692 ASSERT(script_uri != NULL); | 692 ASSERT(script_uri != NULL); |
693 | 693 |
694 const bool needs_load_port = !run_app_snapshot; | 694 const bool needs_load_port = true; |
695 #if defined(PRODUCT) | 695 #if defined(PRODUCT) |
696 const bool run_service_isolate = needs_load_port; | 696 const bool run_service_isolate = needs_load_port; |
697 #else | 697 #else |
698 // Always create the service isolate in DEBUG and RELEASE modes for profiling, | 698 // Always create the service isolate in DEBUG and RELEASE modes for profiling, |
699 // even if we don't need it for loading. | 699 // even if we don't need it for loading. |
700 const bool run_service_isolate = true; | 700 const bool run_service_isolate = true; |
701 #endif // PRODUCT | 701 #endif // PRODUCT |
702 if (!run_service_isolate && | 702 if (!run_service_isolate && |
703 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) { | 703 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) { |
704 return NULL; | 704 return NULL; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 // Setup package root if specified. | 764 // Setup package root if specified. |
765 result = DartUtils::SetupPackageRoot(package_root, packages_config); | 765 result = DartUtils::SetupPackageRoot(package_root, packages_config); |
766 CHECK_RESULT(result); | 766 CHECK_RESULT(result); |
767 | 767 |
768 result = Dart_SetEnvironmentCallback(EnvironmentCallback); | 768 result = Dart_SetEnvironmentCallback(EnvironmentCallback); |
769 CHECK_RESULT(result); | 769 CHECK_RESULT(result); |
770 | 770 |
771 if (run_app_snapshot) { | 771 if (run_app_snapshot) { |
772 result = DartUtils::SetupIOLibrary(script_uri); | 772 result = DartUtils::SetupIOLibrary(script_uri); |
773 CHECK_RESULT(result); | 773 CHECK_RESULT(result); |
| 774 Loader::InitForSnapshot(script_uri); |
774 } else { | 775 } else { |
775 // Load the specified application script into the newly created isolate. | 776 // Load the specified application script into the newly created isolate. |
776 Dart_Handle uri = | 777 Dart_Handle uri = |
777 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)); | 778 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)); |
778 CHECK_RESULT(uri); | 779 CHECK_RESULT(uri); |
779 result = Loader::LibraryTagHandler(Dart_kScriptTag, | 780 result = Loader::LibraryTagHandler(Dart_kScriptTag, |
780 Dart_Null(), | 781 Dart_Null(), |
781 uri); | 782 uri); |
782 CHECK_RESULT(result); | 783 CHECK_RESULT(result); |
783 | 784 |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 GenerateScriptSnapshot(); | 1355 GenerateScriptSnapshot(); |
1355 } else { | 1356 } else { |
1356 // Lookup the library of the root script. | 1357 // Lookup the library of the root script. |
1357 Dart_Handle root_lib = Dart_RootLibrary(); | 1358 Dart_Handle root_lib = Dart_RootLibrary(); |
1358 // Import the root library into the builtin library so that we can easily | 1359 // Import the root library into the builtin library so that we can easily |
1359 // lookup the main entry point exported from the root library. | 1360 // lookup the main entry point exported from the root library. |
1360 IsolateData* isolate_data = | 1361 IsolateData* isolate_data = |
1361 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); | 1362 reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate)); |
1362 result = Dart_LibraryImportLibrary( | 1363 result = Dart_LibraryImportLibrary( |
1363 isolate_data->builtin_lib(), root_lib, Dart_Null()); | 1364 isolate_data->builtin_lib(), root_lib, Dart_Null()); |
1364 #if !defined(PRODUCT) | |
1365 if (is_noopt || | 1365 if (is_noopt || |
1366 (gen_snapshot_kind == kAppAfterRun) || | 1366 (gen_snapshot_kind == kAppAfterRun) || |
1367 (gen_snapshot_kind == kAppAOT) || | 1367 (gen_snapshot_kind == kAppAOT) || |
1368 (gen_snapshot_kind == kAppJITAfterRun)) { | 1368 (gen_snapshot_kind == kAppJITAfterRun)) { |
1369 // Load the embedder's portion of the VM service's Dart code so it will | 1369 // Load the embedder's portion of the VM service's Dart code so it will |
1370 // be included in the app snapshot. | 1370 // be included in the app snapshot. |
1371 if (!VmService::LoadForGenPrecompiled()) { | 1371 if (!VmService::LoadForGenPrecompiled()) { |
1372 fprintf(stderr, | 1372 fprintf(stderr, |
1373 "VM service loading failed: %s\n", | 1373 "VM service loading failed: %s\n", |
1374 VmService::GetErrorMessage()); | 1374 VmService::GetErrorMessage()); |
1375 fflush(stderr); | 1375 fflush(stderr); |
1376 exit(kErrorExitCode); | 1376 exit(kErrorExitCode); |
1377 } | 1377 } |
1378 } | 1378 } |
1379 #endif // PRODUCT | |
1380 | 1379 |
1381 if (compile_all) { | 1380 if (compile_all) { |
1382 result = Dart_CompileAll(); | 1381 result = Dart_CompileAll(); |
1383 CHECK_RESULT(result); | 1382 CHECK_RESULT(result); |
1384 } | 1383 } |
1385 | 1384 |
1386 if (is_noopt || (gen_snapshot_kind == kAppAOT)) { | 1385 if (is_noopt || (gen_snapshot_kind == kAppAOT)) { |
1387 Dart_QualifiedFunctionName standalone_entry_points[] = { | 1386 Dart_QualifiedFunctionName standalone_entry_points[] = { |
1388 { "dart:_builtin", "::", "_getMainClosure" }, | 1387 { "dart:_builtin", "::", "_getMainClosure" }, |
1389 { "dart:_builtin", "::", "_getPrintClosure" }, | 1388 { "dart:_builtin", "::", "_getPrintClosure" }, |
(...skipping 15 matching lines...) Expand all Loading... |
1405 { "dart:io", "Link", "Link." }, | 1404 { "dart:io", "Link", "Link." }, |
1406 { "dart:io", "OSError", "OSError." }, | 1405 { "dart:io", "OSError", "OSError." }, |
1407 { "dart:io", "TlsException", "TlsException." }, | 1406 { "dart:io", "TlsException", "TlsException." }, |
1408 { "dart:io", "X509Certificate", "X509Certificate._" }, | 1407 { "dart:io", "X509Certificate", "X509Certificate._" }, |
1409 { "dart:io", "_ExternalBuffer", "set:data" }, | 1408 { "dart:io", "_ExternalBuffer", "set:data" }, |
1410 { "dart:io", "_Platform", "set:_nativeScript" }, | 1409 { "dart:io", "_Platform", "set:_nativeScript" }, |
1411 { "dart:io", "_ProcessStartStatus", "set:_errorCode" }, | 1410 { "dart:io", "_ProcessStartStatus", "set:_errorCode" }, |
1412 { "dart:io", "_ProcessStartStatus", "set:_errorMessage" }, | 1411 { "dart:io", "_ProcessStartStatus", "set:_errorMessage" }, |
1413 { "dart:io", "_SecureFilterImpl", "get:ENCRYPTED_SIZE" }, | 1412 { "dart:io", "_SecureFilterImpl", "get:ENCRYPTED_SIZE" }, |
1414 { "dart:io", "_SecureFilterImpl", "get:SIZE" }, | 1413 { "dart:io", "_SecureFilterImpl", "get:SIZE" }, |
1415 #if !defined(PRODUCT) | |
1416 { "dart:vmservice_io", "::", "main" }, | 1414 { "dart:vmservice_io", "::", "main" }, |
1417 #endif // !PRODUCT | |
1418 { NULL, NULL, NULL } // Must be terminated with NULL entries. | 1415 { NULL, NULL, NULL } // Must be terminated with NULL entries. |
1419 }; | 1416 }; |
1420 | 1417 |
1421 const bool reset_fields = gen_snapshot_kind == kAppAOT; | 1418 const bool reset_fields = gen_snapshot_kind == kAppAOT; |
1422 result = Dart_Precompile(standalone_entry_points, reset_fields); | 1419 result = Dart_Precompile(standalone_entry_points, reset_fields); |
1423 CHECK_RESULT(result); | 1420 CHECK_RESULT(result); |
1424 } | 1421 } |
1425 | 1422 |
1426 if (gen_snapshot_kind == kAppAOT) { | 1423 if (gen_snapshot_kind == kAppAOT) { |
1427 GeneratePrecompiledSnapshot(); | 1424 GeneratePrecompiledSnapshot(); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 Platform::Exit(Process::GlobalExitCode()); | 1730 Platform::Exit(Process::GlobalExitCode()); |
1734 } | 1731 } |
1735 | 1732 |
1736 } // namespace bin | 1733 } // namespace bin |
1737 } // namespace dart | 1734 } // namespace dart |
1738 | 1735 |
1739 int main(int argc, char** argv) { | 1736 int main(int argc, char** argv) { |
1740 dart::bin::main(argc, argv); | 1737 dart::bin::main(argc, argv); |
1741 UNREACHABLE(); | 1738 UNREACHABLE(); |
1742 } | 1739 } |
OLD | NEW |