blob: 132da675cf304d8b88d21339817bac2ca8920c9b [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
Fred Shih37f05ef2014-07-16 18:38:08 -070020#include <deque>
Ian Rogers6d4d9fc2011-11-30 16:24:48 -080021#include <string>
Carl Shapiro0e5d75d2011-07-06 18:28:37 -070022#include <utility>
23#include <vector>
24
Mathieu Chartierbad02672014-08-25 13:08:22 -070025#include "base/allocator.h"
Mathieu Chartierc2e20622014-11-03 11:41:47 -080026#include "base/hash_set.h"
Elliott Hughes76160052012-12-12 16:31:20 -080027#include "base/macros.h"
Elliott Hughes76b61672012-12-12 17:47:30 -080028#include "base/mutex.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;
45 class DexCacheTest_Open_Test;
46 class IfTable;
47 template<class T> class ObjectArray;
48 class StackTraceElement;
49} // namespace mirror
Ian Rogers1d54e732013-05-02 21:10:01 -070050
Andreas Gampe5a4b8a22014-09-11 08:30:08 -070051template<class T> class Handle;
Elliott Hughescf4c6c42011-09-01 15:16:42 -070052class InternTable;
Mathieu Chartierc528dba2013-11-26 12:00:11 -080053template<class T> class ObjectLock;
Andreas Gampe7ba64962014-10-23 11:37:40 -070054class Runtime;
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070055class ScopedObjectAccessAlreadyRunnable;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070056template<size_t kNumReferences> class PACKED(4) StackHandleScope;
Elliott Hughescf4c6c42011-09-01 15:16:42 -070057
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080058typedef bool (ClassVisitor)(mirror::Class* c, void* arg);
Elliott Hughesa2155262011-11-16 16:26:58 -080059
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,
73 kJavaLangReflectArtField,
74 kJavaLangReflectArtMethod,
75 kJavaLangReflectProxy,
76 kJavaLangStringArrayClass,
77 kJavaLangReflectArtFieldArrayClass,
78 kJavaLangReflectArtMethodArrayClass,
79 kJavaLangClassLoader,
80 kJavaLangThrowable,
81 kJavaLangClassNotFoundException,
82 kJavaLangStackTraceElement,
83 kPrimitiveBoolean,
84 kPrimitiveByte,
85 kPrimitiveChar,
86 kPrimitiveDouble,
87 kPrimitiveFloat,
88 kPrimitiveInt,
89 kPrimitiveLong,
90 kPrimitiveShort,
91 kPrimitiveVoid,
92 kBooleanArrayClass,
93 kByteArrayClass,
94 kCharArrayClass,
95 kDoubleArrayClass,
96 kFloatArrayClass,
97 kIntArrayClass,
98 kLongArrayClass,
99 kShortArrayClass,
100 kJavaLangStackTraceElementArrayClass,
101 kClassRootsMax,
102 };
103
Mathieu Chartier590fee92013-09-13 13:46:47 -0700104 explicit ClassLinker(InternTable* intern_table);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700105 ~ClassLinker();
Carl Shapiro565f5072011-07-10 13:39:43 -0700106
Alex Light64ad14d2014-08-19 14:23:13 -0700107 // Initialize class linker by bootstraping from dex files.
108 void InitWithoutImage(const std::vector<const DexFile*>& boot_class_path)
Mathieu Chartier590fee92013-09-13 13:46:47 -0700109 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
110
111 // Initialize class linker from one or more images.
112 void InitFromImage() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
113
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700114 // Finds a class by its descriptor, loading it if necessary.
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700115 // If class_loader is null, searches boot_class_path_.
Ian Rogers98379392014-02-24 16:53:16 -0800116 mirror::Class* FindClass(Thread* self, const char* descriptor,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700117 Handle<mirror::ClassLoader> class_loader)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700118 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700119
Ian Rogers32427292014-11-19 14:05:21 -0800120 // Find a class in the path class loader, loading it if necessary without using JNI. Hash
121 // function is supposed to be ComputeModifiedUtf8Hash(descriptor).
Mathieu Chartierab0ed822014-09-11 14:21:41 -0700122 mirror::Class* FindClassInPathClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
Mathieu Chartiere7c9a8c2014-11-06 16:35:45 -0800123 Thread* self, const char* descriptor, size_t hash,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700124 Handle<mirror::ClassLoader> class_loader)
Mathieu Chartierab0ed822014-09-11 14:21:41 -0700125 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
126
Ian Rogers98379392014-02-24 16:53:16 -0800127 // Finds a class by its descriptor using the "system" class loader, ie by searching the
128 // boot_class_path_.
129 mirror::Class* FindSystemClass(Thread* self, const char* descriptor)
130 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
131
132 // Finds the array class given for the element class.
Mathieu Chartierb74cd292014-05-29 14:31:33 -0700133 mirror::Class* FindArrayClass(Thread* self, mirror::Class** element_class)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700134 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700135
Ian Rogers63557452014-06-04 16:57:15 -0700136 // Returns true if the class linker is initialized.
Ian Rogers7b078e82014-09-10 14:44:24 -0700137 bool IsInitialized() const {
138 return init_done_;
139 }
Mathieu Chartier590fee92013-09-13 13:46:47 -0700140
Brian Carlstromaded5f72011-10-07 17:15:04 -0700141 // Define a new a class based on a ClassDef from a DexFile
Mathieu Chartiere7c9a8c2014-11-06 16:35:45 -0800142 mirror::Class* DefineClass(Thread* self, const char* descriptor, size_t hash,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700143 Handle<mirror::ClassLoader> class_loader,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800144 const DexFile& dex_file, const DexFile::ClassDef& dex_class_def)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700145 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700146
147 // Finds a class by its descriptor, returning NULL if it isn't wasn't loaded
148 // by the given 'class_loader'.
Mathieu Chartiere7c9a8c2014-11-06 16:35:45 -0800149 mirror::Class* LookupClass(Thread* self, const char* descriptor, size_t hash,
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800150 mirror::ClassLoader* class_loader)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700151 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
152 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700153
Elliott Hughes6fa602d2011-12-02 17:54:25 -0800154 // Finds all the classes with the given descriptor, regardless of ClassLoader.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800155 void LookupClasses(const char* descriptor, std::vector<mirror::Class*>& classes)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700156 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
157 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes6fa602d2011-12-02 17:54:25 -0800158
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800159 mirror::Class* FindPrimitiveClass(char type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughesd8ddfd52011-08-15 14:32:53 -0700160
Brian Carlstromae826982011-11-09 01:33:42 -0800161 // General class unloading is not supported, this is used to prune
162 // unwanted classes during image writing.
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800163 bool RemoveClass(const char* descriptor, mirror::ClassLoader* class_loader)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700164 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
165 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromae826982011-11-09 01:33:42 -0800166
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700167 void DumpAllClasses(int flags)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700168 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
169 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes9d5ccec2011-09-19 13:19:50 -0700170
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700171 void DumpForSigQuit(std::ostream& os)
Ian Rogers7b078e82014-09-10 14:44:24 -0700172 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_);
Elliott Hughescac6cc72011-11-03 20:31:21 -0700173
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700174 size_t NumLoadedClasses()
175 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
176 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughese27955c2011-08-26 15:21:24 -0700177
Brian Carlstromb63ec392011-08-27 17:38:27 -0700178 // Resolve a String with the given index from the DexFile, storing the
Brian Carlstromaded5f72011-10-07 17:15:04 -0700179 // result in the DexCache. The referrer is used to identify the
180 // target DexCache and ClassLoader to use for resolution.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800181 mirror::String* ResolveString(uint32_t string_idx, mirror::ArtMethod* referrer)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800182 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700183
184 // Resolve a String with the given index from the DexFile, storing the
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700185 // result in the DexCache.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800186 mirror::String* ResolveString(const DexFile& dex_file, uint32_t string_idx,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700187 Handle<mirror::DexCache> dex_cache)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700188 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700189
Brian Carlstromb63ec392011-08-27 17:38:27 -0700190 // Resolve a Type with the given index from the DexFile, storing the
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700191 // result in the DexCache. The referrer is used to identity the
192 // target DexCache and ClassLoader to use for resolution.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800193 mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx, mirror::Class* referrer)
Mathieu Chartier590fee92013-09-13 13:46:47 -0700194 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700195
Brian Carlstromb63ec392011-08-27 17:38:27 -0700196 // Resolve a Type with the given index from the DexFile, storing the
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700197 // result in the DexCache. The referrer is used to identify the
Brian Carlstromb63ec392011-08-27 17:38:27 -0700198 // target DexCache and ClassLoader to use for resolution.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800199 mirror::Class* ResolveType(uint16_t type_idx, mirror::ArtMethod* referrer)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800200 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700201
Ian Rogersef7d42f2014-01-06 12:55:46 -0800202 mirror::Class* ResolveType(uint16_t type_idx, mirror::ArtField* referrer)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800203 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromb63ec392011-08-27 17:38:27 -0700204
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700205 // Resolve a type with the given ID from the DexFile, storing the
206 // result in DexCache. The ClassLoader is used to search for the
207 // type, since it may be referenced from but not contained within
208 // the given DexFile.
Mathieu Chartier590fee92013-09-13 13:46:47 -0700209 mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700210 Handle<mirror::DexCache> dex_cache,
211 Handle<mirror::ClassLoader> class_loader)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700212 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700213
214 // Resolve a method with a given ID from the DexFile, storing the
215 // result in DexCache. The ClassLinker and ClassLoader are used as
216 // in ResolveType. What is unique is the method type argument which
217 // is used to determine if this method is a direct, static, or
218 // virtual method.
Brian Carlstromea46f952013-07-30 01:26:50 -0700219 mirror::ArtMethod* ResolveMethod(const DexFile& dex_file,
220 uint32_t method_idx,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700221 Handle<mirror::DexCache> dex_cache,
222 Handle<mirror::ClassLoader> class_loader,
223 Handle<mirror::ArtMethod> referrer,
Brian Carlstromea46f952013-07-30 01:26:50 -0700224 InvokeType type)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700225 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700226
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700227 mirror::ArtMethod* GetResolvedMethod(uint32_t method_idx, mirror::ArtMethod* referrer)
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700228 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
229 mirror::ArtMethod* ResolveMethod(Thread* self, uint32_t method_idx, mirror::ArtMethod** referrer,
Brian Carlstromea46f952013-07-30 01:26:50 -0700230 InvokeType type)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800231 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom16192862011-09-12 17:50:06 -0700232
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700233 mirror::ArtField* GetResolvedField(uint32_t field_idx, mirror::Class* field_declaring_class)
234 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800235 mirror::ArtField* ResolveField(uint32_t field_idx, mirror::ArtMethod* referrer,
Brian Carlstromea46f952013-07-30 01:26:50 -0700236 bool is_static)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800237 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromb9edb842011-08-28 16:31:06 -0700238
Brian Carlstrom16192862011-09-12 17:50:06 -0700239 // Resolve a field with a given ID from the DexFile, storing the
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700240 // result in DexCache. The ClassLinker and ClassLoader are used as
241 // in ResolveType. What is unique is the is_static argument which is
242 // used to determine if we are resolving a static or non-static
243 // field.
Brian Carlstromea46f952013-07-30 01:26:50 -0700244 mirror::ArtField* ResolveField(const DexFile& dex_file,
245 uint32_t field_idx,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700246 Handle<mirror::DexCache> dex_cache,
247 Handle<mirror::ClassLoader> class_loader,
Brian Carlstromea46f952013-07-30 01:26:50 -0700248 bool is_static)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700249 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700250
Ian Rogersb067ac22011-12-13 18:05:09 -0800251 // Resolve a field with a given ID from the DexFile, storing the
252 // result in DexCache. The ClassLinker and ClassLoader are used as
253 // in ResolveType. No is_static argument is provided so that Java
254 // field resolution semantics are followed.
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700255 mirror::ArtField* ResolveFieldJLS(const DexFile& dex_file, uint32_t field_idx,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700256 Handle<mirror::DexCache> dex_cache,
257 Handle<mirror::ClassLoader> class_loader)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700258 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersb067ac22011-12-13 18:05:09 -0800259
Ian Rogersad25ac52011-10-04 19:13:33 -0700260 // Get shorty from method index without resolution. Used to do handlerization.
Brian Carlstromea46f952013-07-30 01:26:50 -0700261 const char* MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700262 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersad25ac52011-10-04 19:13:33 -0700263
Elliott Hughesf4c21c92011-08-19 17:31:31 -0700264 // Returns true on success, false if there's an exception pending.
Brian Carlstrom25c33252011-09-18 15:58:35 -0700265 // can_run_clinit=false allows the compiler to attempt to init a class,
266 // given the restriction that no <clinit> execution is possible.
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700267 bool EnsureInitialized(Thread* self, Handle<mirror::Class> c, bool can_init_fields,
Ian Rogers7b078e82014-09-10 14:44:24 -0700268 bool can_init_parents)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700269 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700270
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700271 // Initializes classes that have instances in the image but that have
272 // <clinit> methods so they could not be initialized by the compiler.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700273 void RunRootClinits() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughes2a20cfd2011-09-23 19:30:41 -0700274
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700275 void RegisterDexFile(const DexFile& dex_file)
276 LOCKS_EXCLUDED(dex_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700277 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700278 void RegisterDexFile(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700279 LOCKS_EXCLUDED(dex_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700280 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700281
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700282 const OatFile* RegisterOatFile(const OatFile* oat_file)
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700283 LOCKS_EXCLUDED(dex_lock_);
Brian Carlstrom866c8622012-01-06 16:35:13 -0800284
Brian Carlstrom8a487412011-08-29 20:08:52 -0700285 const std::vector<const DexFile*>& GetBootClassPath() {
286 return boot_class_path_;
287 }
288
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700289 void VisitClasses(ClassVisitor* visitor, void* arg)
Ian Rogersdbf3be02014-08-29 15:40:08 -0700290 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700291 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersdbf3be02014-08-29 15:40:08 -0700292
293 // Less efficient variant of VisitClasses that copies the class_table_ into secondary storage
294 // so that it can visit individual classes without holding the doesn't hold the
295 // Locks::classlinker_classes_lock_. As the Locks::classlinker_classes_lock_ isn't held this code
296 // can race with insertion and deletion of classes while the visitor is being called.
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700297 void VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* arg)
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700298 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Elliott Hughesa2155262011-11-16 16:26:58 -0800299
Mathieu Chartier52e4b432014-06-10 11:22:31 -0700300 void VisitClassRoots(RootCallback* callback, void* arg, VisitRootFlags flags)
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700301 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
302 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartier893263b2014-03-04 11:07:42 -0800303 void VisitRoots(RootCallback* callback, void* arg, VisitRootFlags flags)
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700304 LOCKS_EXCLUDED(dex_lock_)
305 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700306
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700307 mirror::DexCache* FindDexCache(const DexFile& dex_file)
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700308 LOCKS_EXCLUDED(dex_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700309 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700310 bool IsDexFileRegistered(const DexFile& dex_file)
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700311 LOCKS_EXCLUDED(dex_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700312 void FixupDexCaches(mirror::ArtMethod* resolution_method)
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700313 LOCKS_EXCLUDED(dex_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700314 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom1d9f52b2011-10-13 10:50:45 -0700315
jeffhao262bf462011-10-20 18:36:32 -0700316 // Generate an oat file from a dex file
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700317 bool GenerateOatFile(const char* dex_filename,
Brian Carlstromd601af82012-01-06 10:15:19 -0800318 int oat_fd,
Vladimir Marko60836d52014-01-16 15:53:38 +0000319 const char* oat_cache_filename,
Ian Rogers719d1a32014-03-06 12:13:39 -0800320 std::string* error_msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700321 LOCKS_EXCLUDED(Locks::mutator_lock_);
jeffhao262bf462011-10-20 18:36:32 -0700322
Andreas Gampe833a4852014-05-21 18:46:59 -0700323 // Find or create the oat file holding dex_location. Then load all corresponding dex files
324 // (if multidex) into the given vector.
325 bool OpenDexFilesFromOat(const char* dex_location, const char* oat_location,
326 std::vector<std::string>* error_msgs,
327 std::vector<const DexFile*>* dex_files)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700328 LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
jeffhaof6174e82012-01-31 16:14:17 -0800329
Alex Light6e183f22014-07-18 14:57:04 -0700330 // Returns true if the given oat file has the same image checksum as the image it is paired with.
331 static bool VerifyOatImageChecksum(const OatFile* oat_file, const InstructionSet instruction_set);
332 // Returns true if the oat file checksums match with the image and the offsets are such that it
333 // could be loaded with it.
334 static bool VerifyOatChecksums(const OatFile* oat_file, const InstructionSet instruction_set,
335 std::string* error_msg);
Brian Carlstrom28db0122012-10-18 16:20:41 -0700336 // Returns true if oat file contains the dex file with the given location and checksum.
Alex Light6e183f22014-07-18 14:57:04 -0700337 static bool VerifyOatAndDexFileChecksums(const OatFile* oat_file,
338 const char* dex_location,
339 uint32_t dex_location_checksum,
340 InstructionSet instruction_set,
341 std::string* error_msg);
Brian Carlstromafe25512012-06-27 17:02:58 -0700342
Ian Rogersc0542af2014-09-03 16:16:56 -0700343 // Allocate an instance of a java.lang.Object.
344 mirror::Object* AllocObject(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
345
Elliott Hughes418d20f2011-09-22 14:00:39 -0700346 // TODO: replace this with multiple methods that allocate the correct managed type.
Shih-wei Liao44175362011-08-28 16:59:17 -0700347 template <class T>
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800348 mirror::ObjectArray<T>* AllocObjectArray(Thread* self, size_t length)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700349 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Shih-wei Liao55df06b2011-08-26 14:39:27 -0700350
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800351 mirror::ObjectArray<mirror::Class>* AllocClassArray(Thread* self, size_t length)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700352 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
jeffhao98eacac2011-09-14 16:11:53 -0700353
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800354 mirror::ObjectArray<mirror::String>* AllocStringArray(Thread* self, size_t length)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700355 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800356
Brian Carlstromea46f952013-07-30 01:26:50 -0700357 mirror::ObjectArray<mirror::ArtMethod>* AllocArtMethodArray(Thread* self, size_t length)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800358 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
359
360 mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount)
361 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
362
Brian Carlstromea46f952013-07-30 01:26:50 -0700363 mirror::ObjectArray<mirror::ArtField>* AllocArtFieldArray(Thread* self, size_t length)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800364 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
365
366 mirror::ObjectArray<mirror::StackTraceElement>* AllocStackTraceElementArray(Thread* self,
367 size_t length)
368 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
369
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700370 void VerifyClass(Thread* self, Handle<mirror::Class> klass)
Ian Rogers7b078e82014-09-10 14:44:24 -0700371 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800372 bool VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class* klass,
373 mirror::Class::Status& oat_file_class_status)
374 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800375 void ResolveClassExceptionHandlerTypes(const DexFile& dex_file,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700376 Handle<mirror::Class> klass)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800377 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromea46f952013-07-30 01:26:50 -0700378 void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::ArtMethod* klass)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800379 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
380
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -0700381 mirror::Class* CreateProxyClass(ScopedObjectAccessAlreadyRunnable& soa, jstring name,
382 jobjectArray interfaces, jobject loader, jobjectArray methods,
383 jobjectArray throws)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800384 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800385 std::string GetDescriptorForProxy(mirror::Class* proxy_class)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800386 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800387 mirror::ArtMethod* FindMethodForProxy(mirror::Class* proxy_class,
388 mirror::ArtMethod* proxy_method)
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700389 LOCKS_EXCLUDED(dex_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700390 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Jesse Wilson95caa792011-10-12 18:14:17 -0400391
Ian Rogers19846512012-02-24 11:42:47 -0800392 // Get the oat code for a method when its class isn't yet initialized
Ian Rogersef7d42f2014-01-06 12:55:46 -0800393 const void* GetQuickOatCodeFor(mirror::ArtMethod* method)
394 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
395 const void* GetPortableOatCodeFor(mirror::ArtMethod* method, bool* have_portable_code)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700396 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers19846512012-02-24 11:42:47 -0800397
Mathieu Chartiere35517a2012-10-30 18:49:55 -0700398 // Get the oat code for a method from a method index.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800399 const void* GetQuickOatCodeFor(const DexFile& dex_file, uint16_t class_def_idx, uint32_t method_idx)
400 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
401 const void* GetPortableOatCodeFor(const DexFile& dex_file, uint16_t class_def_idx, uint32_t method_idx)
Ian Rogers33e95662013-05-20 20:29:14 -0700402 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartiere35517a2012-10-30 18:49:55 -0700403
Hiroshi Yamauchi9bdec882014-08-15 17:11:12 -0700404 // Get compiled code for a method, return null if no code
405 // exists. This is unlike Get..OatCodeFor which will return a bridge
406 // or interpreter entrypoint.
407 const void* GetOatMethodQuickCodeFor(mirror::ArtMethod* method)
408 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
409 const void* GetOatMethodPortableCodeFor(mirror::ArtMethod* method)
410 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
411
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700412 pid_t GetClassesLockOwner(); // For SignalCatcher.
413 pid_t GetDexLockOwner(); // For SignalCatcher.
Brian Carlstrom24a3c2e2011-10-17 18:07:52 -0700414
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700415 mirror::Class* GetClassRoot(ClassRoot class_root) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Jeff Hao0aba0ba2013-06-03 14:49:28 -0700416
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700417 static const char* GetClassRootDescriptor(ClassRoot class_root);
Andreas Gampe2da88232014-02-27 12:26:20 -0800418
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700419 // Is the given entry point portable code to run the resolution stub?
420 bool IsPortableResolutionStub(const void* entry_point) const;
Jeff Hao0aba0ba2013-06-03 14:49:28 -0700421
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700422 // Is the given entry point quick code to run the resolution stub?
423 bool IsQuickResolutionStub(const void* entry_point) const;
Jeff Hao88474b42013-10-23 16:24:40 -0700424
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700425 // Is the given entry point portable code to bridge into the interpreter?
426 bool IsPortableToInterpreterBridge(const void* entry_point) const;
Jeff Hao88474b42013-10-23 16:24:40 -0700427
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700428 // Is the given entry point quick code to bridge into the interpreter?
429 bool IsQuickToInterpreterBridge(const void* entry_point) const;
430
431 // Is the given entry point quick code to run the generic JNI stub?
432 bool IsQuickGenericJniStub(const void* entry_point) const;
Vladimir Marko8a630572014-04-09 18:45:35 +0100433
Jeff Hao88474b42013-10-23 16:24:40 -0700434 InternTable* GetInternTable() const {
435 return intern_table_;
436 }
437
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700438 // Set the entrypoints up for method to the given code.
439 void SetEntryPointsToCompiledCode(mirror::ArtMethod* method, const void* method_code,
440 bool is_portable) const
441 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
442
443 // Set the entrypoints up for method to the enter the interpreter.
444 void SetEntryPointsToInterpreter(mirror::ArtMethod* method) const
445 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
446
Ian Rogers848871b2013-08-05 10:56:33 -0700447 // Attempts to insert a class into a class table. Returns NULL if
448 // the class was inserted, otherwise returns an existing class with
449 // the same descriptor and ClassLoader.
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700450 mirror::Class* InsertClass(const char* descriptor, mirror::Class* klass, size_t hash)
Ian Rogers848871b2013-08-05 10:56:33 -0700451 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
452 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
453
Mathieu Chartier590fee92013-09-13 13:46:47 -0700454 // Special code to allocate an art method, use this instead of class->AllocObject.
455 mirror::ArtMethod* AllocArtMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro61e019d2011-07-14 16:53:09 -0700456
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700457 mirror::ObjectArray<mirror::Class>* GetClassRoots() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700458 mirror::ObjectArray<mirror::Class>* class_roots = class_roots_.Read();
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700459 DCHECK(class_roots != NULL);
460 return class_roots;
461 }
462
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800463 // Move all of the image classes into the class table for faster lookups.
464 void MoveImageClassesToClassTable()
465 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
466 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
467 // Move the class table to the pre-zygote table to reduce memory usage. This works by ensuring
468 // that no more classes are ever added to the pre zygote table which makes it that the pages
469 // always remain shared dirty instead of private dirty.
470 void MoveClassTableToPreZygote()
471 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
472 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
473
Sebastien Hertz6963e442014-11-26 22:11:27 +0100474 // Returns true if the method can be called with its direct code pointer, false otherwise.
475 bool MayBeCalledWithDirectCodePointer(mirror::ArtMethod* m)
476 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
477
Mathieu Chartier590fee92013-09-13 13:46:47 -0700478 private:
Mathieu Chartiera89d7ed2014-12-05 10:57:13 -0800479 static void InitFromImageInterpretOnlyCallback(mirror::Object* obj, void* arg)
480 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
481
Ian Rogers97b52f82014-08-14 11:34:07 -0700482 const OatFile::OatMethod FindOatMethodFor(mirror::ArtMethod* method, bool* found)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700483 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
TDYa12785321912012-04-01 15:24:56 -0700484
Brian Carlstrom56d947f2013-07-15 13:14:23 -0700485 OatFile& GetImageOatFile(gc::space::ImageSpace* space)
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700486 LOCKS_EXCLUDED(dex_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700487 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma663ea52011-08-19 23:33:41 -0700488
Ian Rogers98379392014-02-24 16:53:16 -0800489 void FinishInit(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma663ea52011-08-19 23:33:41 -0700490
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700491 // For early bootstrapping by Init
Ian Rogers6fac4472014-02-25 17:01:10 -0800492 mirror::Class* AllocClass(Thread* self, mirror::Class* java_lang_Class, uint32_t class_size)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700493 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700494
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800495 // Alloc* convenience functions to avoid needing to pass in mirror::Class*
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700496 // values that are known to the ClassLinker such as
497 // kObjectArrayClass and kJavaLangString etc.
Ian Rogers6fac4472014-02-25 17:01:10 -0800498 mirror::Class* AllocClass(Thread* self, uint32_t class_size)
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800499 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800500 mirror::DexCache* AllocDexCache(Thread* self, const DexFile& dex_file)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700501 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromea46f952013-07-30 01:26:50 -0700502 mirror::ArtField* AllocArtField(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersbdb03912011-09-14 00:55:44 -0700503
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800504 mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type)
505 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
506 mirror::Class* InitializePrimitiveClass(mirror::Class* primitive_class, Primitive::Type type)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700507 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom5b8e4c82011-09-18 01:38:59 -0700508
Brian Carlstroma331b3c2011-07-18 17:47:56 -0700509
Mathieu Chartiere7c9a8c2014-11-06 16:35:45 -0800510 mirror::Class* CreateArrayClass(Thread* self, const char* descriptor, size_t hash,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700511 Handle<mirror::ClassLoader> class_loader)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700512 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstroma331b3c2011-07-18 17:47:56 -0700513
Ian Rogers7b078e82014-09-10 14:44:24 -0700514 void AppendToBootClassPath(Thread* self, const DexFile& dex_file)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700515 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700516 void AppendToBootClassPath(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700517 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700518
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700519 // Precomputes size needed for Class, in the case of a non-temporary class this size must be
520 // sufficient to hold all static fields.
521 uint32_t SizeOfClassWithoutEmbeddedTables(const DexFile& dex_file,
522 const DexFile::ClassDef& dex_class_def);
Brian Carlstrom4873d462011-08-21 15:23:39 -0700523
Ian Rogers7b078e82014-09-10 14:44:24 -0700524 void LoadClass(Thread* self, const DexFile& dex_file, const DexFile::ClassDef& dex_class_def,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700525 Handle<mirror::Class> klass, mirror::ClassLoader* class_loader)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700526 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers13735952014-10-08 12:43:28 -0700527 void LoadClassMembers(Thread* self, const DexFile& dex_file, const uint8_t* class_data,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700528 Handle<mirror::Class> klass, const OatFile::OatClass* oat_class)
Vladimir Markod3c5beb2014-04-11 16:32:51 +0100529 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700530
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800531 void LoadField(const DexFile& dex_file, const ClassDataItemIterator& it,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700532 Handle<mirror::Class> klass, Handle<mirror::ArtField> dst)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800533 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700534
Brian Carlstromea46f952013-07-30 01:26:50 -0700535 mirror::ArtMethod* LoadMethod(Thread* self, const DexFile& dex_file,
536 const ClassDataItemIterator& dex_method,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700537 Handle<mirror::Class> klass)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800538 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstrom934486c2011-07-12 23:42:50 -0700539
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800540 void FixupStaticTrampolines(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers19846512012-02-24 11:42:47 -0800541
Ian Rogers97b52f82014-08-14 11:34:07 -0700542 // Finds the associated oat class for a dex_file and descriptor. Returns an invalid OatClass on
543 // error and sets found to false.
544 OatFile::OatClass FindOatClass(const DexFile& dex_file, uint16_t class_def_idx, bool* found)
Ian Rogers33e95662013-05-20 20:29:14 -0700545 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers19846512012-02-24 11:42:47 -0800546
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700547 void RegisterDexFileLocked(const DexFile& dex_file, Handle<mirror::DexCache> dex_cache)
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700548 EXCLUSIVE_LOCKS_REQUIRED(dex_lock_)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700549 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700550 bool IsDexFileRegisteredLocked(const DexFile& dex_file)
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700551 SHARED_LOCKS_REQUIRED(dex_lock_, Locks::mutator_lock_);
Brian Carlstromaded5f72011-10-07 17:15:04 -0700552
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700553 bool InitializeClass(Thread* self, Handle<mirror::Class> klass, bool can_run_clinit,
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800554 bool can_init_parents)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700555 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700556 bool WaitForInitializeClass(Handle<mirror::Class> klass, Thread* self,
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800557 ObjectLock<mirror::Class>& lock);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700558 bool ValidateSuperClassDescriptors(Handle<mirror::Class> klass)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700559 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700560
Ian Rogers98379392014-02-24 16:53:16 -0800561 bool IsSameDescriptorInDifferentClassContexts(Thread* self, const char* descriptor,
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700562 Handle<mirror::ClassLoader> class_loader1,
563 Handle<mirror::ClassLoader> class_loader2)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700564 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700565
Ian Rogers98379392014-02-24 16:53:16 -0800566 bool IsSameMethodSignatureInDifferentClassContexts(Thread* self, mirror::ArtMethod* method,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800567 mirror::Class* klass1,
568 mirror::Class* klass2)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700569 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700570
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700571 bool LinkClass(Thread* self, const char* descriptor, Handle<mirror::Class> klass,
572 Handle<mirror::ObjectArray<mirror::Class>> interfaces,
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700573 mirror::Class** new_class)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700574 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700575
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700576 bool LinkSuperClass(Handle<mirror::Class> klass)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700577 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700578
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700579 bool LoadSuperAndInterfaces(Handle<mirror::Class> klass, const DexFile& dex_file)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700580 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700581
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700582 bool LinkMethods(Thread* self, Handle<mirror::Class> klass,
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700583 Handle<mirror::ObjectArray<mirror::Class>> interfaces,
584 StackHandleScope<mirror::Class::kImtSize>* out_imt)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700585 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700586
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700587 bool LinkVirtualMethods(Thread* self, Handle<mirror::Class> klass)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700588 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700589
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700590 bool LinkInterfaceMethods(Thread* const self, Handle<mirror::Class> klass,
591 Handle<mirror::ObjectArray<mirror::Class>> interfaces,
592 StackHandleScope<mirror::Class::kImtSize>* out_imt)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700593 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700594
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700595 bool LinkStaticFields(Thread* self, Handle<mirror::Class> klass, size_t* class_size)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700596 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700597 bool LinkInstanceFields(Thread* self, Handle<mirror::Class> klass)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700598 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700599 bool LinkFields(Thread* self, Handle<mirror::Class> klass, bool is_static, size_t* class_size)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700600 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700601 void LinkCode(Handle<mirror::ArtMethod> method, const OatFile::OatClass* oat_class,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700602 uint32_t class_def_method_index)
Dmitry Petrochenkof0972a42014-05-16 17:43:39 +0700603 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700604 void CreateReferenceInstanceOffsets(Handle<mirror::Class> klass)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700605 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700606
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700607 // For use by ImageWriter to find DexCaches for its roots
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700608 ReaderWriterMutex* DexLock()
609 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) LOCK_RETURNED(dex_lock_) {
610 return &dex_lock_;
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700611 }
Hiroshi Yamauchie9e3e692014-06-24 14:31:37 -0700612 size_t GetDexCacheCount() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, dex_lock_) {
613 return dex_caches_.size();
614 }
615 mirror::DexCache* GetDexCache(size_t idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, dex_lock_);
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700616
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100617 const OatFile::OatDexFile* FindOpenedOatDexFileForDexFile(const DexFile& dex_file)
Ian Rogers33e95662013-05-20 20:29:14 -0700618 LOCKS_EXCLUDED(dex_lock_)
619 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe833a4852014-05-21 18:46:59 -0700620
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100621 // Find an opened oat dex file that contains dex_location. If oat_location is not nullptr,
622 // the file must have that location, else any oat location is accepted.
623 const OatFile::OatDexFile* FindOpenedOatDexFile(const char* oat_location,
624 const char* dex_location,
625 const uint32_t* dex_location_checksum)
Ian Rogers719d1a32014-03-06 12:13:39 -0800626 LOCKS_EXCLUDED(dex_lock_);
Alex Lighta59dd802014-07-02 16:28:08 -0700627
628 // Will open the oat file directly without relocating, even if we could/should do relocation.
629 const OatFile* FindOatFileFromOatLocation(const std::string& oat_location,
630 std::string* error_msg)
631 LOCKS_EXCLUDED(dex_lock_);
632
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700633 const OatFile* FindOpenedOatFileFromOatLocation(const std::string& oat_location)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700634 LOCKS_EXCLUDED(dex_lock_);
Andreas Gampe833a4852014-05-21 18:46:59 -0700635
Alex Lighta59dd802014-07-02 16:28:08 -0700636 const OatFile* OpenOatFileFromDexLocation(const std::string& dex_location,
637 InstructionSet isa,
638 bool* already_opened,
639 bool* obsolete_file_cleanup_failed,
640 std::vector<std::string>* error_msg)
641 LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
642
Alex Light9dcc4572014-08-14 14:16:26 -0700643 const OatFile* GetInterpretedOnlyOat(const std::string& oat_path,
644 InstructionSet isa,
645 std::string* error_msg);
646
Alex Lighta59dd802014-07-02 16:28:08 -0700647 const OatFile* PatchAndRetrieveOat(const std::string& input, const std::string& output,
648 const std::string& image_location, InstructionSet isa,
649 std::string* error_msg)
650 LOCKS_EXCLUDED(Locks::mutator_lock_);
651
Andreas Gampe7ba64962014-10-23 11:37:40 -0700652 bool CheckOatFile(const Runtime* runtime, const OatFile* oat_file, InstructionSet isa,
Alex Lighta59dd802014-07-02 16:28:08 -0700653 bool* checksum_verified, std::string* error_msg);
Alex Lighta59dd802014-07-02 16:28:08 -0700654
Andreas Gampe833a4852014-05-21 18:46:59 -0700655 // Note: will not register the oat file.
656 const OatFile* FindOatFileInOatLocationForDexFile(const char* dex_location,
657 uint32_t dex_location_checksum,
658 const char* oat_location,
659 std::string* error_msg)
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700660 LOCKS_EXCLUDED(dex_lock_);
Ian Rogerse3359f72013-06-11 15:14:11 -0700661
Andreas Gampe833a4852014-05-21 18:46:59 -0700662 // Creates the oat file from the dex_location to the oat_location. Needs a file descriptor for
663 // the file to be written, which is assumed to be under a lock.
664 const OatFile* CreateOatFileForDexLocation(const char* dex_location,
665 int fd, const char* oat_location,
666 std::vector<std::string>* error_msgs)
667 LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
668
669 // Finds an OatFile that contains a DexFile for the given a DexFile location.
670 //
671 // Note 1: this will not check open oat files, which are assumed to be stale when this is run.
672 // Note 2: Does not register the oat file. It is the caller's job to register if the file is to
673 // be kept.
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100674 const OatFile* FindOatFileContainingDexFileFromDexLocation(const char* dex_location,
675 const uint32_t* dex_location_checksum,
Andreas Gampe833a4852014-05-21 18:46:59 -0700676 InstructionSet isa,
Calin Juravlec54aea72014-07-16 14:45:03 +0100677 std::vector<std::string>* error_msgs,
678 bool* obsolete_file_cleanup_failed)
Andreas Gampe833a4852014-05-21 18:46:59 -0700679 LOCKS_EXCLUDED(dex_lock_, Locks::mutator_lock_);
680
Calin Juravle621962a2014-09-02 15:53:55 +0100681 // Verifies:
682 // - that the oat file contains the dex file (with a matching checksum, which may be null if the
683 // file was pre-opted)
684 // - the checksums of the oat file (against the image space)
685 // - the checksum of the dex file against dex_location_checksum
686 // - that the dex file can be opened
687 // Returns true iff all verification succeed.
688 //
689 // The dex_location is the dex location as stored in the oat file header.
690 // (see DexFile::GetDexCanonicalLocation for a description of location conventions)
Alex Lighta59dd802014-07-02 16:28:08 -0700691 bool VerifyOatWithDexFile(const OatFile* oat_file, const char* dex_location,
Calin Juravle621962a2014-09-02 15:53:55 +0100692 const uint32_t* dex_location_checksum,
Alex Lighta59dd802014-07-02 16:28:08 -0700693 std::string* error_msg);
Brian Carlstromfad71432011-10-16 20:25:10 -0700694
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700695 mirror::ArtMethod* CreateProxyConstructor(Thread* self, Handle<mirror::Class> klass,
Brian Carlstromea46f952013-07-30 01:26:50 -0700696 mirror::Class* proxy_class)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700697 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700698 mirror::ArtMethod* CreateProxyMethod(Thread* self, Handle<mirror::Class> klass,
699 Handle<mirror::ArtMethod> prototype)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700700 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Jesse Wilson95caa792011-10-12 18:14:17 -0400701
Andreas Gampe48498592014-09-10 19:48:05 -0700702 // Ensures that methods have the kAccPreverified bit set. We use the kAccPreverfied bit on the
703 // class access flags to determine whether this has been done before.
Andreas Gampe5a4b8a22014-09-11 08:30:08 -0700704 void EnsurePreverifiedMethods(Handle<mirror::Class> c)
Andreas Gampe48498592014-09-10 19:48:05 -0700705 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
706
Ian Rogersdbf3be02014-08-29 15:40:08 -0700707 mirror::Class* LookupClassFromTableLocked(const char* descriptor,
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800708 mirror::ClassLoader* class_loader,
Ian Rogersdbf3be02014-08-29 15:40:08 -0700709 size_t hash)
710 SHARED_LOCKS_REQUIRED(Locks::classlinker_classes_lock_, Locks::mutator_lock_);
711
712 mirror::Class* UpdateClass(const char* descriptor, mirror::Class* klass, size_t hash)
713 LOCKS_EXCLUDED(Locks::classlinker_classes_lock_)
714 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
715
Ian Rogersdbf3be02014-08-29 15:40:08 -0700716 mirror::Class* LookupClassFromImage(const char* descriptor)
717 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
718
719 // EnsureResolved is called to make sure that a class in the class_table_ has been resolved
720 // before returning it to the caller. Its the responsibility of the thread that placed the class
721 // in the table to make it resolved. The thread doing resolution must notify on the class' lock
722 // when resolution has occurred. This happens in mirror::Class::SetStatus. As resolution may
723 // retire a class, the version of the class in the table is returned and this may differ from
724 // the class passed in.
725 mirror::Class* EnsureResolved(Thread* self, const char* descriptor, mirror::Class* klass)
726 WARN_UNUSED SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
727
728 void FixupTemporaryDeclaringClass(mirror::Class* temp_class, mirror::Class* new_class)
729 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
730
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700731 void SetClassRoot(ClassRoot class_root, mirror::Class* klass)
732 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
733
734 // Return the quick generic JNI stub for testing.
735 const void* GetRuntimeQuickGenericJniStub() const;
736
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700737 std::vector<const DexFile*> boot_class_path_;
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700738
Ian Rogers1bf8d4d2013-05-30 00:18:49 -0700739 mutable ReaderWriterMutex dex_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
Andreas Gampec8ccf682014-09-29 20:07:43 -0700740 std::vector<size_t> new_dex_cache_roots_ GUARDED_BY(dex_lock_);
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700741 std::vector<GcRoot<mirror::DexCache>> dex_caches_ GUARDED_BY(dex_lock_);
Elliott Hughesf8349362012-06-18 15:00:06 -0700742 std::vector<const OatFile*> oat_files_ GUARDED_BY(dex_lock_);
Brian Carlstrom47d237a2011-10-18 15:08:33 -0700743
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800744 class ClassDescriptorHashEquals {
745 public:
746 // Same class loader and descriptor.
747 std::size_t operator()(const GcRoot<mirror::Class>& root) const NO_THREAD_SAFETY_ANALYSIS;
748 bool operator()(const GcRoot<mirror::Class>& a, const GcRoot<mirror::Class>& b)
749 NO_THREAD_SAFETY_ANALYSIS;
750 // Same class loader and descriptor.
751 std::size_t operator()(const std::pair<const char*, mirror::ClassLoader*>& element) const
752 NO_THREAD_SAFETY_ANALYSIS;
753 bool operator()(const GcRoot<mirror::Class>& a,
754 const std::pair<const char*, mirror::ClassLoader*>& b)
755 NO_THREAD_SAFETY_ANALYSIS;
756 // Same descriptor.
757 bool operator()(const GcRoot<mirror::Class>& a, const char* descriptor)
758 NO_THREAD_SAFETY_ANALYSIS;
759 std::size_t operator()(const char* descriptor) const NO_THREAD_SAFETY_ANALYSIS;
760 };
761 class GcRootEmptyFn {
762 public:
763 void MakeEmpty(GcRoot<mirror::Class>& item) const {
764 item = GcRoot<mirror::Class>();
765 }
766 bool IsEmpty(const GcRoot<mirror::Class>& item) const {
767 return item.IsNull();
768 }
769 };
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700770
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800771 // hash set which hashes class descriptor, and compares descriptors nad class loaders. Results
772 // should be compared for a matching Class descriptor and class loader.
773 typedef HashSet<GcRoot<mirror::Class>, GcRootEmptyFn, ClassDescriptorHashEquals,
774 ClassDescriptorHashEquals, TrackingAllocator<GcRoot<mirror::Class>, kAllocatorTagClassTable>>
775 Table;
Hiroshi Yamauchia91a4bc2014-06-13 16:44:55 -0700776 // This contains strong roots. To enable concurrent root scanning of
777 // the class table, be careful to use a read barrier when accessing this.
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700778 Table class_table_ GUARDED_BY(Locks::classlinker_classes_lock_);
Mathieu Chartierc2e20622014-11-03 11:41:47 -0800779 Table pre_zygote_class_table_ GUARDED_BY(Locks::classlinker_classes_lock_);
780 std::vector<GcRoot<mirror::Class>> new_class_roots_;
Elliott Hughesf8349362012-06-18 15:00:06 -0700781
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700782 // Do we need to search dex caches to find image classes?
783 bool dex_cache_image_class_lookup_required_;
784 // Number of times we've searched dex caches for a class. After a certain number of misses we move
785 // the classes into the class_table_ to avoid dex cache based searches.
Ian Rogers68b56852014-08-29 20:19:11 -0700786 Atomic<uint32_t> failed_dex_cache_class_lookups_;
Ian Rogers7dfb28c2013-08-22 08:18:36 -0700787
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700788 // Well known mirror::Class roots.
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700789 GcRoot<mirror::ObjectArray<mirror::Class>> class_roots_;
Brian Carlstrom913af1b2011-07-23 21:41:13 -0700790
Ian Rogers98379392014-02-24 16:53:16 -0800791 // The interface table used by all arrays.
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700792 GcRoot<mirror::IfTable> array_iftable_;
Carl Shapiro565f5072011-07-10 13:39:43 -0700793
Ian Rogers98379392014-02-24 16:53:16 -0800794 // A cache of the last FindArrayClass results. The cache serves to avoid creating array class
795 // descriptors for the sake of performing FindClass.
796 static constexpr size_t kFindArrayCacheSize = 16;
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700797 GcRoot<mirror::Class> find_array_class_cache_[kFindArrayCacheSize];
Ian Rogers98379392014-02-24 16:53:16 -0800798 size_t find_array_class_cache_next_victim_;
799
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700800 bool init_done_;
Mathieu Chartier893263b2014-03-04 11:07:42 -0800801 bool log_new_dex_caches_roots_ GUARDED_BY(dex_lock_);
802 bool log_new_class_table_roots_ GUARDED_BY(Locks::classlinker_classes_lock_);
Brian Carlstrom75cb3b42011-07-28 02:13:36 -0700803
Elliott Hughescf4c6c42011-09-01 15:16:42 -0700804 InternTable* intern_table_;
805
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700806 // Trampolines within the image the bounce to runtime entrypoints. Done so that there is a single
807 // patch point within the image. TODO: make these proper relocations.
Jeff Hao0aba0ba2013-06-03 14:49:28 -0700808 const void* portable_resolution_trampoline_;
809 const void* quick_resolution_trampoline_;
Jeff Hao88474b42013-10-23 16:24:40 -0700810 const void* portable_imt_conflict_trampoline_;
811 const void* quick_imt_conflict_trampoline_;
Andreas Gampe2da88232014-02-27 12:26:20 -0800812 const void* quick_generic_jni_trampoline_;
Vladimir Marko8a630572014-04-09 18:45:35 +0100813 const void* quick_to_interpreter_bridge_trampoline_;
Jeff Hao0aba0ba2013-06-03 14:49:28 -0700814
Mathieu Chartier2d721012014-11-10 11:08:06 -0800815 // Image pointer size.
816 size_t image_pointer_size_;
817
Brian Carlstrom34f426c2011-10-04 12:58:02 -0700818 friend class ImageWriter; // for GetClassRoots
Alex Lighta59dd802014-07-02 16:28:08 -0700819 friend class ImageDumper; // for FindOpenedOatFileFromOatLocation
820 friend class ElfPatcher; // for FindOpenedOatFileForDexFile & FindOpenedOatFileFromOatLocation
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700821 friend class JniCompilerTest; // for GetRuntimeQuickGenericJniStub
Nicolas Geoffray4fcdc942014-07-22 10:48:00 +0100822 friend class NoDex2OatTest; // for FindOpenedOatFileForDexFile
Alex Light9dcc4572014-08-14 14:16:26 -0700823 friend class NoPatchoatTest; // for FindOpenedOatFileForDexFile
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700824 ART_FRIEND_TEST(mirror::DexCacheTest, Open); // for AllocDexCache
825
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700826 DISALLOW_COPY_AND_ASSIGN(ClassLinker);
827};
828
829} // namespace art
830
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700831#endif // ART_RUNTIME_CLASS_LINKER_H_