From 28e012a4af2d710e5e5f824709ffd6432e4f549f Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 7 Dec 2017 11:22:59 +0000 Subject: Determine HLoadClass/String load kind early. This helps save memory by avoiding the allocation of HEnvironment and related objects for AOT references to boot image strings and classes (kBootImage* load kinds) and also for JIT references (kJitTableAddress). Compiling aosp_taimen-userdebug boot image, the most memory hungry method BatteryStats.dumpLocked() needs - before: Used 55105384 bytes of arena memory... ... UseListNode 10009704 Environment 423248 EnvVRegs 20676560 ... - after: Used 50559176 bytes of arena memory... ... UseListNode 8568936 Environment 365680 EnvVRegs 17628704 ... Test: m test-art-host-gtest Test: testrunner.py --host --optimizing --jit Bug: 34053922 Change-Id: I68e73a438e6ac8e8908e6fccf53bbeea8a64a077 --- compiler/driver/compiler_driver.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 0ca3c8f613..f49d119900 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -717,7 +717,8 @@ static void ResolveConstStrings(Handle dex_cache, dex::StringIndex string_index((inst->Opcode() == Instruction::CONST_STRING) ? inst->VRegB_21c() : inst->VRegB_31c()); - mirror::String* string = class_linker->ResolveString(dex_file, string_index, dex_cache); + ObjPtr string = + class_linker->ResolveString(dex_file, string_index, dex_cache); CHECK(string != nullptr) << "Could not allocate a string when forcing determinism"; break; } @@ -1371,7 +1372,7 @@ ArtField* CompilerDriver::ComputeInstanceFieldInfo(uint32_t field_idx, const ScopedObjectAccess& soa) { // Try to resolve the field and compiling method's class. ArtField* resolved_field; - mirror::Class* referrer_class; + ObjPtr referrer_class; Handle dex_cache(mUnit->GetDexCache()); { Handle class_loader_handle = mUnit->GetClassLoader(); @@ -1542,7 +1543,7 @@ class ParallelCompilationManager { // A fast version of SkipClass above if the class pointer is available // that avoids the expensive FindInClassPath search. -static bool SkipClass(jobject class_loader, const DexFile& dex_file, mirror::Class* klass) +static bool SkipClass(jobject class_loader, const DexFile& dex_file, ObjPtr klass) REQUIRES_SHARED(Locks::mutator_lock_) { DCHECK(klass != nullptr); const DexFile& original_dex_file = *klass->GetDexCache()->GetDexFile(); @@ -1636,8 +1637,8 @@ class ResolveClassFieldsAndMethodsVisitor : public CompilationVisitor { Handle dex_cache(hs.NewHandle(class_linker->FindDexCache( soa.Self(), dex_file))); // Resolve the class. - mirror::Class* klass = class_linker->ResolveType(dex_file, class_def.class_idx_, dex_cache, - class_loader); + ObjPtr klass = + class_linker->ResolveType(dex_file, class_def.class_idx_, dex_cache, class_loader); bool resolve_fields_and_methods; if (klass == nullptr) { // Class couldn't be resolved, for example, super-class is in a different dex file. Don't -- cgit v1.2.3-59-g8ed1b