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> |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 21 | #include <unordered_map> |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 22 | #include <utility> |
| 23 | #include <vector> |
| 24 | |
Mathieu Chartier | bad0267 | 2014-08-25 13:08:22 -0700 | [diff] [blame] | 25 | #include "base/allocator.h" |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 26 | #include "base/hash_set.h" |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 27 | #include "base/macros.h" |
Elliott Hughes | 76b6167 | 2012-12-12 17:47:30 -0800 | [diff] [blame] | 28 | #include "base/mutex.h" |
Mathieu Chartier | cc5ebdf | 2015-07-27 11:19:43 -0700 | [diff] [blame] | 29 | #include "class_table.h" |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 30 | #include "dex_file.h" |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 31 | #include "gc_root.h" |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 32 | #include "jni.h" |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 33 | #include "oat_file.h" |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 34 | #include "object_callbacks.h" |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 35 | |
| 36 | namespace art { |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 37 | |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 38 | namespace gc { |
| 39 | namespace space { |
| 40 | class ImageSpace; |
| 41 | } // namespace space |
| 42 | } // namespace gc |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 43 | namespace mirror { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 44 | class ClassLoader; |
| 45 | class DexCache; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 46 | class DexCachePointerArray; |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 47 | class DexCacheTest_Open_Test; |
| 48 | class IfTable; |
| 49 | template<class T> class ObjectArray; |
| 50 | class StackTraceElement; |
| 51 | } // namespace mirror |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 52 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 53 | template<class T> class Handle; |
Hiroshi Yamauchi | 679b1cf | 2015-05-21 12:05:27 -0700 | [diff] [blame] | 54 | template<class T> class MutableHandle; |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 55 | class InternTable; |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 56 | template<class T> class ObjectLock; |
Andreas Gampe | 7ba6496 | 2014-10-23 11:37:40 -0700 | [diff] [blame] | 57 | class Runtime; |
Mathieu Chartier | 2b7c4d1 | 2014-05-19 10:52:16 -0700 | [diff] [blame] | 58 | class ScopedObjectAccessAlreadyRunnable; |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 59 | template<size_t kNumReferences> class PACKED(4) StackHandleScope; |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 60 | |
Mathieu Chartier | 893263b | 2014-03-04 11:07:42 -0800 | [diff] [blame] | 61 | enum VisitRootFlags : uint8_t; |
| 62 | |
Mathieu Chartier | 9b1c71e | 2015-09-02 18:51:54 -0700 | [diff] [blame] | 63 | class ClassLoaderVisitor { |
| 64 | public: |
| 65 | virtual ~ClassLoaderVisitor() {} |
| 66 | virtual void Visit(mirror::ClassLoader* class_loader) |
| 67 | SHARED_REQUIRES(Locks::classlinker_classes_lock_, Locks::mutator_lock_) = 0; |
| 68 | }; |
| 69 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 70 | class ClassLinker { |
| 71 | public: |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 72 | // Well known mirror::Class roots accessed via GetClassRoot. |
| 73 | enum ClassRoot { |
| 74 | kJavaLangClass, |
| 75 | kJavaLangObject, |
| 76 | kClassArrayClass, |
| 77 | kObjectArrayClass, |
| 78 | kJavaLangString, |
| 79 | kJavaLangDexCache, |
| 80 | kJavaLangRefReference, |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 81 | kJavaLangReflectConstructor, |
Mathieu Chartier | daaf326 | 2015-03-24 13:30:28 -0700 | [diff] [blame] | 82 | kJavaLangReflectField, |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 83 | kJavaLangReflectMethod, |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 84 | kJavaLangReflectProxy, |
| 85 | kJavaLangStringArrayClass, |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 86 | kJavaLangReflectConstructorArrayClass, |
Mathieu Chartier | daaf326 | 2015-03-24 13:30:28 -0700 | [diff] [blame] | 87 | kJavaLangReflectFieldArrayClass, |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 88 | kJavaLangReflectMethodArrayClass, |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 89 | kJavaLangClassLoader, |
| 90 | kJavaLangThrowable, |
| 91 | kJavaLangClassNotFoundException, |
| 92 | kJavaLangStackTraceElement, |
| 93 | kPrimitiveBoolean, |
| 94 | kPrimitiveByte, |
| 95 | kPrimitiveChar, |
| 96 | kPrimitiveDouble, |
| 97 | kPrimitiveFloat, |
| 98 | kPrimitiveInt, |
| 99 | kPrimitiveLong, |
| 100 | kPrimitiveShort, |
| 101 | kPrimitiveVoid, |
| 102 | kBooleanArrayClass, |
| 103 | kByteArrayClass, |
| 104 | kCharArrayClass, |
| 105 | kDoubleArrayClass, |
| 106 | kFloatArrayClass, |
| 107 | kIntArrayClass, |
| 108 | kLongArrayClass, |
| 109 | kShortArrayClass, |
| 110 | kJavaLangStackTraceElementArrayClass, |
| 111 | kClassRootsMax, |
| 112 | }; |
| 113 | |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 114 | explicit ClassLinker(InternTable* intern_table); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 115 | ~ClassLinker(); |
Carl Shapiro | 565f507 | 2011-07-10 13:39:43 -0700 | [diff] [blame] | 116 | |
Alex Light | 64ad14d | 2014-08-19 14:23:13 -0700 | [diff] [blame] | 117 | // Initialize class linker by bootstraping from dex files. |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 118 | void InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> boot_class_path) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 119 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 120 | REQUIRES(!dex_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 121 | |
| 122 | // Initialize class linker from one or more images. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 123 | void InitFromImage() SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 124 | |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 125 | // Finds a class by its descriptor, loading it if necessary. |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 126 | // If class_loader is null, searches boot_class_path_. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 127 | mirror::Class* FindClass(Thread* self, |
| 128 | const char* descriptor, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 129 | Handle<mirror::ClassLoader> class_loader) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 130 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 131 | REQUIRES(!dex_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 132 | |
Andreas Gampe | f865ea9 | 2015-04-13 22:14:19 -0700 | [diff] [blame] | 133 | // Finds a class in the path class loader, loading it if necessary without using JNI. Hash |
| 134 | // function is supposed to be ComputeModifiedUtf8Hash(descriptor). Returns true if the |
| 135 | // class-loader chain could be handled, false otherwise, i.e., a non-supported class-loader |
| 136 | // was encountered while walking the parent chain (currently only BootClassLoader and |
| 137 | // PathClassLoader are supported). |
| 138 | bool FindClassInPathClassLoader(ScopedObjectAccessAlreadyRunnable& soa, |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 139 | Thread* self, |
| 140 | const char* descriptor, |
| 141 | size_t hash, |
Andreas Gampe | f865ea9 | 2015-04-13 22:14:19 -0700 | [diff] [blame] | 142 | Handle<mirror::ClassLoader> class_loader, |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 143 | mirror::Class** result) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 144 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 145 | REQUIRES(!dex_lock_); |
Mathieu Chartier | ab0ed82 | 2014-09-11 14:21:41 -0700 | [diff] [blame] | 146 | |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 147 | // Finds a class by its descriptor using the "system" class loader, ie by searching the |
| 148 | // boot_class_path_. |
| 149 | mirror::Class* FindSystemClass(Thread* self, const char* descriptor) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 150 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 151 | REQUIRES(!dex_lock_); |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 152 | |
| 153 | // Finds the array class given for the element class. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 154 | mirror::Class* FindArrayClass(Thread* self, mirror::Class** element_class) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 155 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 156 | REQUIRES(!dex_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 157 | |
Ian Rogers | 6355745 | 2014-06-04 16:57:15 -0700 | [diff] [blame] | 158 | // Returns true if the class linker is initialized. |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 159 | bool IsInitialized() const { |
| 160 | return init_done_; |
| 161 | } |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 162 | |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 163 | // Define a new a class based on a ClassDef from a DexFile |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 164 | mirror::Class* DefineClass(Thread* self, |
| 165 | const char* descriptor, |
| 166 | size_t hash, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 167 | Handle<mirror::ClassLoader> class_loader, |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 168 | const DexFile& dex_file, |
| 169 | const DexFile::ClassDef& dex_class_def) |
| 170 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 171 | REQUIRES(!dex_lock_); |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 172 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 173 | // 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] | 174 | // by the given 'class_loader'. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 175 | mirror::Class* LookupClass(Thread* self, |
| 176 | const char* descriptor, |
| 177 | size_t hash, |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 178 | mirror::ClassLoader* class_loader) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 179 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 180 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 181 | |
Elliott Hughes | 6fa602d | 2011-12-02 17:54:25 -0800 | [diff] [blame] | 182 | // Finds all the classes with the given descriptor, regardless of ClassLoader. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 183 | void LookupClasses(const char* descriptor, std::vector<mirror::Class*>& classes) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 184 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 185 | SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | 6fa602d | 2011-12-02 17:54:25 -0800 | [diff] [blame] | 186 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 187 | mirror::Class* FindPrimitiveClass(char type) SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 188 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 189 | // General class unloading is not supported, this is used to prune |
| 190 | // unwanted classes during image writing. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 191 | bool RemoveClass(const char* descriptor, mirror::ClassLoader* class_loader) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 192 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 193 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 194 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 195 | void DumpAllClasses(int flags) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 196 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 197 | SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 198 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 199 | void DumpForSigQuit(std::ostream& os) REQUIRES(!Locks::classlinker_classes_lock_); |
Elliott Hughes | cac6cc7 | 2011-11-03 20:31:21 -0700 | [diff] [blame] | 200 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 201 | size_t NumLoadedClasses() |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 202 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 203 | SHARED_REQUIRES(Locks::mutator_lock_); |
Elliott Hughes | e27955c | 2011-08-26 15:21:24 -0700 | [diff] [blame] | 204 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 205 | // Resolve a String with the given index from the DexFile, storing the |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 206 | // result in the DexCache. The referrer is used to identify the |
| 207 | // target DexCache and ClassLoader to use for resolution. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 208 | mirror::String* ResolveString(uint32_t string_idx, ArtMethod* referrer) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 209 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 210 | |
| 211 | // Resolve a String with the given index from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 212 | // result in the DexCache. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 213 | mirror::String* ResolveString(const DexFile& dex_file, uint32_t string_idx, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 214 | Handle<mirror::DexCache> dex_cache) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 215 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 216 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 217 | // Resolve a Type with the given index from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 218 | // result in the DexCache. The referrer is used to identity the |
| 219 | // target DexCache and ClassLoader to use for resolution. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 220 | mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx, mirror::Class* referrer) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 221 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 222 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 223 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 224 | // Resolve a Type with the given index from the DexFile, storing the |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 225 | // result in the DexCache. The referrer is used to identify the |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 226 | // target DexCache and ClassLoader to use for resolution. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 227 | mirror::Class* ResolveType(uint16_t type_idx, ArtMethod* referrer) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 228 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 229 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 230 | |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 231 | mirror::Class* ResolveType(uint16_t type_idx, ArtField* referrer) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 232 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 233 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 234 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 235 | // Resolve a type with the given ID from the DexFile, storing the |
| 236 | // result in DexCache. The ClassLoader is used to search for the |
| 237 | // type, since it may be referenced from but not contained within |
| 238 | // the given DexFile. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 239 | mirror::Class* ResolveType(const DexFile& dex_file, |
| 240 | uint16_t type_idx, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 241 | Handle<mirror::DexCache> dex_cache, |
| 242 | Handle<mirror::ClassLoader> class_loader) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 243 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 244 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 245 | |
| 246 | // Resolve a method with a given ID from the DexFile, storing the |
| 247 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 248 | // in ResolveType. What is unique is the method type argument which |
| 249 | // is used to determine if this method is a direct, static, or |
| 250 | // virtual method. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 251 | ArtMethod* ResolveMethod(const DexFile& dex_file, |
| 252 | uint32_t method_idx, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 253 | Handle<mirror::DexCache> dex_cache, |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 254 | Handle<mirror::ClassLoader> class_loader, |
| 255 | ArtMethod* referrer, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 256 | InvokeType type) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 257 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 258 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 259 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 260 | ArtMethod* GetResolvedMethod(uint32_t method_idx, ArtMethod* referrer) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 261 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 262 | ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, ArtMethod* referrer, InvokeType type) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 263 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 264 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Jeff Hao | 0042c6d | 2015-07-29 20:14:10 -0700 | [diff] [blame] | 265 | ArtMethod* ResolveMethodWithoutInvokeType(const DexFile& dex_file, |
| 266 | uint32_t method_idx, |
| 267 | Handle<mirror::DexCache> dex_cache, |
| 268 | Handle<mirror::ClassLoader> class_loader) |
| 269 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 270 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 271 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 272 | ArtField* GetResolvedField(uint32_t field_idx, mirror::Class* field_declaring_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 273 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 274 | ArtField* GetResolvedField(uint32_t field_idx, mirror::DexCache* dex_cache) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 275 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 276 | ArtField* ResolveField(uint32_t field_idx, ArtMethod* referrer, bool is_static) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 277 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 278 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | b9edb84 | 2011-08-28 16:31:06 -0700 | [diff] [blame] | 279 | |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 280 | // Resolve a field with a given ID from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 281 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 282 | // in ResolveType. What is unique is the is_static argument which is |
| 283 | // used to determine if we are resolving a static or non-static |
| 284 | // field. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 285 | ArtField* ResolveField(const DexFile& dex_file, uint32_t field_idx, |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 286 | Handle<mirror::DexCache> dex_cache, |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 287 | Handle<mirror::ClassLoader> class_loader, bool is_static) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 288 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 289 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 290 | |
Ian Rogers | b067ac2 | 2011-12-13 18:05:09 -0800 | [diff] [blame] | 291 | // Resolve a field with a given ID from the DexFile, storing the |
| 292 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 293 | // in ResolveType. No is_static argument is provided so that Java |
| 294 | // field resolution semantics are followed. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 295 | ArtField* ResolveFieldJLS(const DexFile& dex_file, |
| 296 | uint32_t field_idx, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 297 | Handle<mirror::DexCache> dex_cache, |
| 298 | Handle<mirror::ClassLoader> class_loader) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 299 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 300 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Ian Rogers | b067ac2 | 2011-12-13 18:05:09 -0800 | [diff] [blame] | 301 | |
Ian Rogers | ad25ac5 | 2011-10-04 19:13:33 -0700 | [diff] [blame] | 302 | // Get shorty from method index without resolution. Used to do handlerization. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 303 | const char* MethodShorty(uint32_t method_idx, ArtMethod* referrer, uint32_t* length) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 304 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | ad25ac5 | 2011-10-04 19:13:33 -0700 | [diff] [blame] | 305 | |
Elliott Hughes | f4c21c9 | 2011-08-19 17:31:31 -0700 | [diff] [blame] | 306 | // Returns true on success, false if there's an exception pending. |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 307 | // can_run_clinit=false allows the compiler to attempt to init a class, |
| 308 | // given the restriction that no <clinit> execution is possible. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 309 | bool EnsureInitialized(Thread* self, |
| 310 | Handle<mirror::Class> c, |
| 311 | bool can_init_fields, |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 312 | bool can_init_parents) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 313 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 314 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 315 | |
Elliott Hughes | 2a20cfd | 2011-09-23 19:30:41 -0700 | [diff] [blame] | 316 | // Initializes classes that have instances in the image but that have |
| 317 | // <clinit> methods so they could not be initialized by the compiler. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 318 | void RunRootClinits() |
| 319 | SHARED_REQUIRES(Locks::mutator_lock_) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 320 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Elliott Hughes | 2a20cfd | 2011-09-23 19:30:41 -0700 | [diff] [blame] | 321 | |
Mathieu Chartier | d57d454 | 2015-10-14 10:55:30 -0700 | [diff] [blame] | 322 | mirror::DexCache* RegisterDexFile(const DexFile& dex_file, LinearAlloc* linear_alloc) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 323 | REQUIRES(!dex_lock_) |
| 324 | SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 325 | void RegisterDexFile(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 326 | REQUIRES(!dex_lock_) |
| 327 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 328 | |
Brian Carlstrom | 8a48741 | 2011-08-29 20:08:52 -0700 | [diff] [blame] | 329 | const std::vector<const DexFile*>& GetBootClassPath() { |
| 330 | return boot_class_path_; |
| 331 | } |
| 332 | |
Mathieu Chartier | e0671ce | 2015-07-28 17:23:28 -0700 | [diff] [blame] | 333 | void VisitClasses(ClassVisitor* visitor) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 334 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 335 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 336 | |
| 337 | // Less efficient variant of VisitClasses that copies the class_table_ into secondary storage |
| 338 | // so that it can visit individual classes without holding the doesn't hold the |
| 339 | // Locks::classlinker_classes_lock_. As the Locks::classlinker_classes_lock_ isn't held this code |
| 340 | // can race with insertion and deletion of classes while the visitor is being called. |
Mathieu Chartier | e0671ce | 2015-07-28 17:23:28 -0700 | [diff] [blame] | 341 | void VisitClassesWithoutClassesLock(ClassVisitor* visitor) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 342 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 343 | REQUIRES(!dex_lock_); |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 344 | |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 345 | void VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 346 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 347 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 348 | void VisitRoots(RootVisitor* visitor, VisitRootFlags flags) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 349 | REQUIRES(!dex_lock_) |
| 350 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 351 | |
Mathieu Chartier | 673ed3d | 2015-08-28 14:56:43 -0700 | [diff] [blame] | 352 | mirror::DexCache* FindDexCache(Thread* self, |
| 353 | const DexFile& dex_file, |
| 354 | bool allow_failure = false) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 355 | REQUIRES(!dex_lock_) |
| 356 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 357 | void FixupDexCaches(ArtMethod* resolution_method) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 358 | REQUIRES(!dex_lock_) |
| 359 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 360 | |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 361 | // Allocate an instance of a java.lang.Object. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 362 | mirror::Object* AllocObject(Thread* self) |
| 363 | SHARED_REQUIRES(Locks::mutator_lock_) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 364 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | c0542af | 2014-09-03 16:16:56 -0700 | [diff] [blame] | 365 | |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 366 | // 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] | 367 | template <class T> |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 368 | mirror::ObjectArray<T>* AllocObjectArray(Thread* self, size_t length) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 369 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 370 | REQUIRES(!Roles::uninterruptible_); |
Shih-wei Liao | 55df06b | 2011-08-26 14:39:27 -0700 | [diff] [blame] | 371 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 372 | mirror::ObjectArray<mirror::Class>* AllocClassArray(Thread* self, size_t length) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 373 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 374 | REQUIRES(!Roles::uninterruptible_); |
jeffhao | 98eacac | 2011-09-14 16:11:53 -0700 | [diff] [blame] | 375 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 376 | mirror::ObjectArray<mirror::String>* AllocStringArray(Thread* self, size_t length) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 377 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 378 | REQUIRES(!Roles::uninterruptible_); |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 379 | |
Mathieu Chartier | 951ec2c | 2015-09-22 08:50:05 -0700 | [diff] [blame] | 380 | LengthPrefixedArray<ArtField>* AllocArtFieldArray(Thread* self, |
| 381 | LinearAlloc* allocator, |
| 382 | size_t length); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 383 | |
Mathieu Chartier | 951ec2c | 2015-09-22 08:50:05 -0700 | [diff] [blame] | 384 | LengthPrefixedArray<ArtMethod>* AllocArtMethodArray(Thread* self, |
| 385 | LinearAlloc* allocator, |
| 386 | size_t length); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 387 | |
| 388 | mirror::PointerArray* AllocPointerArray(Thread* self, size_t length) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 389 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 390 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 391 | |
| 392 | mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 393 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 394 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 395 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 396 | mirror::ObjectArray<mirror::StackTraceElement>* AllocStackTraceElementArray(Thread* self, |
| 397 | size_t length) |
| 398 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 399 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 400 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 401 | void VerifyClass(Thread* self, Handle<mirror::Class> klass) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 402 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 403 | REQUIRES(!dex_lock_); |
| 404 | bool VerifyClassUsingOatFile(const DexFile& dex_file, |
| 405 | mirror::Class* klass, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 406 | mirror::Class::Status& oat_file_class_status) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 407 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 408 | REQUIRES(!dex_lock_); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 409 | void ResolveClassExceptionHandlerTypes(const DexFile& dex_file, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 410 | Handle<mirror::Class> klass) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 411 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 412 | REQUIRES(!dex_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 413 | void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, ArtMethod* klass) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 414 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 415 | REQUIRES(!dex_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 416 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 417 | mirror::Class* CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa, |
| 418 | jstring name, |
| 419 | jobjectArray interfaces, |
| 420 | jobject loader, |
| 421 | jobjectArray methods, |
Mathieu Chartier | 2b7c4d1 | 2014-05-19 10:52:16 -0700 | [diff] [blame] | 422 | jobjectArray throws) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 423 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 424 | std::string GetDescriptorForProxy(mirror::Class* proxy_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 425 | SHARED_REQUIRES(Locks::mutator_lock_); |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 426 | ArtMethod* FindMethodForProxy(mirror::Class* proxy_class, ArtMethod* proxy_method) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 427 | REQUIRES(!dex_lock_) |
| 428 | SHARED_REQUIRES(Locks::mutator_lock_); |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 429 | |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 430 | // 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] | 431 | const void* GetQuickOatCodeFor(ArtMethod* method) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 432 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 433 | |
Mathieu Chartier | e35517a | 2012-10-30 18:49:55 -0700 | [diff] [blame] | 434 | // Get the oat code for a method from a method index. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 435 | const void* GetQuickOatCodeFor(const DexFile& dex_file, |
| 436 | uint16_t class_def_idx, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 437 | uint32_t method_idx) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 438 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e35517a | 2012-10-30 18:49:55 -0700 | [diff] [blame] | 439 | |
Hiroshi Yamauchi | 9bdec88 | 2014-08-15 17:11:12 -0700 | [diff] [blame] | 440 | // Get compiled code for a method, return null if no code |
| 441 | // exists. This is unlike Get..OatCodeFor which will return a bridge |
| 442 | // or interpreter entrypoint. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 443 | const void* GetOatMethodQuickCodeFor(ArtMethod* method) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 444 | SHARED_REQUIRES(Locks::mutator_lock_); |
Hiroshi Yamauchi | 9bdec88 | 2014-08-15 17:11:12 -0700 | [diff] [blame] | 445 | |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 446 | const OatFile::OatMethod FindOatMethodFor(ArtMethod* method, bool* found) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 447 | SHARED_REQUIRES(Locks::mutator_lock_); |
Nicolas Geoffray | 9523a3e | 2015-07-17 11:51:28 +0000 | [diff] [blame] | 448 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 449 | pid_t GetClassesLockOwner(); // For SignalCatcher. |
| 450 | pid_t GetDexLockOwner(); // For SignalCatcher. |
Brian Carlstrom | 24a3c2e | 2011-10-17 18:07:52 -0700 | [diff] [blame] | 451 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 452 | mirror::Class* GetClassRoot(ClassRoot class_root) SHARED_REQUIRES(Locks::mutator_lock_); |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 453 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 454 | static const char* GetClassRootDescriptor(ClassRoot class_root); |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 455 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 456 | // Is the given entry point quick code to run the resolution stub? |
| 457 | bool IsQuickResolutionStub(const void* entry_point) const; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 458 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 459 | // Is the given entry point quick code to bridge into the interpreter? |
| 460 | bool IsQuickToInterpreterBridge(const void* entry_point) const; |
| 461 | |
| 462 | // Is the given entry point quick code to run the generic JNI stub? |
| 463 | bool IsQuickGenericJniStub(const void* entry_point) const; |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 464 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 465 | InternTable* GetInternTable() const { |
| 466 | return intern_table_; |
| 467 | } |
| 468 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 469 | // Set the entrypoints up for method to the given code. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 470 | void SetEntryPointsToCompiledCode(ArtMethod* method, const void* method_code) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 471 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 472 | |
| 473 | // Set the entrypoints up for method to the enter the interpreter. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 474 | void SetEntryPointsToInterpreter(ArtMethod* method) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 475 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 476 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 477 | // Attempts to insert a class into a class table. Returns null if |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 478 | // the class was inserted, otherwise returns an existing class with |
| 479 | // the same descriptor and ClassLoader. |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 480 | mirror::Class* InsertClass(const char* descriptor, mirror::Class* klass, size_t hash) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 481 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 482 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 483 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 484 | mirror::ObjectArray<mirror::Class>* GetClassRoots() SHARED_REQUIRES(Locks::mutator_lock_) { |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 485 | mirror::ObjectArray<mirror::Class>* class_roots = class_roots_.Read(); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 486 | DCHECK(class_roots != nullptr); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 487 | return class_roots; |
| 488 | } |
| 489 | |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 490 | // Move all of the image classes into the class table for faster lookups. |
| 491 | void MoveImageClassesToClassTable() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 492 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 493 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 494 | // Move the class table to the pre-zygote table to reduce memory usage. This works by ensuring |
| 495 | // that no more classes are ever added to the pre zygote table which makes it that the pages |
| 496 | // always remain shared dirty instead of private dirty. |
| 497 | void MoveClassTableToPreZygote() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 498 | REQUIRES(!Locks::classlinker_classes_lock_) |
| 499 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c2e2062 | 2014-11-03 11:41:47 -0800 | [diff] [blame] | 500 | |
Sebastien Hertz | 6963e44 | 2014-11-26 22:11:27 +0100 | [diff] [blame] | 501 | // 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] | 502 | bool MayBeCalledWithDirectCodePointer(ArtMethod* m) |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 503 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Sebastien Hertz | 6963e44 | 2014-11-26 22:11:27 +0100 | [diff] [blame] | 504 | |
Andreas Gampe | 81c6f8d | 2015-03-25 17:19:53 -0700 | [diff] [blame] | 505 | // Creates a GlobalRef PathClassLoader that can be used to load classes from the given dex files. |
| 506 | // Note: the objects are not completely set up. Do not use this outside of tests and the compiler. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 507 | jobject CreatePathClassLoader(Thread* self, std::vector<const DexFile*>& dex_files) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 508 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 509 | REQUIRES(!dex_lock_); |
Andreas Gampe | 81c6f8d | 2015-03-25 17:19:53 -0700 | [diff] [blame] | 510 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 511 | size_t GetImagePointerSize() const { |
| 512 | DCHECK(ValidPointerSize(image_pointer_size_)) << image_pointer_size_; |
| 513 | return image_pointer_size_; |
| 514 | } |
| 515 | |
| 516 | // Used by image writer for checking. |
| 517 | bool ClassInClassTable(mirror::Class* klass) |
Mathieu Chartier | 673ed3d | 2015-08-28 14:56:43 -0700 | [diff] [blame] | 518 | REQUIRES(Locks::classlinker_classes_lock_) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 519 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | a89d7ed | 2014-12-05 10:57:13 -0800 | [diff] [blame] | 520 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 521 | ArtMethod* CreateRuntimeMethod(); |
| 522 | |
Andreas Gampe | 8ac7595 | 2015-06-02 21:01:45 -0700 | [diff] [blame] | 523 | // Clear the ArrayClass cache. This is necessary when cleaning up for the image, as the cache |
| 524 | // entries are roots, but potentially not image classes. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 525 | void DropFindArrayClassCache() SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 8ac7595 | 2015-06-02 21:01:45 -0700 | [diff] [blame] | 526 | |
Mathieu Chartier | 951ec2c | 2015-09-22 08:50:05 -0700 | [diff] [blame] | 527 | // Clean up class loaders, this needs to happen after JNI weak globals are cleared. |
| 528 | void CleanupClassLoaders() |
| 529 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 530 | REQUIRES(!Locks::classlinker_classes_lock_); |
| 531 | |
Mathieu Chartier | 32cc9ee | 2015-10-15 09:19:15 -0700 | [diff] [blame^] | 532 | // Unlike GetOrCreateAllocatorForClassLoader, GetAllocatorForClassLoader asserts that the |
| 533 | // allocator for this class loader is already created. |
Mathieu Chartier | 951ec2c | 2015-09-22 08:50:05 -0700 | [diff] [blame] | 534 | static LinearAlloc* GetAllocatorForClassLoader(mirror::ClassLoader* class_loader) |
Nicolas Geoffray | 7de5dfe | 2015-09-22 09:48:02 +0000 | [diff] [blame] | 535 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | 951ec2c | 2015-09-22 08:50:05 -0700 | [diff] [blame] | 536 | |
Mathieu Chartier | d57d454 | 2015-10-14 10:55:30 -0700 | [diff] [blame] | 537 | // Return the linear alloc for a class loader if it is already allocated, otherwise allocate and |
| 538 | // set it. TODO: Consider using a lock other than classlinker_classes_lock_. |
| 539 | static LinearAlloc* GetOrCreateAllocatorForClassLoader(mirror::ClassLoader* class_loader) |
| 540 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 541 | REQUIRES(!Locks::classlinker_classes_lock_); |
| 542 | |
Mathieu Chartier | 951ec2c | 2015-09-22 08:50:05 -0700 | [diff] [blame] | 543 | private: |
| 544 | struct ClassLoaderData { |
Mathieu Chartier | c3fcd41 | 2015-09-25 16:54:59 -0700 | [diff] [blame] | 545 | jweak weak_root; // Weak root to enable class unloading. |
Mathieu Chartier | 951ec2c | 2015-09-22 08:50:05 -0700 | [diff] [blame] | 546 | ClassTable* class_table; |
| 547 | LinearAlloc* allocator; |
| 548 | }; |
| 549 | |
Mathieu Chartier | 9b1c71e | 2015-09-02 18:51:54 -0700 | [diff] [blame] | 550 | void VisitClassLoaders(ClassLoaderVisitor* visitor) const |
| 551 | SHARED_REQUIRES(Locks::classlinker_classes_lock_, Locks::mutator_lock_); |
| 552 | |
Mathieu Chartier | e0671ce | 2015-07-28 17:23:28 -0700 | [diff] [blame] | 553 | void VisitClassesInternal(ClassVisitor* visitor) |
Mathieu Chartier | 9b1c71e | 2015-09-02 18:51:54 -0700 | [diff] [blame] | 554 | SHARED_REQUIRES(Locks::classlinker_classes_lock_, Locks::mutator_lock_); |
Mathieu Chartier | cc5ebdf | 2015-07-27 11:19:43 -0700 | [diff] [blame] | 555 | |
| 556 | // Returns the number of zygote and image classes. |
Mathieu Chartier | 6b06953 | 2015-08-05 15:08:12 -0700 | [diff] [blame] | 557 | size_t NumZygoteClasses() const |
| 558 | REQUIRES(Locks::classlinker_classes_lock_) |
| 559 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | cc5ebdf | 2015-07-27 11:19:43 -0700 | [diff] [blame] | 560 | |
| 561 | // Returns the number of non zygote nor image classes. |
Mathieu Chartier | 6b06953 | 2015-08-05 15:08:12 -0700 | [diff] [blame] | 562 | size_t NumNonZygoteClasses() const |
| 563 | REQUIRES(Locks::classlinker_classes_lock_) |
| 564 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | cc5ebdf | 2015-07-27 11:19:43 -0700 | [diff] [blame] | 565 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 566 | void FinishInit(Thread* self) |
| 567 | SHARED_REQUIRES(Locks::mutator_lock_) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 568 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 569 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 570 | // For early bootstrapping by Init |
Ian Rogers | 6fac447 | 2014-02-25 17:01:10 -0800 | [diff] [blame] | 571 | mirror::Class* AllocClass(Thread* self, mirror::Class* java_lang_Class, uint32_t class_size) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 572 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 573 | REQUIRES(!Roles::uninterruptible_); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 574 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 575 | // Alloc* convenience functions to avoid needing to pass in mirror::Class* |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 576 | // values that are known to the ClassLinker such as |
| 577 | // kObjectArrayClass and kJavaLangString etc. |
Ian Rogers | 6fac447 | 2014-02-25 17:01:10 -0800 | [diff] [blame] | 578 | mirror::Class* AllocClass(Thread* self, uint32_t class_size) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 579 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 580 | REQUIRES(!Roles::uninterruptible_); |
Mathieu Chartier | d57d454 | 2015-10-14 10:55:30 -0700 | [diff] [blame] | 581 | mirror::DexCache* AllocDexCache(Thread* self, |
| 582 | const DexFile& dex_file, |
| 583 | LinearAlloc* linear_alloc) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 584 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 585 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 586 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 587 | mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 588 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 589 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 590 | mirror::Class* InitializePrimitiveClass(mirror::Class* primitive_class, Primitive::Type type) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 591 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 592 | REQUIRES(!Roles::uninterruptible_); |
Brian Carlstrom | a331b3c | 2011-07-18 17:47:56 -0700 | [diff] [blame] | 593 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 594 | mirror::Class* CreateArrayClass(Thread* self, |
| 595 | const char* descriptor, |
| 596 | size_t hash, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 597 | Handle<mirror::ClassLoader> class_loader) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 598 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 599 | REQUIRES(!dex_lock_, !Roles::uninterruptible_); |
Brian Carlstrom | a331b3c | 2011-07-18 17:47:56 -0700 | [diff] [blame] | 600 | |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 601 | void AppendToBootClassPath(Thread* self, const DexFile& dex_file) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 602 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 603 | REQUIRES(!dex_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 604 | void AppendToBootClassPath(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 605 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 606 | REQUIRES(!dex_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 607 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 608 | // Precomputes size needed for Class, in the case of a non-temporary class this size must be |
| 609 | // sufficient to hold all static fields. |
| 610 | uint32_t SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file, |
| 611 | const DexFile::ClassDef& dex_class_def); |
Brian Carlstrom | 4873d46 | 2011-08-21 15:23:39 -0700 | [diff] [blame] | 612 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 613 | // Setup the classloader, class def index, type idx so that we can insert this class in the class |
| 614 | // table. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 615 | void SetupClass(const DexFile& dex_file, |
| 616 | const DexFile::ClassDef& dex_class_def, |
| 617 | Handle<mirror::Class> klass, |
| 618 | mirror::ClassLoader* class_loader) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 619 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 620 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 621 | void LoadClass(Thread* self, |
| 622 | const DexFile& dex_file, |
| 623 | const DexFile::ClassDef& dex_class_def, |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 624 | Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 625 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 626 | void LoadClassMembers(Thread* self, |
| 627 | const DexFile& dex_file, |
| 628 | const uint8_t* class_data, |
| 629 | Handle<mirror::Class> klass, |
| 630 | const OatFile::OatClass* oat_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 631 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 632 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 633 | void LoadField(const ClassDataItemIterator& it, Handle<mirror::Class> klass, ArtField* dst) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 634 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 635 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 636 | void LoadMethod(Thread* self, |
| 637 | const DexFile& dex_file, |
| 638 | const ClassDataItemIterator& it, |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 639 | Handle<mirror::Class> klass, ArtMethod* dst) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 640 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 934486c | 2011-07-12 23:42:50 -0700 | [diff] [blame] | 641 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 642 | void FixupStaticTrampolines(mirror::Class* klass) SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 643 | |
Ian Rogers | 97b52f8 | 2014-08-14 11:34:07 -0700 | [diff] [blame] | 644 | // Finds the associated oat class for a dex_file and descriptor. Returns an invalid OatClass on |
| 645 | // error and sets found to false. |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 646 | 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] | 647 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 648 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 649 | void RegisterDexFileLocked(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 650 | REQUIRES(dex_lock_) |
| 651 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 652 | mirror::DexCache* FindDexCacheLocked(Thread* self, const DexFile& dex_file, bool allow_failure) |
Mathieu Chartier | 673ed3d | 2015-08-28 14:56:43 -0700 | [diff] [blame] | 653 | REQUIRES(dex_lock_) |
| 654 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 655 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 656 | bool InitializeClass(Thread* self, |
| 657 | Handle<mirror::Class> klass, |
| 658 | bool can_run_clinit, |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 659 | bool can_init_parents) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 660 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 661 | REQUIRES(!dex_lock_); |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 662 | bool InitializeDefaultInterfaceRecursive(Thread* self, |
| 663 | Handle<mirror::Class> klass, |
| 664 | bool can_run_clinit, |
| 665 | bool can_init_parents) |
| 666 | REQUIRES(!dex_lock_) |
| 667 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 668 | bool WaitForInitializeClass(Handle<mirror::Class> klass, |
| 669 | Thread* self, |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 670 | ObjectLock<mirror::Class>& lock); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 671 | bool ValidateSuperClassDescriptors(Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 672 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 673 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 674 | bool IsSameDescriptorInDifferentClassContexts(Thread* self, |
| 675 | const char* descriptor, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 676 | Handle<mirror::ClassLoader> class_loader1, |
| 677 | Handle<mirror::ClassLoader> class_loader2) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 678 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 679 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 680 | bool IsSameMethodSignatureInDifferentClassContexts(Thread* self, |
| 681 | ArtMethod* method, |
| 682 | mirror::Class* klass1, |
| 683 | mirror::Class* klass2) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 684 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 685 | |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 686 | bool LinkClass(Thread* self, |
| 687 | const char* descriptor, |
| 688 | Handle<mirror::Class> klass, |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 689 | Handle<mirror::ObjectArray<mirror::Class>> interfaces, |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 690 | MutableHandle<mirror::Class>* h_new_class_out) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 691 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 692 | REQUIRES(!Locks::classlinker_classes_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 693 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 694 | bool LinkSuperClass(Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 695 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 696 | |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 697 | bool LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 698 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 699 | REQUIRES(!dex_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 700 | |
Mathieu Chartier | cc5ebdf | 2015-07-27 11:19:43 -0700 | [diff] [blame] | 701 | bool LinkMethods(Thread* self, |
| 702 | Handle<mirror::Class> klass, |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 703 | Handle<mirror::ObjectArray<mirror::Class>> interfaces, |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 704 | ArtMethod** out_imt) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 705 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 706 | |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 707 | // Links the virtual methods for the given class and records any default methods that will need to |
| 708 | // be updated later. |
| 709 | // |
| 710 | // Arguments: |
| 711 | // * self - The current thread. |
| 712 | // * klass - class, whose vtable will be filled in. |
| 713 | // * default_translations - Vtable index to new method map. |
| 714 | // Any vtable entries that need to be updated with new default methods |
| 715 | // are stored into the default_translations map. The default_translations |
| 716 | // map is keyed on the vtable index that needs to be updated. We use this |
| 717 | // map because if we override a default method with another default |
| 718 | // method we need to update the vtable to point to the new method. |
| 719 | // Unfortunately since we copy the ArtMethod* we cannot just do a simple |
| 720 | // scan, we therefore store the vtable index's that might need to be |
| 721 | // updated with the method they will turn into. |
| 722 | // TODO This whole default_translations thing is very dirty. There should be a better way. |
| 723 | bool LinkVirtualMethods(Thread* self, |
| 724 | Handle<mirror::Class> klass, |
| 725 | /*out*/std::unordered_map<size_t, ArtMethod*>* default_translations) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 726 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 727 | |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 728 | // Sets up the interface lookup table (IFTable) in the correct order to allow searching for |
| 729 | // default methods. |
| 730 | bool SetupInterfaceLookupTable(Thread* self, |
| 731 | Handle<mirror::Class> klass, |
| 732 | Handle<mirror::ObjectArray<mirror::Class>> interfaces) |
| 733 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 734 | |
| 735 | // Find the default method implementation for 'interface_method' in 'klass', if one exists. |
| 736 | // |
| 737 | // Arguments: |
| 738 | // * self - The current thread. |
| 739 | // * target_method - The method we are trying to find a default implementation for. |
| 740 | // * klass - The class we are searching for a definition of target_method. |
| 741 | // * out_default_method - The pointer we will store the found default method to on success. |
| 742 | // * icce_message - A string we will store an appropriate IncompatibleClassChangeError message |
| 743 | // into in case of failure. Note we must do it this way since we do not know |
| 744 | // whether we can allocate the exception object, which could cause us to go to |
| 745 | // sleep. |
| 746 | // |
| 747 | // Return value: |
| 748 | // * True - There were no conflicting method implementations found in the class while searching |
| 749 | // for target_method. The default method implementation is stored into out_default_method |
| 750 | // if it was found. Otherwise *out_default_method will be set to nullptr. |
| 751 | // * False - Conflicting method implementations were found when searching for target_method. The |
| 752 | // value of *out_default_method is undefined and *icce_message is a string that should |
| 753 | // be used to create an IncompatibleClassChangeError as soon as possible. |
| 754 | bool FindDefaultMethodImplementation(Thread* self, |
| 755 | ArtMethod* target_method, |
| 756 | Handle<mirror::Class> klass, |
| 757 | /*out*/ArtMethod** out_default_method, |
| 758 | /*out*/std::string* icce_message) const |
| 759 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 760 | |
| 761 | // Sets the imt entries and fixes up the vtable for the given class by linking all the interface |
| 762 | // methods. See LinkVirtualMethods for an explanation of what default_translations is. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 763 | bool LinkInterfaceMethods(Thread* self, |
| 764 | Handle<mirror::Class> klass, |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 765 | const std::unordered_map<size_t, ArtMethod*>& default_translations, |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 766 | ArtMethod** out_imt) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 767 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 768 | |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 769 | bool LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 770 | SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 771 | bool LinkInstanceFields(Thread* self, Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 772 | SHARED_REQUIRES(Locks::mutator_lock_); |
Igor Murashkin | b1d8c31 | 2015-08-04 11:18:43 -0700 | [diff] [blame] | 773 | 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] | 774 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 775 | void LinkCode(ArtMethod* method, |
| 776 | const OatFile::OatClass* oat_class, |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 777 | uint32_t class_def_method_index) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 778 | SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 779 | void CreateReferenceInstanceOffsets(Handle<mirror::Class> klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 780 | SHARED_REQUIRES(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 781 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 782 | void CheckProxyConstructor(ArtMethod* constructor) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 783 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 784 | void CheckProxyMethod(ArtMethod* method, ArtMethod* prototype) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 785 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 786 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 787 | // For use by ImageWriter to find DexCaches for its roots |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 788 | ReaderWriterMutex* DexLock() |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 789 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 790 | LOCK_RETURNED(dex_lock_) { |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 791 | return &dex_lock_; |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 792 | } |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 793 | size_t GetDexCacheCount() SHARED_REQUIRES(Locks::mutator_lock_, dex_lock_) { |
Hiroshi Yamauchi | e9e3e69 | 2014-06-24 14:31:37 -0700 | [diff] [blame] | 794 | return dex_caches_.size(); |
| 795 | } |
Mathieu Chartier | 9b1c71e | 2015-09-02 18:51:54 -0700 | [diff] [blame] | 796 | const std::list<jweak>& GetDexCaches() SHARED_REQUIRES(Locks::mutator_lock_, dex_lock_) { |
Mathieu Chartier | 673ed3d | 2015-08-28 14:56:43 -0700 | [diff] [blame] | 797 | return dex_caches_; |
| 798 | } |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 799 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 800 | void CreateProxyConstructor(Handle<mirror::Class> klass, ArtMethod* out) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 801 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 802 | void CreateProxyMethod(Handle<mirror::Class> klass, ArtMethod* prototype, ArtMethod* out) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 803 | SHARED_REQUIRES(Locks::mutator_lock_); |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 804 | |
Andreas Gampe | 4849859 | 2014-09-10 19:48:05 -0700 | [diff] [blame] | 805 | // Ensures that methods have the kAccPreverified bit set. We use the kAccPreverfied bit on the |
| 806 | // class access flags to determine whether this has been done before. |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 807 | void EnsurePreverifiedMethods(Handle<mirror::Class> c) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 808 | SHARED_REQUIRES(Locks::mutator_lock_); |
Andreas Gampe | 4849859 | 2014-09-10 19:48:05 -0700 | [diff] [blame] | 809 | |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 810 | mirror::Class* LookupClassFromImage(const char* descriptor) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 811 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 812 | |
Mathieu Chartier | cc5ebdf | 2015-07-27 11:19:43 -0700 | [diff] [blame] | 813 | // Returns null if not found. |
| 814 | ClassTable* ClassTableForClassLoader(mirror::ClassLoader* class_loader) |
| 815 | SHARED_REQUIRES(Locks::mutator_lock_, Locks::classlinker_classes_lock_); |
| 816 | // Insert a new class table if not found. |
| 817 | ClassTable* InsertClassTableForClassLoader(mirror::ClassLoader* class_loader) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 818 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 819 | REQUIRES(Locks::classlinker_classes_lock_); |
Mathieu Chartier | cc5ebdf | 2015-07-27 11:19:43 -0700 | [diff] [blame] | 820 | |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 821 | // EnsureResolved is called to make sure that a class in the class_table_ has been resolved |
| 822 | // before returning it to the caller. Its the responsibility of the thread that placed the class |
| 823 | // in the table to make it resolved. The thread doing resolution must notify on the class' lock |
| 824 | // when resolution has occurred. This happens in mirror::Class::SetStatus. As resolution may |
| 825 | // retire a class, the version of the class in the table is returned and this may differ from |
| 826 | // the class passed in. |
| 827 | mirror::Class* EnsureResolved(Thread* self, const char* descriptor, mirror::Class* klass) |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 828 | WARN_UNUSED |
| 829 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 830 | REQUIRES(!dex_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 831 | |
| 832 | void FixupTemporaryDeclaringClass(mirror::Class* temp_class, mirror::Class* new_class) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 833 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | dbf3be0 | 2014-08-29 15:40:08 -0700 | [diff] [blame] | 834 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 835 | void SetClassRoot(ClassRoot class_root, mirror::Class* klass) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 836 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 837 | |
| 838 | // Return the quick generic JNI stub for testing. |
| 839 | const void* GetRuntimeQuickGenericJniStub() const; |
| 840 | |
Andreas Gampe | bfdcdc1 | 2015-04-22 18:10:36 -0700 | [diff] [blame] | 841 | // Throw the class initialization failure recorded when first trying to initialize the given |
| 842 | // class. |
| 843 | // Note: Currently we only store the descriptor, so we cannot throw the exact throwable, only |
| 844 | // a recreation with a custom string. |
Mathieu Chartier | c77f3ab | 2015-09-03 19:41:50 -0700 | [diff] [blame] | 845 | void ThrowEarlierClassFailure(mirror::Class* c) |
| 846 | SHARED_REQUIRES(Locks::mutator_lock_) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 847 | REQUIRES(!dex_lock_); |
Andreas Gampe | bfdcdc1 | 2015-04-22 18:10:36 -0700 | [diff] [blame] | 848 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 849 | bool HasInitWithString(Thread* self, const char* descriptor) |
| 850 | SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 851 | |
| 852 | 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] | 853 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 854 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 855 | void UpdateClassVirtualMethods(mirror::Class* klass, |
| 856 | LengthPrefixedArray<ArtMethod>* new_methods) |
| 857 | SHARED_REQUIRES(Locks::mutator_lock_) |
| 858 | REQUIRES(!Locks::classlinker_classes_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 859 | |
Brian Carlstrom | 4a96b60 | 2011-07-26 16:40:23 -0700 | [diff] [blame] | 860 | std::vector<const DexFile*> boot_class_path_; |
Richard Uhler | fbef44d | 2014-12-23 09:48:51 -0800 | [diff] [blame] | 861 | std::vector<std::unique_ptr<const DexFile>> opened_dex_files_; |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 862 | |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 863 | mutable ReaderWriterMutex dex_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
Mathieu Chartier | 673ed3d | 2015-08-28 14:56:43 -0700 | [diff] [blame] | 864 | // JNI weak globals to allow dex caches to get unloaded. We lazily delete weak globals when we |
| 865 | // register new dex files. |
Mathieu Chartier | 9b1c71e | 2015-09-02 18:51:54 -0700 | [diff] [blame] | 866 | std::list<jweak> dex_caches_ GUARDED_BY(dex_lock_); |
Brian Carlstrom | 47d237a | 2011-10-18 15:08:33 -0700 | [diff] [blame] | 867 | |
Mathieu Chartier | 9b1c71e | 2015-09-02 18:51:54 -0700 | [diff] [blame] | 868 | // This contains the class loaders which have class tables. It is populated by |
Mathieu Chartier | 951ec2c | 2015-09-22 08:50:05 -0700 | [diff] [blame] | 869 | // InsertClassTableForClassLoader. |
| 870 | std::list<ClassLoaderData> class_loaders_ |
Mathieu Chartier | 6b06953 | 2015-08-05 15:08:12 -0700 | [diff] [blame] | 871 | GUARDED_BY(Locks::classlinker_classes_lock_); |
| 872 | |
| 873 | // Boot class path table. Since the class loader for this is null. |
| 874 | ClassTable boot_class_table_ GUARDED_BY(Locks::classlinker_classes_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 875 | |
Mathieu Chartier | cc5ebdf | 2015-07-27 11:19:43 -0700 | [diff] [blame] | 876 | // New class roots, only used by CMS since the GC needs to mark these in the pause. |
| 877 | std::vector<GcRoot<mirror::Class>> new_class_roots_ GUARDED_BY(Locks::classlinker_classes_lock_); |
Elliott Hughes | f834936 | 2012-06-18 15:00:06 -0700 | [diff] [blame] | 878 | |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 879 | // Do we need to search dex caches to find image classes? |
| 880 | bool dex_cache_image_class_lookup_required_; |
| 881 | // Number of times we've searched dex caches for a class. After a certain number of misses we move |
| 882 | // the classes into the class_table_ to avoid dex cache based searches. |
Ian Rogers | 68b5685 | 2014-08-29 20:19:11 -0700 | [diff] [blame] | 883 | Atomic<uint32_t> failed_dex_cache_class_lookups_; |
Ian Rogers | 7dfb28c | 2013-08-22 08:18:36 -0700 | [diff] [blame] | 884 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 885 | // Well known mirror::Class roots. |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 886 | GcRoot<mirror::ObjectArray<mirror::Class>> class_roots_; |
Brian Carlstrom | 913af1b | 2011-07-23 21:41:13 -0700 | [diff] [blame] | 887 | |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 888 | // The interface table used by all arrays. |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 889 | GcRoot<mirror::IfTable> array_iftable_; |
Carl Shapiro | 565f507 | 2011-07-10 13:39:43 -0700 | [diff] [blame] | 890 | |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 891 | // A cache of the last FindArrayClass results. The cache serves to avoid creating array class |
| 892 | // descriptors for the sake of performing FindClass. |
| 893 | static constexpr size_t kFindArrayCacheSize = 16; |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 894 | GcRoot<mirror::Class> find_array_class_cache_[kFindArrayCacheSize]; |
Ian Rogers | 9837939 | 2014-02-24 16:53:16 -0800 | [diff] [blame] | 895 | size_t find_array_class_cache_next_victim_; |
| 896 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 897 | bool init_done_; |
Mathieu Chartier | 893263b | 2014-03-04 11:07:42 -0800 | [diff] [blame] | 898 | bool log_new_class_table_roots_ GUARDED_BY(Locks::classlinker_classes_lock_); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 899 | |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 900 | InternTable* intern_table_; |
| 901 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 902 | // Trampolines within the image the bounce to runtime entrypoints. Done so that there is a single |
| 903 | // patch point within the image. TODO: make these proper relocations. |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 904 | const void* quick_resolution_trampoline_; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 905 | const void* quick_imt_conflict_trampoline_; |
Andreas Gampe | 2da8823 | 2014-02-27 12:26:20 -0800 | [diff] [blame] | 906 | const void* quick_generic_jni_trampoline_; |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 907 | const void* quick_to_interpreter_bridge_trampoline_; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 908 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 909 | // Image pointer size. |
| 910 | size_t image_pointer_size_; |
| 911 | |
Mathieu Chartier | f9c6fc6 | 2015-10-07 11:44:05 -0700 | [diff] [blame] | 912 | friend class ImageDumper; // for DexLock |
Brian Carlstrom | 34f426c | 2011-10-04 12:58:02 -0700 | [diff] [blame] | 913 | friend class ImageWriter; // for GetClassRoots |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 914 | friend class JniCompilerTest; // for GetRuntimeQuickGenericJniStub |
Andreas Gampe | 5f4a09a | 2015-09-28 13:16:33 -0700 | [diff] [blame] | 915 | friend class JniInternalTest; // for GetRuntimeQuickGenericJniStub |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 916 | ART_FRIEND_TEST(mirror::DexCacheTest, Open); // for AllocDexCache |
| 917 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 918 | DISALLOW_COPY_AND_ASSIGN(ClassLinker); |
| 919 | }; |
| 920 | |
| 921 | } // namespace art |
| 922 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 923 | #endif // ART_RUNTIME_CLASS_LINKER_H_ |