Avoid creating verification_results_ unnecessarily
For compiler filters that don't quicken or compile, avoid creating
the verification results. This avoids creating some arrays that
were using a few MB of RAM in some cases.
For a large app verify compile:
Maximum resident set size (kbytes): 258948 -> 254300
Bug: 63467744
Test: test-art-host
Change-Id: I1d0536b2a6a5c301396641371915394cf4c0e5f3
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index c04e45d..00a852f 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -514,8 +514,9 @@
// TODO: Refactor the compilation to avoid having to distinguish the two passes
// here. That should be done on a higher level. http://b/29089975
if (driver->GetCurrentDexToDexMethods()->IsBitSet(method_idx)) {
- const VerifiedMethod* verified_method =
- driver->GetVerificationResults()->GetVerifiedMethod(method_ref);
+ VerificationResults* results = driver->GetVerificationResults();
+ DCHECK(results != nullptr);
+ const VerifiedMethod* verified_method = results->GetVerifiedMethod(method_ref);
// Do not optimize if a VerifiedMethod is missing. SafeCast elision,
// for example, relies on it.
compiled_method = optimizer::ArtCompileDEX(
@@ -576,12 +577,12 @@
} else if ((access_flags & kAccAbstract) != 0) {
// Abstract methods don't have code.
} else {
- const VerifiedMethod* verified_method =
- driver->GetVerificationResults()->GetVerifiedMethod(method_ref);
+ VerificationResults* results = driver->GetVerificationResults();
+ DCHECK(results != nullptr);
+ const VerifiedMethod* verified_method = results->GetVerifiedMethod(method_ref);
bool compile = compilation_enabled &&
// Basic checks, e.g., not <clinit>.
- driver->GetVerificationResults()
- ->IsCandidateForCompilation(method_ref, access_flags) &&
+ results->IsCandidateForCompilation(method_ref, access_flags) &&
// Did not fail to create VerifiedMethod metadata.
verified_method != nullptr &&
// Do not have failures that should punt to the interpreter.