diff options
author | 2020-03-31 20:52:09 +0100 | |
---|---|---|
committer | 2020-04-01 17:19:07 +0100 | |
commit | 4fa07a5727551018e2dcd93d41dac98f20212e99 (patch) | |
tree | 8214358e517601c67706a4fbbb4010408a45780a | |
parent | d31def587a914c1d306355a7331c24d7b13ad5ca (diff) |
Add explicit compiler option to enable test-specific features.
We can no longer rely on checking the "core.art" image name,
since we plan to remove it and use the shipped boot image.
This option enables test-specific features, such as $noinline$.
Test: ./art/test.py -r --optimizing --64
Bug: 147817558
Change-Id: Iadac6e1b0f46e83efd0551fb8462a6b268ad33d8
-rw-r--r-- | compiler/driver/compiler_options.cc | 22 | ||||
-rw-r--r-- | compiler/driver/compiler_options.h | 15 | ||||
-rw-r--r-- | compiler/driver/compiler_options_map-inl.h | 4 | ||||
-rw-r--r-- | compiler/driver/compiler_options_map.def | 1 | ||||
-rw-r--r-- | compiler/jit/jit_compiler.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/inliner.cc | 5 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 2 | ||||
-rw-r--r-- | dex2oat/dex2oat.cc | 3 | ||||
-rwxr-xr-x | test/etc/run-test-jar | 4 |
9 files changed, 18 insertions, 40 deletions
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc index 5681134666..05500751f8 100644 --- a/compiler/driver/compiler_options.cc +++ b/compiler/driver/compiler_options.cc @@ -51,7 +51,7 @@ CompilerOptions::CompilerOptions() image_classes_(), verification_results_(nullptr), image_type_(ImageType::kNone), - compiling_with_core_image_(false), + compile_art_test_(false), baseline_(false), debuggable_(false), generate_debug_info_(kDefaultGenerateDebugInfo), @@ -186,24 +186,4 @@ bool CompilerOptions::IsMethodVerifiedWithoutFailures(uint32_t method_idx, return is_system_class; } -bool CompilerOptions::IsCoreImageFilename(const std::string& boot_image_filename) { - std::string_view filename(boot_image_filename); - size_t colon_pos = filename.find(':'); - if (colon_pos != std::string_view::npos) { - filename = filename.substr(0u, colon_pos); - } - // Look for "core.art" or "core-*.art". - if (EndsWith(filename, "core.art")) { - return true; - } - if (!EndsWith(filename, ".art")) { - return false; - } - size_t slash_pos = filename.rfind('/'); - if (slash_pos == std::string::npos) { - return StartsWith(filename, "core-"); - } - return filename.compare(slash_pos + 1, 5u, "core-") == 0; -} - } // namespace art diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h index 639c5475e8..6cdb821e6e 100644 --- a/compiler/driver/compiler_options.h +++ b/compiler/driver/compiler_options.h @@ -218,11 +218,10 @@ class CompilerOptions final { return image_type_ == ImageType::kAppImage; } - // Returns whether we are compiling against a "core" image, which - // is an indicative we are running tests. The compiler will use that - // information for checking invariants. - bool CompilingWithCoreImage() const { - return compiling_with_core_image_; + // Returns whether we are running ART tests. + // The compiler will use that information for checking invariants. + bool CompileArtTest() const { + return compile_art_test_; } // Should the code be compiled as position independent? @@ -367,10 +366,6 @@ class CompilerOptions final { return initialize_app_image_classes_; } - // Is `boot_image_filename` the name of a core image (small boot - // image used for ART testing only)? - static bool IsCoreImageFilename(const std::string& boot_image_filename); - private: bool ParseDumpInitFailures(const std::string& option, std::string* error_msg); bool ParseRegisterAllocationStrategy(const std::string& option, std::string* error_msg); @@ -400,7 +395,7 @@ class CompilerOptions final { const VerificationResults* verification_results_; ImageType image_type_; - bool compiling_with_core_image_; + bool compile_art_test_; bool baseline_; bool debuggable_; bool generate_debug_info_; diff --git a/compiler/driver/compiler_options_map-inl.h b/compiler/driver/compiler_options_map-inl.h index e8a425d465..e80fb46503 100644 --- a/compiler/driver/compiler_options_map-inl.h +++ b/compiler/driver/compiler_options_map-inl.h @@ -43,6 +43,7 @@ inline bool ReadCompilerOptions(Base& map, CompilerOptions* options, std::string } options->SetCompilerFilter(compiler_filter); } + map.AssignIfExists(Base::CompileArtTest, &options->compile_art_test_); map.AssignIfExists(Base::HugeMethodMaxThreshold, &options->huge_method_threshold_); map.AssignIfExists(Base::LargeMethodMaxThreshold, &options->large_method_threshold_); map.AssignIfExists(Base::NumDexMethodsThreshold, &options->num_dex_methods_threshold_); @@ -110,6 +111,9 @@ inline void AddCompilerOptionsArgumentParserOptions(Builder& b) { .template WithType<std::string>() .IntoKey(Map::CompilerFilter) + .Define({"--compile-art-test", "--no-compile-art-test"}) + .WithValues({true, false}) + .IntoKey(Map::CompileArtTest) .Define("--huge-method-max=_") .template WithType<unsigned int>() .IntoKey(Map::HugeMethodMaxThreshold) diff --git a/compiler/driver/compiler_options_map.def b/compiler/driver/compiler_options_map.def index df06bd827c..40a62843dc 100644 --- a/compiler/driver/compiler_options_map.def +++ b/compiler/driver/compiler_options_map.def @@ -37,6 +37,7 @@ // TODO: Add type parser. COMPILER_OPTIONS_KEY (std::string, CompilerFilter) +COMPILER_OPTIONS_KEY (bool, CompileArtTest) COMPILER_OPTIONS_KEY (Unit, PIC) COMPILER_OPTIONS_KEY (unsigned int, HugeMethodMaxThreshold) COMPILER_OPTIONS_KEY (unsigned int, LargeMethodMaxThreshold) diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index 0f12457f6b..31dbec4ed0 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -106,8 +106,6 @@ void JitCompiler::ParseCompilerOptions() { instruction_set_features = InstructionSetFeatures::FromCppDefines(); } compiler_options_->instruction_set_features_ = std::move(instruction_set_features); - compiler_options_->compiling_with_core_image_ = - CompilerOptions::IsCoreImageFilename(runtime->GetImageLocation()); if (compiler_options_->GetGenerateDebugInfo()) { jit_logger_.reset(new JitLogger()); diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 24d6e656c2..05a0afacfd 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -148,15 +148,14 @@ bool HInliner::Run() { DCHECK_NE(total_number_of_instructions_, 0u); DCHECK_NE(inlining_budget_, 0u); - // If we're compiling with a core image (which is only used for - // test purposes), honor inlining directives in method names: + // If we're compiling tests, honor inlining directives in method names: // - if a method's name contains the substring "$noinline$", do not // inline that method; // - if a method's name contains the substring "$inline$", ensure // that this method is actually inlined. // We limit the latter to AOT compilation, as the JIT may or may not inline // depending on the state of classes at runtime. - const bool honor_noinline_directives = codegen_->GetCompilerOptions().CompilingWithCoreImage(); + const bool honor_noinline_directives = codegen_->GetCompilerOptions().CompileArtTest(); const bool honor_inline_directives = honor_noinline_directives && Runtime::Current()->IsAotCompiler(); diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 346f60d4dc..3945b17c0d 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -1106,7 +1106,7 @@ CompiledMethod* OptimizingCompiler::Compile(const dex::CodeItem* code_item, } if (kIsDebugBuild && - compiler_options.CompilingWithCoreImage() && + compiler_options.CompileArtTest() && IsInstructionSetSupported(compiler_options.GetInstructionSet())) { // For testing purposes, we put a special marker on method names // that should be compiled with this compiler (when the diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 32200bcff1..cb49bfe127 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -1142,9 +1142,6 @@ class Dex2Oat final { } compiler_options_->passes_to_run_ = passes_to_run_.get(); - compiler_options_->compiling_with_core_image_ = - !boot_image_filename_.empty() && - CompilerOptions::IsCoreImageFilename(boot_image_filename_); } void ExpandOatAndImageFilenames() { diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar index 32f7cb9561..fc74f0516d 100755 --- a/test/etc/run-test-jar +++ b/test/etc/run-test-jar @@ -111,6 +111,10 @@ ANDROID_FLAGS="${ANDROID_FLAGS} -XX:SlowDebug=true" ANDROID_FLAGS="${ANDROID_FLAGS} -Xcompiler-option --runtime-arg -Xcompiler-option -XX:SlowDebug=true" COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -XX:SlowDebug=true" +# Let the compiler and runtime know that we are running tests. +COMPILE_FLAGS="${COMPILE_FLAGS} --compile-art-test" +FLAGS="${FLAGS} -Xcompiler-option --compile-art-test" + while true; do if [ "x$1" = "x--quiet" ]; then QUIET="y" |