Small cleanups
This change addresses several cleanup opportunities that came up during
https://r.android.com/1298080, including:
* Remove --no-dex2oat from the run-test usage message, since this option
is no longer supported.
* Refactor the `b ? OatHeader::kTrueValue : OatHeader::kFalseValue`
pattern in dex2oat so there is less code duplication.
Test: ./test.py --host
Change-Id: I9a2a6649116cd431c3829901965f2e48812fcbd6
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 1745295..e767224 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -774,6 +774,15 @@
Handle<mirror::Object> old_field_value_;
};
+class OatKeyValueStore : public SafeMap<std::string, std::string> {
+ public:
+ using SafeMap::Put;
+
+ iterator Put(const std::string& k, bool v) {
+ return SafeMap::Put(k, v ? OatHeader::kTrueValue : OatHeader::kFalseValue);
+ }
+};
+
class Dex2Oat final {
public:
explicit Dex2Oat(TimingLogger* timings) :
@@ -1111,7 +1120,7 @@
}
// Fill some values into the key-value store for the oat header.
- key_value_store_.reset(new SafeMap<std::string, std::string>());
+ key_value_store_.reset(new OatKeyValueStore());
// Automatically force determinism for the boot image and boot image extensions in a host build.
if (!kIsTargetBuild && (IsBootImage() || IsBootImageExtension())) {
@@ -1200,16 +1209,12 @@
}
key_value_store_->Put(OatHeader::kDex2OatCmdLineKey, oss.str());
}
- key_value_store_->Put(
- OatHeader::kDebuggableKey,
- compiler_options_->debuggable_ ? OatHeader::kTrueValue : OatHeader::kFalseValue);
- key_value_store_->Put(
- OatHeader::kNativeDebuggableKey,
- compiler_options_->GetNativeDebuggable() ? OatHeader::kTrueValue : OatHeader::kFalseValue);
+ key_value_store_->Put(OatHeader::kDebuggableKey, compiler_options_->debuggable_);
+ key_value_store_->Put(OatHeader::kNativeDebuggableKey,
+ compiler_options_->GetNativeDebuggable());
key_value_store_->Put(OatHeader::kCompilerFilter,
- CompilerFilter::NameOfFilter(compiler_options_->GetCompilerFilter()));
- key_value_store_->Put(OatHeader::kConcurrentCopying,
- kUseReadBarrier ? OatHeader::kTrueValue : OatHeader::kFalseValue);
+ CompilerFilter::NameOfFilter(compiler_options_->GetCompilerFilter()));
+ key_value_store_->Put(OatHeader::kConcurrentCopying, kUseReadBarrier);
if (invocation_file_.get() != -1) {
std::ostringstream oss;
for (int i = 0; i < argc; ++i) {
@@ -2983,7 +2988,7 @@
std::unique_ptr<CompilerOptions> compiler_options_;
Compiler::Kind compiler_kind_;
- std::unique_ptr<SafeMap<std::string, std::string> > key_value_store_;
+ std::unique_ptr<OatKeyValueStore> key_value_store_;
std::unique_ptr<VerificationResults> verification_results_;
diff --git a/test/run-test b/test/run-test
index 717938f..714c90a 100755
--- a/test/run-test
+++ b/test/run-test
@@ -797,7 +797,6 @@
echo " --zygote Spawn the process from the Zygote." \
"If used, then the"
echo " other runtime options are ignored."
- echo " --no-dex2oat Run as though dex2oat was failing."
echo " --prebuild Run dex2oat on the files before starting test. (default)"
echo " --no-prebuild Do not run dex2oat on the files before starting"
echo " the test."