Cleanup resolution of type, field, method indexes
When resolving a type_idx of a static field, you cannot assume the
type_idx refers to the class that actually provides the storage, it
might be a subclass. The compiler now resolves to the storage class if
possible at compile time, otherwise it reverts to the slow path.
When resolve field and method indexes, you need to know if a field is
static or instance and if a method is direct or virtual. Previously we
tried to guess, which led to problems in classes that had one of
each. Now the compiler resolves which kind of field and method based
on the context of class definitions and dex instructions.
Change-Id: I31826dc90562057eadd81f39d6369aa1216509af
diff --git a/src/class_linker.h b/src/class_linker.h
index ca71b1f..bb38f00 100644
--- a/src/class_linker.h
+++ b/src/class_linker.h
@@ -115,13 +115,13 @@
return ResolveMethod(dex_file, method_idx, dex_cache, class_loader, is_direct);
}
- Field* ResolveField(uint32_t field_idx, const Method* referrer) {
+ Field* ResolveField(uint32_t field_idx, const Method* referrer, bool is_static) {
Class* declaring_class = referrer->GetDeclaringClass();
DexCache* dex_cache = declaring_class->GetDexCache();
// TODO: we could check for a dex cache hit here
const ClassLoader* class_loader = declaring_class->GetClassLoader();
const DexFile& dex_file = FindDexFile(dex_cache);
- return ResolveField(dex_file, field_idx, dex_cache, class_loader, true);
+ return ResolveField(dex_file, field_idx, dex_cache, class_loader, is_static);
}
// Resolve a field with a given ID from the DexFile, storing the