From a0485607a4a4d8c683a9849f6f20902c4e1da7a4 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Tue, 2 Dec 2014 15:48:04 -0800 Subject: Move GetClassFromTypeIdx to ArtMethod. Move GetClassFromTypeIdx out of MethodHelper into ArtMethod in preparation for the removal of MethodHelper. Change-Id: I9c03dd8c821944c606ea08cdf92afc80c4275247 --- runtime/debugger.cc | 8 +++---- runtime/interpreter/interpreter_common.cc | 15 +++--------- runtime/method_helper-inl.h | 16 +------------ runtime/method_helper.cc | 5 ++-- runtime/method_helper.h | 3 --- runtime/mirror/art_method-inl.h | 9 +++++++ runtime/mirror/art_method.cc | 3 +-- runtime/mirror/art_method.h | 4 ++++ runtime/reflection.cc | 39 +++++++++++++++---------------- 9 files changed, 43 insertions(+), 59 deletions(-) diff --git a/runtime/debugger.cc b/runtime/debugger.cc index dae1566d17..d5cba50582 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -30,7 +30,6 @@ #include "gc/space/space-inl.h" #include "handle_scope.h" #include "jdwp/object_registry.h" -#include "method_helper-inl.h" #include "mirror/art_field-inl.h" #include "mirror/art_method-inl.h" #include "mirror/class.h" @@ -3678,7 +3677,7 @@ JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId objec { StackHandleScope<3> hs(soa.Self()); - MethodHelper mh(hs.NewHandle(m)); + HandleWrapper h_m(hs.NewHandleWrapper(&m)); HandleWrapper h_obj(hs.NewHandleWrapper(&receiver)); HandleWrapper h_klass(hs.NewHandleWrapper(&c)); const DexFile::TypeList* types = m->GetParameterTypeList(); @@ -3689,7 +3688,8 @@ JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId objec if (shorty[i + 1] == 'L') { // Did we really get an argument of an appropriate reference type? - mirror::Class* parameter_type = mh.GetClassFromTypeIdx(types->GetTypeItem(i).type_idx_); + mirror::Class* parameter_type = + h_m->GetClassFromTypeIndex(types->GetTypeItem(i).type_idx_, true); mirror::Object* argument = gRegistry->Get(arg_values[i], &error); if (error != JDWP::ERR_NONE) { return JDWP::ERR_INVALID_OBJECT; @@ -3703,8 +3703,6 @@ JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId objec v.l = gRegistry->GetJObject(arg_values[i]); } } - // Update in case it moved. - m = mh.GetMethod(); } req->receiver = receiver; diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index 041650f150..3c7db85395 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -538,16 +538,6 @@ void AbortTransaction(Thread* self, const char* fmt, ...) { va_end(args); } -static mirror::Class* GetClassFromTypeIdx(mirror::ArtMethod* method, uint16_t type_idx) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::Class* type = method->GetDexCacheResolvedType(type_idx); - if (type == nullptr) { - type = Runtime::Current()->GetClassLinker()->ResolveType(type_idx, method); - CHECK(type != nullptr || Thread::Current()->IsExceptionPending()); - } - return type; -} - template bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data, JValue* result) { @@ -610,8 +600,9 @@ bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame, case 'L': { Object* o = shadow_frame.GetVRegReference(src_reg); if (do_assignability_check && o != NULL) { - Class* arg_type = GetClassFromTypeIdx(new_shadow_frame->GetMethod(), - params->GetTypeItem(shorty_pos).type_idx_); + Class* arg_type = + new_shadow_frame->GetMethod()->GetClassFromTypeIndex( + params->GetTypeItem(shorty_pos).type_idx_, true); if (arg_type == NULL) { CHECK(self->IsExceptionPending()); return false; diff --git a/runtime/method_helper-inl.h b/runtime/method_helper-inl.h index 7a7949e0fa..2c18205ec0 100644 --- a/runtime/method_helper-inl.h +++ b/runtime/method_helper-inl.h @@ -20,9 +20,7 @@ #include "method_helper.h" #include "class_linker.h" -#include "mirror/object_array.h" -#include "runtime.h" -#include "thread-inl.h" +#include "dex_file-inl.h" namespace art { @@ -45,18 +43,6 @@ inline bool MethodHelperT::HasSameNameAndSignature(MethodHelperTGetMethodSignature(mid) == other_dex_file->GetMethodSignature(other_mid); } -template