summaryrefslogtreecommitdiff
path: root/runtime/class_linker.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2017-12-07 11:22:59 +0000
committer Vladimir Marko <vmarko@google.com> 2017-12-08 15:27:27 +0000
commit28e012a4af2d710e5e5f824709ffd6432e4f549f (patch)
tree576ebdbff9d5f9f098cd29d652215b8f67b6b042 /runtime/class_linker.cc
parent4388fb213ec746ee18a6bea38ee894f8c19990b9 (diff)
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
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r--runtime/class_linker.cc38
1 files changed, 19 insertions, 19 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index e5bb7862cb..80d4bb15b8 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -7727,14 +7727,14 @@ void ClassLinker::CreateReferenceInstanceOffsets(Handle<mirror::Class> klass) {
klass->SetReferenceInstanceOffsets(reference_offsets);
}
-mirror::String* ClassLinker::ResolveString(const DexFile& dex_file,
- dex::StringIndex string_idx,
- Handle<mirror::DexCache> dex_cache) {
+ObjPtr<mirror::String> ClassLinker::ResolveString(const DexFile& dex_file,
+ dex::StringIndex string_idx,
+ Handle<mirror::DexCache> dex_cache) {
DCHECK(dex_cache != nullptr);
Thread::PoisonObjectPointersIfDebug();
ObjPtr<mirror::String> resolved = dex_cache->GetResolvedString(string_idx);
if (resolved != nullptr) {
- return resolved.Ptr();
+ return resolved;
}
uint32_t utf16_length;
const char* utf8_data = dex_file.StringDataAndUtf16LengthByIdx(string_idx, &utf16_length);
@@ -7742,16 +7742,16 @@ mirror::String* ClassLinker::ResolveString(const DexFile& dex_file,
if (string != nullptr) {
dex_cache->SetResolvedString(string_idx, string);
}
- return string.Ptr();
+ return string;
}
-mirror::String* ClassLinker::LookupString(const DexFile& dex_file,
- dex::StringIndex string_idx,
- ObjPtr<mirror::DexCache> dex_cache) {
+ObjPtr<mirror::String> ClassLinker::LookupString(const DexFile& dex_file,
+ dex::StringIndex string_idx,
+ ObjPtr<mirror::DexCache> dex_cache) {
DCHECK(dex_cache != nullptr);
ObjPtr<mirror::String> resolved = dex_cache->GetResolvedString(string_idx);
if (resolved != nullptr) {
- return resolved.Ptr();
+ return resolved;
}
uint32_t utf16_length;
const char* utf8_data = dex_file.StringDataAndUtf16LengthByIdx(string_idx, &utf16_length);
@@ -7760,7 +7760,7 @@ mirror::String* ClassLinker::LookupString(const DexFile& dex_file,
if (string != nullptr) {
dex_cache->SetResolvedString(string_idx, string);
}
- return string.Ptr();
+ return string;
}
ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(const DexFile& dex_file,
@@ -7794,19 +7794,19 @@ ObjPtr<mirror::Class> ClassLinker::LookupResolvedType(const DexFile& dex_file,
return type;
}
-mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file,
- dex::TypeIndex type_idx,
- ObjPtr<mirror::Class> referrer) {
+ObjPtr<mirror::Class> ClassLinker::ResolveType(const DexFile& dex_file,
+ dex::TypeIndex type_idx,
+ ObjPtr<mirror::Class> referrer) {
StackHandleScope<2> hs(Thread::Current());
Handle<mirror::DexCache> dex_cache(hs.NewHandle(referrer->GetDexCache()));
Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referrer->GetClassLoader()));
return ResolveType(dex_file, type_idx, dex_cache, class_loader);
}
-mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file,
- dex::TypeIndex type_idx,
- Handle<mirror::DexCache> dex_cache,
- Handle<mirror::ClassLoader> class_loader) {
+ObjPtr<mirror::Class> ClassLinker::ResolveType(const DexFile& dex_file,
+ dex::TypeIndex type_idx,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader) {
DCHECK(dex_cache != nullptr);
Thread::PoisonObjectPointersIfDebug();
ObjPtr<mirror::Class> resolved = dex_cache->GetResolvedType(type_idx);
@@ -7835,7 +7835,7 @@ mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file,
}
DCHECK((resolved == nullptr) || resolved->IsResolved())
<< resolved->PrettyDescriptor() << " " << resolved->GetStatus();
- return resolved.Ptr();
+ return resolved;
}
template <ClassLinker::ResolveMode kResolveMode>
@@ -8410,7 +8410,7 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod(
DexFileParameterIterator it(*dex_file, target_method->GetPrototype());
while (it.HasNext()) {
const dex::TypeIndex type_idx = it.GetTypeIdx();
- mirror::Class* klass = ResolveType(*dex_file, type_idx, dex_cache, class_loader);
+ ObjPtr<mirror::Class> klass = ResolveType(*dex_file, type_idx, dex_cache, class_loader);
if (nullptr == klass) {
DCHECK(self->IsExceptionPending());
return nullptr;