diff options
| author | 2015-04-22 13:56:20 -0700 | |
|---|---|---|
| committer | 2015-06-02 09:21:27 -0700 | |
| commit | 3d21bdf8894e780d349c481e5c9e29fe1556051c (patch) | |
| tree | 61a5231f36c0dabd73457fec81df103462a05aff /runtime/class_linker.h | |
| parent | 71f0a8a123fa27bdc857a98afebbaf0ed09dac15 (diff) | |
Move mirror::ArtMethod to native
Optimizing + quick tests are passing, devices boot.
TODO: Test and fix bugs in mips64.
Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.
Bug: 19264997
(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)
Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
Fix some ArtMethod related bugs
Added root visiting for runtime methods, not currently required
since the GcRoots in these methods are null.
Added missing GetInterfaceMethodIfProxy in GetMethodLine, fixes
--trace run-tests 005, 044.
Fixed optimizing compiler bug where we used a normal stack location
instead of double on ARM64, this fixes the debuggable tests.
TODO: Fix JDWP tests.
Bug: 19264997
Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3
ART: Fix casts for 64-bit pointers on 32-bit compiler.
Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457
Fix JDWP tests after ArtMethod change
Fixes Throwable::GetStackDepth for exception event detection after
internal stack trace representation change.
Adds missing ArtMethod::GetInterfaceMethodIfProxy call in case of
proxy method.
Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2
Fix accidental IMT and root marking regression
Was always using the conflict trampoline. Also included fix for
regression in GC time caused by extra roots. Most of the regression
was IMT.
Fixed bug in DumpGcPerformanceInfo where we would get SIGABRT due to
detached thread.
EvaluateAndApplyChanges:
From ~2500 -> ~1980
GC time: 8.2s -> 7.2s due to 1s less of MarkConcurrentRoots
Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0
Fix bogus image test assert
Previously we were comparing the size of the non moving space to
size of the image file.
Now we properly compare the size of the image space against the size
of the image file.
Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a
[MIPS64] Fix art_quick_invoke_stub argument offsets.
ArtMethod reference's size got bigger, so we need to move other args
and leave enough space for ArtMethod* and 'this' pointer.
This fixes mips64 boot.
Bug: 19264997
Change-Id: I47198d5f39a4caab30b3b77479d5eedaad5006ab
Diffstat (limited to 'runtime/class_linker.h')
| -rw-r--r-- | runtime/class_linker.h | 110 |
1 files changed, 63 insertions, 47 deletions
diff --git a/runtime/class_linker.h b/runtime/class_linker.h index 947e15210b..fa8b2e796b 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -42,6 +42,7 @@ namespace space { namespace mirror { class ClassLoader; class DexCache; + class DexCachePointerArray; class DexCacheTest_Open_Test; class IfTable; template<class T> class ObjectArray; @@ -71,13 +72,11 @@ class ClassLinker { kJavaLangString, kJavaLangDexCache, kJavaLangRefReference, - kJavaLangReflectArtMethod, kJavaLangReflectConstructor, kJavaLangReflectField, kJavaLangReflectMethod, kJavaLangReflectProxy, kJavaLangStringArrayClass, - kJavaLangReflectArtMethodArrayClass, kJavaLangReflectConstructorArrayClass, kJavaLangReflectFieldArrayClass, kJavaLangReflectMethodArrayClass, @@ -187,7 +186,7 @@ class ClassLinker { // Resolve a String 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. - mirror::String* ResolveString(uint32_t string_idx, mirror::ArtMethod* referrer) + mirror::String* ResolveString(uint32_t string_idx, ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a String with the given index from the DexFile, storing the @@ -205,7 +204,7 @@ class ClassLinker { // 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. - mirror::Class* ResolveType(uint16_t type_idx, mirror::ArtMethod* referrer) + mirror::Class* ResolveType(uint16_t type_idx, ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Class* ResolveType(uint16_t type_idx, ArtField* referrer) @@ -225,25 +224,22 @@ class ClassLinker { // 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. - mirror::ArtMethod* ResolveMethod(const DexFile& dex_file, - uint32_t method_idx, - Handle<mirror::DexCache> dex_cache, - Handle<mirror::ClassLoader> class_loader, - Handle<mirror::ArtMethod> referrer, - InvokeType type) + ArtMethod* ResolveMethod(const DexFile& dex_file, uint32_t method_idx, + Handle<mirror::DexCache> dex_cache, + Handle<mirror::ClassLoader> class_loader, ArtMethod* referrer, + InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ArtMethod* GetResolvedMethod(uint32_t method_idx, mirror::ArtMethod* referrer) + ArtMethod* GetResolvedMethod(uint32_t method_idx, ArtMethod* referrer) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, mirror::ArtMethod** referrer, - InvokeType type) + ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, ArtMethod* referrer, InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); ArtField* GetResolvedField(uint32_t field_idx, mirror::Class* field_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); ArtField* GetResolvedField(uint32_t field_idx, mirror::DexCache* dex_cache) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - ArtField* ResolveField(uint32_t field_idx, mirror::ArtMethod* referrer, bool is_static) + ArtField* ResolveField(uint32_t field_idx, ArtMethod* referrer, bool is_static) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Resolve a field with a given ID from the DexFile, storing the @@ -263,12 +259,12 @@ class ClassLinker { // in ResolveType. No is_static argument is provided so that Java // field resolution semantics are followed. ArtField* ResolveFieldJLS(const DexFile& dex_file, uint32_t field_idx, - Handle<mirror::DexCache> dex_cache, - Handle<mirror::ClassLoader> class_loader) + Handle<mirror::DexCache> dex_cache, + Handle<mirror::ClassLoader> class_loader) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get shorty from method index without resolution. Used to do handlerization. - const char* MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length) + const char* MethodShorty(uint32_t method_idx, ArtMethod* referrer, uint32_t* length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns true on success, false if there's an exception pending. @@ -323,7 +319,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool IsDexFileRegistered(const DexFile& dex_file) LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void FixupDexCaches(mirror::ArtMethod* resolution_method) + void FixupDexCaches(ArtMethod* resolution_method) LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -360,7 +356,9 @@ class ClassLinker { mirror::ObjectArray<mirror::String>* AllocStringArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ObjectArray<mirror::ArtMethod>* AllocArtMethodArray(Thread* self, size_t length) + ArtMethod* AllocArtMethodArray(Thread* self, size_t length); + + mirror::PointerArray* AllocPointerArray(Thread* self, size_t length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount) @@ -381,7 +379,7 @@ class ClassLinker { void ResolveClassExceptionHandlerTypes(const DexFile& dex_file, Handle<mirror::Class> klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::ArtMethod* klass) + void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, ArtMethod* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); mirror::Class* CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa, jstring name, @@ -390,23 +388,23 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); std::string GetDescriptorForProxy(mirror::Class* proxy_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ArtMethod* FindMethodForProxy(mirror::Class* proxy_class, - mirror::ArtMethod* proxy_method) + ArtMethod* FindMethodForProxy(mirror::Class* proxy_class, ArtMethod* proxy_method) LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method when its class isn't yet initialized - const void* GetQuickOatCodeFor(mirror::ArtMethod* method) + const void* GetQuickOatCodeFor(ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get the oat code for a method from a method index. - const void* GetQuickOatCodeFor(const DexFile& dex_file, uint16_t class_def_idx, uint32_t method_idx) + const void* GetQuickOatCodeFor(const DexFile& dex_file, uint16_t class_def_idx, + uint32_t method_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Get compiled code for a method, return null if no code // exists. This is unlike Get..OatCodeFor which will return a bridge // or interpreter entrypoint. - const void* GetOatMethodQuickCodeFor(mirror::ArtMethod* method) + const void* GetOatMethodQuickCodeFor(ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); pid_t GetClassesLockOwner(); // For SignalCatcher. @@ -430,11 +428,11 @@ class ClassLinker { } // Set the entrypoints up for method to the given code. - void SetEntryPointsToCompiledCode(mirror::ArtMethod* method, const void* method_code) const + void SetEntryPointsToCompiledCode(ArtMethod* method, const void* method_code) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Set the entrypoints up for method to the enter the interpreter. - void SetEntryPointsToInterpreter(mirror::ArtMethod* method) const + void SetEntryPointsToInterpreter(ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Attempts to insert a class into a class table. Returns null if @@ -444,9 +442,6 @@ class ClassLinker { LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - // Special code to allocate an art method, use this instead of class->AllocObject. - mirror::ArtMethod* AllocArtMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ObjectArray<mirror::Class>* GetClassRoots() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { mirror::ObjectArray<mirror::Class>* class_roots = class_roots_.Read(); DCHECK(class_roots != nullptr); @@ -465,7 +460,7 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Returns true if the method can be called with its direct code pointer, false otherwise. - bool MayBeCalledWithDirectCodePointer(mirror::ArtMethod* m) + bool MayBeCalledWithDirectCodePointer(ArtMethod* m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Creates a GlobalRef PathClassLoader that can be used to load classes from the given dex files. @@ -473,11 +468,20 @@ class ClassLinker { jobject CreatePathClassLoader(Thread* self, std::vector<const DexFile*>& dex_files) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - private: - static void InitFromImageInterpretOnlyCallback(mirror::Object* obj, void* arg) + size_t GetImagePointerSize() const { + DCHECK(ValidPointerSize(image_pointer_size_)) << image_pointer_size_; + return image_pointer_size_; + } + + // Used by image writer for checking. + bool ClassInClassTable(mirror::Class* klass) + LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - const OatFile::OatMethod FindOatMethodFor(mirror::ArtMethod* method, bool* found) + ArtMethod* CreateRuntimeMethod(); + + private: + const OatFile::OatMethod FindOatMethodFor(ArtMethod* method, bool* found) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); OatFile& GetImageOatFile(gc::space::ImageSpace* space) @@ -535,9 +539,8 @@ class ClassLinker { ArtField* dst) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ArtMethod* LoadMethod(Thread* self, const DexFile& dex_file, - const ClassDataItemIterator& dex_method, - Handle<mirror::Class> klass) + void LoadMethod(Thread* self, const DexFile& dex_file, const ClassDataItemIterator& it, + Handle<mirror::Class> klass, ArtMethod* dst) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void FixupStaticTrampolines(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -566,9 +569,8 @@ class ClassLinker { Handle<mirror::ClassLoader> class_loader2) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool IsSameMethodSignatureInDifferentClassContexts(Thread* self, mirror::ArtMethod* method, - mirror::Class* klass1, - mirror::Class* klass2) + bool IsSameMethodSignatureInDifferentClassContexts(Thread* self, ArtMethod* method, + mirror::Class* klass1, mirror::Class* klass2) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool LinkClass(Thread* self, const char* descriptor, Handle<mirror::Class> klass, @@ -584,15 +586,15 @@ class ClassLinker { bool LinkMethods(Thread* self, Handle<mirror::Class> klass, Handle<mirror::ObjectArray<mirror::Class>> interfaces, - StackHandleScope<mirror::Class::kImtSize>* out_imt) + ArtMethod** out_imt) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool LinkVirtualMethods(Thread* self, Handle<mirror::Class> klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - bool LinkInterfaceMethods(Thread* const self, Handle<mirror::Class> klass, + bool LinkInterfaceMethods(Thread* self, Handle<mirror::Class> klass, Handle<mirror::ObjectArray<mirror::Class>> interfaces, - StackHandleScope<mirror::Class::kImtSize>* out_imt) + ArtMethod** out_imt) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size) @@ -601,12 +603,17 @@ class ClassLinker { SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); bool LinkFields(Thread* self, Handle<mirror::Class> klass, bool is_static, size_t* class_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void LinkCode(Handle<mirror::ArtMethod> method, const OatFile::OatClass* oat_class, + void LinkCode(ArtMethod* method, const OatFile::OatClass* oat_class, uint32_t class_def_method_index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); void CreateReferenceInstanceOffsets(Handle<mirror::Class> klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void CheckProxyConstructor(ArtMethod* constructor) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + void CheckProxyMethod(ArtMethod* method, ArtMethod* prototype) const + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // For use by ImageWriter to find DexCaches for its roots ReaderWriterMutex* DexLock() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) LOCK_RETURNED(dex_lock_) { @@ -623,10 +630,9 @@ class ClassLinker { // Returns the boot image oat file. const OatFile* GetBootOatFile() SHARED_LOCKS_REQUIRED(dex_lock_); - mirror::ArtMethod* CreateProxyConstructor(Thread* self, Handle<mirror::Class> klass) + void CreateProxyConstructor(Handle<mirror::Class> klass, ArtMethod* out) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - mirror::ArtMethod* CreateProxyMethod(Thread* self, Handle<mirror::Class> klass, - Handle<mirror::ArtMethod> prototype) + void CreateProxyMethod(Handle<mirror::Class> klass, ArtMethod* prototype, ArtMethod* out) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); // Ensures that methods have the kAccPreverified bit set. We use the kAccPreverfied bit on the @@ -673,6 +679,16 @@ class ClassLinker { // Check for duplicate class definitions of the given oat file against all open oat files. bool HasCollisions(const OatFile* oat_file, std::string* error_msg) LOCKS_EXCLUDED(dex_lock_); + bool HasInitWithString(Thread* self, ClassLinker* class_linker, const char* descriptor) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + bool CanWeInitializeClass(mirror::Class* klass, bool can_init_statics, bool can_init_parents) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + void UpdateClassVirtualMethods(mirror::Class* klass, ArtMethod* new_methods, + size_t new_num_methods) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) LOCKS_EXCLUDED(Locks::classlinker_classes_lock_); + std::vector<const DexFile*> boot_class_path_; std::vector<std::unique_ptr<const DexFile>> opened_dex_files_; |