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

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

Issue 1261673004: Non-tree-shaking --precompile. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months 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
« no previous file with comments | « no previous file | runtime/include/dart_native_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // Value of the --package-root flag. 58 // Value of the --package-root flag.
59 // (This pointer points into an argv buffer and does not need to be 59 // (This pointer points into an argv buffer and does not need to be
60 // free'd.) 60 // free'd.)
61 static const char* commandline_package_root = NULL; 61 static const char* commandline_package_root = NULL;
62 62
63 63
64 // Global flag that is used to indicate that we want to compile all the 64 // Global flag that is used to indicate that we want to compile all the
65 // dart functions and not run anything. 65 // dart functions and not run anything.
66 static bool has_compile_all = false; 66 static bool has_compile_all = false;
67 67
68
69 // Global flag that is used to indicate that we want to compile all the
70 // dart functions before running main and not compile anything thereafter.
71 static bool has_precompile = false;
72
73
68 // Global flag that is used to indicate that we want to trace resolution of 74 // Global flag that is used to indicate that we want to trace resolution of
69 // URIs and the loading of libraries, parts and scripts. 75 // URIs and the loading of libraries, parts and scripts.
70 static bool has_trace_loading = false; 76 static bool has_trace_loading = false;
71 77
72 78
73 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; 79 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1";
74 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; 80 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181;
75 // VM Service options. 81 // VM Service options.
76 static bool start_vm_service = false; 82 static bool start_vm_service = false;
77 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; 83 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 static bool ProcessCompileAllOption(const char* arg, 265 static bool ProcessCompileAllOption(const char* arg,
260 CommandLineOptions* vm_options) { 266 CommandLineOptions* vm_options) {
261 ASSERT(arg != NULL); 267 ASSERT(arg != NULL);
262 if (*arg != '\0') { 268 if (*arg != '\0') {
263 return false; 269 return false;
264 } 270 }
265 has_compile_all = true; 271 has_compile_all = true;
266 return true; 272 return true;
267 } 273 }
268 274
275
276 static bool ProcessPrecompileOption(const char* arg,
277 CommandLineOptions* vm_options) {
278 ASSERT(arg != NULL);
279 if (*arg != '\0') {
280 return false;
281 }
282 has_precompile = true;
283 vm_options->AddArgument("--precompile");
284 return true;
285 }
286
287
269 static bool ProcessDebugOption(const char* option_value, 288 static bool ProcessDebugOption(const char* option_value,
270 CommandLineOptions* vm_options) { 289 CommandLineOptions* vm_options) {
271 ASSERT(option_value != NULL); 290 ASSERT(option_value != NULL);
272 if (!ExtractPortAndIP(option_value, &debug_port, &debug_ip, 291 if (!ExtractPortAndIP(option_value, &debug_port, &debug_ip,
273 DEFAULT_DEBUG_PORT, DEFAULT_DEBUG_IP)) { 292 DEFAULT_DEBUG_PORT, DEFAULT_DEBUG_IP)) {
274 Log::PrintErr("unrecognized --debug option syntax. " 293 Log::PrintErr("unrecognized --debug option syntax. "
275 "Use --debug[:<port number>[/<IPv4 address>]]\n"); 294 "Use --debug[:<port number>[/<IPv4 address>]]\n");
276 return false; 295 return false;
277 } 296 }
278 297
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 { "--version", ProcessVersionOption }, 387 { "--version", ProcessVersionOption },
369 { "--help", ProcessHelpOption }, 388 { "--help", ProcessHelpOption },
370 { "-h", ProcessHelpOption }, 389 { "-h", ProcessHelpOption },
371 { "--verbose", ProcessVerboseOption }, 390 { "--verbose", ProcessVerboseOption },
372 { "-v", ProcessVerboseOption }, 391 { "-v", ProcessVerboseOption },
373 { "--package-root=", ProcessPackageRootOption }, 392 { "--package-root=", ProcessPackageRootOption },
374 { "-D", ProcessEnvironmentOption }, 393 { "-D", ProcessEnvironmentOption },
375 // VM specific options to the standalone dart program. 394 // VM specific options to the standalone dart program.
376 { "--break-at=", ProcessBreakpointOption }, 395 { "--break-at=", ProcessBreakpointOption },
377 { "--compile_all", ProcessCompileAllOption }, 396 { "--compile_all", ProcessCompileAllOption },
397 { "--precompile", ProcessPrecompileOption },
378 { "--debug", ProcessDebugOption }, 398 { "--debug", ProcessDebugOption },
379 { "--snapshot=", ProcessGenScriptSnapshotOption }, 399 { "--snapshot=", ProcessGenScriptSnapshotOption },
380 { "--enable-vm-service", ProcessEnableVmServiceOption }, 400 { "--enable-vm-service", ProcessEnableVmServiceOption },
381 { "--observe", ProcessObserveOption }, 401 { "--observe", ProcessObserveOption },
382 { "--trace-debug-protocol", ProcessTraceDebugProtocolOption }, 402 { "--trace-debug-protocol", ProcessTraceDebugProtocolOption },
383 { "--trace-loading", ProcessTraceLoadingOption}, 403 { "--trace-loading", ProcessTraceLoadingOption},
384 { NULL, NULL } 404 { NULL, NULL }
385 }; 405 };
386 406
387 407
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 // Set up the library tag handler for this isolate. 610 // Set up the library tag handler for this isolate.
591 Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); 611 Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler);
592 CHECK_RESULT(result); 612 CHECK_RESULT(result);
593 613
594 if (Dart_IsServiceIsolate(isolate)) { 614 if (Dart_IsServiceIsolate(isolate)) {
595 // If this is the service isolate, load embedder specific bits and return. 615 // If this is the service isolate, load embedder specific bits and return.
596 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port)) { 616 if (!VmService::Setup(vm_service_server_ip, vm_service_server_port)) {
597 *error = strdup(VmService::GetErrorMessage()); 617 *error = strdup(VmService::GetErrorMessage());
598 return NULL; 618 return NULL;
599 } 619 }
600 if (has_compile_all) { 620 if (has_precompile) {
621 result = Dart_Precompile();
622 CHECK_RESULT(result);
623 } else if (has_compile_all) {
601 result = Dart_CompileAll(); 624 result = Dart_CompileAll();
602 CHECK_RESULT(result); 625 CHECK_RESULT(result);
603 } 626 }
604 Dart_ExitScope(); 627 Dart_ExitScope();
605 Dart_ExitIsolate(); 628 Dart_ExitIsolate();
606 return isolate; 629 return isolate;
607 } 630 }
608 631
609 // Load the specified application script into the newly created isolate. 632 // Load the specified application script into the newly created isolate.
610 633
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 } else { 1057 } else {
1035 // Lookup the library of the root script. 1058 // Lookup the library of the root script.
1036 Dart_Handle root_lib = Dart_RootLibrary(); 1059 Dart_Handle root_lib = Dart_RootLibrary();
1037 // Import the root library into the builtin library so that we can easily 1060 // Import the root library into the builtin library so that we can easily
1038 // lookup the main entry point exported from the root library. 1061 // lookup the main entry point exported from the root library.
1039 Dart_Handle builtin_lib = 1062 Dart_Handle builtin_lib =
1040 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); 1063 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
1041 ASSERT(!Dart_IsError(builtin_lib)); 1064 ASSERT(!Dart_IsError(builtin_lib));
1042 result = Dart_LibraryImportLibrary(builtin_lib, root_lib, Dart_Null()); 1065 result = Dart_LibraryImportLibrary(builtin_lib, root_lib, Dart_Null());
1043 1066
1044 if (has_compile_all) { 1067 if (has_precompile) {
1068 result = Dart_Precompile();
1069 DartExitOnError(result);
1070 } else if (has_compile_all) {
1045 result = Dart_CompileAll(); 1071 result = Dart_CompileAll();
1046 DartExitOnError(result); 1072 DartExitOnError(result);
1047 } 1073 }
1048 1074
1049 if (Dart_IsNull(root_lib)) { 1075 if (Dart_IsNull(root_lib)) {
1050 ErrorExit(kErrorExitCode, 1076 ErrorExit(kErrorExitCode,
1051 "Unable to find root library for '%s'\n", 1077 "Unable to find root library for '%s'\n",
1052 script_name); 1078 script_name);
1053 } 1079 }
1054 1080
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 exit(Process::GlobalExitCode()); 1143 exit(Process::GlobalExitCode());
1118 } 1144 }
1119 1145
1120 } // namespace bin 1146 } // namespace bin
1121 } // namespace dart 1147 } // namespace dart
1122 1148
1123 int main(int argc, char** argv) { 1149 int main(int argc, char** argv) {
1124 dart::bin::main(argc, argv); 1150 dart::bin::main(argc, argv);
1125 UNREACHABLE(); 1151 UNREACHABLE();
1126 } 1152 }
OLDNEW
« no previous file with comments | « no previous file | runtime/include/dart_native_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698