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
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
index 5681134..0550075 100644
--- a/compiler/driver/compiler_options.cc
+++ b/compiler/driver/compiler_options.cc
@@ -51,7 +51,7 @@
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 @@
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 639c547..6cdb821 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -218,11 +218,10 @@
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 @@
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 @@
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 e8a425d..e80fb46 100644
--- a/compiler/driver/compiler_options_map-inl.h
+++ b/compiler/driver/compiler_options_map-inl.h
@@ -43,6 +43,7 @@
}
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 @@
.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 df06bd8..40a6284 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)