Do not pass DexFile to ClassLinker::ResolveField*().
The DexFile can be easily retrieved from the DexCache,
so reduce the number of arguments that need to be passed.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I0579db64c63afea789c7c9ad8db81e37c9248e97
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 81aa371..095cb30 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4818,7 +4818,6 @@
if (num_static_fields > 0) {
const DexFile::ClassDef* dex_class_def = klass->GetClassDef();
CHECK(dex_class_def != nullptr);
- const DexFile& dex_file = klass->GetDexFile();
StackHandleScope<3> hs(self);
Handle<mirror::ClassLoader> class_loader(hs.NewHandle(klass->GetClassLoader()));
Handle<mirror::DexCache> dex_cache(hs.NewHandle(klass->GetDexCache()));
@@ -4836,11 +4835,11 @@
}
}
- annotations::RuntimeEncodedStaticFieldValueIterator value_it(dex_file,
- &dex_cache,
- &class_loader,
+ annotations::RuntimeEncodedStaticFieldValueIterator value_it(dex_cache,
+ class_loader,
this,
*dex_class_def);
+ const DexFile& dex_file = *dex_cache->GetDexFile();
const uint8_t* class_data = dex_file.GetClassData(*dex_class_def);
ClassDataItemIterator field_it(dex_file, class_data);
if (value_it.HasNext()) {
@@ -4848,7 +4847,7 @@
CHECK(can_init_statics);
for ( ; value_it.HasNext(); value_it.Next(), field_it.Next()) {
ArtField* field = ResolveField(
- dex_file, field_it.GetMemberIndex(), dex_cache, class_loader, true);
+ field_it.GetMemberIndex(), dex_cache, class_loader, /* is_static */ true);
if (Runtime::Current()->IsActiveTransaction()) {
value_it.ReadValueToField<true>(field);
} else {
@@ -8114,8 +8113,7 @@
return resolved_field;
}
-ArtField* ClassLinker::ResolveField(const DexFile& dex_file,
- uint32_t field_idx,
+ArtField* ClassLinker::ResolveField(uint32_t field_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
bool is_static) {
@@ -8125,6 +8123,7 @@
if (resolved != nullptr) {
return resolved;
}
+ const DexFile& dex_file = *dex_cache->GetDexFile();
const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
Thread* const self = Thread::Current();
ObjPtr<mirror::Class> klass = ResolveType(dex_file, field_id.class_idx_, dex_cache, class_loader);
@@ -8156,8 +8155,7 @@
return resolved;
}
-ArtField* ClassLinker::ResolveFieldJLS(const DexFile& dex_file,
- uint32_t field_idx,
+ArtField* ClassLinker::ResolveFieldJLS(uint32_t field_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader) {
DCHECK(dex_cache != nullptr);
@@ -8166,6 +8164,7 @@
if (resolved != nullptr) {
return resolved;
}
+ const DexFile& dex_file = *dex_cache->GetDexFile();
const DexFile::FieldId& field_id = dex_file.GetFieldId(field_idx);
Thread* self = Thread::Current();
ObjPtr<mirror::Class> klass(ResolveType(dex_file, field_id.class_idx_, dex_cache, class_loader));