Compilation filter
This CL introduces a static compilation filter mechanism intended
to allow us to reduce compilation time and space requirements until
we have a profiling mechanism in place.
It supports 5 modes of filtering:
o interpret-only (compile nothing)
o deferred-compilation (compile only those methods believe to be
compute-intensive)
o space (optimized for space)
o balanced (best return on space investment)
o speed (compile everything)
A future CL will allow the default filtering mode to be set
via system property. For now, you can pass it in via command
line as follows:
dalvikvm -compiler-filter:[interpret-only|defer-compilation|
space|balanced|speed]
or dex2oat --runtime-arg -compiler-filter:[one of the above modes]
Creating a file named art/SMALL_ART will force the filter
default to interpret-only. Later on we'll move this capability
to a persistent system property.
or modify kDefaultCompilerFilter in runtime.h
It also changes the compiler driver to allow the compilers to
decline to compile a method by return NULL.
Change-Id: Ic73411818f8bb845a4a19a05b0395c50902c534f
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 84f186d..6052993 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -609,6 +609,28 @@
oat_location_option_string += oat_cache_filename;
const char* oat_location_option = oat_location_option_string.c_str();
+ std::string oat_compiler_filter_string("-compiler-filter:");
+ switch (Runtime::Current()->GetCompilerFilter()) {
+ case Runtime::kInterpretOnly:
+ oat_compiler_filter_string += "interpret-only";
+ break;
+ case Runtime::kDeferCompilation:
+ oat_compiler_filter_string += "defer-compilation";
+ break;
+ case Runtime::kSpace:
+ oat_compiler_filter_string += "space";
+ break;
+ case Runtime::kBalanced:
+ oat_compiler_filter_string += "balanced";
+ break;
+ case Runtime::kSpeed:
+ oat_compiler_filter_string += "speed";
+ break;
+ default:
+ LOG(FATAL) << "Unexpected case.";
+ }
+ const char* oat_compiler_filter_option = oat_compiler_filter_string.c_str();
+
// fork and exec dex2oat
pid_t pid = fork();
if (pid == 0) {
@@ -622,6 +644,7 @@
<< " --runtime-arg -Xmx64m"
<< " --runtime-arg -classpath"
<< " --runtime-arg " << class_path
+ << " --runtime-arg " << oat_compiler_filter_option
#if !defined(ART_TARGET)
<< " --host"
#endif
@@ -635,6 +658,7 @@
"--runtime-arg", "-Xmx64m",
"--runtime-arg", "-classpath",
"--runtime-arg", class_path,
+ "--runtime-arg", oat_compiler_filter_option,
#if !defined(ART_TARGET)
"--host",
#endif