Do not pass DexFile to ClassLinker::Lookup/ResolveType().
The DexFile can be easily retrieved from the DexCache,
so reduce the number of arguments that need to be passed.
Also refactor the code to avoid doing the DexCache lookup
twice and avoid unnecessary read barriers in the initial
DexCache lookup (also for Lookup/ResolveField()).
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: Idea9aa42b6a5bade947e93e330b1abdb9d11b2da
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 0a76cdd..ca5b799 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -1250,17 +1250,8 @@
} else {
DCHECK_EQ(invoke_type, kSuper);
CHECK(caller != nullptr) << invoke_type;
- StackHandleScope<2> hs(self);
- Handle<mirror::DexCache> dex_cache(
- hs.NewHandle(caller->GetDeclaringClass()->GetDexCache()));
- Handle<mirror::ClassLoader> class_loader(
- hs.NewHandle(caller->GetDeclaringClass()->GetClassLoader()));
- // TODO Maybe put this into a mirror::Class function.
ObjPtr<mirror::Class> ref_class = linker->LookupResolvedType(
- *dex_cache->GetDexFile(),
- dex_cache->GetDexFile()->GetMethodId(called_method.index).class_idx_,
- dex_cache.Get(),
- class_loader.Get());
+ caller->GetDexFile()->GetMethodId(called_method.index).class_idx_, caller);
if (ref_class->IsInterface()) {
called = ref_class->FindVirtualMethodForInterfaceSuper(called, kRuntimePointerSize);
} else {
@@ -2580,9 +2571,8 @@
const Instruction& inst = code->InstructionAt(dex_pc);
DCHECK(inst.Opcode() == Instruction::INVOKE_POLYMORPHIC ||
inst.Opcode() == Instruction::INVOKE_POLYMORPHIC_RANGE);
- const DexFile* dex_file = caller_method->GetDexFile();
const uint32_t proto_idx = inst.VRegH();
- const char* shorty = dex_file->GetShorty(proto_idx);
+ const char* shorty = caller_method->GetDexFile()->GetShorty(proto_idx);
const size_t shorty_length = strlen(shorty);
static const bool kMethodIsStatic = false; // invoke() and invokeExact() are not static.
RememberForGcArgumentVisitor gc_visitor(sp, kMethodIsStatic, shorty, shorty_length, &soa);