OSDN Git Service

Remove ResolveString from MethodHelper.
authorIan Rogers <irogers@google.com>
Tue, 28 Oct 2014 19:49:06 +0000 (12:49 -0700)
committerIan Rogers <irogers@google.com>
Tue, 28 Oct 2014 19:49:06 +0000 (12:49 -0700)
Change-Id: Ice0fff0680f876285539f78cd79d520d424e2f5e

runtime/interpreter/interpreter_common.h
runtime/interpreter/interpreter_goto_table_impl.cc
runtime/interpreter/interpreter_switch_impl.cc
runtime/method_helper-inl.h
runtime/method_helper.h

index fa03fc7..6a0aaf2 100644 (file)
@@ -187,7 +187,7 @@ bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint1
 
 // Handles string resolution for const-string and const-string-jumbo instructions. Also ensures the
 // java.lang.String class is initialized.
-static inline String* ResolveString(Thread* self, MethodHelper& mh, uint32_t string_idx)
+static inline String* ResolveString(Thread* self, ShadowFrame& shadow_frame, uint32_t string_idx)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   CHECK(!kMovingMethods);
   Class* java_lang_string_class = String::GetJavaLangString();
@@ -200,7 +200,15 @@ static inline String* ResolveString(Thread* self, MethodHelper& mh, uint32_t str
       return nullptr;
     }
   }
-  return mh.ResolveString(string_idx);
+  mirror::ArtMethod* method = shadow_frame.GetMethod();
+  mirror::String* s = method->GetDexCacheStrings()->Get(string_idx);
+  if (UNLIKELY(s == nullptr)) {
+    StackHandleScope<1> hs(self);
+    Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
+    s = Runtime::Current()->GetClassLinker()->ResolveString(*method->GetDexFile(), string_idx,
+                                                            dex_cache);
+  }
+  return s;
 }
 
 // Handles div-int, div-int/2addr, div-int/li16 and div-int/lit8 instructions.
index 88d6544..b970879 100644 (file)
@@ -420,7 +420,7 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem*
   HANDLE_INSTRUCTION_END();
 
   HANDLE_INSTRUCTION_START(CONST_STRING) {
-    String* s = ResolveString(self, mh, inst->VRegB_21c());
+    String* s = ResolveString(self, shadow_frame, inst->VRegB_21c());
     if (UNLIKELY(s == NULL)) {
       HANDLE_PENDING_EXCEPTION();
     } else {
@@ -431,7 +431,7 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem*
   HANDLE_INSTRUCTION_END();
 
   HANDLE_INSTRUCTION_START(CONST_STRING_JUMBO) {
-    String* s = ResolveString(self, mh, inst->VRegB_31c());
+    String* s = ResolveString(self, shadow_frame, inst->VRegB_31c());
     if (UNLIKELY(s == NULL)) {
       HANDLE_PENDING_EXCEPTION();
     } else {
index 14e8a52..1364ed2 100644 (file)
@@ -331,7 +331,7 @@ JValue ExecuteSwitchImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem
         break;
       case Instruction::CONST_STRING: {
         PREAMBLE();
-        String* s = ResolveString(self, mh,  inst->VRegB_21c());
+        String* s = ResolveString(self, shadow_frame,  inst->VRegB_21c());
         if (UNLIKELY(s == NULL)) {
           HANDLE_PENDING_EXCEPTION();
         } else {
@@ -342,7 +342,7 @@ JValue ExecuteSwitchImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem
       }
       case Instruction::CONST_STRING_JUMBO: {
         PREAMBLE();
-        String* s = ResolveString(self, mh,  inst->VRegB_31c());
+        String* s = ResolveString(self, shadow_frame,  inst->VRegB_31c());
         if (UNLIKELY(s == NULL)) {
           HANDLE_PENDING_EXCEPTION();
         } else {
index 143f4bc..fca5cf7 100644 (file)
@@ -67,19 +67,6 @@ inline mirror::Class* MethodHelperT<HandleKind>::GetReturnType(bool resolve) {
   return GetClassFromTypeIdx(return_type_idx, resolve);
 }
 
-template <template <class T> class HandleKind>
-inline mirror::String* MethodHelperT<HandleKind>::ResolveString(uint32_t string_idx) {
-  mirror::ArtMethod* method = GetMethod();
-  mirror::String* s = method->GetDexCacheStrings()->Get(string_idx);
-  if (UNLIKELY(s == nullptr)) {
-    StackHandleScope<1> hs(Thread::Current());
-    Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
-    s = Runtime::Current()->GetClassLinker()->ResolveString(*method->GetDexFile(), string_idx,
-                                                            dex_cache);
-  }
-  return s;
-}
-
 }  // namespace art
 
 #endif  // ART_RUNTIME_METHOD_HELPER_INL_H_
index fe364d3..1458f88 100644 (file)
@@ -115,8 +115,6 @@ class MethodHelperT {
   mirror::Class* GetClassFromTypeIdx(uint16_t type_idx, bool resolve = true)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
-  mirror::String* ResolveString(uint32_t string_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
   uint32_t FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);