blob: fbf4035842dc783a9de3a870db651d6d2aac5980 [file] [log] [blame]
Elliott Hughes418d20f2011-09-22 14:00:39 -07001/*
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 Shapiro0e5d75d2011-07-06 18:28:37 -070016
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_CLASS_LINKER_H_
18#define ART_RUNTIME_CLASS_LINKER_H_
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070019
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080020#include <string>
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070021#include <utility>
22#include <vector>
23
Mathieu Chartierbad02672014-08-25 13:08:22 -070024#include "base/allocator.h"
Mathieu Chartierc2e20622014-11-03 11:41:47 -080025#include "base/hash_set.h"
Elliott Hughes76160052012-12-12 16:31:20 -080026#include "base/macros.h"
Elliott Hughes76b61672012-12-12 17:47:30 -080027#include "base/mutex.h"
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -070028#include "class_table.h"
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070029#include "dex_file.h"
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070030#include "gc_root.h"
Mathieu Chartier590fee92013-09-13 13:46:47 -070031#include "jni.h"
Brian Carlstrom58ae9412011-10-04 00:56:06 -070032#include "oat_file.h"
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080033#include "object_callbacks.h"
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070034
35namespace art {
Mingyao Yang98d1cc82014-05-15 17:02:16 -070036
Ian Rogers1d54e732013-05-02 21:10:01 -070037namespace gc {
38namespace space {
39 class ImageSpace;
40} // namespace space
41} // namespace gc
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080042namespace mirror {
Ian Rogers33e95662013-05-20 20:29:14 -070043 class ClassLoader;
44 class DexCache;
Mathieu Chartiere401d142015-04-22 13:56:20 -070045 class DexCachePointerArray;
Ian Rogers33e95662013-05-20 20:29:14 -070046 class DexCacheTest_Open_Test;
47 class IfTable;
48 template<class T> class ObjectArray;
49 class StackTraceElement;
50} // namespace mirror
Ian Rogers1d54e732013-05-02 21:10:01 -070051
Andreas Gampe5a4b8a22014-09-11 08:30:08 -070052template<class T> class Handle;
Hiroshi Yamauchi679b1cf2015-05-21 12:05:27 -070053template<class T> class MutableHandle;
Elliott Hughescf4c6c42011-09-01 15:16:42 -070054class InternTable;
Mathieu Chartierc528dba2013-11-26 12:00:11 -080055template<class T> class ObjectLock;
Andreas Gampe7ba64962014-10-23 11:37:40 -070056class Runtime;
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070057class ScopedObjectAccessAlreadyRunnable;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070058template<size_t kNumReferences> class PACKED(4) StackHandleScope;
Elliott Hughescf4c6c42011-09-01 15:16:42 -070059
Mathieu Chartier893263b2014-03-04 11:07:42 -080060enum VisitRootFlags : uint8_t;
61
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070062class ClassLinker {
63 public:
Ian Rogers6f3dbba2014-10-14 17:41:57 -070064 // 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 Chartierfc58af42015-04-16 18:00:39 -070073 kJavaLangReflectConstructor,
Mathieu Chartierdaaf3262015-03-24 13:30:28 -070074 kJavaLangReflectField,
Mathieu Chartierfc58af42015-04-16 18:00:39 -070075 kJavaLangReflectMethod,
Ian Rogers6f3dbba2014-10-14 17:41:57 -070076 kJavaLangReflectProxy,
77 kJavaLangStringArrayClass,
Mathieu Chartierfc58af42015-04-16 18:00:39 -070078 kJavaLangReflectConstructorArrayClass,
Mathieu Chartierdaaf3262015-03-24 13:30:28 -070079 kJavaLangReflectFieldArrayClass,
Mathieu Chartierfc58af42015-04-16 18:00:39 -070080 kJavaLangReflectMethodArrayClass,
Ian Rogers6f3dbba2014-10-14 17:41:57 -070081 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 Chartier590fee92013-09-13 13:46:47 -0700106 explicit ClassLinker(InternTable* intern_table);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700107 ~ClassLinker();
Carl Shapiro565f5072011-07-10 13:39:43 -0700108
Alex Light64ad14d2014-08-19 14:23:13 -0700109 // Initialize class linker by bootstraping from dex files.
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800110 void InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> boot_class_path)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700111 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Mathieu Chartier590fee92013-09-13 13:46:47 -0700112
113 // Initialize class linker from one or more images.
Mathieu Chartier90443472015-07-16 20:32:27 -0700114 void InitFromImage() SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Mathieu Chartier590fee92013-09-13 13:46:47 -0700115
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700116 // Finds a class by its descriptor, loading it if necessary.
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700117 // If class_loader is null, searches boot_class_path_.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700118 mirror::Class* FindClass(Thread* self, const char* descriptor,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700119 Handle<mirror::ClassLoader> class_loader)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700120 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700121
Andreas Gampef865ea92015-04-13 22:14:19 -0700122 // 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,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700128 Thread* self, const char* descriptor, size_t hash,
Andreas Gampef865ea92015-04-13 22:14:19 -0700129 Handle<mirror::ClassLoader> class_loader,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700130 mirror::Class** result)
131 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Mathieu Chartierab0ed822014-09-11 14:21:41 -0700132
Ian Rogers98379392014-02-24 16:53:16 -0800133 // 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)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700136 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Ian Rogers98379392014-02-24 16:53:16 -0800137
138 // Finds the array class given for the element class.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700139 mirror::Class* FindArrayClass(Thread* self, mirror::Class** element_class)
140 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700141
Ian Rogers63557452014-06-04 16:57:15 -0700142 // Returns true if the class linker is initialized.
Ian Rogers7b078e82014-09-10 14:44:24 -0700143 bool IsInitialized() const {
144 return init_done_;
145 }
Mathieu Chartier590fee92013-09-13 13:46:47 -0700146
Brian Carlstromaded5f72011-10-07 17:15:04 -0700147 // Define a new a class based on a ClassDef from a DexFile
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700148 mirror::Class* DefineClass(Thread* self, const char* descriptor, size_t hash,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700149 Handle<mirror::ClassLoader> class_loader,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700150 const DexFile& dex_file, const DexFile::ClassDef& dex_class_def)
151 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700152
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700153 // Finds a class by its descriptor, returning null if it isn't wasn't loaded
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700154 // by the given 'class_loader'.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700155 mirror::Class* LookupClass(Thread* self, const char* descriptor, size_t hash,
156 mirror::ClassLoader* class_loader)
Mathieu Chartier90443472015-07-16 20:32:27 -0700157 REQUIRES(!Locks::classlinker_classes_lock_)
158 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700159
Elliott Hughes6fa602d2011-12-02 17:54:25 -0800160 // Finds all the classes with the given descriptor, regardless of ClassLoader.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700161 void LookupClasses(const char* descriptor, std::vector<mirror::Class*>& classes)
Mathieu Chartier90443472015-07-16 20:32:27 -0700162 REQUIRES(!Locks::classlinker_classes_lock_)
163 SHARED_REQUIRES(Locks::mutator_lock_);
Elliott Hughes6fa602d2011-12-02 17:54:25 -0800164
Mathieu Chartier90443472015-07-16 20:32:27 -0700165 mirror::Class* FindPrimitiveClass(char type) SHARED_REQUIRES(Locks::mutator_lock_);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -0700166
Brian Carlstromae826982011-11-09 01:33:42 -0800167 // General class unloading is not supported, this is used to prune
168 // unwanted classes during image writing.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700169 bool RemoveClass(const char* descriptor, mirror::ClassLoader* class_loader)
170 REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstromae826982011-11-09 01:33:42 -0800171
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700172 void DumpAllClasses(int flags)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700173 REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Elliott Hughes9d5ccec2011-09-19 13:19:50 -0700174
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700175 void DumpForSigQuit(std::ostream& os)
Mathieu Chartier90443472015-07-16 20:32:27 -0700176 REQUIRES(!Locks::classlinker_classes_lock_);
Elliott Hughescac6cc72011-11-03 20:31:21 -0700177
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700178 size_t NumLoadedClasses()
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700179 REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Elliott Hughese27955c2011-08-26 15:21:24 -0700180
Brian Carlstromb63ec392011-08-27 17:38:27 -0700181 // Resolve a String with the given index from the DexFile, storing the
Brian Carlstromaded5f72011-10-07 17:15:04 -0700182 // result in the DexCache. The referrer is used to identify the
183 // target DexCache and ClassLoader to use for resolution.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700184 mirror::String* ResolveString(uint32_t string_idx, ArtMethod* referrer)
Mathieu Chartier90443472015-07-16 20:32:27 -0700185 SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700186
187 // Resolve a String with the given index from the DexFile, storing the
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700188 // result in the DexCache.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700189 mirror::String* ResolveString(const DexFile& dex_file, uint32_t string_idx,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700190 Handle<mirror::DexCache> dex_cache)
Mathieu Chartier90443472015-07-16 20:32:27 -0700191 SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700192
Brian Carlstromb63ec392011-08-27 17:38:27 -0700193 // Resolve a Type with the given index from the DexFile, storing the
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700194 // result in the DexCache. The referrer is used to identity the
195 // target DexCache and ClassLoader to use for resolution.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700196 mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx, mirror::Class* referrer)
197 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700198
Brian Carlstromb63ec392011-08-27 17:38:27 -0700199 // Resolve a Type with the given index from the DexFile, storing the
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700200 // result in the DexCache. The referrer is used to identify the
Brian Carlstromb63ec392011-08-27 17:38:27 -0700201 // target DexCache and ClassLoader to use for resolution.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700202 mirror::Class* ResolveType(uint16_t type_idx, ArtMethod* referrer)
203 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700204
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700205 mirror::Class* ResolveType(uint16_t type_idx, ArtField* referrer)
206 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstromb63ec392011-08-27 17:38:27 -0700207
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700208 // 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.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700212 mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700213 Handle<mirror::DexCache> dex_cache,
214 Handle<mirror::ClassLoader> class_loader)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700215 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700216
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.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700222 ArtMethod* ResolveMethod(const DexFile& dex_file, uint32_t method_idx,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700223 Handle<mirror::DexCache> dex_cache,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700224 Handle<mirror::ClassLoader> class_loader, ArtMethod* referrer,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700225 InvokeType type)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700226 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700227
Mathieu Chartiere401d142015-04-22 13:56:20 -0700228 ArtMethod* GetResolvedMethod(uint32_t method_idx, ArtMethod* referrer)
Mathieu Chartier90443472015-07-16 20:32:27 -0700229 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700230 ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, ArtMethod* referrer, InvokeType type)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700231 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Jeff Hao13e748b2015-08-25 20:44:19 +0000232 ArtMethod* ResolveMethodWithoutInvokeType(const DexFile& dex_file,
233 uint32_t method_idx,
234 Handle<mirror::DexCache> dex_cache,
235 Handle<mirror::ClassLoader> class_loader)
236 SHARED_REQUIRES(Locks::mutator_lock_)
237 REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom16192862011-09-12 17:50:06 -0700238
Mathieu Chartierc7853442015-03-27 14:35:38 -0700239 ArtField* GetResolvedField(uint32_t field_idx, mirror::Class* field_declaring_class)
Mathieu Chartier90443472015-07-16 20:32:27 -0700240 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierc7853442015-03-27 14:35:38 -0700241 ArtField* GetResolvedField(uint32_t field_idx, mirror::DexCache* dex_cache)
Mathieu Chartier90443472015-07-16 20:32:27 -0700242 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700243 ArtField* ResolveField(uint32_t field_idx, ArtMethod* referrer, bool is_static)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700244 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstromb9edb842011-08-28 16:31:06 -0700245
Brian Carlstrom16192862011-09-12 17:50:06 -0700246 // Resolve a field with a given ID from the DexFile, storing the
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700247 // result in DexCache. The ClassLinker and ClassLoader are used as
248 // in ResolveType. What is unique is the is_static argument which is
249 // used to determine if we are resolving a static or non-static
250 // field.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700251 ArtField* ResolveField(const DexFile& dex_file, uint32_t field_idx,
Mathieu Chartier90443472015-07-16 20:32:27 -0700252 Handle<mirror::DexCache> dex_cache,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700253 Handle<mirror::ClassLoader> class_loader, bool is_static)
254 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700255
Ian Rogersb067ac22011-12-13 18:05:09 -0800256 // Resolve a field with a given ID from the DexFile, storing the
257 // result in DexCache. The ClassLinker and ClassLoader are used as
258 // in ResolveType. No is_static argument is provided so that Java
259 // field resolution semantics are followed.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700260 ArtField* ResolveFieldJLS(const DexFile& dex_file, uint32_t field_idx,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700261 Handle<mirror::DexCache> dex_cache,
262 Handle<mirror::ClassLoader> class_loader)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700263 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Ian Rogersb067ac22011-12-13 18:05:09 -0800264
Ian Rogersad25ac52011-10-04 19:13:33 -0700265 // Get shorty from method index without resolution. Used to do handlerization.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700266 const char* MethodShorty(uint32_t method_idx, ArtMethod* referrer, uint32_t* length)
Mathieu Chartier90443472015-07-16 20:32:27 -0700267 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogersad25ac52011-10-04 19:13:33 -0700268
Elliott Hughesf4c21c92011-08-19 17:31:31 -0700269 // Returns true on success, false if there's an exception pending.
Brian Carlstrom25c33252011-09-18 15:58:35 -0700270 // can_run_clinit=false allows the compiler to attempt to init a class,
271 // given the restriction that no <clinit> execution is possible.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700272 bool EnsureInitialized(Thread* self, Handle<mirror::Class> c, bool can_init_fields,
Ian Rogers7b078e82014-09-10 14:44:24 -0700273 bool can_init_parents)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700274 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700275
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700276 // Initializes classes that have instances in the image but that have
277 // <clinit> methods so they could not be initialized by the compiler.
Mathieu Chartier4e2cb092015-07-22 16:17:51 -0700278 void RunRootClinits() SHARED_REQUIRES(Locks::mutator_lock_)
279 REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700280
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700281 void RegisterDexFile(const DexFile& dex_file)
Mathieu Chartier90443472015-07-16 20:32:27 -0700282 REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700283 void RegisterDexFile(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
Mathieu Chartier90443472015-07-16 20:32:27 -0700284 REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700285
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700286 const OatFile* RegisterOatFile(const OatFile* oat_file)
Mathieu Chartier90443472015-07-16 20:32:27 -0700287 REQUIRES(!dex_lock_);
Brian Carlstrom866c8622012-01-06 16:35:13 -0800288
Brian Carlstrom8a487412011-08-29 20:08:52 -0700289 const std::vector<const DexFile*>& GetBootClassPath() {
290 return boot_class_path_;
291 }
292
Sebastien Hertz0de11332015-05-13 12:14:05 +0200293 // Returns the first non-image oat file in the class path.
294 const OatFile* GetPrimaryOatFile()
Mathieu Chartier90443472015-07-16 20:32:27 -0700295 REQUIRES(!dex_lock_);
Sebastien Hertz0de11332015-05-13 12:14:05 +0200296
Mathieu Chartiere0671ce2015-07-28 17:23:28 -0700297 void VisitClasses(ClassVisitor* visitor)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700298 REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogersdbf3be02014-08-29 15:40:08 -0700299
300 // Less efficient variant of VisitClasses that copies the class_table_ into secondary storage
301 // so that it can visit individual classes without holding the doesn't hold the
302 // Locks::classlinker_classes_lock_. As the Locks::classlinker_classes_lock_ isn't held this code
303 // can race with insertion and deletion of classes while the visitor is being called.
Mathieu Chartiere0671ce2015-07-28 17:23:28 -0700304 void VisitClassesWithoutClassesLock(ClassVisitor* visitor)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700305 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Elliott Hughesa2155262011-11-16 16:26:58 -0800306
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700307 void VisitClassRoots(RootVisitor* visitor, VisitRootFlags flags)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700308 REQUIRES(!Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -0700309 void VisitRoots(RootVisitor* visitor, VisitRootFlags flags)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700310 REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700311
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700312 mirror::DexCache* FindDexCache(const DexFile& dex_file)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700313 REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700314 bool IsDexFileRegistered(const DexFile& dex_file)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700315 REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700316 void FixupDexCaches(ArtMethod* resolution_method)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700317 REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstrom1d9f52b2011-10-13 10:50:45 -0700318
Richard Uhler66d874d2015-01-15 09:37:19 -0800319 // Finds or creates the oat file holding dex_location. Then loads and returns
320 // all corresponding dex files (there may be more than one dex file loaded
321 // in the case of multidex).
322 // This may return the original, unquickened dex files if the oat file could
323 // not be generated.
324 //
325 // Returns an empty vector if the dex files could not be loaded. In this
326 // case, there will be at least one error message returned describing why no
327 // dex files could not be loaded. The 'error_msgs' argument must not be
328 // null, regardless of whether there is an error or not.
329 //
330 // This method should not be called with the mutator_lock_ held, because it
331 // could end up starving GC if we need to generate or relocate any oat
332 // files.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700333 std::vector<std::unique_ptr<const DexFile>> OpenDexFilesFromOat(
334 const char* dex_location, const char* oat_location,
335 std::vector<std::string>* error_msgs)
Mathieu Chartier90443472015-07-16 20:32:27 -0700336 REQUIRES(!dex_lock_, !Locks::mutator_lock_);
jeffhaof6174e82012-01-31 16:14:17 -0800337
Ian Rogersc0542af2014-09-03 16:16:56 -0700338 // Allocate an instance of a java.lang.Object.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700339 mirror::Object* AllocObject(Thread* self) SHARED_REQUIRES(Locks::mutator_lock_)
Mathieu Chartier4e2cb092015-07-22 16:17:51 -0700340 REQUIRES(!Roles::uninterruptible_);
Ian Rogersc0542af2014-09-03 16:16:56 -0700341
Elliott Hughes418d20f2011-09-22 14:00:39 -0700342 // TODO: replace this with multiple methods that allocate the correct managed type.
Shih-wei Liao44175362011-08-28 16:59:17 -0700343 template <class T>
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800344 mirror::ObjectArray<T>* AllocObjectArray(Thread* self, size_t length)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700345 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Shih-wei Liao55df06b2011-08-26 14:39:27 -0700346
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800347 mirror::ObjectArray<mirror::Class>* AllocClassArray(Thread* self, size_t length)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700348 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
jeffhao98eacac2011-09-14 16:11:53 -0700349
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800350 mirror::ObjectArray<mirror::String>* AllocStringArray(Thread* self, size_t length)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700351 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Mathieu Chartier4e2cb092015-07-22 16:17:51 -0700352
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700353 LengthPrefixedArray<ArtField>* AllocArtFieldArray(Thread* self, size_t length);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800354
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700355 LengthPrefixedArray<ArtMethod>* AllocArtMethodArray(Thread* self, size_t length);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700356
357 mirror::PointerArray* AllocPointerArray(Thread* self, size_t length)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700358 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800359
360 mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700361 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800362
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700363 mirror::ObjectArray<mirror::StackTraceElement>* AllocStackTraceElementArray(
364 Thread* self, size_t length) SHARED_REQUIRES(Locks::mutator_lock_)
365 REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800366
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700367 void VerifyClass(Thread* self, Handle<mirror::Class> klass)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700368 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
369 bool VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class* klass,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800370 mirror::Class::Status& oat_file_class_status)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700371 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800372 void ResolveClassExceptionHandlerTypes(const DexFile& dex_file,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700373 Handle<mirror::Class> klass)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700374 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700375 void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, ArtMethod* klass)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700376 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800377
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700378 mirror::Class* CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa, jstring name,
379 jobjectArray interfaces, jobject loader, jobjectArray methods,
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -0700380 jobjectArray throws)
Mathieu Chartier90443472015-07-16 20:32:27 -0700381 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800382 std::string GetDescriptorForProxy(mirror::Class* proxy_class)
Mathieu Chartier90443472015-07-16 20:32:27 -0700383 SHARED_REQUIRES(Locks::mutator_lock_);
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700384 ArtMethod* FindMethodForProxy(mirror::Class* proxy_class, ArtMethod* proxy_method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700385 REQUIRES(!dex_lock_)
386 SHARED_REQUIRES(Locks::mutator_lock_);
Jesse Wilson95caa792011-10-12 18:14:17 -0400387
Ian Rogers19846512012-02-24 11:42:47 -0800388 // Get the oat code for a method when its class isn't yet initialized
Mathieu Chartiere401d142015-04-22 13:56:20 -0700389 const void* GetQuickOatCodeFor(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700390 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers19846512012-02-24 11:42:47 -0800391
Mathieu Chartiere35517a2012-10-30 18:49:55 -0700392 // Get the oat code for a method from a method index.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700393 const void* GetQuickOatCodeFor(const DexFile& dex_file, uint16_t class_def_idx,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700394 uint32_t method_idx)
Mathieu Chartier90443472015-07-16 20:32:27 -0700395 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere35517a2012-10-30 18:49:55 -0700396
Hiroshi Yamauchi9bdec882014-08-15 17:11:12 -0700397 // Get compiled code for a method, return null if no code
398 // exists. This is unlike Get..OatCodeFor which will return a bridge
399 // or interpreter entrypoint.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700400 const void* GetOatMethodQuickCodeFor(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700401 SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchi9bdec882014-08-15 17:11:12 -0700402
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700403 const OatFile::OatMethod FindOatMethodFor(ArtMethod* method, bool* found)
Mathieu Chartier90443472015-07-16 20:32:27 -0700404 SHARED_REQUIRES(Locks::mutator_lock_);
Nicolas Geoffray9523a3e2015-07-17 11:51:28 +0000405
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700406 pid_t GetClassesLockOwner(); // For SignalCatcher.
407 pid_t GetDexLockOwner(); // For SignalCatcher.
Brian Carlstrom24a3c2e2011-10-17 18:07:52 -0700408
Mathieu Chartier90443472015-07-16 20:32:27 -0700409 mirror::Class* GetClassRoot(ClassRoot class_root) SHARED_REQUIRES(Locks::mutator_lock_);
Jeff Hao0aba0ba2013-06-03 14:49:28 -0700410
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700411 static const char* GetClassRootDescriptor(ClassRoot class_root);
Andreas Gampe2da88232014-02-27 12:26:20 -0800412
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700413 // Is the given entry point quick code to run the resolution stub?
414 bool IsQuickResolutionStub(const void* entry_point) const;
Jeff Hao88474b42013-10-23 16:24:40 -0700415
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700416 // Is the given entry point quick code to bridge into the interpreter?
417 bool IsQuickToInterpreterBridge(const void* entry_point) const;
418
419 // Is the given entry point quick code to run the generic JNI stub?
420 bool IsQuickGenericJniStub(const void* entry_point) const;
Vladimir Marko8a630572014-04-09 18:45:35 +0100421
Jeff Hao88474b42013-10-23 16:24:40 -0700422 InternTable* GetInternTable() const {
423 return intern_table_;
424 }
425
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700426 // Set the entrypoints up for method to the given code.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700427 void SetEntryPointsToCompiledCode(ArtMethod* method, const void* method_code) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700428 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700429
430 // Set the entrypoints up for method to the enter the interpreter.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700431 void SetEntryPointsToInterpreter(ArtMethod* method) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700432 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700433
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700434 // Attempts to insert a class into a class table. Returns null if
Ian Rogers848871b2013-08-05 10:56:33 -0700435 // the class was inserted, otherwise returns an existing class with
436 // the same descriptor and ClassLoader.
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700437 mirror::Class* InsertClass(const char* descriptor, mirror::Class* klass, size_t hash)
Mathieu Chartier90443472015-07-16 20:32:27 -0700438 REQUIRES(!Locks::classlinker_classes_lock_)
439 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers848871b2013-08-05 10:56:33 -0700440
Mathieu Chartier90443472015-07-16 20:32:27 -0700441 mirror::ObjectArray<mirror::Class>* GetClassRoots() SHARED_REQUIRES(Locks::mutator_lock_) {
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700442 mirror::ObjectArray<mirror::Class>* class_roots = class_roots_.Read();
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700443 DCHECK(class_roots != nullptr);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700444 return class_roots;
445 }
446
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800447 // Move all of the image classes into the class table for faster lookups.
448 void MoveImageClassesToClassTable()
Mathieu Chartier90443472015-07-16 20:32:27 -0700449 REQUIRES(!Locks::classlinker_classes_lock_)
450 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800451 // Move the class table to the pre-zygote table to reduce memory usage. This works by ensuring
452 // that no more classes are ever added to the pre zygote table which makes it that the pages
453 // always remain shared dirty instead of private dirty.
454 void MoveClassTableToPreZygote()
Mathieu Chartier90443472015-07-16 20:32:27 -0700455 REQUIRES(!Locks::classlinker_classes_lock_)
456 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800457
Sebastien Hertz6963e442014-11-26 22:11:27 +0100458 // Returns true if the method can be called with its direct code pointer, false otherwise.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700459 bool MayBeCalledWithDirectCodePointer(ArtMethod* m)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700460 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Sebastien Hertz6963e442014-11-26 22:11:27 +0100461
Andreas Gampe81c6f8d2015-03-25 17:19:53 -0700462 // Creates a GlobalRef PathClassLoader that can be used to load classes from the given dex files.
463 // Note: the objects are not completely set up. Do not use this outside of tests and the compiler.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700464 jobject CreatePathClassLoader(Thread* self, std::vector<const DexFile*>& dex_files)
465 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Andreas Gampe81c6f8d2015-03-25 17:19:53 -0700466
Mathieu Chartiere401d142015-04-22 13:56:20 -0700467 size_t GetImagePointerSize() const {
468 DCHECK(ValidPointerSize(image_pointer_size_)) << image_pointer_size_;
469 return image_pointer_size_;
470 }
471
472 // Used by image writer for checking.
473 bool ClassInClassTable(mirror::Class* klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700474 REQUIRES(!Locks::classlinker_classes_lock_)
475 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiera89d7ed2014-12-05 10:57:13 -0800476
Mathieu Chartiere401d142015-04-22 13:56:20 -0700477 ArtMethod* CreateRuntimeMethod();
478
Andreas Gampe8ac75952015-06-02 21:01:45 -0700479 // Clear the ArrayClass cache. This is necessary when cleaning up for the image, as the cache
480 // entries are roots, but potentially not image classes.
Mathieu Chartier90443472015-07-16 20:32:27 -0700481 void DropFindArrayClassCache() SHARED_REQUIRES(Locks::mutator_lock_);
Andreas Gampe8ac75952015-06-02 21:01:45 -0700482
Mathieu Chartiere401d142015-04-22 13:56:20 -0700483 private:
Mathieu Chartiere0671ce2015-07-28 17:23:28 -0700484 void VisitClassesInternal(ClassVisitor* visitor)
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700485 REQUIRES(Locks::classlinker_classes_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
486
487 // Returns the number of zygote and image classes.
Mathieu Chartier6b069532015-08-05 15:08:12 -0700488 size_t NumZygoteClasses() const
489 REQUIRES(Locks::classlinker_classes_lock_)
490 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700491
492 // Returns the number of non zygote nor image classes.
Mathieu Chartier6b069532015-08-05 15:08:12 -0700493 size_t NumNonZygoteClasses() const
494 REQUIRES(Locks::classlinker_classes_lock_)
495 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700496
Brian Carlstrom56d947f2013-07-15 13:14:23 -0700497 OatFile& GetImageOatFile(gc::space::ImageSpace* space)
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700498 REQUIRES(!dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstroma663ea52011-08-19 23:33:41 -0700499
Mathieu Chartier4e2cb092015-07-22 16:17:51 -0700500 void FinishInit(Thread* self) SHARED_REQUIRES(Locks::mutator_lock_)
501 REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstroma663ea52011-08-19 23:33:41 -0700502
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700503 // For early bootstrapping by Init
Ian Rogers6fac4472014-02-25 17:01:10 -0800504 mirror::Class* AllocClass(Thread* self, mirror::Class* java_lang_Class, uint32_t class_size)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700505 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700506
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800507 // Alloc* convenience functions to avoid needing to pass in mirror::Class*
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700508 // values that are known to the ClassLinker such as
509 // kObjectArrayClass and kJavaLangString etc.
Ian Rogers6fac4472014-02-25 17:01:10 -0800510 mirror::Class* AllocClass(Thread* self, uint32_t class_size)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700511 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800512 mirror::DexCache* AllocDexCache(Thread* self, const DexFile& dex_file)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700513 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Ian Rogersbdb03912011-09-14 00:55:44 -0700514
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800515 mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700516 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800517 mirror::Class* InitializePrimitiveClass(mirror::Class* primitive_class, Primitive::Type type)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700518 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Brian Carlstroma331b3c2011-07-18 17:47:56 -0700519
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700520 mirror::Class* CreateArrayClass(Thread* self, const char* descriptor, size_t hash,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700521 Handle<mirror::ClassLoader> class_loader)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700522 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_, !Roles::uninterruptible_);
Brian Carlstroma331b3c2011-07-18 17:47:56 -0700523
Ian Rogers7b078e82014-09-10 14:44:24 -0700524 void AppendToBootClassPath(Thread* self, const DexFile& dex_file)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700525 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700526 void AppendToBootClassPath(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700527 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700528
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700529 // Precomputes size needed for Class, in the case of a non-temporary class this size must be
530 // sufficient to hold all static fields.
531 uint32_t SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file,
532 const DexFile::ClassDef& dex_class_def);
Brian Carlstrom4873d462011-08-21 15:23:39 -0700533
Mathieu Chartierc7853442015-03-27 14:35:38 -0700534 // Setup the classloader, class def index, type idx so that we can insert this class in the class
535 // table.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700536 void SetupClass(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def,
537 Handle<mirror::Class> klass, mirror::ClassLoader* class_loader)
Mathieu Chartier90443472015-07-16 20:32:27 -0700538 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierc7853442015-03-27 14:35:38 -0700539
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700540 void LoadClass(Thread* self, const DexFile& dex_file, const DexFile::ClassDef& dex_class_def,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700541 Handle<mirror::Class> klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700542 SHARED_REQUIRES(Locks::mutator_lock_);
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700543 void LoadClassMembers(Thread* self, const DexFile& dex_file, const uint8_t* class_data,
544 Handle<mirror::Class> klass, const OatFile::OatClass* oat_class)
Mathieu Chartier90443472015-07-16 20:32:27 -0700545 SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700546
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700547 void LoadField(const ClassDataItemIterator& it, Handle<mirror::Class> klass,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700548 ArtField* dst)
Mathieu Chartier90443472015-07-16 20:32:27 -0700549 SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700550
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700551 void LoadMethod(Thread* self, const DexFile& dex_file, const ClassDataItemIterator& it,
552 Handle<mirror::Class> klass, ArtMethod* dst)
Mathieu Chartier90443472015-07-16 20:32:27 -0700553 SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstrom934486c2011-07-12 23:42:50 -0700554
Mathieu Chartier90443472015-07-16 20:32:27 -0700555 void FixupStaticTrampolines(mirror::Class* klass) SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers19846512012-02-24 11:42:47 -0800556
Ian Rogers97b52f82014-08-14 11:34:07 -0700557 // Finds the associated oat class for a dex_file and descriptor. Returns an invalid OatClass on
558 // error and sets found to false.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700559 OatFile::OatClass FindOatClass(const DexFile& dex_file, uint16_t class_def_idx, bool* found)
Mathieu Chartier90443472015-07-16 20:32:27 -0700560 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers19846512012-02-24 11:42:47 -0800561
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700562 void RegisterDexFileLocked(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700563 REQUIRES(dex_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700564 bool IsDexFileRegisteredLocked(const DexFile& dex_file)
Mathieu Chartier90443472015-07-16 20:32:27 -0700565 SHARED_REQUIRES(dex_lock_, Locks::mutator_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700566
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700567 bool InitializeClass(Thread* self, Handle<mirror::Class> klass, bool can_run_clinit,
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800568 bool can_init_parents)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700569 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
570 bool WaitForInitializeClass(Handle<mirror::Class> klass, Thread* self,
571 ObjectLock<mirror::Class>& lock);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700572 bool ValidateSuperClassDescriptors(Handle<mirror::Class> klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700573 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700574
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700575 bool IsSameDescriptorInDifferentClassContexts(Thread* self, const char* descriptor,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700576 Handle<mirror::ClassLoader> class_loader1,
577 Handle<mirror::ClassLoader> class_loader2)
Mathieu Chartier90443472015-07-16 20:32:27 -0700578 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700579
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700580 bool IsSameMethodSignatureInDifferentClassContexts(Thread* self, ArtMethod* method,
581 mirror::Class* klass1, mirror::Class* klass2)
Mathieu Chartier90443472015-07-16 20:32:27 -0700582 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700583
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700584 bool LinkClass(Thread* self, const char* descriptor, Handle<mirror::Class> klass,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700585 Handle<mirror::ObjectArray<mirror::Class>> interfaces,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700586 MutableHandle<mirror::Class>* h_new_class_out)
587 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Locks::classlinker_classes_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700588
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700589 bool LinkSuperClass(Handle<mirror::Class> klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700590 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700591
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700592 bool LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file)
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700593 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700594
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700595 bool LinkMethods(Thread* self,
596 Handle<mirror::Class> klass,
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700597 Handle<mirror::ObjectArray<mirror::Class>> interfaces,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700598 ArtMethod** out_imt)
Mathieu Chartier90443472015-07-16 20:32:27 -0700599 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700600
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700601 bool LinkVirtualMethods(Thread* self, Handle<mirror::Class> klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700602 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700603
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700604 bool LinkInterfaceMethods(Thread* self, Handle<mirror::Class> klass,
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700605 Handle<mirror::ObjectArray<mirror::Class>> interfaces,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700606 ArtMethod** out_imt)
Mathieu Chartier90443472015-07-16 20:32:27 -0700607 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700608
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700609 bool LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size)
Mathieu Chartier90443472015-07-16 20:32:27 -0700610 SHARED_REQUIRES(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700611 bool LinkInstanceFields(Thread* self, Handle<mirror::Class> klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700612 SHARED_REQUIRES(Locks::mutator_lock_);
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700613 bool LinkFields(Thread* self, Handle<mirror::Class> klass, bool is_static, size_t* class_size)
Mathieu Chartier90443472015-07-16 20:32:27 -0700614 SHARED_REQUIRES(Locks::mutator_lock_);
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700615 void LinkCode(ArtMethod* method, const OatFile::OatClass* oat_class,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700616 uint32_t class_def_method_index)
Mathieu Chartier90443472015-07-16 20:32:27 -0700617 SHARED_REQUIRES(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700618 void CreateReferenceInstanceOffsets(Handle<mirror::Class> klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700619 SHARED_REQUIRES(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700620
Mathieu Chartiere401d142015-04-22 13:56:20 -0700621 void CheckProxyConstructor(ArtMethod* constructor) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700622 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700623 void CheckProxyMethod(ArtMethod* method, ArtMethod* prototype) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700624 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700625
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700626 // For use by ImageWriter to find DexCaches for its roots
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700627 ReaderWriterMutex* DexLock()
Mathieu Chartier90443472015-07-16 20:32:27 -0700628 SHARED_REQUIRES(Locks::mutator_lock_) LOCK_RETURNED(dex_lock_) {
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700629 return &dex_lock_;
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700630 }
Mathieu Chartier90443472015-07-16 20:32:27 -0700631 size_t GetDexCacheCount() SHARED_REQUIRES(Locks::mutator_lock_, dex_lock_) {
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700632 return dex_caches_.size();
633 }
Mathieu Chartier90443472015-07-16 20:32:27 -0700634 mirror::DexCache* GetDexCache(size_t idx) SHARED_REQUIRES(Locks::mutator_lock_, dex_lock_);
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700635
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700636 const OatFile* FindOpenedOatFileFromOatLocation(const std::string& oat_location)
Mathieu Chartier90443472015-07-16 20:32:27 -0700637 REQUIRES(!dex_lock_);
Andreas Gampe833a4852014-05-21 18:46:59 -0700638
Sebastien Hertz0de11332015-05-13 12:14:05 +0200639 // Returns the boot image oat file.
Mathieu Chartier90443472015-07-16 20:32:27 -0700640 const OatFile* GetBootOatFile() SHARED_REQUIRES(dex_lock_);
Sebastien Hertz0de11332015-05-13 12:14:05 +0200641
Mathieu Chartiere401d142015-04-22 13:56:20 -0700642 void CreateProxyConstructor(Handle<mirror::Class> klass, ArtMethod* out)
Mathieu Chartier90443472015-07-16 20:32:27 -0700643 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700644 void CreateProxyMethod(Handle<mirror::Class> klass, ArtMethod* prototype, ArtMethod* out)
Mathieu Chartier90443472015-07-16 20:32:27 -0700645 SHARED_REQUIRES(Locks::mutator_lock_);
Jesse Wilson95caa792011-10-12 18:14:17 -0400646
Andreas Gampe48498592014-09-10 19:48:05 -0700647 // Ensures that methods have the kAccPreverified bit set. We use the kAccPreverfied bit on the
648 // class access flags to determine whether this has been done before.
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700649 void EnsurePreverifiedMethods(Handle<mirror::Class> c)
Mathieu Chartier90443472015-07-16 20:32:27 -0700650 SHARED_REQUIRES(Locks::mutator_lock_);
Andreas Gampe48498592014-09-10 19:48:05 -0700651
Ian Rogersdbf3be02014-08-29 15:40:08 -0700652 mirror::Class* LookupClassFromImage(const char* descriptor)
Mathieu Chartier90443472015-07-16 20:32:27 -0700653 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogersdbf3be02014-08-29 15:40:08 -0700654
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700655 // Returns null if not found.
656 ClassTable* ClassTableForClassLoader(mirror::ClassLoader* class_loader)
657 SHARED_REQUIRES(Locks::mutator_lock_, Locks::classlinker_classes_lock_);
658 // Insert a new class table if not found.
659 ClassTable* InsertClassTableForClassLoader(mirror::ClassLoader* class_loader)
660 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(Locks::classlinker_classes_lock_);
661
Ian Rogersdbf3be02014-08-29 15:40:08 -0700662 // EnsureResolved is called to make sure that a class in the class_table_ has been resolved
663 // before returning it to the caller. Its the responsibility of the thread that placed the class
664 // in the table to make it resolved. The thread doing resolution must notify on the class' lock
665 // when resolution has occurred. This happens in mirror::Class::SetStatus. As resolution may
666 // retire a class, the version of the class in the table is returned and this may differ from
667 // the class passed in.
668 mirror::Class* EnsureResolved(Thread* self, const char* descriptor, mirror::Class* klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700669 WARN_UNUSED SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Ian Rogersdbf3be02014-08-29 15:40:08 -0700670
671 void FixupTemporaryDeclaringClass(mirror::Class* temp_class, mirror::Class* new_class)
Mathieu Chartier90443472015-07-16 20:32:27 -0700672 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogersdbf3be02014-08-29 15:40:08 -0700673
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700674 void SetClassRoot(ClassRoot class_root, mirror::Class* klass)
Mathieu Chartier90443472015-07-16 20:32:27 -0700675 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700676
677 // Return the quick generic JNI stub for testing.
678 const void* GetRuntimeQuickGenericJniStub() const;
679
Andreas Gampebfdcdc12015-04-22 18:10:36 -0700680 // Throw the class initialization failure recorded when first trying to initialize the given
681 // class.
682 // Note: Currently we only store the descriptor, so we cannot throw the exact throwable, only
683 // a recreation with a custom string.
Mathieu Chartier90443472015-07-16 20:32:27 -0700684 void ThrowEarlierClassFailure(mirror::Class* c) SHARED_REQUIRES(Locks::mutator_lock_)
685 REQUIRES(!dex_lock_);
Andreas Gampebfdcdc12015-04-22 18:10:36 -0700686
Andreas Gampeb9aec2c2015-04-23 22:23:47 -0700687 // Check for duplicate class definitions of the given oat file against all open oat files.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700688 bool HasCollisions(const OatFile* oat_file, std::string* error_msg) REQUIRES(!dex_lock_);
Andreas Gampeb9aec2c2015-04-23 22:23:47 -0700689
Mathieu Chartier90443472015-07-16 20:32:27 -0700690 bool HasInitWithString(Thread* self, const char* descriptor)
691 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!dex_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700692
693 bool CanWeInitializeClass(mirror::Class* klass, bool can_init_statics, bool can_init_parents)
Mathieu Chartier90443472015-07-16 20:32:27 -0700694 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700695
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700696 void UpdateClassVirtualMethods(mirror::Class* klass,
697 LengthPrefixedArray<ArtMethod>* new_methods)
698 SHARED_REQUIRES(Locks::mutator_lock_)
699 REQUIRES(!Locks::classlinker_classes_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700700
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700701 std::vector<const DexFile*> boot_class_path_;
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800702 std::vector<std::unique_ptr<const DexFile>> opened_dex_files_;
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700703
Ian Rogers1bf8d4d2013-05-30 00:18:49 -0700704 mutable ReaderWriterMutex dex_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
Andreas Gampec8ccf682014-09-29 20:07:43 -0700705 std::vector<size_t> new_dex_cache_roots_ GUARDED_BY(dex_lock_);
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700706 std::vector<GcRoot<mirror::DexCache>> dex_caches_ GUARDED_BY(dex_lock_);
Elliott Hughesf8349362012-06-18 15:00:06 -0700707 std::vector<const OatFile*> oat_files_ GUARDED_BY(dex_lock_);
Brian Carlstrom47d237a2011-10-18 15:08:33 -0700708
Mathieu Chartier6b069532015-08-05 15:08:12 -0700709 // This contains the class laoders which have class tables. It is populated by
710 // InsertClassTableForClassLoader.
711 std::vector<GcRoot<mirror::ClassLoader>> class_loaders_
712 GUARDED_BY(Locks::classlinker_classes_lock_);
713
714 // Boot class path table. Since the class loader for this is null.
715 ClassTable boot_class_table_ GUARDED_BY(Locks::classlinker_classes_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700716
Mathieu Chartiercc5ebdf2015-07-27 11:19:43 -0700717 // New class roots, only used by CMS since the GC needs to mark these in the pause.
718 std::vector<GcRoot<mirror::Class>> new_class_roots_ GUARDED_BY(Locks::classlinker_classes_lock_);
Elliott Hughesf8349362012-06-18 15:00:06 -0700719
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700720 // Do we need to search dex caches to find image classes?
721 bool dex_cache_image_class_lookup_required_;
722 // Number of times we've searched dex caches for a class. After a certain number of misses we move
723 // the classes into the class_table_ to avoid dex cache based searches.
Ian Rogers68b56852014-08-29 20:19:11 -0700724 Atomic<uint32_t> failed_dex_cache_class_lookups_;
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700725
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700726 // Well known mirror::Class roots.
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700727 GcRoot<mirror::ObjectArray<mirror::Class>> class_roots_;
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700728
Ian Rogers98379392014-02-24 16:53:16 -0800729 // The interface table used by all arrays.
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700730 GcRoot<mirror::IfTable> array_iftable_;
Carl Shapiro565f5072011-07-10 13:39:43 -0700731
Ian Rogers98379392014-02-24 16:53:16 -0800732 // A cache of the last FindArrayClass results. The cache serves to avoid creating array class
733 // descriptors for the sake of performing FindClass.
734 static constexpr size_t kFindArrayCacheSize = 16;
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700735 GcRoot<mirror::Class> find_array_class_cache_[kFindArrayCacheSize];
Ian Rogers98379392014-02-24 16:53:16 -0800736 size_t find_array_class_cache_next_victim_;
737
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700738 bool init_done_;
Mathieu Chartier893263b2014-03-04 11:07:42 -0800739 bool log_new_dex_caches_roots_ GUARDED_BY(dex_lock_);
740 bool log_new_class_table_roots_ GUARDED_BY(Locks::classlinker_classes_lock_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700741
Elliott Hughescf4c6c42011-09-01 15:16:42 -0700742 InternTable* intern_table_;
743
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700744 // Trampolines within the image the bounce to runtime entrypoints. Done so that there is a single
745 // patch point within the image. TODO: make these proper relocations.
Jeff Hao0aba0ba2013-06-03 14:49:28 -0700746 const void* quick_resolution_trampoline_;
Jeff Hao88474b42013-10-23 16:24:40 -0700747 const void* quick_imt_conflict_trampoline_;
Andreas Gampe2da88232014-02-27 12:26:20 -0800748 const void* quick_generic_jni_trampoline_;
Vladimir Marko8a630572014-04-09 18:45:35 +0100749 const void* quick_to_interpreter_bridge_trampoline_;
Jeff Hao0aba0ba2013-06-03 14:49:28 -0700750
Mathieu Chartier2d721012014-11-10 11:08:06 -0800751 // Image pointer size.
752 size_t image_pointer_size_;
753
Brian Carlstrom34f426c2011-10-04 12:58:02 -0700754 friend class ImageWriter; // for GetClassRoots
Alex Lighta59dd802014-07-02 16:28:08 -0700755 friend class ImageDumper; // for FindOpenedOatFileFromOatLocation
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700756 friend class JniCompilerTest; // for GetRuntimeQuickGenericJniStub
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700757 ART_FRIEND_TEST(mirror::DexCacheTest, Open); // for AllocDexCache
758
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700759 DISALLOW_COPY_AND_ASSIGN(ClassLinker);
760};
761
762} // namespace art
763
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700764#endif // ART_RUNTIME_CLASS_LINKER_H_