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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/include/dart_native_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 5b14dff3ec5c9961d3168e07df1ce9a89931f701..66647ebea30da35110f55c9049e9bde111bf32bc 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -65,6 +65,12 @@ static const char* commandline_package_root = NULL;
// dart functions and not run anything.
static bool has_compile_all = false;
+
+// Global flag that is used to indicate that we want to compile all the
+// dart functions before running main and not compile anything thereafter.
+static bool has_precompile = false;
+
+
// Global flag that is used to indicate that we want to trace resolution of
// URIs and the loading of libraries, parts and scripts.
static bool has_trace_loading = false;
@@ -266,6 +272,19 @@ static bool ProcessCompileAllOption(const char* arg,
return true;
}
+
+static bool ProcessPrecompileOption(const char* arg,
+ CommandLineOptions* vm_options) {
+ ASSERT(arg != NULL);
+ if (*arg != '\0') {
+ return false;
+ }
+ has_precompile = true;
+ vm_options->AddArgument("--precompile");
+ return true;
+}
+
+
static bool ProcessDebugOption(const char* option_value,
CommandLineOptions* vm_options) {
ASSERT(option_value != NULL);
@@ -375,6 +394,7 @@ static struct {
// VM specific options to the standalone dart program.
{ "--break-at=", ProcessBreakpointOption },
{ "--compile_all", ProcessCompileAllOption },
+ { "--precompile", ProcessPrecompileOption },
{ "--debug", ProcessDebugOption },
{ "--snapshot=", ProcessGenScriptSnapshotOption },
{ "--enable-vm-service", ProcessEnableVmServiceOption },
@@ -597,7 +617,10 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
*error = strdup(VmService::GetErrorMessage());
return NULL;
}
- if (has_compile_all) {
+ if (has_precompile) {
+ result = Dart_Precompile();
+ CHECK_RESULT(result);
+ } else if (has_compile_all) {
result = Dart_CompileAll();
CHECK_RESULT(result);
}
@@ -1041,7 +1064,10 @@ void main(int argc, char** argv) {
ASSERT(!Dart_IsError(builtin_lib));
result = Dart_LibraryImportLibrary(builtin_lib, root_lib, Dart_Null());
- if (has_compile_all) {
+ if (has_precompile) {
+ result = Dart_Precompile();
+ DartExitOnError(result);
+ } else if (has_compile_all) {
result = Dart_CompileAll();
DartExitOnError(result);
}
« 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