Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_CLASS_LINKER_H_ |
| 18 | #define ART_RUNTIME_CLASS_LINKER_H_ |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 20 | #include <string> |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 21 | #include <utility> |
| 22 | #include <vector> |
| 23 | |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 24 | #include "base/macros.h" |
Elliott Hughes | 76b6167 | 2012-12-12 17:47:30 -0800 | [diff] [blame] | 25 | #include "base/mutex.h" |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 26 | #include "dex_file.h" |
Elliott Hughes | e5448b5 | 2012-01-18 16:44:06 -0800 | [diff] [blame] | 27 | #include "gtest/gtest.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 28 | #include "root_visitor.h" |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 29 | #include "oat_file.h" |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 30 | |
| 31 | namespace art { |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 32 | namespace gc { |
| 33 | namespace space { |
| 34 | class ImageSpace; |
| 35 | } // namespace space |
| 36 | } // namespace gc |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 37 | namespace mirror { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 38 | class ClassLoader; |
| 39 | class DexCache; |
| 40 | class DexCacheTest_Open_Test; |
| 41 | class IfTable; |
| 42 | template<class T> class ObjectArray; |
| 43 | class StackTraceElement; |
| 44 | } // namespace mirror |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 45 | |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 46 | class InternTable; |
Brian Carlstrom | d1422f8 | 2011-09-28 11:37:09 -0700 | [diff] [blame] | 47 | class ObjectLock; |
Ian Rogers | 1f53934 | 2012-10-03 21:09:42 -0700 | [diff] [blame] | 48 | template<class T> class SirtRef; |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 49 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 50 | typedef bool (ClassVisitor)(mirror::Class* c, void* arg); |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 51 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 52 | class ClassLinker { |
| 53 | public: |
Ian Rogers | 1f53934 | 2012-10-03 21:09:42 -0700 | [diff] [blame] | 54 | // Creates the class linker by bootstrapping from dex files. |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 55 | static ClassLinker* CreateFromCompiler(const std::vector<const DexFile*>& boot_class_path, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 56 | InternTable* intern_table) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 57 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 58 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 59 | // Creates the class linker from an image. |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 60 | static ClassLinker* CreateFromImage(InternTable* intern_table) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 61 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 62 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 63 | ~ClassLinker(); |
Carl Shapiro | 565f507 | 2011-07-10 13:39:43 -0700 | [diff] [blame] | 64 | |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 65 | // Finds a class by its descriptor, loading it if necessary. |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 66 | // If class_loader is null, searches boot_class_path_. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 67 | mirror::Class* FindClass(const char* descriptor, mirror::ClassLoader* class_loader) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 68 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 69 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 70 | mirror::Class* FindSystemClass(const char* descriptor) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 71 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 72 | |
| 73 | // Define a new a class based on a ClassDef from a DexFile |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 74 | mirror::Class* DefineClass(const StringPiece& descriptor, mirror::ClassLoader* class_loader, |
| 75 | const DexFile& dex_file, const DexFile::ClassDef& dex_class_def) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 76 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 64bf5a3 | 2011-09-20 14:43:12 -0700 | [diff] [blame] | 77 | |
| 78 | // Finds a class by its descriptor, returning NULL if it isn't wasn't loaded |
| 79 | // by the given 'class_loader'. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 80 | mirror::Class* LookupClass(const char* descriptor, const mirror::ClassLoader* class_loader) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 81 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) |
| 82 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 83 | |
Elliott Hughes | 6fa602d | 2011-12-02 17:54:25 -0800 | [diff] [blame] | 84 | // Finds all the classes with the given descriptor, regardless of ClassLoader. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 85 | void LookupClasses(const char* descriptor, std::vector<mirror::Class*>& classes) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 86 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) |
| 87 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 6fa602d | 2011-12-02 17:54:25 -0800 | [diff] [blame] | 88 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 89 | mirror::Class* FindPrimitiveClass(char type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 90 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 91 | // General class unloading is not supported, this is used to prune |
| 92 | // unwanted classes during image writing. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 93 | bool RemoveClass(const char* descriptor, const mirror::ClassLoader* class_loader) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 94 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) |
| 95 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 96 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 97 | void DumpAllClasses(int flags) const |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 98 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) |
| 99 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 9d5ccec | 2011-09-19 13:19:50 -0700 | [diff] [blame] | 100 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 101 | void DumpForSigQuit(std::ostream& os) const |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 102 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_); |
Elliott Hughes | cac6cc7 | 2011-11-03 20:31:21 -0700 | [diff] [blame] | 103 | |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 104 | size_t NumLoadedClasses() const LOCKS_EXCLUDED(Locks::classlinker_classes_lock_); |
Elliott Hughes | e27955c | 2011-08-26 15:21:24 -0700 | [diff] [blame] | 105 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 106 | // Resolve a String with the given index from the DexFile, storing the |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 107 | // result in the DexCache. The referrer is used to identify the |
| 108 | // target DexCache and ClassLoader to use for resolution. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 109 | mirror::String* ResolveString(uint32_t string_idx, const mirror::ArtMethod* referrer) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 110 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 111 | |
| 112 | // Resolve a String with the given index from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 113 | // result in the DexCache. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 114 | mirror::String* ResolveString(const DexFile& dex_file, uint32_t string_idx, |
| 115 | mirror::DexCache* dex_cache) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 116 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 117 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 118 | // Resolve a Type with the given index from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 119 | // result in the DexCache. The referrer is used to identity the |
| 120 | // target DexCache and ClassLoader to use for resolution. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 121 | mirror::Class* ResolveType(const DexFile& dex_file, uint16_t type_idx, |
| 122 | const mirror::Class* referrer) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 123 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 124 | return ResolveType(dex_file, |
| 125 | type_idx, |
| 126 | referrer->GetDexCache(), |
| 127 | referrer->GetClassLoader()); |
| 128 | } |
| 129 | |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 130 | // Resolve a Type with the given index from the DexFile, storing the |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 131 | // result in the DexCache. The referrer is used to identify the |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 132 | // target DexCache and ClassLoader to use for resolution. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 133 | mirror::Class* ResolveType(uint16_t type_idx, const mirror::ArtMethod* referrer) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 134 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 135 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 136 | mirror::Class* ResolveType(uint16_t type_idx, const mirror::ArtField* referrer) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 137 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | b63ec39 | 2011-08-27 17:38:27 -0700 | [diff] [blame] | 138 | |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 139 | // Resolve a type with the given ID from the DexFile, storing the |
| 140 | // result in DexCache. The ClassLoader is used to search for the |
| 141 | // type, since it may be referenced from but not contained within |
| 142 | // the given DexFile. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 143 | mirror::Class* ResolveType(const DexFile& dex_file, |
| 144 | uint16_t type_idx, |
| 145 | mirror::DexCache* dex_cache, |
| 146 | mirror::ClassLoader* class_loader) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 147 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 148 | |
| 149 | // Resolve a method with a given ID from the DexFile, storing the |
| 150 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 151 | // in ResolveType. What is unique is the method type argument which |
| 152 | // is used to determine if this method is a direct, static, or |
| 153 | // virtual method. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 154 | mirror::ArtMethod* ResolveMethod(const DexFile& dex_file, |
| 155 | uint32_t method_idx, |
| 156 | mirror::DexCache* dex_cache, |
| 157 | mirror::ClassLoader* class_loader, |
| 158 | const mirror::ArtMethod* referrer, |
| 159 | InvokeType type) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 160 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 161 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 162 | mirror::ArtMethod* ResolveMethod(uint32_t method_idx, const mirror::ArtMethod* referrer, |
| 163 | InvokeType type) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 164 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 165 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 166 | mirror::ArtField* ResolveField(uint32_t field_idx, const mirror::ArtMethod* referrer, |
| 167 | bool is_static) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 168 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | b9edb84 | 2011-08-28 16:31:06 -0700 | [diff] [blame] | 169 | |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 170 | // Resolve a field with a given ID from the DexFile, storing the |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 171 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 172 | // in ResolveType. What is unique is the is_static argument which is |
| 173 | // used to determine if we are resolving a static or non-static |
| 174 | // field. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 175 | mirror::ArtField* ResolveField(const DexFile& dex_file, |
| 176 | uint32_t field_idx, |
| 177 | mirror::DexCache* dex_cache, |
| 178 | mirror::ClassLoader* class_loader, |
| 179 | bool is_static) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 180 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 181 | |
Ian Rogers | b067ac2 | 2011-12-13 18:05:09 -0800 | [diff] [blame] | 182 | // Resolve a field with a given ID from the DexFile, storing the |
| 183 | // result in DexCache. The ClassLinker and ClassLoader are used as |
| 184 | // in ResolveType. No is_static argument is provided so that Java |
| 185 | // field resolution semantics are followed. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 186 | mirror::ArtField* ResolveFieldJLS(const DexFile& dex_file, |
| 187 | uint32_t field_idx, |
| 188 | mirror::DexCache* dex_cache, |
| 189 | mirror::ClassLoader* class_loader) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 190 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | b067ac2 | 2011-12-13 18:05:09 -0800 | [diff] [blame] | 191 | |
Ian Rogers | ad25ac5 | 2011-10-04 19:13:33 -0700 | [diff] [blame] | 192 | // Get shorty from method index without resolution. Used to do handlerization. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 193 | const char* MethodShorty(uint32_t method_idx, mirror::ArtMethod* referrer, uint32_t* length) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 194 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | ad25ac5 | 2011-10-04 19:13:33 -0700 | [diff] [blame] | 195 | |
Elliott Hughes | f4c21c9 | 2011-08-19 17:31:31 -0700 | [diff] [blame] | 196 | // Returns true on success, false if there's an exception pending. |
Brian Carlstrom | 25c3325 | 2011-09-18 15:58:35 -0700 | [diff] [blame] | 197 | // can_run_clinit=false allows the compiler to attempt to init a class, |
| 198 | // given the restriction that no <clinit> execution is possible. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 199 | bool EnsureInitialized(mirror::Class* c, bool can_run_clinit, bool can_init_fields) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 200 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 201 | |
Elliott Hughes | 2a20cfd | 2011-09-23 19:30:41 -0700 | [diff] [blame] | 202 | // Initializes classes that have instances in the image but that have |
| 203 | // <clinit> methods so they could not be initialized by the compiler. |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 204 | void RunRootClinits() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 2a20cfd | 2011-09-23 19:30:41 -0700 | [diff] [blame] | 205 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 206 | void RegisterDexFile(const DexFile& dex_file) |
| 207 | LOCKS_EXCLUDED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 208 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 209 | void RegisterDexFile(const DexFile& dex_file, SirtRef<mirror::DexCache>& dex_cache) |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 210 | LOCKS_EXCLUDED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 211 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 212 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 213 | void RegisterOatFile(const OatFile& oat_file) |
| 214 | LOCKS_EXCLUDED(dex_lock_); |
Brian Carlstrom | 866c862 | 2012-01-06 16:35:13 -0800 | [diff] [blame] | 215 | |
Brian Carlstrom | 8a48741 | 2011-08-29 20:08:52 -0700 | [diff] [blame] | 216 | const std::vector<const DexFile*>& GetBootClassPath() { |
| 217 | return boot_class_path_; |
| 218 | } |
| 219 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 220 | void VisitClasses(ClassVisitor* visitor, void* arg) const |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 221 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 222 | // Less efficient variant of VisitClasses that doesn't hold the classlinker_classes_lock_ |
| 223 | // when calling the visitor. |
| 224 | void VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* arg) const |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 225 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_); |
Elliott Hughes | a215526 | 2011-11-16 16:26:58 -0800 | [diff] [blame] | 226 | |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 227 | void VisitRoots(RootVisitor* visitor, void* arg, bool clean_dirty) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 228 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_, dex_lock_); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 229 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 230 | mirror::DexCache* FindDexCache(const DexFile& dex_file) const |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 231 | LOCKS_EXCLUDED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 232 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 233 | bool IsDexFileRegistered(const DexFile& dex_file) const |
| 234 | LOCKS_EXCLUDED(dex_lock_); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 235 | void FixupDexCaches(mirror::ArtMethod* resolution_method) const |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 236 | LOCKS_EXCLUDED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 237 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 238 | |
jeffhao | 262bf46 | 2011-10-20 18:36:32 -0700 | [diff] [blame] | 239 | // Generate an oat file from a dex file |
Brian Carlstrom | d601af8 | 2012-01-06 10:15:19 -0800 | [diff] [blame] | 240 | bool GenerateOatFile(const std::string& dex_filename, |
| 241 | int oat_fd, |
| 242 | const std::string& oat_cache_filename); |
jeffhao | 262bf46 | 2011-10-20 18:36:32 -0700 | [diff] [blame] | 243 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 244 | const OatFile* FindOatFileFromOatLocation(const std::string& location) |
| 245 | LOCKS_EXCLUDED(dex_lock_); |
| 246 | |
| 247 | const OatFile* FindOatFileFromOatLocationLocked(const std::string& location) |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 248 | SHARED_LOCKS_REQUIRED(dex_lock_); |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 249 | |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 250 | // Finds the oat file for a dex location, generating the oat file if |
| 251 | // it is missing or out of date. Returns the DexFile from within the |
| 252 | // created oat file. |
| 253 | const DexFile* FindOrCreateOatFileForDexLocation(const std::string& dex_location, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 254 | const std::string& oat_location) |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 255 | LOCKS_EXCLUDED(dex_lock_) |
| 256 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 257 | const DexFile* FindOrCreateOatFileForDexLocationLocked(const std::string& dex_location, |
| 258 | const std::string& oat_location) |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 259 | EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) |
| 260 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 261 | // Find a DexFile within an OatFile given a DexFile location. Note |
| 262 | // that this returns null if the location checksum of the DexFile |
| 263 | // does not match the OatFile. |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 264 | const DexFile* FindDexFileInOatFileFromDexLocation(const std::string& location) |
| 265 | LOCKS_EXCLUDED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 266 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 267 | |
jeffhao | f6174e8 | 2012-01-31 16:14:17 -0800 | [diff] [blame] | 268 | |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 269 | // Returns true if oat file contains the dex file with the given location and checksum. |
Brian Carlstrom | afe2551 | 2012-06-27 17:02:58 -0700 | [diff] [blame] | 270 | static bool VerifyOatFileChecksums(const OatFile* oat_file, |
| 271 | const std::string& dex_location, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 272 | uint32_t dex_location_checksum) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 273 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | afe2551 | 2012-06-27 17:02:58 -0700 | [diff] [blame] | 274 | |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 275 | // TODO: replace this with multiple methods that allocate the correct managed type. |
Shih-wei Liao | 4417536 | 2011-08-28 16:59:17 -0700 | [diff] [blame] | 276 | template <class T> |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 277 | mirror::ObjectArray<T>* AllocObjectArray(Thread* self, size_t length) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 278 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Shih-wei Liao | 55df06b | 2011-08-26 14:39:27 -0700 | [diff] [blame] | 279 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 280 | mirror::ObjectArray<mirror::Class>* AllocClassArray(Thread* self, size_t length) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 281 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
jeffhao | 98eacac | 2011-09-14 16:11:53 -0700 | [diff] [blame] | 282 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 283 | mirror::ObjectArray<mirror::String>* AllocStringArray(Thread* self, size_t length) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 284 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 285 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 286 | mirror::ObjectArray<mirror::ArtMethod>* AllocArtMethodArray(Thread* self, size_t length) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 287 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 288 | |
| 289 | mirror::IfTable* AllocIfTable(Thread* self, size_t ifcount) |
| 290 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 291 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 292 | mirror::ObjectArray<mirror::ArtField>* AllocArtFieldArray(Thread* self, size_t length) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 293 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 294 | |
| 295 | mirror::ObjectArray<mirror::StackTraceElement>* AllocStackTraceElementArray(Thread* self, |
| 296 | size_t length) |
| 297 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 298 | |
| 299 | void VerifyClass(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 300 | bool VerifyClassUsingOatFile(const DexFile& dex_file, mirror::Class* klass, |
| 301 | mirror::Class::Status& oat_file_class_status) |
| 302 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 303 | void ResolveClassExceptionHandlerTypes(const DexFile& dex_file, mirror::Class* klass) |
| 304 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 305 | void ResolveMethodExceptionHandlerTypes(const DexFile& dex_file, mirror::ArtMethod* klass) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 306 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 307 | |
| 308 | mirror::Class* CreateProxyClass(mirror::String* name, mirror::ObjectArray<mirror::Class>* interfaces, |
| 309 | mirror::ClassLoader* loader, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 310 | mirror::ObjectArray<mirror::ArtMethod>* methods, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 311 | mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >* throws) |
| 312 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 313 | std::string GetDescriptorForProxy(const mirror::Class* proxy_class) |
| 314 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 315 | mirror::ArtMethod* FindMethodForProxy(const mirror::Class* proxy_class, |
| 316 | const mirror::ArtMethod* proxy_method) |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 317 | LOCKS_EXCLUDED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 318 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 319 | |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 320 | // Get the oat code for a method when its class isn't yet initialized |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 321 | const void* GetOatCodeFor(const mirror::ArtMethod* method) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 322 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 323 | |
Mathieu Chartier | e35517a | 2012-10-30 18:49:55 -0700 | [diff] [blame] | 324 | // Get the oat code for a method from a method index. |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 325 | const void* GetOatCodeFor(const DexFile& dex_file, uint32_t method_idx) |
| 326 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mathieu Chartier | e35517a | 2012-10-30 18:49:55 -0700 | [diff] [blame] | 327 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 328 | pid_t GetClassesLockOwner(); // For SignalCatcher. |
| 329 | pid_t GetDexLockOwner(); // For SignalCatcher. |
Brian Carlstrom | 24a3c2e | 2011-10-17 18:07:52 -0700 | [diff] [blame] | 330 | |
Mathieu Chartier | 9ebae1f | 2012-10-15 17:38:16 -0700 | [diff] [blame] | 331 | bool IsDirty() const { |
| 332 | return is_dirty_; |
| 333 | } |
| 334 | |
| 335 | void Dirty() { |
| 336 | is_dirty_ = true; |
| 337 | } |
| 338 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 339 | const void* GetPortableResolutionTrampoline() const { |
| 340 | return portable_resolution_trampoline_; |
| 341 | } |
| 342 | |
| 343 | const void* GetQuickResolutionTrampoline() const { |
| 344 | return quick_resolution_trampoline_; |
| 345 | } |
| 346 | |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 347 | InternTable* GetInternTable() const { |
| 348 | return intern_table_; |
| 349 | } |
| 350 | |
| 351 | // Attempts to insert a class into a class table. Returns NULL if |
| 352 | // the class was inserted, otherwise returns an existing class with |
| 353 | // the same descriptor and ClassLoader. |
| 354 | mirror::Class* InsertClass(const StringPiece& descriptor, mirror::Class* klass, bool image_class) |
| 355 | LOCKS_EXCLUDED(Locks::classlinker_classes_lock_) |
| 356 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 357 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 358 | private: |
Elliott Hughes | 4dd9b4d | 2011-12-12 18:29:24 -0800 | [diff] [blame] | 359 | explicit ClassLinker(InternTable*); |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 360 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 361 | const OatFile::OatMethod GetOatMethodFor(const mirror::ArtMethod* method) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 362 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
TDYa127 | 8532191 | 2012-04-01 15:24:56 -0700 | [diff] [blame] | 363 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 364 | // Initialize class linker by bootstraping from dex files |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 365 | void InitFromCompiler(const std::vector<const DexFile*>& boot_class_path) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 366 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 367 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 368 | // Initialize class linker from one or more images. |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 369 | void InitFromImage() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 56d947f | 2013-07-15 13:14:23 -0700 | [diff] [blame] | 370 | OatFile& GetImageOatFile(gc::space::ImageSpace* space) |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 371 | LOCKS_EXCLUDED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 372 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 373 | |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 374 | void FinishInit() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 375 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 376 | // For early bootstrapping by Init |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 377 | mirror::Class* AllocClass(Thread* self, mirror::Class* java_lang_Class, size_t class_size) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 378 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 379 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 380 | // Alloc* convenience functions to avoid needing to pass in mirror::Class* |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 381 | // values that are known to the ClassLinker such as |
| 382 | // kObjectArrayClass and kJavaLangString etc. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 383 | mirror::Class* AllocClass(Thread* self, size_t class_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 384 | mirror::DexCache* AllocDexCache(Thread* self, const DexFile& dex_file) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 385 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 386 | mirror::ArtField* AllocArtField(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 387 | mirror::ArtMethod* AllocArtMethod(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | bdb0391 | 2011-09-14 00:55:44 -0700 | [diff] [blame] | 388 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 389 | mirror::Class* CreatePrimitiveClass(Thread* self, Primitive::Type type) |
| 390 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 391 | mirror::Class* InitializePrimitiveClass(mirror::Class* primitive_class, Primitive::Type type) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 392 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 5b8e4c8 | 2011-09-18 01:38:59 -0700 | [diff] [blame] | 393 | |
Brian Carlstrom | a331b3c | 2011-07-18 17:47:56 -0700 | [diff] [blame] | 394 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 395 | mirror::Class* CreateArrayClass(const std::string& descriptor, mirror::ClassLoader* class_loader) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 396 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | a331b3c | 2011-07-18 17:47:56 -0700 | [diff] [blame] | 397 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 398 | void AppendToBootClassPath(const DexFile& dex_file) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 399 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 400 | void AppendToBootClassPath(const DexFile& dex_file, SirtRef<mirror::DexCache>& dex_cache) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 401 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 402 | |
Elliott Hughes | 5fe594f | 2011-09-08 12:33:17 -0700 | [diff] [blame] | 403 | void ConstructFieldMap(const DexFile& dex_file, const DexFile::ClassDef& dex_class_def, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 404 | mirror::Class* c, SafeMap<uint32_t, mirror::ArtField*>& field_map) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 405 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Elliott Hughes | 5fe594f | 2011-09-08 12:33:17 -0700 | [diff] [blame] | 406 | |
Brian Carlstrom | 4873d46 | 2011-08-21 15:23:39 -0700 | [diff] [blame] | 407 | size_t SizeOfClass(const DexFile& dex_file, |
| 408 | const DexFile::ClassDef& dex_class_def); |
| 409 | |
Brian Carlstrom | f615a61 | 2011-07-23 12:50:34 -0700 | [diff] [blame] | 410 | void LoadClass(const DexFile& dex_file, |
| 411 | const DexFile::ClassDef& dex_class_def, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 412 | SirtRef<mirror::Class>& klass, |
| 413 | mirror::ClassLoader* class_loader) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 414 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 415 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 416 | void LoadField(const DexFile& dex_file, const ClassDataItemIterator& it, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 417 | SirtRef<mirror::Class>& klass, SirtRef<mirror::ArtField>& dst) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 418 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 419 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 420 | mirror::ArtMethod* LoadMethod(Thread* self, const DexFile& dex_file, |
| 421 | const ClassDataItemIterator& dex_method, |
| 422 | SirtRef<mirror::Class>& klass) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 423 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 934486c | 2011-07-12 23:42:50 -0700 | [diff] [blame] | 424 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 425 | void FixupStaticTrampolines(mirror::Class* klass) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 426 | |
| 427 | // Finds the associated oat class for a dex_file and descriptor |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 428 | const OatFile::OatClass* GetOatClass(const DexFile& dex_file, const char* descriptor) |
| 429 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 430 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 431 | void RegisterDexFileLocked(const DexFile& dex_file, SirtRef<mirror::DexCache>& dex_cache) |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 432 | EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 433 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 434 | bool IsDexFileRegisteredLocked(const DexFile& dex_file) const SHARED_LOCKS_REQUIRED(dex_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 435 | void RegisterOatFileLocked(const OatFile& oat_file) EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) |
| 436 | EXCLUSIVE_LOCKS_REQUIRED(dex_lock_); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 437 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 438 | bool InitializeClass(mirror::Class* klass, bool can_run_clinit, bool can_init_statics) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 439 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 440 | bool WaitForInitializeClass(mirror::Class* klass, Thread* self, ObjectLock& lock); |
| 441 | bool ValidateSuperClassDescriptors(const mirror::Class* klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 442 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 443 | bool InitializeSuperClass(mirror::Class* klass, bool can_run_clinit, bool can_init_fields) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 444 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 0045a29 | 2012-03-31 21:08:41 -0700 | [diff] [blame] | 445 | // Initialize static fields, returns true if fields were initialized. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 446 | bool InitializeStaticFields(mirror::Class* klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 447 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 448 | |
Ian Rogers | 595799e | 2012-01-11 17:32:51 -0800 | [diff] [blame] | 449 | bool IsSameDescriptorInDifferentClassContexts(const char* descriptor, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 450 | const mirror::Class* klass1, |
| 451 | const mirror::Class* klass2) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 452 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 453 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 454 | bool IsSameMethodSignatureInDifferentClassContexts(const mirror::ArtMethod* method, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 455 | const mirror::Class* klass1, |
| 456 | const mirror::Class* klass2) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 457 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 458 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 459 | bool LinkClass(SirtRef<mirror::Class>& klass, mirror::ObjectArray<mirror::Class>* interfaces) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 460 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 461 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 462 | bool LinkSuperClass(SirtRef<mirror::Class>& klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 463 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 464 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 465 | bool LoadSuperAndInterfaces(SirtRef<mirror::Class>& klass, const DexFile& dex_file) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 466 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 467 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 468 | bool LinkMethods(SirtRef<mirror::Class>& klass, mirror::ObjectArray<mirror::Class>* interfaces) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 469 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 470 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 471 | bool LinkVirtualMethods(SirtRef<mirror::Class>& klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 472 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 473 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 474 | bool LinkInterfaceMethods(SirtRef<mirror::Class>& klass, |
| 475 | mirror::ObjectArray<mirror::Class>* interfaces) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 476 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 477 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 478 | bool LinkStaticFields(SirtRef<mirror::Class>& klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 479 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 480 | bool LinkInstanceFields(SirtRef<mirror::Class>& klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 481 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 482 | bool LinkFields(SirtRef<mirror::Class>& klass, bool is_static) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 483 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 0cfe1fb | 2011-08-26 03:29:44 -0700 | [diff] [blame] | 484 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 485 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 486 | void CreateReferenceInstanceOffsets(SirtRef<mirror::Class>& klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 487 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 488 | void CreateReferenceStaticOffsets(SirtRef<mirror::Class>& klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 489 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 490 | void CreateReferenceOffsets(SirtRef<mirror::Class>& klass, bool is_static, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 491 | uint32_t reference_offsets) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 492 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 493 | |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 494 | // For use by ImageWriter to find DexCaches for its roots |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 495 | const std::vector<mirror::DexCache*>& GetDexCaches() { |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 496 | return dex_caches_; |
| 497 | } |
| 498 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 499 | const OatFile* FindOpenedOatFileForDexFile(const DexFile& dex_file) |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 500 | LOCKS_EXCLUDED(dex_lock_) |
| 501 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 502 | const OatFile* FindOpenedOatFileFromDexLocation(const std::string& dex_location) |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 503 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, dex_lock_); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 504 | const OatFile* FindOpenedOatFileFromOatLocation(const std::string& oat_location) |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 505 | SHARED_LOCKS_REQUIRED(dex_lock_); |
Ian Rogers | e3359f7 | 2013-06-11 15:14:11 -0700 | [diff] [blame] | 506 | const DexFile* FindDexFileInOatLocation(const std::string& dex_location, |
| 507 | uint32_t dex_location_checksum, |
| 508 | const std::string& oat_location) |
| 509 | EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) |
| 510 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 511 | |
Brian Carlstrom | afe2551 | 2012-06-27 17:02:58 -0700 | [diff] [blame] | 512 | const DexFile* VerifyAndOpenDexFileFromOatFile(const OatFile* oat_file, |
| 513 | const std::string& dex_location, |
| 514 | uint32_t dex_location_checksum) |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 515 | EXCLUSIVE_LOCKS_REQUIRED(dex_lock_) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 516 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | fad7143 | 2011-10-16 20:25:10 -0700 | [diff] [blame] | 517 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 518 | mirror::ArtMethod* CreateProxyConstructor(Thread* self, SirtRef<mirror::Class>& klass, |
| 519 | mirror::Class* proxy_class) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 520 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 521 | mirror::ArtMethod* CreateProxyMethod(Thread* self, SirtRef<mirror::Class>& klass, |
| 522 | SirtRef<mirror::ArtMethod>& prototype) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 523 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Jesse Wilson | 95caa79 | 2011-10-12 18:14:17 -0400 | [diff] [blame] | 524 | |
Brian Carlstrom | 4a96b60 | 2011-07-26 16:40:23 -0700 | [diff] [blame] | 525 | std::vector<const DexFile*> boot_class_path_; |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 526 | |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 527 | mutable ReaderWriterMutex dex_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 528 | std::vector<mirror::DexCache*> dex_caches_ GUARDED_BY(dex_lock_); |
Elliott Hughes | f834936 | 2012-06-18 15:00:06 -0700 | [diff] [blame] | 529 | std::vector<const OatFile*> oat_files_ GUARDED_BY(dex_lock_); |
Brian Carlstrom | 47d237a | 2011-10-18 15:08:33 -0700 | [diff] [blame] | 530 | |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 531 | |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 532 | // multimap from a string hash code of a class descriptor to |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 533 | // mirror::Class* instances. Results should be compared for a matching |
Brian Carlstrom | 9cff8e1 | 2011-08-18 16:47:29 -0700 | [diff] [blame] | 534 | // Class::descriptor_ and Class::class_loader_. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 535 | typedef std::multimap<size_t, mirror::Class*> Table; |
| 536 | Table image_classes_ GUARDED_BY(Locks::classlinker_classes_lock_); |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 537 | Table classes_ GUARDED_BY(Locks::classlinker_classes_lock_); |
Elliott Hughes | f834936 | 2012-06-18 15:00:06 -0700 | [diff] [blame] | 538 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 539 | mirror::Class* LookupClassLocked(const char* descriptor, const mirror::ClassLoader* class_loader, |
| 540 | size_t hash, const Table& classes) |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 541 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::classlinker_classes_lock_); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 542 | |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 543 | // indexes into class_roots_. |
| 544 | // needs to be kept in sync with class_roots_descriptors_. |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 545 | enum ClassRoot { |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 546 | kJavaLangClass, |
| 547 | kJavaLangObject, |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 548 | kClassArrayClass, |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 549 | kObjectArrayClass, |
| 550 | kJavaLangString, |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 551 | kJavaLangDexCache, |
Elliott Hughes | bf61ba3 | 2011-10-11 10:53:09 -0700 | [diff] [blame] | 552 | kJavaLangRefReference, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 553 | kJavaLangReflectArtField, |
| 554 | kJavaLangReflectArtMethod, |
Ian Rogers | 466bb25 | 2011-10-14 03:29:56 -0700 | [diff] [blame] | 555 | kJavaLangReflectProxy, |
Mathieu Chartier | 66f1925 | 2012-09-18 08:57:04 -0700 | [diff] [blame] | 556 | kJavaLangStringArrayClass, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame^] | 557 | kJavaLangReflectArtFieldArrayClass, |
| 558 | kJavaLangReflectArtMethodArrayClass, |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 559 | kJavaLangClassLoader, |
Ian Rogers | 5167c97 | 2012-02-03 10:41:20 -0800 | [diff] [blame] | 560 | kJavaLangThrowable, |
jeffhao | 8cd6dda | 2012-02-22 10:15:34 -0800 | [diff] [blame] | 561 | kJavaLangClassNotFoundException, |
Shih-wei Liao | 55df06b | 2011-08-26 14:39:27 -0700 | [diff] [blame] | 562 | kJavaLangStackTraceElement, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 563 | kPrimitiveBoolean, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 564 | kPrimitiveByte, |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 565 | kPrimitiveChar, |
| 566 | kPrimitiveDouble, |
| 567 | kPrimitiveFloat, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 568 | kPrimitiveInt, |
| 569 | kPrimitiveLong, |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 570 | kPrimitiveShort, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 571 | kPrimitiveVoid, |
Elliott Hughes | d8ddfd5 | 2011-08-15 14:32:53 -0700 | [diff] [blame] | 572 | kBooleanArrayClass, |
| 573 | kByteArrayClass, |
| 574 | kCharArrayClass, |
| 575 | kDoubleArrayClass, |
| 576 | kFloatArrayClass, |
| 577 | kIntArrayClass, |
| 578 | kLongArrayClass, |
| 579 | kShortArrayClass, |
Shih-wei Liao | 55df06b | 2011-08-26 14:39:27 -0700 | [diff] [blame] | 580 | kJavaLangStackTraceElementArrayClass, |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 581 | kClassRootsMax, |
| 582 | }; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 583 | mirror::ObjectArray<mirror::Class>* class_roots_; |
Brian Carlstrom | 913af1b | 2011-07-23 21:41:13 -0700 | [diff] [blame] | 584 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 585 | mirror::Class* GetClassRoot(ClassRoot class_root) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | 74eb46a | 2011-08-02 20:10:14 -0700 | [diff] [blame] | 586 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 587 | void SetClassRoot(ClassRoot class_root, mirror::Class* klass) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 588 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 589 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 590 | mirror::ObjectArray<mirror::Class>* GetClassRoots() { |
Brian Carlstrom | 34f426c | 2011-10-04 12:58:02 -0700 | [diff] [blame] | 591 | DCHECK(class_roots_ != NULL); |
| 592 | return class_roots_; |
| 593 | } |
| 594 | |
Elliott Hughes | 418d20f | 2011-09-22 14:00:39 -0700 | [diff] [blame] | 595 | static const char* class_roots_descriptors_[]; |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 596 | |
| 597 | const char* GetClassRootDescriptor(ClassRoot class_root) { |
| 598 | const char* descriptor = class_roots_descriptors_[class_root]; |
| 599 | CHECK(descriptor != NULL); |
| 600 | return descriptor; |
| 601 | } |
| 602 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 603 | mirror::IfTable* array_iftable_; |
Carl Shapiro | 565f507 | 2011-07-10 13:39:43 -0700 | [diff] [blame] | 604 | |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 605 | bool init_done_; |
Mathieu Chartier | 9ebae1f | 2012-10-15 17:38:16 -0700 | [diff] [blame] | 606 | bool is_dirty_; |
Brian Carlstrom | 75cb3b4 | 2011-07-28 02:13:36 -0700 | [diff] [blame] | 607 | |
Elliott Hughes | cf4c6c4 | 2011-09-01 15:16:42 -0700 | [diff] [blame] | 608 | InternTable* intern_table_; |
| 609 | |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 610 | const void* portable_resolution_trampoline_; |
| 611 | const void* quick_resolution_trampoline_; |
| 612 | |
Brian Carlstrom | 34f426c | 2011-10-04 12:58:02 -0700 | [diff] [blame] | 613 | friend class ImageWriter; // for GetClassRoots |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 614 | FRIEND_TEST(ClassLinkerTest, ClassRootDescriptors); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 615 | FRIEND_TEST(mirror::DexCacheTest, Open); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 616 | FRIEND_TEST(ExceptionTest, FindExceptionHandler); |
| 617 | FRIEND_TEST(ObjectTest, AllocObjectArray); |
Carl Shapiro | 0e5d75d | 2011-07-06 18:28:37 -0700 | [diff] [blame] | 618 | DISALLOW_COPY_AND_ASSIGN(ClassLinker); |
| 619 | }; |
| 620 | |
| 621 | } // namespace art |
| 622 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 623 | #endif // ART_RUNTIME_CLASS_LINKER_H_ |