Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_CLASS_LINKER_H_ |
| 18 | #define ART_RUNTIME_CLASS_LINKER_H_ |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 20 | #include <string> |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 21 | #include <utility> |
| 22 | #include <vector> |
| 23 | |
Mathieu Chartier | bad0267 | 2014-08-25 13:08:22 -0700 | [diff] [blame] | 24 | #include "base/allocator.h" |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 25 | #include "base/hash_set.h" |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 26 | #include "base/macros.h" |
Elliott Hughes | 76b6167 | 2012-12-12 17:47:30 -0800 | [diff] [blame] | 27 | #include "base/mutex.h" |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 28 | #include "dex_file.h" |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 29 | #include "gc_root.h" |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 30 | #include "jni.h" |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 31 | #include "oat_file.h" |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 32 | #include "object_callbacks.h" |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 33 | |
| 34 | namespace art { |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 35 | |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 36 | namespace gc { |
| 37 | namespace space { |
| 38 | class ImageSpace; |
| 39 | } // namespace space |
| 40 | } // namespace gc |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 41 | namespace mirror { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 42 | class ClassLoader; |
| 43 | class DexCache; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 44 | class DexCachePointerArray; |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 45 | class DexCacheTest_Open_Test; |
| 46 | class IfTable; |
| 47 | template<class T> class ObjectArray; |
| 48 | class StackTraceElement; |
| 49 | } // namespace mirror |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 50 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 51 | template<class T> class Handle; |
Hiroshi Yamauchi | 679b1cf | 2015-05-21 12:05:27 -0700 | [diff] [blame] | 52 | template<class T> class MutableHandle; |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 53 | class InternTable; |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 54 | template<class T> class ObjectLock; |
Andreas Gampe | 7ba6496 | 2014-10-23 11:37:40 -0700 | [diff] [blame] | 55 | class Runtime; |
Mathieu Chartier | 2b7c4d1 | 2014-05-19 10:52:16 -0700 | [diff] [blame] | 56 | class ScopedObjectAccessAlreadyRunnable; |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 57 | template<size_t kNumReferences> class PACKED(4) StackHandleScope; |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 58 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 59 | typedef bool (ClassVisitor)(mirror::Class* c, void* arg); |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 60 | |
Mathieu Chartier | 893263b | 2014-03-04 11:07:42 -0800 | [diff] [blame] | 61 | enum VisitRootFlags : uint8_t; |
| 62 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 63 | class ClassLinker { |
| 64 | public: |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 65 | // Well known mirror::Class roots accessed via GetClassRoot. |
| 66 | enum ClassRoot { |
| 67 | kJavaLangClass, |
| 68 | kJavaLangObject, |
| 69 | kClassArrayClass, |
| 70 | kObjectArrayClass, |
| 71 | kJavaLangString, |
| 72 | kJavaLangDexCache, |
| 73 | kJavaLangRefReference, |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 74 | kJavaLangReflectConstructor, |
Mathieu Chartier | daaf326 | 2015-03-24 13:30:28 -0700 | [diff] [blame] | 75 | kJavaLangReflectField, |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 76 | kJavaLangReflectMethod, |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 77 | kJavaLangReflectProxy, |
| 78 | kJavaLangStringArrayClass, |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 79 | kJavaLangReflectConstructorArrayClass, |
Mathieu Chartier | daaf326 | 2015-03-24 13:30:28 -0700 | [diff] [blame] | 80 | kJavaLangReflectFieldArrayClass, |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 81 | kJavaLangReflectMethodArrayClass, |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 82 | kJavaLangClassLoader, |
| 83 | kJavaLangThrowable, |
| 84 | kJavaLangClassNotFoundException, |
| 85 | kJavaLangStackTraceElement, |
| 86 | kPrimitiveBoolean, |
| 87 | kPrimitiveByte, |
| 88 | kPrimitiveChar, |
| 89 | kPrimitiveDouble, |
| 90 | kPrimitiveFloat, |
| 91 | kPrimitiveInt, |
| 92 | kPrimitiveLong, |
| 93 | kPrimitiveShort, |
| 94 | kPrimitiveVoid, |
| 95 | kBooleanArrayClass, |
| 96 | kByteArrayClass, |
| 97 | kCharArrayClass, |
| 98 | kDoubleArrayClass, |
| 99 | kFloatArrayClass, |
| 100 | kIntArrayClass, |
| 101 | kLongArrayClass, |
| 102 | kShortArrayClass, |
| 103 | kJavaLangStackTraceElementArrayClass, |
| 104 | kClassRootsMax, |
| 105 | }; |
| 106 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 107 | explicit ClassLinker(InternTable* intern_table); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 108 | ~ClassLinker(); |
Carl Shapiro | 565f507 | 2011-07-10 13:39:43 -0700 | [diff] [blame] | 109 | |
Alex Light | 64ad14d | 2014-08-19 14:23:13 -0700 | [diff] [blame] | 110 | // Initialize class linker by bootstraping from dex files. |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 111 | void InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> boot_class_path) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 112 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 113 | |
| 114 | // Initialize class linker from one or more images. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 115 | void InitFromImage() SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 116 | |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 117 | // Finds a class by its descriptor, loading it if necessary. |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 118 | // If class_loader is null, searches boot_class_path_. |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 119 | mirror::Class* FindClass(Thread* self, const char* descriptor, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 120 | Handle<mirror::ClassLoader> class_loader) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 121 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 122 | |
Andreas Gampe | f865ea9 | 2015-04-13 22:14:19 -0700 | [diff] [blame] | 123 | // Finds a class in the path class loader, loading it if necessary without using JNI. Hash |
| 124 | // function is supposed to be ComputeModifiedUtf8Hash(descriptor). Returns true if the |
| 125 | // class-loader chain could be handled, false otherwise, i.e., a non-supported class-loader |
| 126 | // was encountered while walking the parent chain (currently only BootClassLoader and |
| 127 | // PathClassLoader are supported). |
| 128 | bool FindClassInPathClassLoader(ScopedObjectAccessAlreadyRunnable& soa, |
| 129 | Thread* self, const char* descriptor, size_t hash, |
| 130 | Handle<mirror::ClassLoader> class_loader, |
| 131 | mirror::Class** result) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 132 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Mathieu Chartier | ab0ed82 | 2014-09-11 14:21:41 -0700 | [diff] [blame] | 133 | |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 134 | // Finds a class by its descriptor using the "system" class loader, ie by searching the |
| 135 | // boot_class_path_. |
| 136 | mirror::Class* FindSystemClass(Thread* self, const char* descriptor) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 137 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 138 | |
| 139 | // Finds the array class given for the element class. |
Mathieu Chartier | b74cd29 | 2014-05-29 14:31:33 -0700 | [diff] [blame] | 140 | mirror::Class* FindArrayClass(Thread* self, mirror::Class** element_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 141 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 142 | |
Ian Rogers | 6355745 | 2014-06-04 16:57:15 -0700 | [diff] [blame] | 143 | // Returns true if the class linker is initialized. |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 144 | bool IsInitialized() const { |
| 145 | return init_done_; |
| 146 | } |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 147 | |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 148 | // Define a new a class based on a ClassDef from a DexFile |
Mathieu Chartier | e7c9a8c | 2014-11-06 16:35:45 -0800 | [diff] [blame] | 149 | mirror::Class* DefineClass(Thread* self, const char* descriptor, size_t hash, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 150 | Handle<mirror::ClassLoader> class_loader, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 151 | const DexFile& dex_file, const DexFile::ClassDef& dex_class_def) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 152 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 153 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 154 | // Finds a class by its descriptor, returning null if it isn't wasn't loaded |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 155 | // by the given 'class_loader'. |
Mathieu Chartier | e7c9a8c | 2014-11-06 16:35:45 -0800 | [diff] [blame] | 156 | mirror::Class* LookupClass(Thread* self, const char* descriptor, size_t hash, |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 157 | mirror::ClassLoader* class_loader) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 158 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 159 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 160 | |
Elliott Hughes | 6fa602d | 2011-12-02 17:54:25 -0800 | [diff] [blame] | 161 | // Finds all the classes with the given descriptor, regardless of ClassLoader. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 162 | void LookupClasses(const char* descriptor, std::vector<mirror::Class*>& classes) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 163 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 164 | SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | 6fa602d | 2011-12-02 17:54:25 -0800 | [diff] [blame] | 165 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 166 | mirror::Class* FindPrimitiveClass(char type) SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 167 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 168 | // General class unloading is not supported, this is used to prune |
| 169 | // unwanted classes during image writing. |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 170 | bool RemoveClass(const char* descriptor, mirror::ClassLoader* class_loader) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 171 | REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 172 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 173 | void DumpAllClasses(int flags) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 174 | REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 175 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 176 | void DumpForSigQuit(std::ostream& os) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 177 | REQUIRES(!Locks::classlinker_classes_lock_); |
Elliott Hughes | cac6cc7 | 2011-11-03 20:31:21 -0700 | [diff] [blame] | 178 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 179 | size_t NumLoadedClasses() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 180 | REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | e27955c | 2011-08-26 15:21:24 -0700 | [diff] [blame] | 181 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 182 | // Resolve a String with the given index from the DexFile, storing the |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 183 | // result in the DexCache. The referrer is used to identify the |
| 184 | // target DexCache and ClassLoader to use for resolution. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 185 | mirror::String* ResolveString(uint32_t string_idx, ArtMethod* referrer) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 186 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 187 | |
| 188 | // Resolve a String with the given index from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 189 | // result in the DexCache. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 190 | mirror::String* ResolveString(const DexFile& dex_file, uint32_t string_idx, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 191 | Handle<mirror::DexCache> dex_cache) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 192 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 193 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 194 | // Resolve a Type with the given index from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 195 | // result in the DexCache. The referrer is used to identity the |
| 196 | // target DexCache and ClassLoader to use for resolution. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 197 | mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx, mirror::Class* referrer) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 198 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 199 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 200 | // Resolve a Type with the given index from the DexFile, storing the |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 201 | // result in the DexCache. The referrer is used to identify the |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 202 | // target DexCache and ClassLoader to use for resolution. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 203 | mirror::Class* ResolveType(uint16_t type_idx, ArtMethod* referrer) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 204 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 205 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 206 | mirror::Class* ResolveType(uint16_t type_idx, ArtField* referrer) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 207 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 208 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 209 | // Resolve a type with the given ID from the DexFile, storing the |
| 210 | // result in DexCache. The ClassLoader is used to search for the |
| 211 | // type, since it may be referenced from but not contained within |
| 212 | // the given DexFile. |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 213 | mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 214 | Handle<mirror::DexCache> dex_cache, |
| 215 | Handle<mirror::ClassLoader> class_loader) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 216 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 217 | |
| 218 | // Resolve a method with a given ID from the DexFile, storing the |
| 219 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 220 | // in ResolveType. What is unique is the method type argument which |
| 221 | // is used to determine if this method is a direct, static, or |
| 222 | // virtual method. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 223 | ArtMethod* ResolveMethod(const DexFile& dex_file, uint32_t method_idx, |
| 224 | Handle<mirror::DexCache> dex_cache, |
| 225 | Handle<mirror::ClassLoader> class_loader, ArtMethod* referrer, |
| 226 | InvokeType type) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 227 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 228 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 229 | ArtMethod* GetResolvedMethod(uint32_t method_idx, ArtMethod* referrer) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 230 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 231 | ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, ArtMethod* referrer, InvokeType type) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 232 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 233 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 234 | ArtField* GetResolvedField(uint32_t field_idx, mirror::Class* field_declaring_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 235 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 236 | ArtField* GetResolvedField(uint32_t field_idx, mirror::DexCache* dex_cache) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 237 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 238 | ArtField* ResolveField(uint32_t field_idx, ArtMethod* referrer, bool is_static) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 239 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | b9edb84 | 2011-08-28 16:31:06 -0700 | [diff] [blame] | 240 | |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 241 | // Resolve a field with a given ID from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 242 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 243 | // in ResolveType. What is unique is the is_static argument which is |
| 244 | // used to determine if we are resolving a static or non-static |
| 245 | // field. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 246 | ArtField* ResolveField(const DexFile& dex_file, uint32_t field_idx, |
| 247 | Handle<mirror::DexCache> dex_cache, |
| 248 | Handle<mirror::ClassLoader> class_loader, bool is_static) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 249 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 250 | |
Ian Rogers | b067ac2 | 2011-12-13 18:05:09 -0800 | [diff] [blame] | 251 | // Resolve a field with a given ID from the DexFile, storing the |
| 252 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 253 | // in ResolveType. No is_static argument is provided so that Java |
| 254 | // field resolution semantics are followed. |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 255 | ArtField* ResolveFieldJLS(const DexFile& dex_file, uint32_t field_idx, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 256 | Handle<mirror::DexCache> dex_cache, |
| 257 | Handle<mirror::ClassLoader> class_loader) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 258 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Ian Rogers | b067ac2 | 2011-12-13 18:05:09 -0800 | [diff] [blame] | 259 | |
Ian Rogers | ad25ac5 | 2011-10-04 19:13:33 -0700 | [diff] [blame] | 260 | // Get shorty from method index without resolution. Used to do handlerization. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 261 | const char* MethodShorty(uint32_t method_idx, ArtMethod* referrer, uint32_t* length) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 262 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | ad25ac5 | 2011-10-04 19:13:33 -0700 | [diff] [blame] | 263 | |
Elliott Hughes | f4c21c9 | 2011-08-19 17:31:31 -0700 | [diff] [blame] | 264 | // Returns true on success, false if there's an exception pending. |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 265 | // can_run_clinit=false allows the compiler to attempt to init a class, |
| 266 | // given the restriction that no <clinit> execution is possible. |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 267 | bool EnsureInitialized(Thread* self, Handle<mirror::Class> c, bool can_init_fields, |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 268 | bool can_init_parents) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 269 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 270 | |
Elliott Hughes | 2a20cfd | 2011-09-23 19:30:41 -0700 | [diff] [blame] | 271 | // Initializes classes that have instances in the image but that have |
| 272 | // <clinit> methods so they could not be initialized by the compiler. |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 273 | void RunRootClinits() SHARED_REQUIRES(Locks::mutator_lock_) |
| 274 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Elliott Hughes | 2a20cfd | 2011-09-23 19:30:41 -0700 | [diff] [blame] | 275 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 276 | void RegisterDexFile(const DexFile& dex_file) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 277 | REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 278 | void RegisterDexFile(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 279 | REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 280 | |
Ian Rogers | 8d31bbd | 2013-10-13 10:44:14 -0700 | [diff] [blame] | 281 | const OatFile* RegisterOatFile(const OatFile* oat_file) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 282 | REQUIRES(!dex_lock_); |
Brian Carlstrom | 866c862 | 2012-01-06 16:35:13 -0800 | [diff] [blame] | 283 | |
Brian Carlstrom | 8a48741 | 2011-08-29 20:08:52 -0700 | [diff] [blame] | 284 | const std::vector<const DexFile*>& GetBootClassPath() { |
| 285 | return boot_class_path_; |
| 286 | } |
| 287 | |
Sebastien Hertz | 0de1133 | 2015-05-13 12:14:05 +0200 | [diff] [blame] | 288 | // Returns the first non-image oat file in the class path. |
| 289 | const OatFile* GetPrimaryOatFile() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 290 | REQUIRES(!dex_lock_); |
Sebastien Hertz | 0de1133 | 2015-05-13 12:14:05 +0200 | [diff] [blame] | 291 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 292 | void VisitClasses(ClassVisitor* visitor, void* arg) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 293 | REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 294 | |
| 295 | // Less efficient variant of VisitClasses that copies the class_table_ into secondary storage |
| 296 | // so that it can visit individual classes without holding the doesn't hold the |
| 297 | // Locks::classlinker_classes_lock_. As the Locks::classlinker_classes_lock_ isn't held this code |
| 298 | // can race with insertion and deletion of classes while the visitor is being called. |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 299 | void VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* arg) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 300 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 301 | |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 302 | void VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 303 | REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 304 | void VisitRoots(RootVisitor* visitor, VisitRootFlags flags) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 305 | REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 306 | |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 307 | mirror::DexCache* FindDexCache(const DexFile& dex_file) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 308 | REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 309 | bool IsDexFileRegistered(const DexFile& dex_file) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 310 | REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 311 | void FixupDexCaches(ArtMethod* resolution_method) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 312 | REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 313 | |
Richard Uhler | 66d874d | 2015-01-15 09:37:19 -0800 | [diff] [blame] | 314 | // Finds or creates the oat file holding dex_location. Then loads and returns |
| 315 | // all corresponding dex files (there may be more than one dex file loaded |
| 316 | // in the case of multidex). |
| 317 | // This may return the original, unquickened dex files if the oat file could |
| 318 | // not be generated. |
| 319 | // |
| 320 | // Returns an empty vector if the dex files could not be loaded. In this |
| 321 | // case, there will be at least one error message returned describing why no |
| 322 | // dex files could not be loaded. The 'error_msgs' argument must not be |
| 323 | // null, regardless of whether there is an error or not. |
| 324 | // |
| 325 | // This method should not be called with the mutator_lock_ held, because it |
| 326 | // could end up starving GC if we need to generate or relocate any oat |
| 327 | // files. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 328 | std::vector<std::unique_ptr<const DexFile>> OpenDexFilesFromOat( |
Richard Uhler | 66d874d | 2015-01-15 09:37:19 -0800 | [diff] [blame] | 329 | const char* dex_location, const char* oat_location, |
| 330 | std::vector<std::string>* error_msgs) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 331 | REQUIRES(!dex_lock_, !Locks::mutator_lock_); |
jeffhao | f6174e8 | 2012-01-31 16:14:17 -0800 | [diff] [blame] | 332 | |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 333 | // Allocate an instance of a java.lang.Object. |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 334 | mirror::Object* AllocObject(Thread* self) SHARED_REQUIRES(Locks::mutator_lock_) |
| 335 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 336 | |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 337 | // TODO: replace this with multiple methods that allocate the correct managed type. |
Shih-wei Liao | 4417536 | 2011-08-28 16:59:17 -0700 | [diff] [blame] | 338 | template <class T> |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 339 | mirror::ObjectArray<T>* AllocObjectArray(Thread* self, size_t length) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 340 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Shih-wei Liao | 55df06b | 2011-08-26 14:39:27 -0700 | [diff] [blame] | 341 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 342 | mirror::ObjectArray<mirror::Class>* AllocClassArray(Thread* self, size_t length) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 343 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
jeffhao | 98eacac | 2011-09-14 16:11:53 -0700 | [diff] [blame] | 344 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 345 | mirror::ObjectArray<mirror::String>* AllocStringArray(Thread* self, size_t length) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 346 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
| 347 | |
| 348 | ArtField* AllocArtFieldArray(Thread* self, size_t length); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 349 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 350 | ArtMethod* AllocArtMethodArray(Thread* self, size_t length); |
| 351 | |
| 352 | mirror::PointerArray* AllocPointerArray(Thread* self, size_t length) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 353 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 354 | |
| 355 | mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 356 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 357 | |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 358 | mirror::ObjectArray<mirror::StackTraceElement>* AllocStackTraceElementArray( |
| 359 | Thread* self, size_t length) SHARED_REQUIRES(Locks::mutator_lock_) |
| 360 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 361 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 362 | void VerifyClass(Thread* self, Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 363 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 364 | bool VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class* klass, |
| 365 | mirror::Class::Status& oat_file_class_status) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 366 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 367 | void ResolveClassExceptionHandlerTypes(const DexFile& dex_file, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 368 | Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 369 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 370 | void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, ArtMethod* klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 371 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 372 | |
Mathieu Chartier | 2b7c4d1 | 2014-05-19 10:52:16 -0700 | [diff] [blame] | 373 | mirror::Class* CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa, jstring name, |
| 374 | jobjectArray interfaces, jobject loader, jobjectArray methods, |
| 375 | jobjectArray throws) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 376 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 377 | std::string GetDescriptorForProxy(mirror::Class* proxy_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 378 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 379 | ArtMethod* FindMethodForProxy(mirror::Class* proxy_class, ArtMethod* proxy_method) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 380 | REQUIRES(!dex_lock_) |
| 381 | SHARED_REQUIRES(Locks::mutator_lock_); |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 382 | |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 383 | // Get the oat code for a method when its class isn't yet initialized |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 384 | const void* GetQuickOatCodeFor(ArtMethod* method) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 385 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 386 | |
Mathieu Chartier | e35517a | 2012-10-30 18:49:55 -0700 | [diff] [blame] | 387 | // Get the oat code for a method from a method index. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 388 | const void* GetQuickOatCodeFor(const DexFile& dex_file, uint16_t class_def_idx, |
| 389 | uint32_t method_idx) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 390 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e35517a | 2012-10-30 18:49:55 -0700 | [diff] [blame] | 391 | |
Hiroshi Yamauchi | 9bdec88 | 2014-08-15 17:11:12 -0700 | [diff] [blame] | 392 | // Get compiled code for a method, return null if no code |
| 393 | // exists. This is unlike Get..OatCodeFor which will return a bridge |
| 394 | // or interpreter entrypoint. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 395 | const void* GetOatMethodQuickCodeFor(ArtMethod* method) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 396 | SHARED_REQUIRES(Locks::mutator_lock_); |
Hiroshi Yamauchi | 9bdec88 | 2014-08-15 17:11:12 -0700 | [diff] [blame] | 397 | |
Nicolas Geoffray | 9523a3e | 2015-07-17 11:51:28 +0000 | [diff] [blame] | 398 | const OatFile::OatMethod FindOatMethodFor(ArtMethod* method, bool* found) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 399 | SHARED_REQUIRES(Locks::mutator_lock_); |
Nicolas Geoffray | 9523a3e | 2015-07-17 11:51:28 +0000 | [diff] [blame] | 400 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 401 | pid_t GetClassesLockOwner(); // For SignalCatcher. |
| 402 | pid_t GetDexLockOwner(); // For SignalCatcher. |
Brian Carlstrom | 24a3c2e | 2011-10-17 18:07:52 -0700 | [diff] [blame] | 403 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 404 | mirror::Class* GetClassRoot(ClassRoot class_root) SHARED_REQUIRES(Locks::mutator_lock_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 405 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 406 | static const char* GetClassRootDescriptor(ClassRoot class_root); |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 407 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 408 | // Is the given entry point quick code to run the resolution stub? |
| 409 | bool IsQuickResolutionStub(const void* entry_point) const; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 410 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 411 | // Is the given entry point quick code to bridge into the interpreter? |
| 412 | bool IsQuickToInterpreterBridge(const void* entry_point) const; |
| 413 | |
| 414 | // Is the given entry point quick code to run the generic JNI stub? |
| 415 | bool IsQuickGenericJniStub(const void* entry_point) const; |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 416 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 417 | InternTable* GetInternTable() const { |
| 418 | return intern_table_; |
| 419 | } |
| 420 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 421 | // Set the entrypoints up for method to the given code. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 422 | void SetEntryPointsToCompiledCode(ArtMethod* method, const void* method_code) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 423 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 424 | |
| 425 | // Set the entrypoints up for method to the enter the interpreter. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 426 | void SetEntryPointsToInterpreter(ArtMethod* method) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 427 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 428 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 429 | // Attempts to insert a class into a class table. Returns null if |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 430 | // the class was inserted, otherwise returns an existing class with |
| 431 | // the same descriptor and ClassLoader. |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 432 | mirror::Class* InsertClass(const char* descriptor, mirror::Class* klass, size_t hash) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 433 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 434 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 435 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 436 | mirror::ObjectArray<mirror::Class>* GetClassRoots() SHARED_REQUIRES(Locks::mutator_lock_) { |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 437 | mirror::ObjectArray<mirror::Class>* class_roots = class_roots_.Read(); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 438 | DCHECK(class_roots != nullptr); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 439 | return class_roots; |
| 440 | } |
| 441 | |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 442 | // Move all of the image classes into the class table for faster lookups. |
| 443 | void MoveImageClassesToClassTable() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 444 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 445 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 446 | // Move the class table to the pre-zygote table to reduce memory usage. This works by ensuring |
| 447 | // that no more classes are ever added to the pre zygote table which makes it that the pages |
| 448 | // always remain shared dirty instead of private dirty. |
| 449 | void MoveClassTableToPreZygote() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 450 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 451 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 452 | |
Sebastien Hertz | 6963e44 | 2014-11-26 22:11:27 +0100 | [diff] [blame] | 453 | // Returns true if the method can be called with its direct code pointer, false otherwise. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 454 | bool MayBeCalledWithDirectCodePointer(ArtMethod* m) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 455 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Sebastien Hertz | 6963e44 | 2014-11-26 22:11:27 +0100 | [diff] [blame] | 456 | |
Andreas Gampe | 81c6f8d | 2015-03-25 17:19:53 -0700 | [diff] [blame] | 457 | // Creates a GlobalRef PathClassLoader that can be used to load classes from the given dex files. |
| 458 | // Note: the objects are not completely set up. Do not use this outside of tests and the compiler. |
| 459 | jobject CreatePathClassLoader(Thread* self, std::vector<const DexFile*>& dex_files) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 460 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Andreas Gampe | 81c6f8d | 2015-03-25 17:19:53 -0700 | [diff] [blame] | 461 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 462 | size_t GetImagePointerSize() const { |
| 463 | DCHECK(ValidPointerSize(image_pointer_size_)) << image_pointer_size_; |
| 464 | return image_pointer_size_; |
| 465 | } |
| 466 | |
| 467 | // Used by image writer for checking. |
| 468 | bool ClassInClassTable(mirror::Class* klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 469 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 470 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | a89d7ed | 2014-12-05 10:57:13 -0800 | [diff] [blame] | 471 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 472 | ArtMethod* CreateRuntimeMethod(); |
| 473 | |
Andreas Gampe | 8ac7595 | 2015-06-02 21:01:45 -0700 | [diff] [blame] | 474 | // Clear the ArrayClass cache. This is necessary when cleaning up for the image, as the cache |
| 475 | // entries are roots, but potentially not image classes. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 476 | void DropFindArrayClassCache() SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 8ac7595 | 2015-06-02 21:01:45 -0700 | [diff] [blame] | 477 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 478 | private: |
Brian Carlstrom | 56d947f | 2013-07-15 13:14:23 -0700 | [diff] [blame] | 479 | OatFile& GetImageOatFile(gc::space::ImageSpace* space) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 480 | REQUIRES(!dex_lock_) |
| 481 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 482 | |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 483 | void FinishInit(Thread* self) SHARED_REQUIRES(Locks::mutator_lock_) |
| 484 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 485 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 486 | // For early bootstrapping by Init |
Ian Rogers | 6fac447 | 2014-02-25 17:01:10 -0800 | [diff] [blame] | 487 | mirror::Class* AllocClass(Thread* self, mirror::Class* java_lang_Class, uint32_t class_size) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 488 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 489 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 490 | // Alloc* convenience functions to avoid needing to pass in mirror::Class* |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 491 | // values that are known to the ClassLinker such as |
| 492 | // kObjectArrayClass and kJavaLangString etc. |
Ian Rogers | 6fac447 | 2014-02-25 17:01:10 -0800 | [diff] [blame] | 493 | mirror::Class* AllocClass(Thread* self, uint32_t class_size) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 494 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 495 | mirror::DexCache* AllocDexCache(Thread* self, const DexFile& dex_file) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 496 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 497 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 498 | mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 499 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 500 | mirror::Class* InitializePrimitiveClass(mirror::Class* primitive_class, Primitive::Type type) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 501 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Brian Carlstrom | a331b3c | 2011-07-18 17:47:56 -0700 | [diff] [blame] | 502 | |
Mathieu Chartier | e7c9a8c | 2014-11-06 16:35:45 -0800 | [diff] [blame] | 503 | mirror::Class* CreateArrayClass(Thread* self, const char* descriptor, size_t hash, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 504 | Handle<mirror::ClassLoader> class_loader) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 505 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | a331b3c | 2011-07-18 17:47:56 -0700 | [diff] [blame] | 506 | |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 507 | void AppendToBootClassPath(Thread* self, const DexFile& dex_file) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 508 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 509 | void AppendToBootClassPath(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 510 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 511 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 512 | // Precomputes size needed for Class, in the case of a non-temporary class this size must be |
| 513 | // sufficient to hold all static fields. |
| 514 | uint32_t SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file, |
| 515 | const DexFile::ClassDef& dex_class_def); |
Brian Carlstrom | 4873d46 | 2011-08-21 15:23:39 -0700 | [diff] [blame] | 516 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 517 | // Setup the classloader, class def index, type idx so that we can insert this class in the class |
| 518 | // table. |
| 519 | void SetupClass(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, |
| 520 | Handle<mirror::Class> klass, mirror::ClassLoader* class_loader) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 521 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 522 | |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 523 | void LoadClass(Thread* self, const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 524 | Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 525 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 526 | void LoadClassMembers(Thread* self, const DexFile& dex_file, const uint8_t* class_data, |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 527 | Handle<mirror::Class> klass, const OatFile::OatClass* oat_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 528 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 529 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 530 | void LoadField(const ClassDataItemIterator& it, Handle<mirror::Class> klass, |
| 531 | ArtField* dst) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 532 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 533 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 534 | void LoadMethod(Thread* self, const DexFile& dex_file, const ClassDataItemIterator& it, |
| 535 | Handle<mirror::Class> klass, ArtMethod* dst) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 536 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 934486c | 2011-07-12 23:42:50 -0700 | [diff] [blame] | 537 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 538 | void FixupStaticTrampolines(mirror::Class* klass) SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 539 | |
Ian Rogers | 97b52f8 | 2014-08-14 11:34:07 -0700 | [diff] [blame] | 540 | // Finds the associated oat class for a dex_file and descriptor. Returns an invalid OatClass on |
| 541 | // error and sets found to false. |
| 542 | OatFile::OatClass FindOatClass(const DexFile& dex_file, uint16_t class_def_idx, bool* found) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 543 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 544 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 545 | void RegisterDexFileLocked(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 546 | REQUIRES(dex_lock_) |
| 547 | SHARED_REQUIRES(Locks::mutator_lock_); |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 548 | bool IsDexFileRegisteredLocked(const DexFile& dex_file) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 549 | SHARED_REQUIRES(dex_lock_, Locks::mutator_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 550 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 551 | bool InitializeClass(Thread* self, Handle<mirror::Class> klass, bool can_run_clinit, |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 552 | bool can_init_parents) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 553 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 554 | bool WaitForInitializeClass(Handle<mirror::Class> klass, Thread* self, |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 555 | ObjectLock<mirror::Class>& lock); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 556 | bool ValidateSuperClassDescriptors(Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 557 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 558 | |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 559 | bool IsSameDescriptorInDifferentClassContexts(Thread* self, const char* descriptor, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 560 | Handle<mirror::ClassLoader> class_loader1, |
| 561 | Handle<mirror::ClassLoader> class_loader2) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 562 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 563 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 564 | bool IsSameMethodSignatureInDifferentClassContexts(Thread* self, ArtMethod* method, |
| 565 | mirror::Class* klass1, mirror::Class* klass2) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 566 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 567 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 568 | bool LinkClass(Thread* self, const char* descriptor, Handle<mirror::Class> klass, |
| 569 | Handle<mirror::ObjectArray<mirror::Class>> interfaces, |
Hiroshi Yamauchi | 679b1cf | 2015-05-21 12:05:27 -0700 | [diff] [blame] | 570 | MutableHandle<mirror::Class>* h_new_class_out) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 571 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 572 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 573 | bool LinkSuperClass(Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 574 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 575 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 576 | bool LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 577 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 578 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 579 | bool LinkMethods(Thread* self, Handle<mirror::Class> klass, |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 580 | Handle<mirror::ObjectArray<mirror::Class>> interfaces, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 581 | ArtMethod** out_imt) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 582 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 583 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 584 | bool LinkVirtualMethods(Thread* self, Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 585 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 586 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 587 | bool LinkInterfaceMethods(Thread* self, Handle<mirror::Class> klass, |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 588 | Handle<mirror::ObjectArray<mirror::Class>> interfaces, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 589 | ArtMethod** out_imt) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 590 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 591 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 592 | bool LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 593 | SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 594 | bool LinkInstanceFields(Thread* self, Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 595 | SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 596 | bool LinkFields(Thread* self, Handle<mirror::Class> klass, bool is_static, size_t* class_size) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 597 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 598 | void LinkCode(ArtMethod* method, const OatFile::OatClass* oat_class, |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 599 | uint32_t class_def_method_index) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 600 | SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 601 | void CreateReferenceInstanceOffsets(Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 602 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 603 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 604 | void CheckProxyConstructor(ArtMethod* constructor) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 605 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 606 | void CheckProxyMethod(ArtMethod* method, ArtMethod* prototype) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 607 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 608 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 609 | // For use by ImageWriter to find DexCaches for its roots |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 610 | ReaderWriterMutex* DexLock() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 611 | SHARED_REQUIRES(Locks::mutator_lock_) LOCK_RETURNED(dex_lock_) { |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 612 | return &dex_lock_; |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 613 | } |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 614 | size_t GetDexCacheCount() SHARED_REQUIRES(Locks::mutator_lock_, dex_lock_) { |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 615 | return dex_caches_.size(); |
| 616 | } |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 617 | mirror::DexCache* GetDexCache(size_t idx) SHARED_REQUIRES(Locks::mutator_lock_, dex_lock_); |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 618 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 619 | const OatFile* FindOpenedOatFileFromOatLocation(const std::string& oat_location) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 620 | REQUIRES(!dex_lock_); |
Andreas Gampe | 833a485 | 2014-05-21 18:46:59 -0700 | [diff] [blame] | 621 | |
Sebastien Hertz | 0de1133 | 2015-05-13 12:14:05 +0200 | [diff] [blame] | 622 | // Returns the boot image oat file. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 623 | const OatFile* GetBootOatFile() SHARED_REQUIRES(dex_lock_); |
Sebastien Hertz | 0de1133 | 2015-05-13 12:14:05 +0200 | [diff] [blame] | 624 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 625 | void CreateProxyConstructor(Handle<mirror::Class> klass, ArtMethod* out) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 626 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 627 | void CreateProxyMethod(Handle<mirror::Class> klass, ArtMethod* prototype, ArtMethod* out) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 628 | SHARED_REQUIRES(Locks::mutator_lock_); |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 629 | |
Andreas Gampe | 4849859 | 2014-09-10 19:48:05 -0700 | [diff] [blame] | 630 | // Ensures that methods have the kAccPreverified bit set. We use the kAccPreverfied bit on the |
| 631 | // class access flags to determine whether this has been done before. |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 632 | void EnsurePreverifiedMethods(Handle<mirror::Class> c) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 633 | SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 4849859 | 2014-09-10 19:48:05 -0700 | [diff] [blame] | 634 | |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 635 | mirror::Class* LookupClassFromTableLocked(const char* descriptor, |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 636 | mirror::ClassLoader* class_loader, |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 637 | size_t hash) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 638 | SHARED_REQUIRES(Locks::classlinker_classes_lock_, Locks::mutator_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 639 | |
| 640 | mirror::Class* UpdateClass(const char* descriptor, mirror::Class* klass, size_t hash) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 641 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 642 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 643 | |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 644 | mirror::Class* LookupClassFromImage(const char* descriptor) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 645 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 646 | |
| 647 | // EnsureResolved is called to make sure that a class in the class_table_ has been resolved |
| 648 | // before returning it to the caller. Its the responsibility of the thread that placed the class |
| 649 | // in the table to make it resolved. The thread doing resolution must notify on the class' lock |
| 650 | // when resolution has occurred. This happens in mirror::Class::SetStatus. As resolution may |
| 651 | // retire a class, the version of the class in the table is returned and this may differ from |
| 652 | // the class passed in. |
| 653 | mirror::Class* EnsureResolved(Thread* self, const char* descriptor, mirror::Class* klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 654 | WARN_UNUSED SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 655 | |
| 656 | void FixupTemporaryDeclaringClass(mirror::Class* temp_class, mirror::Class* new_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 657 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 658 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 659 | void SetClassRoot(ClassRoot class_root, mirror::Class* klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 660 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 661 | |
| 662 | // Return the quick generic JNI stub for testing. |
| 663 | const void* GetRuntimeQuickGenericJniStub() const; |
| 664 | |
Andreas Gampe | bfdcdc1 | 2015-04-22 18:10:36 -0700 | [diff] [blame] | 665 | // Throw the class initialization failure recorded when first trying to initialize the given |
| 666 | // class. |
| 667 | // Note: Currently we only store the descriptor, so we cannot throw the exact throwable, only |
| 668 | // a recreation with a custom string. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 669 | void ThrowEarlierClassFailure(mirror::Class* c) SHARED_REQUIRES(Locks::mutator_lock_) |
| 670 | REQUIRES(!dex_lock_); |
Andreas Gampe | bfdcdc1 | 2015-04-22 18:10:36 -0700 | [diff] [blame] | 671 | |
Andreas Gampe | b9aec2c | 2015-04-23 22:23:47 -0700 | [diff] [blame] | 672 | // Check for duplicate class definitions of the given oat file against all open oat files. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 673 | bool HasCollisions(const OatFile* oat_file, std::string* error_msg) REQUIRES(!dex_lock_); |
Andreas Gampe | b9aec2c | 2015-04-23 22:23:47 -0700 | [diff] [blame] | 674 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 675 | bool HasInitWithString(Thread* self, const char* descriptor) |
| 676 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 677 | |
| 678 | bool CanWeInitializeClass(mirror::Class* klass, bool can_init_statics, bool can_init_parents) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 679 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 680 | |
| 681 | void UpdateClassVirtualMethods(mirror::Class* klass, ArtMethod* new_methods, |
| 682 | size_t new_num_methods) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 683 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Locks::classlinker_classes_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 684 | |
Brian Carlstrom | 4a96b60 | 2011-07-26 16:40:23 -0700 | [diff] [blame] | 685 | std::vector<const DexFile*> boot_class_path_; |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 686 | std::vector<std::unique_ptr<const DexFile>> opened_dex_files_; |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 687 | |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 688 | mutable ReaderWriterMutex dex_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 689 | std::vector<size_t> new_dex_cache_roots_ GUARDED_BY(dex_lock_); |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 690 | std::vector<GcRoot<mirror::DexCache>> dex_caches_ GUARDED_BY(dex_lock_); |
Elliott Hughes | f834936 | 2012-06-18 15:00:06 -0700 | [diff] [blame] | 691 | std::vector<const OatFile*> oat_files_ GUARDED_BY(dex_lock_); |
Brian Carlstrom | 47d237a | 2011-10-18 15:08:33 -0700 | [diff] [blame] | 692 | |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 693 | class ClassDescriptorHashEquals { |
| 694 | public: |
| 695 | // Same class loader and descriptor. |
| 696 | std::size_t operator()(const GcRoot<mirror::Class>& root) const NO_THREAD_SAFETY_ANALYSIS; |
Mathieu Chartier | 47f867a | 2015-03-18 10:39:00 -0700 | [diff] [blame] | 697 | bool operator()(const GcRoot<mirror::Class>& a, const GcRoot<mirror::Class>& b) const |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 698 | NO_THREAD_SAFETY_ANALYSIS; |
| 699 | // Same class loader and descriptor. |
| 700 | std::size_t operator()(const std::pair<const char*, mirror::ClassLoader*>& element) const |
| 701 | NO_THREAD_SAFETY_ANALYSIS; |
| 702 | bool operator()(const GcRoot<mirror::Class>& a, |
Mathieu Chartier | 47f867a | 2015-03-18 10:39:00 -0700 | [diff] [blame] | 703 | const std::pair<const char*, mirror::ClassLoader*>& b) const |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 704 | NO_THREAD_SAFETY_ANALYSIS; |
| 705 | // Same descriptor. |
Mathieu Chartier | 47f867a | 2015-03-18 10:39:00 -0700 | [diff] [blame] | 706 | bool operator()(const GcRoot<mirror::Class>& a, const char* descriptor) const |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 707 | NO_THREAD_SAFETY_ANALYSIS; |
| 708 | std::size_t operator()(const char* descriptor) const NO_THREAD_SAFETY_ANALYSIS; |
| 709 | }; |
| 710 | class GcRootEmptyFn { |
| 711 | public: |
| 712 | void MakeEmpty(GcRoot<mirror::Class>& item) const { |
| 713 | item = GcRoot<mirror::Class>(); |
| 714 | } |
| 715 | bool IsEmpty(const GcRoot<mirror::Class>& item) const { |
| 716 | return item.IsNull(); |
| 717 | } |
| 718 | }; |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 719 | |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 720 | // hash set which hashes class descriptor, and compares descriptors nad class loaders. Results |
| 721 | // should be compared for a matching Class descriptor and class loader. |
| 722 | typedef HashSet<GcRoot<mirror::Class>, GcRootEmptyFn, ClassDescriptorHashEquals, |
| 723 | ClassDescriptorHashEquals, TrackingAllocator<GcRoot<mirror::Class>, kAllocatorTagClassTable>> |
| 724 | Table; |
Hiroshi Yamauchi | a91a4bc | 2014-06-13 16:44:55 -0700 | [diff] [blame] | 725 | // This contains strong roots. To enable concurrent root scanning of |
| 726 | // the class table, be careful to use a read barrier when accessing this. |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 727 | Table class_table_ GUARDED_BY(Locks::classlinker_classes_lock_); |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 728 | Table pre_zygote_class_table_ GUARDED_BY(Locks::classlinker_classes_lock_); |
| 729 | std::vector<GcRoot<mirror::Class>> new_class_roots_; |
Elliott Hughes | f834936 | 2012-06-18 15:00:06 -0700 | [diff] [blame] | 730 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 731 | // Do we need to search dex caches to find image classes? |
| 732 | bool dex_cache_image_class_lookup_required_; |
| 733 | // Number of times we've searched dex caches for a class. After a certain number of misses we move |
| 734 | // the classes into the class_table_ to avoid dex cache based searches. |
Ian Rogers | 68b5685 | 2014-08-29 20:19:11 -0700 | [diff] [blame] | 735 | Atomic<uint32_t> failed_dex_cache_class_lookups_; |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 736 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 737 | // Well known mirror::Class roots. |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 738 | GcRoot<mirror::ObjectArray<mirror::Class>> class_roots_; |
Brian Carlstrom | 913af1b | 2011-07-23 21:41:13 -0700 | [diff] [blame] | 739 | |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 740 | // The interface table used by all arrays. |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 741 | GcRoot<mirror::IfTable> array_iftable_; |
Carl Shapiro | 565f507 | 2011-07-10 13:39:43 -0700 | [diff] [blame] | 742 | |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 743 | // A cache of the last FindArrayClass results. The cache serves to avoid creating array class |
| 744 | // descriptors for the sake of performing FindClass. |
| 745 | static constexpr size_t kFindArrayCacheSize = 16; |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 746 | GcRoot<mirror::Class> find_array_class_cache_[kFindArrayCacheSize]; |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 747 | size_t find_array_class_cache_next_victim_; |
| 748 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 749 | bool init_done_; |
Mathieu Chartier | 893263b | 2014-03-04 11:07:42 -0800 | [diff] [blame] | 750 | bool log_new_dex_caches_roots_ GUARDED_BY(dex_lock_); |
| 751 | bool log_new_class_table_roots_ GUARDED_BY(Locks::classlinker_classes_lock_); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 752 | |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 753 | InternTable* intern_table_; |
| 754 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 755 | // Trampolines within the image the bounce to runtime entrypoints. Done so that there is a single |
| 756 | // patch point within the image. TODO: make these proper relocations. |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 757 | const void* quick_resolution_trampoline_; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 758 | const void* quick_imt_conflict_trampoline_; |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 759 | const void* quick_generic_jni_trampoline_; |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 760 | const void* quick_to_interpreter_bridge_trampoline_; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 761 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 762 | // Image pointer size. |
| 763 | size_t image_pointer_size_; |
| 764 | |
Brian Carlstrom | 34f426c | 2011-10-04 12:58:02 -0700 | [diff] [blame] | 765 | friend class ImageWriter; // for GetClassRoots |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 766 | friend class ImageDumper; // for FindOpenedOatFileFromOatLocation |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 767 | friend class JniCompilerTest; // for GetRuntimeQuickGenericJniStub |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 768 | ART_FRIEND_TEST(mirror::DexCacheTest, Open); // for AllocDexCache |
| 769 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 770 | DISALLOW_COPY_AND_ASSIGN(ClassLinker); |
| 771 | }; |
| 772 | |
| 773 | } // namespace art |
| 774 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 775 | #endif // ART_RUNTIME_CLASS_LINKER_H_ |