diff options
Diffstat (limited to 'runtime/class_linker.h')
| -rw-r--r-- | runtime/class_linker.h | 87 | 
1 files changed, 51 insertions, 36 deletions
diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 6a5768ec27..10562f0890 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -255,45 +255,50 @@ class ClassLinker {                                        ObjPtr<mirror::DexCache> dex_cache)        REQUIRES_SHARED(Locks::mutator_lock_); -  // Resolve a Type with the given index from the DexFile, storing the -  // result in the DexCache. The referrer is used to identify the -  // target DexCache and ClassLoader to use for resolution. -  ObjPtr<mirror::Class> ResolveType(const DexFile& dex_file, -                                    dex::TypeIndex type_idx, -                                    ObjPtr<mirror::Class> referrer) +  // Resolve a Type with the given index from the DexFile associated with the given `referrer`, +  // storing the result in the DexCache. The `referrer` is used to identify the target DexCache +  // and ClassLoader to use for resolution. +  ObjPtr<mirror::Class> ResolveType(dex::TypeIndex type_idx, ObjPtr<mirror::Class> referrer)        REQUIRES_SHARED(Locks::mutator_lock_)        REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); -  // Resolve a Type with the given index from the DexFile, storing the -  // result in the DexCache. The referrer is used to identify the -  // target DexCache and ClassLoader to use for resolution. +  // Resolve a type with the given index from the DexFile associated with the given `referrer`, +  // storing the result in the DexCache. The `referrer` is used to identify the target DexCache +  // and ClassLoader to use for resolution.    ObjPtr<mirror::Class> ResolveType(dex::TypeIndex type_idx, ArtMethod* referrer)        REQUIRES_SHARED(Locks::mutator_lock_)        REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); -  // Look up a resolved type with the given ID from the DexFile. The ClassLoader is used to search -  // for the type, since it may be referenced from but not contained within the given DexFile. -  ObjPtr<mirror::Class> LookupResolvedType(const DexFile& dex_file, -                                           dex::TypeIndex type_idx, -                                           ObjPtr<mirror::DexCache> dex_cache, -                                           ObjPtr<mirror::ClassLoader> class_loader) -      REQUIRES_SHARED(Locks::mutator_lock_); -  static ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_idx, -                                                  ObjPtr<mirror::DexCache> dex_cache, -                                                  ObjPtr<mirror::ClassLoader> class_loader) -      REQUIRES_SHARED(Locks::mutator_lock_); - -  // Resolve a type with the given ID from the DexFile, storing the -  // result in DexCache. The ClassLoader is used to search for the -  // type, since it may be referenced from but not contained within -  // the given DexFile. -  ObjPtr<mirror::Class> ResolveType(const DexFile& dex_file, -                                    dex::TypeIndex type_idx, +  // Resolve a type with the given index from the DexFile associated with the given DexCache +  // and ClassLoader, storing the result in DexCache. The ClassLoader is used to search for +  // the type, since it may be referenced from but not contained within the DexFile. +  ObjPtr<mirror::Class> ResolveType(dex::TypeIndex type_idx,                                      Handle<mirror::DexCache> dex_cache,                                      Handle<mirror::ClassLoader> class_loader)        REQUIRES_SHARED(Locks::mutator_lock_)        REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); +  // Look up a resolved type with the given index from the DexFile associated with the given +  // `referrer`, storing the result in the DexCache. The `referrer` is used to identify the +  // target DexCache and ClassLoader to use for lookup. +  ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_idx, +                                           ObjPtr<mirror::Class> referrer) +      REQUIRES_SHARED(Locks::mutator_lock_); + +  // Look up a resolved type with the given index from the DexFile associated with the given +  // `referrer`, storing the result in the DexCache. The `referrer` is used to identify the +  // target DexCache and ClassLoader to use for lookup. +  ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_idx, ArtMethod* referrer) +      REQUIRES_SHARED(Locks::mutator_lock_); + +  // Look up a resolved type with the given index from the DexFile associated with the given +  // DexCache and ClassLoader. The ClassLoader is used to search for the type, since it may +  // be referenced from but not contained within the DexFile. +  ObjPtr<mirror::Class> LookupResolvedType(dex::TypeIndex type_idx, +                                           ObjPtr<mirror::DexCache> dex_cache, +                                           ObjPtr<mirror::ClassLoader> class_loader) +      REQUIRES_SHARED(Locks::mutator_lock_); +    // Determine whether a dex cache result should be trusted, or an IncompatibleClassChangeError    // check and IllegalAccessError check should be performed even after a hit.    enum class ResolveMode {  // private. @@ -307,14 +312,12 @@ class ClassLinker {                                    ObjPtr<mirror::ClassLoader> class_loader)        REQUIRES_SHARED(Locks::mutator_lock_); -  // Resolve a method with a given ID from the DexFile, storing the -  // result in DexCache. The ClassLinker and ClassLoader are used as -  // in ResolveType. What is unique is the method type argument which -  // is used to determine if this method is a direct, static, or -  // virtual method. +  // Resolve a method with a given ID from the DexFile associated with the given DexCache +  // and ClassLoader, storing the result in DexCache. The ClassLinker and ClassLoader are +  // used as in ResolveType. What is unique is the method type argument which is used to +  // determine if this method is a direct, static, or virtual method.    template <ResolveMode kResolveMode> -  ArtMethod* ResolveMethod(const DexFile& dex_file, -                           uint32_t method_idx, +  ArtMethod* ResolveMethod(uint32_t method_idx,                             Handle<mirror::DexCache> dex_cache,                             Handle<mirror::ClassLoader> class_loader,                             ArtMethod* referrer, @@ -330,8 +333,7 @@ class ClassLinker {    ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, ArtMethod* referrer, InvokeType type)        REQUIRES_SHARED(Locks::mutator_lock_)        REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); -  ArtMethod* ResolveMethodWithoutInvokeType(const DexFile& dex_file, -                                            uint32_t method_idx, +  ArtMethod* ResolveMethodWithoutInvokeType(uint32_t method_idx,                                              Handle<mirror::DexCache> dex_cache,                                              Handle<mirror::ClassLoader> class_loader)        REQUIRES_SHARED(Locks::mutator_lock_) @@ -879,6 +881,19 @@ class ClassLinker {        REQUIRES_SHARED(Locks::mutator_lock_)        REQUIRES(!Locks::dex_lock_); +  // Implementation of LookupResolvedType() called when the type was not found in the dex cache. +  ObjPtr<mirror::Class> DoLookupResolvedType(dex::TypeIndex type_idx, +                                             ObjPtr<mirror::DexCache> dex_cache, +                                             ObjPtr<mirror::ClassLoader> class_loader) +      REQUIRES_SHARED(Locks::mutator_lock_); + +  // Implementation of ResolveType() called when the type was not found in the dex cache. +  ObjPtr<mirror::Class> DoResolveType(dex::TypeIndex type_idx, +                                      Handle<mirror::DexCache> dex_cache, +                                      Handle<mirror::ClassLoader> class_loader) +      REQUIRES_SHARED(Locks::mutator_lock_) +      REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); +    // Finds a class by its descriptor, returning NULL if it isn't wasn't loaded    // by the given 'class_loader'. Uses the provided hash for the descriptor.    mirror::Class* LookupClass(Thread* self,  |