Use help-text generator for dex2oat
The use of a static text blob makes keeping the dex2oat help text up
to date difficult. Change to use the new cmdline help-text generator
code.
Test: dex2oat --help
Change-Id: I1139cba2c773242e15f863d7efd2c7050c05ab4f
diff --git a/compiler/driver/compiler_options_map-inl.h b/compiler/driver/compiler_options_map-inl.h
index e80fb46..fcbc0f2 100644
--- a/compiler/driver/compiler_options_map-inl.h
+++ b/compiler/driver/compiler_options_map-inl.h
@@ -31,17 +31,29 @@
namespace art {
+template <>
+struct CmdlineType<CompilerFilter::Filter> : CmdlineTypeParser<CompilerFilter::Filter> {
+ Result Parse(const std::string& option) {
+ CompilerFilter::Filter compiler_filter;
+ if (!CompilerFilter::ParseCompilerFilter(option.c_str(), &compiler_filter)) {
+ return Result::Failure(
+ android::base::StringPrintf("Unknown --compiler-filter value %s", option.c_str()));
+ }
+ return Result::Success(compiler_filter);
+ }
+
+ static const char* Name() {
+ return "CompilerFilter";
+ }
+ static const char* DescribeType() {
+ return CompilerFilter::DescribeOptions();
+ }
+};
+
template <class Base>
inline bool ReadCompilerOptions(Base& map, CompilerOptions* options, std::string* error_msg) {
if (map.Exists(Base::CompilerFilter)) {
- CompilerFilter::Filter compiler_filter;
- if (!CompilerFilter::ParseCompilerFilter(map.Get(Base::CompilerFilter)->c_str(),
- &compiler_filter)) {
- *error_msg = android::base::StringPrintf("Unknown --compiler-filter value %s",
- map.Get(Base::CompilerFilter)->c_str());
- return false;
- }
- options->SetCompilerFilter(compiler_filter);
+ options->SetCompilerFilter(*map.Get(Base::CompilerFilter));
}
map.AssignIfExists(Base::CompileArtTest, &options->compile_art_test_);
map.AssignIfExists(Base::HugeMethodMaxThreshold, &options->huge_method_threshold_);
@@ -108,7 +120,9 @@
inline void AddCompilerOptionsArgumentParserOptions(Builder& b) {
b.
Define("--compiler-filter=_")
- .template WithType<std::string>()
+ .template WithType<CompilerFilter::Filter>()
+ .WithHelp("Select compiler filter\n"
+ "Default: speed-profile if profile provided, speed otherwise")
.IntoKey(Map::CompilerFilter)
.Define({"--compile-art-test", "--no-compile-art-test"})
@@ -116,31 +130,49 @@
.IntoKey(Map::CompileArtTest)
.Define("--huge-method-max=_")
.template WithType<unsigned int>()
+ .WithHelp("threshold size for a huge method for compiler filter tuning.")
.IntoKey(Map::HugeMethodMaxThreshold)
.Define("--large-method-max=_")
.template WithType<unsigned int>()
+ .WithHelp("threshold size for a large method for compiler filter tuning.")
.IntoKey(Map::LargeMethodMaxThreshold)
.Define("--num-dex-methods=_")
.template WithType<unsigned int>()
+ .WithHelp("threshold size for a small dex file for compiler filter tuning. If the input\n"
+ "has fewer than this many methods and the filter is not interpret-only or\n"
+ "verify-none or verify-at-runtime, overrides the filter to use speed")
.IntoKey(Map::NumDexMethodsThreshold)
.Define("--inline-max-code-units=_")
.template WithType<unsigned int>()
+ .WithHelp("the maximum code units that a methodcan have to be considered for inlining.\n"
+ "A zero value will disable inlining. Honored only by Optimizing. Has priority\n"
+ "over the --compiler-filter option. Intended for development/experimental use.")
.IntoKey(Map::InlineMaxCodeUnitsThreshold)
.Define({"--generate-debug-info", "-g", "--no-generate-debug-info"})
.WithValues({true, true, false})
+ .WithHelp("Generate (or don't generate) debug information for native debugging, such as\n"
+ "stack unwinding information, ELF symbols and dwarf sections. If used without\n"
+ "--debuggable it will be best effort only. Does not affect the generated\n"
+ "code. Disabled by default.")
.IntoKey(Map::GenerateDebugInfo)
.Define({"--generate-mini-debug-info", "--no-generate-mini-debug-info"})
.WithValues({true, false})
+ .WithHelp("Whether or not to generate minimal amount of LZMA-compressed debug\n"
+ "information necessary to print backtraces (disabled by default).")
.IntoKey(Map::GenerateMiniDebugInfo)
.Define({"--generate-build-id", "--no-generate-build-id"})
.WithValues({true, false})
+ .WithHelp("Generate GNU-compatible linker build ID ELF section with SHA-1 of the file\n"
+ "content (and thus stable across identical builds)")
.IntoKey(Map::GenerateBuildID)
.Define({"--deduplicate-code=_"})
.template WithType<bool>()
.WithValueMap({{"false", false}, {"true", true}})
+ .WithHelp("enable|disable code deduplication. Deduplicated code will have an arbitrary\n"
+ "symbol tagged with [DEDUPED].")
.IntoKey(Map::DeduplicateCode)
.Define({"--count-hotness-in-compiled-code"})
@@ -153,18 +185,24 @@
.IntoKey(Map::CheckProfiledMethods)
.Define({"--dump-timings"})
+ .WithHelp("Display a breakdown of where time was spent.")
.IntoKey(Map::DumpTimings)
.Define({"--dump-pass-timings"})
+ .WithHelp("Display a breakdown time spent in optimization passes for each compiled"
+ " method.")
.IntoKey(Map::DumpPassTimings)
.Define({"--dump-stats"})
+ .WithHelp("Display overall compilation statistics.")
.IntoKey(Map::DumpStats)
.Define("--debuggable")
+ .WithHelp("Produce code debuggable with a java-debugger.")
.IntoKey(Map::Debuggable)
.Define("--baseline")
+ .WithHelp("Produce code using the baseline compilation")
.IntoKey(Map::Baseline)
.Define("--top-k-profile-threshold=_")
@@ -184,8 +222,12 @@
.Define("--dump-cfg=_")
.template WithType<std::string>()
+ .WithHelp("Dump control-flow graphs (CFGs) to specified file.")
.IntoKey(Map::DumpCFG)
.Define("--dump-cfg-append")
+ .WithHelp("when dumping CFGs to an existing file, append new CFG data to existing data\n"
+ "(instead of overwriting existing data with new data, which is the default\n"
+ "behavior). This option is only meaningful when used with --dump-cfg.")
.IntoKey(Map::DumpCFGAppend)
.Define("--register-allocation-strategy=_")
@@ -195,6 +237,8 @@
.Define("--resolve-startup-const-strings=_")
.template WithType<bool>()
.WithValueMap({{"false", false}, {"true", true}})
+ .WithHelp("If true, the compiler eagerly resolves strings referenced from const-string\n"
+ "of startup methods.")
.IntoKey(Map::ResolveStartupConstStrings)
.Define("--initialize-app-image-classes=_")
@@ -204,10 +248,13 @@
.Define("--verbose-methods=_")
.template WithType<ParseStringList<','>>()
+ .WithHelp("Restrict the dumped CFG data to methods whose name is listed.\n"
+ "Eg: --verbose-methods=toString,hashCode")
.IntoKey(Map::VerboseMethods)
.Define("--max-image-block-size=_")
.template WithType<unsigned int>()
+ .WithHelp("Maximum solid block size for compressed images.")
.IntoKey(Map::MaxImageBlockSize);
}