summaryrefslogtreecommitdiffstats
path: root/runtime/class_linker-inl.h
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2017-01-16 20:52:19 +0000
committerVladimir Marko <vmarko@google.com>2017-01-17 16:12:15 +0000
commit942fd3130254d8276cbfe8e6201825e9c49e9b2c (patch)
tree62dbcd85ab150604e2d72a3c2d0c3639a28c9b7a /runtime/class_linker-inl.h
parent8bd59a0fd46db83616785168231e09fb95ed2ead (diff)
downloadart-942fd3130254d8276cbfe8e6201825e9c49e9b2c.tar.gz
art-942fd3130254d8276cbfe8e6201825e9c49e9b2c.tar.bz2
art-942fd3130254d8276cbfe8e6201825e9c49e9b2c.zip
Reduce using ArtMethod's dex_cache_resolved_types_.
Avoid using the ArtMethod's dex cache type array shortcut in runtime, preparing for its removal. We do not completely remove the shortcut yet because it is still used by array allocation entrypoints. Fix ArgArray::BuildArgArrayFromObjectArray in reflection.cc to not ask for the parameter type to be resolved. It should have been previously resolved when retrieving the Method. Also partially revert https://android-review.googlesource.com/310717 because it relied on the removed AIOOBE check in the removed ArtMethod::GetDexCacheResolvedType(). The removed check was simply defensive but it could not be triggered without some memory corruption. Test: m test-art-host Bug: 30627598 Change-Id: Ic45a5ff8c66b79429e440cbc08d67bf22a083682
Diffstat (limited to 'runtime/class_linker-inl.h')
-rw-r--r--runtime/class_linker-inl.h30
1 files changed, 10 insertions, 20 deletions
diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h
index 5fc5f1a2f5..2e17dd85e6 100644
--- a/runtime/class_linker-inl.h
+++ b/runtime/class_linker-inl.h
@@ -25,7 +25,6 @@
#include "mirror/class_loader.h"
#include "mirror/dex_cache-inl.h"
#include "mirror/iftable.h"
-#include "mirror/throwable.h"
#include "mirror/object_array.h"
#include "handle_scope-inl.h"
#include "scoped_thread_state_change-inl.h"
@@ -90,25 +89,16 @@ inline mirror::Class* ClassLinker::ResolveType(dex::TypeIndex type_idx, ArtMetho
if (kIsDebugBuild) {
Thread::Current()->AssertNoPendingException();
}
- ObjPtr<mirror::Class> resolved_type =
- referrer->GetDexCacheResolvedType(type_idx, image_pointer_size_);
+ ObjPtr<mirror::Class> resolved_type = referrer->GetDexCache()->GetResolvedType(type_idx);
if (UNLIKELY(resolved_type == nullptr)) {
StackHandleScope<2> hs(Thread::Current());
- // There could be an out of bounds exception from GetDexCacheResolvedType, don't call
- // ResolveType for this case.
- if (LIKELY(!hs.Self()->IsExceptionPending())) {
- ObjPtr<mirror::Class> declaring_class = referrer->GetDeclaringClass();
- Handle<mirror::DexCache> dex_cache(hs.NewHandle(declaring_class->GetDexCache()));
- Handle<mirror::ClassLoader> class_loader(hs.NewHandle(declaring_class->GetClassLoader()));
- const DexFile& dex_file = *dex_cache->GetDexFile();
- resolved_type = ResolveType(dex_file, type_idx, dex_cache, class_loader);
- // Note: We cannot check here to see whether we added the type to the cache. The type
- // might be an erroneous class, which results in it being hidden from us.
- } else {
- // Make sure its an array out of bounds exception.
- DCHECK(hs.Self()->GetException()->GetClass()->DescriptorEquals(
- "Ljava/lang/ArrayIndexOutOfBoundsException;"));
- }
+ ObjPtr<mirror::Class> declaring_class = referrer->GetDeclaringClass();
+ Handle<mirror::DexCache> dex_cache(hs.NewHandle(declaring_class->GetDexCache()));
+ Handle<mirror::ClassLoader> class_loader(hs.NewHandle(declaring_class->GetClassLoader()));
+ const DexFile& dex_file = *dex_cache->GetDexFile();
+ resolved_type = ResolveType(dex_file, type_idx, dex_cache, class_loader);
+ // Note: We cannot check here to see whether we added the type to the cache. The type
+ // might be an erroneous class, which results in it being hidden from us.
}
return resolved_type.Ptr();
}
@@ -256,8 +246,8 @@ ArtMethod* ClassLinker::FindMethodForProxy(ObjPtr<mirror::Class> proxy_class,
// Locate the dex cache of the original interface/Object
for (const DexCacheData& data : dex_caches_) {
if (!self->IsJWeakCleared(data.weak_root) &&
- proxy_method->HasSameDexCacheResolvedTypes(data.resolved_types,
- image_pointer_size_)) {
+ proxy_method->HasSameDexCacheResolvedMethods(data.resolved_methods,
+ image_pointer_size_)) {
ObjPtr<mirror::DexCache> dex_cache =
ObjPtr<mirror::DexCache>::DownCast(self->DecodeJObject(data.weak_root));
if (dex_cache != nullptr) {