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
(cherry picked from commit a024a0686c3b0fea13f362bff70d65981e5febc5)
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 38d00a0..e7ba402 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -334,8 +334,8 @@
std::string const& filename);
CompilerDriver::CompilerDriver(CompilerBackend compiler_backend, InstructionSet instruction_set,
- bool image, DescriptorSet* image_classes,
- size_t thread_count, bool dump_stats)
+ bool image, DescriptorSet* image_classes, size_t thread_count,
+ bool dump_stats)
: compiler_backend_(compiler_backend),
instruction_set_(instruction_set),
freezing_constructor_lock_("freezing constructor lock"),
@@ -2253,6 +2253,10 @@
} else {
bool compile = verifier::MethodVerifier::IsCandidateForCompilation(code_item, access_flags);
if (compile) {
+ // If we're doing the image, override the compiler filter to force full compilation.
+ if ((image_classes_.get() != NULL) && (image_classes_->size() != 0)) {
+ Runtime::Current()->SetCompilerFilter(Runtime::kSpeed);
+ }
CompilerFn compiler = compiler_;
#ifdef ART_SEA_IR_MODE
bool use_sea = Runtime::Current()->IsSeaIRMode();
@@ -2261,9 +2265,9 @@
compiler = sea_ir_compiler_;
}
#endif
+ // NOTE: if compiler declines to compile this method, it will return NULL.
compiled_method = (*compiler)(*this, code_item, access_flags, invoke_type, class_def_idx,
method_idx, class_loader, dex_file);
- CHECK(compiled_method != NULL) << PrettyMethod(method_idx, dex_file);
} else if (dex_to_dex_compilation_level != kDontDexToDexCompile) {
// TODO: add a mode to disable DEX-to-DEX compilation ?
(*dex_to_dex_compiler_)(*this, code_item, access_flags,