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/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h
index 7e118d5..42fc4aa 100644
--- a/compiler/driver/compiler_driver-inl.h
+++ b/compiler/driver/compiler_driver-inl.h
@@ -58,13 +58,13 @@
return ResolveClass(soa, dex_cache, class_loader, referrer_method_id.class_idx_, mUnit);
}
-inline ArtField* CompilerDriver::ResolveFieldWithDexFile(
- const ScopedObjectAccess& soa, Handle<mirror::DexCache> dex_cache,
- Handle<mirror::ClassLoader> class_loader, const DexFile* dex_file,
- uint32_t field_idx, bool is_static) {
- DCHECK_EQ(dex_cache->GetDexFile(), dex_file);
+inline ArtField* CompilerDriver::ResolveField(const ScopedObjectAccess& soa,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
+ uint32_t field_idx,
+ bool is_static) {
ArtField* resolved_field = Runtime::Current()->GetClassLinker()->ResolveField(
- *dex_file, field_idx, dex_cache, class_loader, is_static);
+ field_idx, dex_cache, class_loader, is_static);
DCHECK_EQ(resolved_field == nullptr, soa.Self()->IsExceptionPending());
if (UNLIKELY(resolved_field == nullptr)) {
// Clean up any exception left by type resolution.
@@ -79,15 +79,6 @@
return resolved_field;
}
-inline ArtField* CompilerDriver::ResolveField(
- const ScopedObjectAccess& soa, Handle<mirror::DexCache> dex_cache,
- Handle<mirror::ClassLoader> class_loader, const DexCompilationUnit* mUnit,
- uint32_t field_idx, bool is_static) {
- DCHECK_EQ(class_loader.Get(), mUnit->GetClassLoader().Get());
- return ResolveFieldWithDexFile(soa, dex_cache, class_loader, mUnit->GetDexFile(), field_idx,
- is_static);
-}
-
inline std::pair<bool, bool> CompilerDriver::IsFastInstanceField(
ObjPtr<mirror::DexCache> dex_cache,
ObjPtr<mirror::Class> referrer_class,
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index f49d119..2d43476 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -1368,17 +1368,18 @@
}
ArtField* CompilerDriver::ComputeInstanceFieldInfo(uint32_t field_idx,
- const DexCompilationUnit* mUnit, bool is_put,
+ const DexCompilationUnit* mUnit,
+ bool is_put,
const ScopedObjectAccess& soa) {
// Try to resolve the field and compiling method's class.
ArtField* resolved_field;
ObjPtr<mirror::Class> referrer_class;
Handle<mirror::DexCache> dex_cache(mUnit->GetDexCache());
{
- Handle<mirror::ClassLoader> class_loader_handle = mUnit->GetClassLoader();
- resolved_field = ResolveField(soa, dex_cache, class_loader_handle, mUnit, field_idx, false);
+ Handle<mirror::ClassLoader> class_loader = mUnit->GetClassLoader();
+ resolved_field = ResolveField(soa, dex_cache, class_loader, field_idx, /* is_static */ false);
referrer_class = resolved_field != nullptr
- ? ResolveCompilingMethodsClass(soa, dex_cache, class_loader_handle, mUnit) : nullptr;
+ ? ResolveCompilingMethodsClass(soa, dex_cache, class_loader, mUnit) : nullptr;
}
bool can_link = false;
if (resolved_field != nullptr && referrer_class != nullptr) {
@@ -1664,8 +1665,8 @@
ClassDataItemIterator it(dex_file, class_data);
while (it.HasNextStaticField()) {
if (resolve_fields_and_methods) {
- ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(),
- dex_cache, class_loader, true);
+ ArtField* field = class_linker->ResolveField(
+ it.GetMemberIndex(), dex_cache, class_loader, /* is_static */ true);
if (field == nullptr) {
CheckAndClearResolveException(soa.Self());
}
@@ -1679,8 +1680,8 @@
requires_constructor_barrier = true;
}
if (resolve_fields_and_methods) {
- ArtField* field = class_linker->ResolveField(dex_file, it.GetMemberIndex(),
- dex_cache, class_loader, false);
+ ArtField* field = class_linker->ResolveField(
+ it.GetMemberIndex(), dex_cache, class_loader, /* is_static */ false);
if (field == nullptr) {
CheckAndClearResolveException(soa.Self());
}
@@ -2329,22 +2330,21 @@
DCHECK(!klass->IsInitialized());
StackHandleScope<1> hs(Thread::Current());
- Handle<mirror::DexCache> h_dex_cache = hs.NewHandle(klass->GetDexCache());
+ Handle<mirror::DexCache> dex_cache = hs.NewHandle(klass->GetDexCache());
const DexFile* dex_file = manager_->GetDexFile();
const DexFile::ClassDef* class_def = klass->GetClassDef();
ClassLinker* class_linker = manager_->GetClassLinker();
// Check encoded final field values for strings and intern.
- annotations::RuntimeEncodedStaticFieldValueIterator value_it(*dex_file,
- &h_dex_cache,
- &class_loader,
+ annotations::RuntimeEncodedStaticFieldValueIterator value_it(dex_cache,
+ class_loader,
manager_->GetClassLinker(),
*class_def);
for ( ; value_it.HasNext(); value_it.Next()) {
if (value_it.GetValueType() == annotations::RuntimeEncodedStaticFieldValueIterator::kString) {
// Resolve the string. This will intern the string.
art::ObjPtr<mirror::String> resolved = class_linker->ResolveString(
- *dex_file, dex::StringIndex(value_it.GetJavaValue().i), h_dex_cache);
+ *dex_file, dex::StringIndex(value_it.GetJavaValue().i), dex_cache);
CHECK(resolved != nullptr);
}
}
@@ -2357,11 +2357,11 @@
for (const DexInstructionPcPair& inst : code_item->Instructions()) {
if (inst->Opcode() == Instruction::CONST_STRING) {
ObjPtr<mirror::String> s = class_linker->ResolveString(
- *dex_file, dex::StringIndex(inst->VRegB_21c()), h_dex_cache);
+ *dex_file, dex::StringIndex(inst->VRegB_21c()), dex_cache);
CHECK(s != nullptr);
} else if (inst->Opcode() == Instruction::CONST_STRING_JUMBO) {
ObjPtr<mirror::String> s = class_linker->ResolveString(
- *dex_file, dex::StringIndex(inst->VRegB_31c()), h_dex_cache);
+ *dex_file, dex::StringIndex(inst->VRegB_31c()), dex_cache);
CHECK(s != nullptr);
}
}
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index ce7ec45..ab788e3 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -232,17 +232,11 @@
// Resolve a field. Returns null on failure, including incompatible class change.
// NOTE: Unlike ClassLinker's ResolveField(), this method enforces is_static.
- ArtField* ResolveField(
- const ScopedObjectAccess& soa, Handle<mirror::DexCache> dex_cache,
- Handle<mirror::ClassLoader> class_loader, const DexCompilationUnit* mUnit,
- uint32_t field_idx, bool is_static)
- REQUIRES_SHARED(Locks::mutator_lock_);
-
- // Resolve a field with a given dex file.
- ArtField* ResolveFieldWithDexFile(
- const ScopedObjectAccess& soa, Handle<mirror::DexCache> dex_cache,
- Handle<mirror::ClassLoader> class_loader, const DexFile* dex_file,
- uint32_t field_idx, bool is_static)
+ ArtField* ResolveField(const ScopedObjectAccess& soa,
+ Handle<mirror::DexCache> dex_cache,
+ Handle<mirror::ClassLoader> class_loader,
+ uint32_t field_idx,
+ bool is_static)
REQUIRES_SHARED(Locks::mutator_lock_);
// Can we fast-path an IGET/IPUT access to an instance field? If yes, compute the field offset.
@@ -271,9 +265,9 @@
REQUIRES(!Locks::mutator_lock_);
ArtField* ComputeInstanceFieldInfo(uint32_t field_idx,
- const DexCompilationUnit* mUnit,
- bool is_put,
- const ScopedObjectAccess& soa)
+ const DexCompilationUnit* mUnit,
+ bool is_put,
+ const ScopedObjectAccess& soa)
REQUIRES_SHARED(Locks::mutator_lock_);
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 4485f06..bce4de3 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -1484,8 +1484,7 @@
Handle<mirror::ClassLoader> class_loader = dex_compilation_unit_->GetClassLoader();
Handle<mirror::Class> compiling_class(hs.NewHandle(GetCompilingClass()));
- ArtField* resolved_field = class_linker->ResolveField(*dex_compilation_unit_->GetDexFile(),
- field_idx,
+ ArtField* resolved_field = class_linker->ResolveField(field_idx,
dex_compilation_unit_->GetDexCache(),
class_loader,
is_static);