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
diff --git a/runtime/dex_file_annotations.cc b/runtime/dex_file_annotations.cc
index b44bd51..27b9202 100644
--- a/runtime/dex_file_annotations.cc
+++ b/runtime/dex_file_annotations.cc
@@ -783,9 +783,8 @@
uint32_t type_index = DecodeUnsignedLeb128(&annotation);
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Thread* self = Thread::Current();
- mirror::Class* resolved_class;
StackHandleScope<2> hs(self);
- resolved_class = class_linker->ResolveType(
+ ObjPtr<mirror::Class> resolved_class = class_linker->ResolveType(
klass.GetDexFile(),
dex::TypeIndex(type_index),
hs.NewHandle(klass.GetDexCache()),
@@ -1594,17 +1593,17 @@
case kDouble: field->SetDouble<kTransactionActive>(field->GetDeclaringClass(), jval_.d); break;
case kNull: field->SetObject<kTransactionActive>(field->GetDeclaringClass(), nullptr); break;
case kString: {
- mirror::String* resolved = linker_->ResolveString(dex_file_,
- dex::StringIndex(jval_.i),
- *dex_cache_);
+ ObjPtr<mirror::String> resolved = linker_->ResolveString(dex_file_,
+ dex::StringIndex(jval_.i),
+ *dex_cache_);
field->SetObject<kTransactionActive>(field->GetDeclaringClass(), resolved);
break;
}
case kType: {
- mirror::Class* resolved = linker_->ResolveType(dex_file_,
- dex::TypeIndex(jval_.i),
- *dex_cache_,
- *class_loader_);
+ ObjPtr<mirror::Class> resolved = linker_->ResolveType(dex_file_,
+ dex::TypeIndex(jval_.i),
+ *dex_cache_,
+ *class_loader_);
field->SetObject<kTransactionActive>(field->GetDeclaringClass(), resolved);
break;
}