OSDN Git Service

Move GetNameAsString out of MethodHelper into ArtMethod.
authorIan Rogers <irogers@google.com>
Wed, 29 Oct 2014 04:50:58 +0000 (21:50 -0700)
committerIan Rogers <irogers@google.com>
Wed, 29 Oct 2014 04:50:58 +0000 (21:50 -0700)
Change-Id: I98b8ed9d91741267659616cb76ce5f6fec4feae8

runtime/interpreter/interpreter_common.cc
runtime/method_helper.cc
runtime/method_helper.h
runtime/mirror/art_method.cc
runtime/mirror/art_method.h

index c887a88..5c77b96 100644 (file)
@@ -891,9 +891,8 @@ static void UnstartedRuntimeInvoke(Thread* self, MethodHelper* mh,
     Object* obj = shadow_frame->GetVRegReference(arg_offset);
     result->SetI(obj->IdentityHashCode());
   } else if (name == "java.lang.String java.lang.reflect.ArtMethod.getMethodName(java.lang.reflect.ArtMethod)") {
-    StackHandleScope<1> hs(self);
-    MethodHelper mh(hs.NewHandle(shadow_frame->GetVRegReference(arg_offset)->AsArtMethod()));
-    result->SetL(mh.GetNameAsString(self));
+    mirror::ArtMethod* method = shadow_frame->GetVRegReference(arg_offset)->AsArtMethod();
+    result->SetL(method->GetNameAsString(self));
   } else if (name == "void java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int)" ||
              name == "void java.lang.System.arraycopy(char[], int, char[], int, int)") {
     // Special case array copying without initializing System.
index 0799bb0..81e1794 100644 (file)
 namespace art {
 
 template <template <class T> class HandleKind>
-mirror::String* MethodHelperT<HandleKind>::GetNameAsString(Thread* self) {
-  const DexFile* dex_file = method_->GetDexFile();
-  mirror::ArtMethod* method = method_->GetInterfaceMethodIfProxy();
-  uint32_t dex_method_idx = method->GetDexMethodIndex();
-  const DexFile::MethodId& method_id = dex_file->GetMethodId(dex_method_idx);
-  StackHandleScope<1> hs(self);
-  Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
-  return Runtime::Current()->GetClassLinker()->ResolveString(*dex_file, method_id.name_idx_,
-                                                             dex_cache);
-}
-
-template <template <class T> class HandleKind>
 template <template <class T2> class HandleKind2>
 bool MethodHelperT<HandleKind>::HasSameSignatureWithDifferentClassLoaders(Thread* self,
     MethodHelperT<HandleKind2>* other) {
@@ -144,10 +132,6 @@ uint32_t MethodHelperT<HandleKind>::FindDexMethodIndexInOtherDexFile(
 }
 
 // Instantiate methods.
-template mirror::String* MethodHelperT<Handle>::GetNameAsString(Thread* self);
-
-template mirror::String* MethodHelperT<MutableHandle>::GetNameAsString(Thread* self);
-
 template
 uint32_t MethodHelperT<Handle>::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile);
 template
index 14ba7d1..dc305d5 100644 (file)
@@ -40,8 +40,6 @@ class MethodHelperT {
     return method_.Get();
   }
 
-  mirror::String* GetNameAsString(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
   const char* GetShorty() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
     const char* result = shorty_;
     if (result == nullptr) {
index ddc16fb..acd1043 100644 (file)
@@ -67,6 +67,17 @@ void ArtMethod::VisitRoots(RootCallback* callback, void* arg) {
   }
 }
 
+mirror::String* ArtMethod::GetNameAsString(Thread* self) {
+  mirror::ArtMethod* method = GetInterfaceMethodIfProxy();
+  const DexFile* dex_file = method->GetDexFile();
+  uint32_t dex_method_idx = method->GetDexMethodIndex();
+  const DexFile::MethodId& method_id = dex_file->GetMethodId(dex_method_idx);
+  StackHandleScope<1> hs(self);
+  Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
+  return Runtime::Current()->GetClassLinker()->ResolveString(*dex_file, method_id.name_idx_,
+                                                             dex_cache);
+}
+
 InvokeType ArtMethod::GetInvokeType() {
   // TODO: kSuper?
   if (GetDeclaringClass()->IsInterface()) {
index 9bb838b..6927f1d 100644 (file)
@@ -484,6 +484,8 @@ class MANAGED ArtMethod FINAL : public Object {
 
   ALWAYS_INLINE const char* GetName() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
+  mirror::String* GetNameAsString(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
   const DexFile::CodeItem* GetCodeItem() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
   bool IsResolvedTypeIdx(uint16_t type_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -515,7 +517,7 @@ class MANAGED ArtMethod FINAL : public Object {
 
   ALWAYS_INLINE ArtMethod* GetInterfaceMethodIfProxy() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
- protected:
+ private:
   // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
   // The class we are a part of.
   HeapReference<Class> declaring_class_;