summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2017-12-11 13:45:05 +0000
committer Vladimir Marko <vmarko@google.com> 2017-12-11 15:43:45 +0000
commit890111968fbd3f5ae528d97e42984c12a3dd27bd (patch)
treeedb4ed38332a817b7d3037ea260856cec839dca9
parent0f13269734be07b5869005952a3cb91b0b34b73d (diff)
Do not pass DexFile to ClassLinker::Lookup/ResolveMethod().
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: I2e47280e7cb8b84595130c4abfb5ece18d7f5c75
-rw-r--r--compiler/dex/dex_to_dex_compiler.cc1
-rw-r--r--compiler/driver/compiler_driver-inl.h2
-rw-r--r--compiler/driver/compiler_driver.cc5
-rw-r--r--compiler/optimizing/instruction_builder.cc1
-rw-r--r--compiler/optimizing/reference_type_propagation.cc2
-rw-r--r--compiler/verifier_deps_test.cc3
-rw-r--r--dex2oat/linker/oat_writer.cc3
-rw-r--r--runtime/class_linker-inl.h4
-rw-r--r--runtime/class_linker.cc13
-rw-r--r--runtime/class_linker.h15
-rw-r--r--runtime/dex_file_annotations.cc2
-rw-r--r--runtime/verifier/method_verifier.cc2
12 files changed, 21 insertions, 32 deletions
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index 476903522e..ead909af9a 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -296,7 +296,6 @@ void DexCompiler::CompileInvokeVirtual(Instruction* inst, uint32_t dex_pc,
ClassLinker* class_linker = unit_.GetClassLinker();
ArtMethod* resolved_method =
class_linker->ResolveMethod<ClassLinker::ResolveMode::kCheckICCEAndIAE>(
- GetDexFile(),
method_idx,
unit_.GetDexCache(),
unit_.GetClassLoader(),
diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h
index 42fc4aa5ba..34c8f22c03 100644
--- a/compiler/driver/compiler_driver-inl.h
+++ b/compiler/driver/compiler_driver-inl.h
@@ -105,7 +105,7 @@ inline ArtMethod* CompilerDriver::ResolveMethod(
DCHECK_EQ(class_loader.Get(), mUnit->GetClassLoader().Get());
ArtMethod* resolved_method =
mUnit->GetClassLinker()->ResolveMethod<ClassLinker::ResolveMode::kCheckICCEAndIAE>(
- *dex_cache->GetDexFile(), method_idx, dex_cache, class_loader, nullptr, invoke_type);
+ method_idx, dex_cache, class_loader, /* referrer */ nullptr, invoke_type);
if (UNLIKELY(resolved_method == nullptr)) {
DCHECK(soa.Self()->IsExceptionPending());
// Clean up any exception left by type resolution.
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index fcc6b8be9e..8f726895de 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -1690,7 +1690,10 @@ class ResolveClassFieldsAndMethodsVisitor : public CompilationVisitor {
if (resolve_fields_and_methods) {
while (it.HasNextMethod()) {
ArtMethod* method = class_linker->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
- dex_file, it.GetMemberIndex(), dex_cache, class_loader, nullptr,
+ it.GetMemberIndex(),
+ dex_cache,
+ class_loader,
+ /* referrer */ nullptr,
it.GetMethodInvokeType(class_def));
if (method == nullptr) {
CheckAndClearResolveException(soa.Self());
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index bce4de32d5..6fdb616ce2 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -796,7 +796,6 @@ ArtMethod* HInstructionBuilder::ResolveMethod(uint16_t method_idx, InvokeType in
ArtMethod* resolved_method =
class_linker->ResolveMethod<ClassLinker::ResolveMode::kCheckICCEAndIAE>(
- *dex_compilation_unit_->GetDexFile(),
method_idx,
dex_compilation_unit_->GetDexCache(),
class_loader,
diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc
index d84f14acc0..549572ce40 100644
--- a/compiler/optimizing/reference_type_propagation.cc
+++ b/compiler/optimizing/reference_type_propagation.cc
@@ -544,7 +544,7 @@ void ReferenceTypePropagation::RTPVisitor::SetClassAsTypeInfo(HInstruction* inst
// the method is from the String class, the null loader is good enough.
Handle<mirror::ClassLoader> loader(hs.NewHandle<mirror::ClassLoader>(nullptr));
ArtMethod* method = cl->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
- dex_file, invoke->GetDexMethodIndex(), dex_cache, loader, nullptr, kDirect);
+ invoke->GetDexMethodIndex(), dex_cache, loader, /* referrer */ nullptr, kDirect);
DCHECK(method != nullptr);
mirror::Class* declaring_class = method->GetDeclaringClass();
DCHECK(declaring_class != nullptr);
diff --git a/compiler/verifier_deps_test.cc b/compiler/verifier_deps_test.cc
index 4709fd0e9e..ee1d7c69bc 100644
--- a/compiler/verifier_deps_test.cc
+++ b/compiler/verifier_deps_test.cc
@@ -158,11 +158,10 @@ class VerifierDepsTest : public CommonCompilerTest {
while (it.HasNextDirectMethod()) {
ArtMethod* resolved_method =
class_linker_->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
- *primary_dex_file_,
it.GetMemberIndex(),
dex_cache_handle,
class_loader_handle,
- nullptr,
+ /* referrer */ nullptr,
it.GetMethodInvokeType(*class_def));
CHECK(resolved_method != nullptr);
if (method_name == resolved_method->GetName()) {
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index b163eeb7b7..c271a6cdf4 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -1592,11 +1592,10 @@ class OatWriter::InitImageMethodVisitor : public OatDexMethodVisitor {
ScopedObjectAccessUnchecked soa(self);
StackHandleScope<1> hs(self);
method = class_linker_->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
- *dex_file_,
it.GetMemberIndex(),
hs.NewHandle(dex_cache),
ScopedNullHandle<mirror::ClassLoader>(),
- nullptr,
+ /* referrer */ nullptr,
invoke_type);
if (method == nullptr) {
LOG(FATAL_WITHOUT_ABORT) << "Unexpected failure to resolve a method: "
diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h
index 2d8d4b41a0..c086dd2676 100644
--- a/runtime/class_linker-inl.h
+++ b/runtime/class_linker-inl.h
@@ -237,9 +237,7 @@ inline ArtMethod* ClassLinker::ResolveMethod(Thread* self,
StackHandleScope<2> hs(self);
Handle<mirror::DexCache> h_dex_cache(hs.NewHandle(referrer->GetDexCache()));
Handle<mirror::ClassLoader> h_class_loader(hs.NewHandle(declaring_class->GetClassLoader()));
- const DexFile* dex_file = h_dex_cache->GetDexFile();
- resolved_method = ResolveMethod<kResolveMode>(*dex_file,
- method_idx,
+ resolved_method = ResolveMethod<kResolveMode>(method_idx,
h_dex_cache,
h_class_loader,
referrer,
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 093ec6540c..892c28d54f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -7938,8 +7938,7 @@ std::string DescribeLoaders(ObjPtr<mirror::ClassLoader> loader, const char* clas
}
template <ClassLinker::ResolveMode kResolveMode>
-ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file,
- uint32_t method_idx,
+ArtMethod* ClassLinker::ResolveMethod(uint32_t method_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
ArtMethod* referrer,
@@ -7957,6 +7956,7 @@ ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file,
DCHECK(resolved->GetDeclaringClassUnchecked() != nullptr) << resolved->GetDexMethodIndex();
return resolved;
}
+ const DexFile& dex_file = *dex_cache->GetDexFile();
const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
ObjPtr<mirror::Class> klass = nullptr;
if (valid_dex_cache_method) {
@@ -8048,8 +8048,7 @@ ArtMethod* ClassLinker::ResolveMethod(const DexFile& dex_file,
}
}
-ArtMethod* ClassLinker::ResolveMethodWithoutInvokeType(const DexFile& dex_file,
- uint32_t method_idx,
+ArtMethod* ClassLinker::ResolveMethodWithoutInvokeType(uint32_t method_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader) {
ArtMethod* resolved = dex_cache->GetResolvedMethod(method_idx, image_pointer_size_);
@@ -8060,6 +8059,7 @@ ArtMethod* ClassLinker::ResolveMethodWithoutInvokeType(const DexFile& dex_file,
return resolved;
}
// Fail, get the declaring class.
+ const DexFile& dex_file = *dex_cache->GetDexFile();
const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
ObjPtr<mirror::Class> klass =
ResolveType(dex_file, method_id.class_idx_, dex_cache, class_loader);
@@ -8431,8 +8431,7 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod(
// the invocation type to determine if the method is private. We
// then resolve again specifying the intended invocation type to
// force the appropriate checks.
- target_method = ResolveMethodWithoutInvokeType(*dex_file,
- method_handle.field_or_method_idx_,
+ target_method = ResolveMethodWithoutInvokeType(method_handle.field_or_method_idx_,
hs.NewHandle(referrer->GetDexCache()),
hs.NewHandle(referrer->GetClassLoader()));
if (UNLIKELY(target_method == nullptr)) {
@@ -9033,14 +9032,12 @@ mirror::IfTable* ClassLinker::AllocIfTable(Thread* self, size_t ifcount) {
// Instantiate ResolveMethod.
template ArtMethod* ClassLinker::ResolveMethod<ClassLinker::ResolveMode::kCheckICCEAndIAE>(
- const DexFile& dex_file,
uint32_t method_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
ArtMethod* referrer,
InvokeType type);
template ArtMethod* ClassLinker::ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
- const DexFile& dex_file,
uint32_t method_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 6a5768ec27..55a4d2db15 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -307,14 +307,12 @@ class ClassLinker {
ObjPtr<mirror::ClassLoader> class_loader)
REQUIRES_SHARED(Locks::mutator_lock_);
- // Resolve a method with a given ID from the DexFile, storing the
- // result in DexCache. The ClassLinker and ClassLoader are used as
- // in ResolveType. What is unique is the method type argument which
- // is used to determine if this method is a direct, static, or
- // virtual method.
+ // Resolve a method with a given ID from the DexFile associated with the given DexCache
+ // and ClassLoader, storing the result in DexCache. The ClassLinker and ClassLoader are
+ // used as in ResolveType. What is unique is the method type argument which is used to
+ // determine if this method is a direct, static, or virtual method.
template <ResolveMode kResolveMode>
- ArtMethod* ResolveMethod(const DexFile& dex_file,
- uint32_t method_idx,
+ ArtMethod* ResolveMethod(uint32_t method_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader,
ArtMethod* referrer,
@@ -330,8 +328,7 @@ class ClassLinker {
ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, ArtMethod* referrer, InvokeType type)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_);
- ArtMethod* ResolveMethodWithoutInvokeType(const DexFile& dex_file,
- uint32_t method_idx,
+ ArtMethod* ResolveMethodWithoutInvokeType(uint32_t method_idx,
Handle<mirror::DexCache> dex_cache,
Handle<mirror::ClassLoader> class_loader)
REQUIRES_SHARED(Locks::mutator_lock_)
diff --git a/runtime/dex_file_annotations.cc b/runtime/dex_file_annotations.cc
index eaf31f308f..43260f733b 100644
--- a/runtime/dex_file_annotations.cc
+++ b/runtime/dex_file_annotations.cc
@@ -501,7 +501,6 @@ bool ProcessAnnotationValue(const ClassData& klass,
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
StackHandleScope<2> hs(self);
ArtMethod* method = class_linker->ResolveMethodWithoutInvokeType(
- klass.GetDexFile(),
index,
hs.NewHandle(klass.GetDexCache()),
hs.NewHandle(klass.GetClassLoader()));
@@ -1398,7 +1397,6 @@ mirror::Class* GetEnclosingClass(Handle<mirror::Class> klass) {
}
StackHandleScope<2> hs(Thread::Current());
ArtMethod* method = Runtime::Current()->GetClassLinker()->ResolveMethodWithoutInvokeType(
- data.GetDexFile(),
annotation_value.value_.GetI(),
hs.NewHandle(data.GetDexCache()),
hs.NewHandle(data.GetClassLoader()));
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 24f83b881d..bf02450744 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -230,7 +230,7 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethods(Thread* self,
previous_method_idx = method_idx;
InvokeType type = it->GetMethodInvokeType(class_def);
ArtMethod* method = linker->ResolveMethod<ClassLinker::ResolveMode::kNoChecks>(
- *dex_file, method_idx, dex_cache, class_loader, nullptr, type);
+ method_idx, dex_cache, class_loader, /* referrer */ nullptr, type);
if (method == nullptr) {
DCHECK(self->IsExceptionPending());
// We couldn't resolve the method, but continue regardless.