summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-09-17 14:03:21 -0700
committerAndreas Gampe <agampe@google.com>2015-09-28 15:18:20 -0700
commitcc07760776c3d2fb2ebc90858b6c20c48c78d783 (patch)
treebe25f4a19b687984b5f87b1337f21f44f3fca8e1
parente4cf5892c2a244034900d49499c071b255571bba (diff)
downloadart-cc07760776c3d2fb2ebc90858b6c20c48c78d783.zip
art-cc07760776c3d2fb2ebc90858b6c20c48c78d783.tar.gz
art-cc07760776c3d2fb2ebc90858b6c20c48c78d783.tar.bz2
ART: Clean up less in dex2oat
In non-debug builds, clean up even less. We already did not shut down the runtime. Also skipping the compiler driver and the verification results removes all major points of destructor performance. Tested with a common large app on Nexus 9. Time between dex2oat timing message and executable exit (log from immediately-after log echo) [w/o swap, w/ swap]. Before: 2.409s / 48.774s After: 0.132s / 0.188s Bug: 24199200 Change-Id: I5d8c17f8e28796545cfbb3887c07c92905f9b48d (cherry picked from commit 3f30e1219dd76f78bb9b6504e696a04a3dfae564)
-rw-r--r--dex2oat/dex2oat.cc57
1 files changed, 34 insertions, 23 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index e913c20..466f5e6 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -502,6 +502,7 @@ class Dex2Oat FINAL {
compiler_kind_(kUseOptimizingCompiler ? Compiler::kOptimizing : Compiler::kQuick),
instruction_set_(kRuntimeISA),
// Take the default set of instruction features from the build.
+ verification_results_(nullptr),
method_inliner_map_(),
runtime_(nullptr),
thread_count_(sysconf(_SC_NPROCESSORS_CONF)),
@@ -517,6 +518,7 @@ class Dex2Oat FINAL {
compiled_methods_filename_(nullptr),
image_(false),
is_host_(false),
+ driver_(nullptr),
dump_stats_(false),
dump_passes_(false),
dump_timing_(false),
@@ -536,6 +538,8 @@ class Dex2Oat FINAL {
if (kIsDebugBuild || (RUNNING_ON_VALGRIND != 0)) {
delete runtime_; // See field declaration for why this is manual.
+ delete driver_;
+ delete verification_results_;
}
}
@@ -1167,9 +1171,9 @@ class Dex2Oat FINAL {
runtime_options.push_back(std::make_pair(runtime_args_[i], nullptr));
}
- verification_results_.reset(new VerificationResults(compiler_options_.get()));
+ verification_results_ = new VerificationResults(compiler_options_.get());
callbacks_.reset(new QuickCompilerCallbacks(
- verification_results_.get(),
+ verification_results_,
&method_inliner_map_,
image_ ?
CompilerCallbacks::CallbackMode::kCompileBootImage :
@@ -1381,23 +1385,23 @@ class Dex2Oat FINAL {
class_loader = class_linker->CreatePathClassLoader(self, class_path_files);
}
- driver_.reset(new CompilerDriver(compiler_options_.get(),
- verification_results_.get(),
- &method_inliner_map_,
- compiler_kind_,
- instruction_set_,
- instruction_set_features_.get(),
- image_,
- image_classes_.release(),
- compiled_classes_.release(),
- nullptr,
- thread_count_,
- dump_stats_,
- dump_passes_,
- dump_cfg_file_name_,
- compiler_phases_timings_.get(),
- swap_fd_,
- profile_file_));
+ driver_ = new CompilerDriver(compiler_options_.get(),
+ verification_results_,
+ &method_inliner_map_,
+ compiler_kind_,
+ instruction_set_,
+ instruction_set_features_.get(),
+ image_,
+ image_classes_.release(),
+ compiled_classes_.release(),
+ nullptr,
+ thread_count_,
+ dump_stats_,
+ dump_passes_,
+ dump_cfg_file_name_,
+ compiler_phases_timings_.get(),
+ swap_fd_,
+ profile_file_);
driver_->CompileAll(class_loader, dex_files_, timings_);
}
@@ -1499,7 +1503,7 @@ class Dex2Oat FINAL {
oat_writer.reset(new OatWriter(dex_files_, image_file_location_oat_checksum,
image_file_location_oat_data_begin,
image_patch_delta,
- driver_.get(),
+ driver_,
image_writer_.get(),
timings_,
key_value_store_.get()));
@@ -1839,7 +1843,7 @@ class Dex2Oat FINAL {
// Note: driver creation can fail when loading an invalid dex file.
LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_)
<< " (threads: " << thread_count_ << ") "
- << ((Runtime::Current() != nullptr && driver_.get() != nullptr) ?
+ << ((Runtime::Current() != nullptr && driver_ != nullptr) ?
driver_->GetMemoryUsageString(kIsDebugBuild || VLOG_IS_ON(compiler)) :
"");
}
@@ -1852,7 +1856,10 @@ class Dex2Oat FINAL {
std::unique_ptr<SafeMap<std::string, std::string> > key_value_store_;
- std::unique_ptr<VerificationResults> verification_results_;
+ // Not a unique_ptr as we want to just exit on non-debug builds, not bringing the compiler down
+ // in an orderly fashion. The destructor takes care of deleting this.
+ VerificationResults* verification_results_;
+
DexFileToMethodInlinerMap method_inliner_map_;
std::unique_ptr<QuickCompilerCallbacks> callbacks_;
@@ -1895,7 +1902,11 @@ class Dex2Oat FINAL {
std::string android_root_;
std::vector<const DexFile*> dex_files_;
std::vector<std::unique_ptr<const DexFile>> opened_dex_files_;
- std::unique_ptr<CompilerDriver> driver_;
+
+ // Not a unique_ptr as we want to just exit on non-debug builds, not bringing the driver down
+ // in an orderly fashion. The destructor takes care of deleting this.
+ CompilerDriver* driver_;
+
std::vector<std::string> verbose_methods_;
bool dump_stats_;
bool dump_passes_;