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