Move GetClassFromTypeIdx to ArtMethod.
Move GetClassFromTypeIdx out of MethodHelper into ArtMethod in
preparation for the removal of MethodHelper.
Change-Id: I9c03dd8c821944c606ea08cdf92afc80c4275247
diff --git a/runtime/mirror/art_method-inl.h b/runtime/mirror/art_method-inl.h
index 85ef4e6..c29276a 100644
--- a/runtime/mirror/art_method-inl.h
+++ b/runtime/mirror/art_method-inl.h
@@ -140,6 +140,15 @@
return GetDexCacheResolvedTypes() == other->GetDexCacheResolvedTypes();
}
+inline mirror::Class* ArtMethod::GetClassFromTypeIndex(uint16_t type_idx, bool resolve) {
+ mirror::Class* type = GetDexCacheResolvedType(type_idx);
+ if (type == nullptr && resolve) {
+ type = Runtime::Current()->GetClassLinker()->ResolveType(type_idx, this);
+ CHECK(type != nullptr || Thread::Current()->IsExceptionPending());
+ }
+ return type;
+}
+
inline uint32_t ArtMethod::GetCodeSize() {
DCHECK(!IsRuntimeMethod() && !IsProxyMethod()) << PrettyMethod(this);
const void* code = EntryPointToCodePointer(GetEntryPointFromQuickCompiledCode());
diff --git a/runtime/mirror/art_method.cc b/runtime/mirror/art_method.cc
index 40c2b2c..0f13344 100644
--- a/runtime/mirror/art_method.cc
+++ b/runtime/mirror/art_method.cc
@@ -257,7 +257,6 @@
uint32_t ArtMethod::FindCatchBlock(Handle<ArtMethod> h_this, Handle<Class> exception_type,
uint32_t dex_pc, bool* has_no_move_exception) {
- MethodHelper mh(h_this);
const DexFile::CodeItem* code_item = h_this->GetCodeItem();
// Set aside the exception while we resolve its type.
Thread* self = Thread::Current();
@@ -277,7 +276,7 @@
break;
}
// Does this catch exception type apply?
- Class* iter_exception_type = mh.GetClassFromTypeIdx(iter_type_idx);
+ Class* iter_exception_type = h_this->GetClassFromTypeIndex(iter_type_idx, true);
if (UNLIKELY(iter_exception_type == nullptr)) {
// Now have a NoClassDefFoundError as exception. Ignore in case the exception class was
// removed by a pro-guard like tool.
diff --git a/runtime/mirror/art_method.h b/runtime/mirror/art_method.h
index 04f8efc..2107944 100644
--- a/runtime/mirror/art_method.h
+++ b/runtime/mirror/art_method.h
@@ -237,6 +237,10 @@
bool HasSameDexCacheResolvedTypes(ObjectArray<Class>* other_cache)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ // Get the Class* from the type index into this method's dex cache.
+ mirror::Class* GetClassFromTypeIndex(uint16_t type_idx, bool resolve)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
// Find the method that this method overrides.
ArtMethod* FindOverriddenMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);