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