Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: runtime/bin/main.cc

Issue 2558673002: Add Kernel Isolate (Closed)
Patch Set: wip Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 static bool run_app_snapshot = false; 54 static bool run_app_snapshot = false;
55 static const char* snapshot_filename = NULL; 55 static const char* snapshot_filename = NULL;
56 enum SnapshotKind { 56 enum SnapshotKind {
57 kNone, 57 kNone,
58 kScript, 58 kScript,
59 kAppAOT, 59 kAppAOT,
60 kAppJIT, 60 kAppJIT,
61 }; 61 };
62 static SnapshotKind gen_snapshot_kind = kNone; 62 static SnapshotKind gen_snapshot_kind = kNone;
63 63
64 static bool use_dart_frontend = false;
65
66 static const char* frontend_filename = NULL;
67
64 // Value of the --package-root flag. 68 // Value of the --package-root flag.
65 // (This pointer points into an argv buffer and does not need to be 69 // (This pointer points into an argv buffer and does not need to be
66 // free'd.) 70 // free'd.)
67 static const char* commandline_package_root = NULL; 71 static const char* commandline_package_root = NULL;
68 72
69 // Value of the --packages flag. 73 // Value of the --packages flag.
70 // (This pointer points into an argv buffer and does not need to be 74 // (This pointer points into an argv buffer and does not need to be
71 // free'd.) 75 // free'd.)
72 static const char* commandline_packages_file = NULL; 76 static const char* commandline_packages_file = NULL;
73 77
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 CommandLineOptions* vm_options) { 321 CommandLineOptions* vm_options) {
318 ASSERT(arg != NULL); 322 ASSERT(arg != NULL);
319 if (*arg != '\0') { 323 if (*arg != '\0') {
320 return false; 324 return false;
321 } 325 }
322 parse_all = true; 326 parse_all = true;
323 return true; 327 return true;
324 } 328 }
325 329
326 330
331 static bool ProcessFrontendOption(const char* filename,
332 CommandLineOptions* vm_options) {
333 ASSERT(filename != NULL);
334 if (filename[0] == '\0') {
335 return false;
336 }
337 use_dart_frontend = true;
338 frontend_filename = filename;
339 vm_options->AddArgument("--use-dart-frontend");
340 return true;
341 }
342
343
327 static bool ProcessUseBlobsOption(const char* arg, 344 static bool ProcessUseBlobsOption(const char* arg,
328 CommandLineOptions* vm_options) { 345 CommandLineOptions* vm_options) {
329 ASSERT(arg != NULL); 346 ASSERT(arg != NULL);
330 if (*arg != '\0') { 347 if (*arg != '\0') {
331 return false; 348 return false;
332 } 349 }
333 use_blobs = true; 350 use_blobs = true;
334 return true; 351 return true;
335 } 352 }
336 353
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 {"--help", ProcessHelpOption}, 550 {"--help", ProcessHelpOption},
534 {"--packages=", ProcessPackagesOption}, 551 {"--packages=", ProcessPackagesOption},
535 {"--package-root=", ProcessPackageRootOption}, 552 {"--package-root=", ProcessPackageRootOption},
536 {"-v", ProcessVerboseOption}, 553 {"-v", ProcessVerboseOption},
537 {"--verbose", ProcessVerboseOption}, 554 {"--verbose", ProcessVerboseOption},
538 {"--version", ProcessVersionOption}, 555 {"--version", ProcessVersionOption},
539 556
540 // VM specific options to the standalone dart program. 557 // VM specific options to the standalone dart program.
541 {"--compile_all", ProcessCompileAllOption}, 558 {"--compile_all", ProcessCompileAllOption},
542 {"--parse_all", ProcessParseAllOption}, 559 {"--parse_all", ProcessParseAllOption},
560 {"--dfe=", ProcessFrontendOption},
543 {"--enable-vm-service", ProcessEnableVmServiceOption}, 561 {"--enable-vm-service", ProcessEnableVmServiceOption},
544 {"--disable-service-origin-check", ProcessDisableServiceOriginCheckOption}, 562 {"--disable-service-origin-check", ProcessDisableServiceOriginCheckOption},
545 {"--observe", ProcessObserveOption}, 563 {"--observe", ProcessObserveOption},
546 {"--snapshot=", ProcessSnapshotFilenameOption}, 564 {"--snapshot=", ProcessSnapshotFilenameOption},
547 {"--snapshot-kind=", ProcessSnapshotKindOption}, 565 {"--snapshot-kind=", ProcessSnapshotKindOption},
548 {"--use-blobs", ProcessUseBlobsOption}, 566 {"--use-blobs", ProcessUseBlobsOption},
549 {"--trace-loading", ProcessTraceLoadingOption}, 567 {"--trace-loading", ProcessTraceLoadingOption},
550 {"--hot-reload-test-mode", ProcessHotReloadTestModeOption}, 568 {"--hot-reload-test-mode", ProcessHotReloadTestModeOption},
551 {"--hot-reload-rollback-test-mode", ProcessHotReloadRollbackTestModeOption}, 569 {"--hot-reload-rollback-test-mode", ProcessHotReloadRollbackTestModeOption},
552 {"--short_socket_read", ProcessShortSocketReadOption}, 570 {"--short_socket_read", ProcessShortSocketReadOption},
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 const bool run_service_isolate = needs_load_port; 802 const bool run_service_isolate = needs_load_port;
785 #else 803 #else
786 // Always create the service isolate in DEBUG and RELEASE modes for profiling, 804 // Always create the service isolate in DEBUG and RELEASE modes for profiling,
787 // even if we don't need it for loading. 805 // even if we don't need it for loading.
788 const bool run_service_isolate = true; 806 const bool run_service_isolate = true;
789 #endif // PRODUCT 807 #endif // PRODUCT
790 if (!run_service_isolate && 808 if (!run_service_isolate &&
791 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) { 809 (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0)) {
792 return NULL; 810 return NULL;
793 } 811 }
812 if (strcmp(script_uri, DART_KERNEL_ISOLATE_NAME) == 0) {
813 if (!use_dart_frontend) {
814 *error = strdup("Kernel isolate not supported.");
815 return NULL;
816 } else {
817 if (packages_config == NULL) {
818 packages_config = commandline_packages_file;
819 }
820 }
821 }
794 822
795 // If the script is a Kernel binary, then we will try to bootstrap from the 823 // If the script is a Kernel binary, then we will try to bootstrap from the
796 // script. 824 // script.
797 const uint8_t* kernel_file = NULL; 825 const uint8_t* kernel_file = NULL;
798 intptr_t kernel_length = -1; 826 intptr_t kernel_length = -1;
799 const bool is_kernel = 827 const bool is_kernel =
800 !run_app_snapshot && 828 !run_app_snapshot &&
801 TryReadKernel(script_uri, &kernel_file, &kernel_length); 829 TryReadKernel(script_uri, &kernel_file, &kernel_length);
802 830
803 void* kernel_program = NULL; 831 void* kernel_program = NULL;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 result = DartUtils::PrepareForScriptLoading(false, trace_loading); 891 result = DartUtils::PrepareForScriptLoading(false, trace_loading);
864 CHECK_RESULT(result); 892 CHECK_RESULT(result);
865 893
866 if (needs_load_port) { 894 if (needs_load_port) {
867 // Set up the load port provided by the service isolate so that we can 895 // Set up the load port provided by the service isolate so that we can
868 // load scripts. 896 // load scripts.
869 result = DartUtils::SetupServiceLoadPort(); 897 result = DartUtils::SetupServiceLoadPort();
870 CHECK_RESULT(result); 898 CHECK_RESULT(result);
871 } 899 }
872 900
901 if (Dart_IsKernelIsolate(isolate)) {
902 script_uri = frontend_filename;
903 }
904
873 // Setup package root if specified. 905 // Setup package root if specified.
874 result = DartUtils::SetupPackageRoot(package_root, packages_config); 906 result = DartUtils::SetupPackageRoot(package_root, packages_config);
875 CHECK_RESULT(result); 907 CHECK_RESULT(result);
876 908
877 result = Dart_SetEnvironmentCallback(EnvironmentCallback); 909 result = Dart_SetEnvironmentCallback(EnvironmentCallback);
878 CHECK_RESULT(result); 910 CHECK_RESULT(result);
879 911
912 if (!Dart_IsKernelIsolate(isolate) && use_dart_frontend) {
913 Log::PrintErr("Waiting for Kernel isolate to load.\n");
914 // This must be the main script to be loaded. Wait for Kernel isolate
915 // to finish initialization.
916 Dart_Port port = Dart_ServiceWaitForKernelPort();
917 if (port == ILLEGAL_PORT) {
918 *error = strdup("Error while initializing Kernel isolate");
919 return NULL;
920 }
921 }
922
880 if (run_app_snapshot) { 923 if (run_app_snapshot) {
881 result = DartUtils::SetupIOLibrary(script_uri); 924 result = DartUtils::SetupIOLibrary(script_uri);
882 CHECK_RESULT(result); 925 CHECK_RESULT(result);
883 Loader::InitForSnapshot(script_uri); 926 Loader::InitForSnapshot(script_uri);
884 } else { 927 } else {
885 // Load the specified application script into the newly created isolate. 928 // Load the specified application script into the newly created isolate.
886 Dart_Handle uri = 929 Dart_Handle uri =
887 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)); 930 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri));
888 CHECK_RESULT(uri); 931 CHECK_RESULT(uri);
889 if (!is_kernel) { 932 if (!is_kernel) {
(...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 Platform::Exit(Process::GlobalExitCode()); 1986 Platform::Exit(Process::GlobalExitCode());
1944 } 1987 }
1945 1988
1946 } // namespace bin 1989 } // namespace bin
1947 } // namespace dart 1990 } // namespace dart
1948 1991
1949 int main(int argc, char** argv) { 1992 int main(int argc, char** argv) {
1950 dart::bin::main(argc, argv); 1993 dart::bin::main(argc, argv);
1951 UNREACHABLE(); 1994 UNREACHABLE();
1952 } 1995 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698