diff options
| author | 2017-12-08 15:01:18 +0000 | |
|---|---|---|
| committer | 2017-12-08 18:31:50 +0000 | |
| commit | af94020190a2153834e30fc962e28c3b63d7ffc2 (patch) | |
| tree | 3f08bb09dd6d5ded7a6c85e812f1cba54ca83285 /runtime | |
| parent | e11dd50ac2b5ccbf3b02213b7361f55b1f1a90da (diff) | |
Do not pass DexFile to ClassLinker::ResolveMethodType().
The DexFile can be easily retrieved from the DexCache,
so reduce the number of arguments that need to be passed.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I00634b89013b7348460aa73561fa14be7c8cdb7e
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/class_linker.cc | 26 | ||||
| -rw-r--r-- | runtime/class_linker.h | 23 | ||||
| -rw-r--r-- | runtime/class_linker_test.cc | 18 | ||||
| -rw-r--r-- | runtime/interpreter/interpreter_common.cc | 10 | ||||
| -rw-r--r-- | runtime/interpreter/interpreter_common.h | 12 | ||||
| -rw-r--r-- | runtime/mirror/dex_cache_test.cc | 2 |
6 files changed, 37 insertions, 54 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 095cb30a04..012e2a4548 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -8184,11 +8184,11 @@ ArtField* ClassLinker::ResolveFieldJLS(uint32_t field_idx, return resolved; } -mirror::MethodType* ClassLinker::ResolveMethodType(Thread* self, - const DexFile& dex_file, - uint32_t proto_idx, - Handle<mirror::DexCache> dex_cache, - Handle<mirror::ClassLoader> class_loader) { +ObjPtr<mirror::MethodType> ClassLinker::ResolveMethodType( + Thread* self, + uint32_t proto_idx, + Handle<mirror::DexCache> dex_cache, + Handle<mirror::ClassLoader> class_loader) { DCHECK(Runtime::Current()->IsMethodHandlesEnabled()); DCHECK(dex_cache != nullptr); @@ -8200,6 +8200,7 @@ mirror::MethodType* ClassLinker::ResolveMethodType(Thread* self, StackHandleScope<4> hs(self); // First resolve the return type. + const DexFile& dex_file = *dex_cache->GetDexFile(); const DexFile::ProtoId& proto_id = dex_file.GetProtoId(proto_idx); Handle<mirror::Class> return_type(hs.NewHandle( ResolveType(dex_file, proto_id.return_type_idx_, dex_cache, class_loader))); @@ -8246,14 +8247,13 @@ mirror::MethodType* ClassLinker::ResolveMethodType(Thread* self, return type.Get(); } -mirror::MethodType* ClassLinker::ResolveMethodType(Thread* self, - uint32_t proto_idx, - ArtMethod* referrer) { +ObjPtr<mirror::MethodType> ClassLinker::ResolveMethodType(Thread* self, + uint32_t proto_idx, + ArtMethod* referrer) { StackHandleScope<2> hs(self); - const DexFile* dex_file = referrer->GetDexFile(); Handle<mirror::DexCache> dex_cache(hs.NewHandle(referrer->GetDexCache())); Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referrer->GetClassLoader())); - return ResolveMethodType(self, *dex_file, proto_idx, dex_cache, class_loader); + return ResolveMethodType(self, proto_idx, dex_cache, class_loader); } mirror::MethodHandle* ClassLinker::ResolveMethodHandleForField( @@ -8548,9 +8548,9 @@ mirror::MethodHandle* ClassLinker::ResolveMethodHandleForMethod( return mirror::MethodHandleImpl::Create(self, target, kind, method_type); } -mirror::MethodHandle* ClassLinker::ResolveMethodHandle(Thread* self, - uint32_t method_handle_idx, - ArtMethod* referrer) +ObjPtr<mirror::MethodHandle> ClassLinker::ResolveMethodHandle(Thread* self, + uint32_t method_handle_idx, + ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_) { const DexFile* const dex_file = referrer->GetDexFile(); const DexFile::MethodHandleItem& method_handle = dex_file->GetMethodHandle(method_handle_idx); diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 6a8c7c1d05..a5cde5b592 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -366,25 +366,26 @@ class ClassLinker { REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); - // Resolve a method type with a given ID from the DexFile, storing - // the result in the DexCache. - mirror::MethodType* ResolveMethodType(Thread* self, - const DexFile& dex_file, - uint32_t proto_idx, - Handle<mirror::DexCache> dex_cache, - Handle<mirror::ClassLoader> class_loader) + // Resolve a method type with a given ID from the DexFile associated with a given DexCache + // and ClassLoader, storing the result in the DexCache. + ObjPtr<mirror::MethodType> ResolveMethodType(Thread* self, + uint32_t proto_idx, + Handle<mirror::DexCache> dex_cache, + Handle<mirror::ClassLoader> class_loader) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); - mirror::MethodType* ResolveMethodType(Thread* self, uint32_t proto_idx, ArtMethod* referrer) + ObjPtr<mirror::MethodType> ResolveMethodType(Thread* self, + uint32_t proto_idx, + ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_); // Resolve a method handle with a given ID from the DexFile. The // result is not cached in the DexCache as the instance will only be // used once in most circumstances. - mirror::MethodHandle* ResolveMethodHandle(Thread* self, - uint32_t method_handle_idx, - ArtMethod* referrer) + ObjPtr<mirror::MethodHandle> ResolveMethodHandle(Thread* self, + uint32_t method_handle_idx, + ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_); // Returns true on success, false if there's an exception pending. diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index 94125507ef..b625c40fc3 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -1549,11 +1549,7 @@ TEST_F(ClassLinkerMethodHandlesTest, TestResolveMethodTypes) { // Its RType = Ljava/lang/String; // Its PTypes = { Ljava/lang/String; } Handle<mirror::MethodType> method1_type = hs.NewHandle( - class_linker_->ResolveMethodType(soa.Self(), - dex_file, - method1_id.proto_idx_, - dex_cache, - class_loader)); + class_linker_->ResolveMethodType(soa.Self(), method1_id.proto_idx_, dex_cache, class_loader)); // Assert that the method type was resolved successfully. ASSERT_TRUE(method1_type != nullptr); @@ -1567,11 +1563,7 @@ TEST_F(ClassLinkerMethodHandlesTest, TestResolveMethodTypes) { // Resolve the method type again and assert that we get back the same value. Handle<mirror::MethodType> method1_type2 = hs.NewHandle( - class_linker_->ResolveMethodType(soa.Self(), - dex_file, - method1_id.proto_idx_, - dex_cache, - class_loader)); + class_linker_->ResolveMethodType(soa.Self(), method1_id.proto_idx_, dex_cache, class_loader)); ASSERT_EQ(method1_type.Get(), method1_type2.Get()); // Resolve the MethodType associated with a different method signature @@ -1584,11 +1576,7 @@ TEST_F(ClassLinkerMethodHandlesTest, TestResolveMethodTypes) { ASSERT_FALSE(method2->IsDirect()); const DexFile::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex()); Handle<mirror::MethodType> method2_type = hs.NewHandle( - class_linker_->ResolveMethodType(soa.Self(), - dex_file, - method2_id.proto_idx_, - dex_cache, - class_loader)); + class_linker_->ResolveMethodType(soa.Self(), method2_id.proto_idx_, dex_cache, class_loader)); ASSERT_TRUE(method1_type.Get() != method2_type.Get()); } diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index d2d017e118..10cbf8daf1 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -1073,12 +1073,8 @@ static ObjPtr<mirror::CallSite> InvokeBootstrapMethod(Thread* self, // The third parameter is the method type associated with the name. uint32_t method_type_idx = static_cast<uint32_t>(it.GetJavaValue().i); - Handle<mirror::MethodType> - method_type(hs.NewHandle(class_linker->ResolveMethodType(self, - *dex_file, - method_type_idx, - dex_cache, - class_loader))); + Handle<mirror::MethodType> method_type(hs.NewHandle( + class_linker->ResolveMethodType(self, method_type_idx, dex_cache, class_loader))); if (method_type.IsNull()) { DCHECK(self->IsExceptionPending()); return nullptr; @@ -1113,7 +1109,7 @@ static ObjPtr<mirror::CallSite> InvokeBootstrapMethod(Thread* self, case EncodedArrayValueIterator::ValueType::kMethodType: { uint32_t idx = static_cast<uint32_t>(jvalue.i); ObjPtr<mirror::MethodType> ref = - class_linker->ResolveMethodType(self, *dex_file, idx, dex_cache, class_loader); + class_linker->ResolveMethodType(self, idx, dex_cache, class_loader); if (ref.IsNull()) { DCHECK(self->IsExceptionPending()); return nullptr; diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h index f097bc71b9..ebd67ab4ec 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -206,17 +206,17 @@ static inline bool DoInvoke(Thread* self, } } -static inline mirror::MethodHandle* ResolveMethodHandle(Thread* self, - uint32_t method_handle_index, - ArtMethod* referrer) +static inline ObjPtr<mirror::MethodHandle> ResolveMethodHandle(Thread* self, + uint32_t method_handle_index, + ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); return class_linker->ResolveMethodHandle(self, method_handle_index, referrer); } -static inline mirror::MethodType* ResolveMethodType(Thread* self, - uint32_t method_type_index, - ArtMethod* referrer) +static inline ObjPtr<mirror::MethodType> ResolveMethodType(Thread* self, + uint32_t method_type_index, + ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); return class_linker->ResolveMethodType(self, method_type_index, referrer); diff --git a/runtime/mirror/dex_cache_test.cc b/runtime/mirror/dex_cache_test.cc index 8198636b3d..d2bff2c19a 100644 --- a/runtime/mirror/dex_cache_test.cc +++ b/runtime/mirror/dex_cache_test.cc @@ -150,13 +150,11 @@ TEST_F(DexCacheMethodHandlesTest, TestResolvedMethodTypes) { const DexFile::MethodId& method2_id = dex_file.GetMethodId(method2->GetDexMethodIndex()); Handle<mirror::MethodType> method1_type = hs.NewHandle( class_linker_->ResolveMethodType(soa.Self(), - dex_file, method1_id.proto_idx_, dex_cache, class_loader)); Handle<mirror::MethodType> method2_type = hs.NewHandle( class_linker_->ResolveMethodType(soa.Self(), - dex_file, method2_id.proto_idx_, dex_cache, class_loader)); |