blob: c545a9b7d5ddc2ccb3cc22340b6c6869ab568714 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
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 */
16
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_MIRROR_CLASS_H_
18#define ART_RUNTIME_MIRROR_CLASS_H_
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019
Andreas Gampe3b7dc352017-06-06 20:02:03 -070020#include "base/bit_utils.h"
Andreas Gampe542451c2016-07-26 09:02:02 -070021#include "base/enums.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070022#include "base/iteration_range.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070023#include "class_flags.h"
Andreas Gampeee5303f2017-08-31 15:34:42 -070024#include "class_status.h"
Mathieu Chartierf8322842014-05-16 10:59:25 -070025#include "dex_file.h"
Andreas Gampea5b09a62016-11-17 15:21:22 -080026#include "dex_file_types.h"
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070027#include "gc/allocator_type.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070028#include "gc_root.h"
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +000029#include "imtable.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030#include "modifiers.h"
31#include "object.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070032#include "object_array.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080033#include "primitive.h"
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070034#include "read_barrier_option.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070035#include "stride_iterator.h"
Alex Lighteb7c1442015-08-31 13:17:42 -070036#include "thread.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070037#include "utils.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080038
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080039namespace art {
40
Mathieu Chartierc7853442015-03-27 14:35:38 -070041class ArtField;
Mathieu Chartiere401d142015-04-22 13:56:20 -070042class ArtMethod;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080043struct ClassOffsets;
Andreas Gampe5a4b8a22014-09-11 08:30:08 -070044template<class T> class Handle;
Andreas Gampe04c6ab92017-06-08 21:49:14 -070045enum InvokeType : uint32_t;
Mathieu Chartier54d220e2015-07-30 16:20:06 -070046template<typename T> class LengthPrefixedArray;
Alex Lighte64300b2015-12-15 15:02:47 -080047template<typename T> class ArraySlice;
Ian Rogersd91d6d62013-09-25 20:26:14 -070048class Signature;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080049class StringPiece;
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070050template<size_t kNumReferences> class PACKED(4) StackHandleScope;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080051
52namespace mirror {
53
Alex Lightd6251582016-10-31 11:12:30 -070054class ClassExt;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080055class ClassLoader;
Mathieu Chartierfc58af42015-04-16 18:00:39 -070056class Constructor;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080057class DexCache;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080058class IfTable;
Andreas Gampebc4d2182016-02-22 10:03:12 -080059class Method;
Narayan Kamathc38a6f82016-09-29 17:07:20 +010060template <typename T> struct PACKED(8) DexCachePair;
Christina Wadsworthbf44e0e2016-08-18 10:37:42 -070061
Mathieu Chartier28bd2e42016-10-04 13:54:57 -070062using StringDexCachePair = DexCachePair<String>;
Narayan Kamathc38a6f82016-09-29 17:07:20 +010063using StringDexCacheType = std::atomic<StringDexCachePair>;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080064
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080065// C++ mirror of java.lang.Class
Mingyao Yang98d1cc82014-05-15 17:02:16 -070066class MANAGED Class FINAL : public Object {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080067 public:
Ian Rogerscdc1aaf2014-10-09 13:21:38 -070068 // A magic value for reference_instance_offsets_. Ignore the bits and walk the super chain when
69 // this is the value.
70 // [This is an unlikely "natural" value, since it would be 30 non-ref instance fields followed by
71 // 2 ref instance fields.]
72 static constexpr uint32_t kClassWalkSuper = 0xC0000000;
73
Mathieu Chartier8261d022016-08-08 09:41:04 -070074 // Shift primitive type by kPrimitiveTypeSizeShiftShift to get the component type size shift
75 // Used for computing array size as follows:
76 // array_bytes = header_size + (elements << (primitive_type >> kPrimitiveTypeSizeShiftShift))
77 static constexpr uint32_t kPrimitiveTypeSizeShiftShift = 16;
78 static constexpr uint32_t kPrimitiveTypeMask = (1u << kPrimitiveTypeSizeShiftShift) - 1;
79
Andreas Gampeee5303f2017-08-31 15:34:42 -070080 // Make ClassStatus available as Class::Status.
81 using Status = ClassStatus;
82
83 // Required for a minimal change. Fix up and remove in a future change.
84 static constexpr Status kStatusRetired = Status::kStatusRetired;
85 static constexpr Status kStatusErrorResolved = Status::kStatusErrorResolved;
86 static constexpr Status kStatusErrorUnresolved = Status::kStatusErrorUnresolved;
87 static constexpr Status kStatusNotReady = Status::kStatusNotReady;
88 static constexpr Status kStatusIdx = Status::kStatusIdx;
89 static constexpr Status kStatusLoaded = Status::kStatusLoaded;
90 static constexpr Status kStatusResolving = Status::kStatusResolving;
91 static constexpr Status kStatusResolved = Status::kStatusResolved;
92 static constexpr Status kStatusVerifying = Status::kStatusVerifying;
93 static constexpr Status kStatusRetryVerificationAtRuntime =
94 Status::kStatusRetryVerificationAtRuntime;
95 static constexpr Status kStatusVerifyingAtRuntime = Status::kStatusVerifyingAtRuntime;
96 static constexpr Status kStatusVerified = Status::kStatusVerified;
97 static constexpr Status kStatusSuperclassValidated = Status::kStatusSuperclassValidated;
98 static constexpr Status kStatusInitializing = Status::kStatusInitializing;
99 static constexpr Status kStatusInitialized = Status::kStatusInitialized;
100 static constexpr Status kStatusMax = Status::kStatusMax;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800101
Mathieu Chartier4e305412014-02-19 10:54:44 -0800102 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700103 Status GetStatus() REQUIRES_SHARED(Locks::mutator_lock_) {
Igor Murashkin86083f72017-10-27 10:59:04 -0700104 // Avoid including "subtype_check_bits_and_status.h" to get the field.
105 // The ClassStatus is always in the least-significant bits of status_.
106 return static_cast<Status>(static_cast<uint8_t>(
107 static_cast<uint32_t>(GetField32Volatile<kVerifyFlags>(StatusOffset())) & 0xff));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800108 }
109
Hiroshi Yamauchi5b783e62015-03-18 17:20:11 -0700110 // This is static because 'this' may be moved by GC.
111 static void SetStatus(Handle<Class> h_this, Status new_status, Thread* self)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700112 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800113
Ian Rogers5ddb4102014-01-07 08:58:46 -0800114 static MemberOffset StatusOffset() {
Igor Murashkin86083f72017-10-27 10:59:04 -0700115 return MemberOffset(OFFSET_OF_OBJECT_MEMBER(Class, status_));
Ian Rogers5ddb4102014-01-07 08:58:46 -0800116 }
117
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700118 // Returns true if the class has been retired.
119 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700120 bool IsRetired() REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700121 return GetStatus<kVerifyFlags>() == kStatusRetired;
122 }
123
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800124 // Returns true if the class has failed to link.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800125 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Vladimir Marko72ab6842017-01-20 19:32:50 +0000126 bool IsErroneousUnresolved() REQUIRES_SHARED(Locks::mutator_lock_) {
127 return GetStatus<kVerifyFlags>() == kStatusErrorUnresolved;
128 }
129
130 // Returns true if the class has failed to initialize.
131 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
132 bool IsErroneousResolved() REQUIRES_SHARED(Locks::mutator_lock_) {
133 return GetStatus<kVerifyFlags>() == kStatusErrorResolved;
134 }
135
136 // Returns true if the class status indicets that the class has failed to link or initialize.
137 static bool IsErroneous(Status status) {
138 return status == kStatusErrorUnresolved || status == kStatusErrorResolved;
139 }
140
141 // Returns true if the class has failed to link or initialize.
142 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700143 bool IsErroneous() REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko72ab6842017-01-20 19:32:50 +0000144 return IsErroneous(GetStatus<kVerifyFlags>());
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800145 }
146
147 // Returns true if the class has been loaded.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800148 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700149 bool IsIdxLoaded() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800150 return GetStatus<kVerifyFlags>() >= kStatusIdx;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800151 }
152
153 // Returns true if the class has been loaded.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800154 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700155 bool IsLoaded() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800156 return GetStatus<kVerifyFlags>() >= kStatusLoaded;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800157 }
158
159 // Returns true if the class has been linked.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800160 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700161 bool IsResolved() REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko72ab6842017-01-20 19:32:50 +0000162 Status status = GetStatus<kVerifyFlags>();
163 return status >= kStatusResolved || status == kStatusErrorResolved;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800164 }
165
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000166 // Returns true if the class should be verified at runtime.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800167 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Nicolas Geoffray7cc3ae52017-03-07 14:33:37 +0000168 bool ShouldVerifyAtRuntime() REQUIRES_SHARED(Locks::mutator_lock_) {
169 return GetStatus<kVerifyFlags>() == kStatusRetryVerificationAtRuntime;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800170 }
171
172 // Returns true if the class has been verified.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800173 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700174 bool IsVerified() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800175 return GetStatus<kVerifyFlags>() >= kStatusVerified;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800176 }
177
178 // Returns true if the class is initializing.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800179 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700180 bool IsInitializing() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800181 return GetStatus<kVerifyFlags>() >= kStatusInitializing;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800182 }
183
184 // Returns true if the class is initialized.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800185 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700186 bool IsInitialized() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800187 return GetStatus<kVerifyFlags>() == kStatusInitialized;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800188 }
189
Mathieu Chartier4e305412014-02-19 10:54:44 -0800190 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampe90b936d2017-01-31 08:58:55 -0800191 ALWAYS_INLINE uint32_t GetAccessFlags() REQUIRES_SHARED(Locks::mutator_lock_) {
192 if (kIsDebugBuild) {
193 GetAccessFlagsDCheck<kVerifyFlags>();
194 }
195 return GetField32<kVerifyFlags>(AccessFlagsOffset());
196 }
197
Hiroshi Yamauchie01a5202015-03-19 12:35:04 -0700198 static MemberOffset AccessFlagsOffset() {
199 return OFFSET_OF_OBJECT_MEMBER(Class, access_flags_);
200 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800201
Mathieu Chartier52a7f5c2015-08-18 18:35:52 -0700202 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700203 ALWAYS_INLINE uint32_t GetClassFlags() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier52a7f5c2015-08-18 18:35:52 -0700204 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_flags_));
205 }
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700206 void SetClassFlags(uint32_t new_flags) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier52a7f5c2015-08-18 18:35:52 -0700207
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700208 void SetAccessFlags(uint32_t new_access_flags) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800209
210 // Returns true if the class is an interface.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700211 ALWAYS_INLINE bool IsInterface() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800212 return (GetAccessFlags() & kAccInterface) != 0;
213 }
214
215 // Returns true if the class is declared public.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700216 ALWAYS_INLINE bool IsPublic() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800217 return (GetAccessFlags() & kAccPublic) != 0;
218 }
219
220 // Returns true if the class is declared final.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700221 ALWAYS_INLINE bool IsFinal() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800222 return (GetAccessFlags() & kAccFinal) != 0;
223 }
224
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700225 ALWAYS_INLINE bool IsFinalizable() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800226 return (GetAccessFlags() & kAccClassIsFinalizable) != 0;
227 }
228
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700229 ALWAYS_INLINE void SetRecursivelyInitialized() REQUIRES_SHARED(Locks::mutator_lock_) {
Alex Lighteb7c1442015-08-31 13:17:42 -0700230 DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
231 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
232 SetAccessFlags(flags | kAccRecursivelyInitialized);
233 }
234
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700235 ALWAYS_INLINE void SetHasDefaultMethods() REQUIRES_SHARED(Locks::mutator_lock_) {
Alex Lighteb7c1442015-08-31 13:17:42 -0700236 DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId());
237 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
238 SetAccessFlags(flags | kAccHasDefaultMethod);
239 }
240
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700241 ALWAYS_INLINE void SetFinalizable() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700242 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800243 SetAccessFlags(flags | kAccClassIsFinalizable);
244 }
245
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700246 ALWAYS_INLINE bool IsStringClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier52a7f5c2015-08-18 18:35:52 -0700247 return (GetClassFlags() & kClassFlagString) != 0;
Jeff Hao848f70a2014-01-15 13:49:50 -0800248 }
249
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700250 ALWAYS_INLINE void SetStringClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier66c2d2d2015-08-25 14:32:32 -0700251 SetClassFlags(kClassFlagString | kClassFlagNoReferenceFields);
Jeff Hao848f70a2014-01-15 13:49:50 -0800252 }
253
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700254 ALWAYS_INLINE bool IsClassLoaderClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier66c2d2d2015-08-25 14:32:32 -0700255 return GetClassFlags() == kClassFlagClassLoader;
Mathieu Chartiere4275c02015-08-06 15:34:15 -0700256 }
257
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700258 ALWAYS_INLINE void SetClassLoaderClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier66c2d2d2015-08-25 14:32:32 -0700259 SetClassFlags(kClassFlagClassLoader);
Mathieu Chartiere4275c02015-08-06 15:34:15 -0700260 }
261
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700262 ALWAYS_INLINE bool IsDexCacheClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko05792b92015-08-03 11:56:49 +0100263 return (GetClassFlags() & kClassFlagDexCache) != 0;
264 }
265
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700266 ALWAYS_INLINE void SetDexCacheClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko05792b92015-08-03 11:56:49 +0100267 SetClassFlags(GetClassFlags() | kClassFlagDexCache);
268 }
269
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800270 // Returns true if the class is abstract.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700271 ALWAYS_INLINE bool IsAbstract() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800272 return (GetAccessFlags() & kAccAbstract) != 0;
273 }
274
275 // Returns true if the class is an annotation.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700276 ALWAYS_INLINE bool IsAnnotation() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800277 return (GetAccessFlags() & kAccAnnotation) != 0;
278 }
279
280 // Returns true if the class is synthetic.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700281 ALWAYS_INLINE bool IsSynthetic() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800282 return (GetAccessFlags() & kAccSynthetic) != 0;
283 }
284
Igor Murashkin8d1da852016-02-04 11:01:21 -0800285 // Return whether the class had run the verifier at least once.
Igor Murashkindf707e42016-02-02 16:56:50 -0800286 // This does not necessarily mean that access checks are avoidable,
287 // since the class methods might still need to be run with access checks.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700288 bool WasVerificationAttempted() REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Markob0a6aee2017-10-27 10:34:04 +0100289 return (GetAccessFlags() & kAccVerificationAttempted) != 0;
Ian Rogers7b078e82014-09-10 14:44:24 -0700290 }
291
Igor Murashkindf707e42016-02-02 16:56:50 -0800292 // Mark the class as having gone through a verification attempt.
293 // Mutually exclusive from whether or not each method is allowed to skip access checks.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700294 void SetVerificationAttempted() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers7b078e82014-09-10 14:44:24 -0700295 uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
Mathieu Chartier085a0722016-04-01 17:33:31 -0700296 if ((flags & kAccVerificationAttempted) == 0) {
297 SetAccessFlags(flags | kAccVerificationAttempted);
298 }
Ian Rogers7b078e82014-09-10 14:44:24 -0700299 }
300
Mathieu Chartier4e305412014-02-19 10:54:44 -0800301 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700302 bool IsTypeOfReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier52a7f5c2015-08-18 18:35:52 -0700303 return (GetClassFlags<kVerifyFlags>() & kClassFlagReference) != 0;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800304 }
305
Mathieu Chartier4e305412014-02-19 10:54:44 -0800306 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700307 bool IsWeakReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier66c2d2d2015-08-25 14:32:32 -0700308 return GetClassFlags<kVerifyFlags>() == kClassFlagWeakReference;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800309 }
310
Mathieu Chartier4e305412014-02-19 10:54:44 -0800311 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700312 bool IsSoftReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier66c2d2d2015-08-25 14:32:32 -0700313 return GetClassFlags<kVerifyFlags>() == kClassFlagSoftReference;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800314 }
315
Mathieu Chartier4e305412014-02-19 10:54:44 -0800316 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700317 bool IsFinalizerReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier66c2d2d2015-08-25 14:32:32 -0700318 return GetClassFlags<kVerifyFlags>() == kClassFlagFinalizerReference;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800319 }
320
Mathieu Chartier4e305412014-02-19 10:54:44 -0800321 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700322 bool IsPhantomReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier66c2d2d2015-08-25 14:32:32 -0700323 return GetClassFlags<kVerifyFlags>() == kClassFlagPhantomReference;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800324 }
325
Ian Rogers04f94f42013-06-10 15:09:26 -0700326 // Can references of this type be assigned to by things of another type? For non-array types
327 // this is a matter of whether sub-classes may exist - which they can't if the type is final.
328 // For array classes, where all the classes are final due to there being no sub-classes, an
329 // Object[] may be assigned to by a String[] but a String[] may not be assigned to by other
330 // types as the component is final.
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700331 bool CannotBeAssignedFromOtherTypes() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800332
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700333 // Returns true if this class is the placeholder and should retire and
334 // be replaced with a class with the right size for embedded imt/vtable.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700335 bool IsTemp() REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700336 Status s = GetStatus();
Vladimir Marko72ab6842017-01-20 19:32:50 +0000337 return s < Status::kStatusResolving && s != kStatusErrorResolved && ShouldHaveEmbeddedVTable();
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700338 }
339
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700340 String* GetName() REQUIRES_SHARED(Locks::mutator_lock_); // Returns the cached name.
Mathieu Chartier1a5337f2016-10-13 13:48:23 -0700341 void SetName(ObjPtr<String> name) REQUIRES_SHARED(Locks::mutator_lock_); // Sets the cached name.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800342 // Computes the name, then sets the cached value.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700343 static String* ComputeName(Handle<Class> h_this) REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartiered8990a2015-07-23 14:11:16 -0700344 REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800345
Mathieu Chartierc2f4d022014-03-03 16:11:42 -0800346 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700347 bool IsProxyClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800348 // Read access flags without using getter as whether something is a proxy can be check in
349 // any loaded state
350 // TODO: switch to a check if the super class is java.lang.reflect.Proxy?
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700351 uint32_t access_flags = GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800352 return (access_flags & kAccClassIsProxy) != 0;
353 }
354
Nicolas Geoffray85c7bab2015-09-18 13:40:46 +0000355 static MemberOffset PrimitiveTypeOffset() {
356 return OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_);
357 }
358
Mathieu Chartier4e305412014-02-19 10:54:44 -0800359 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700360 Primitive::Type GetPrimitiveType() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800361
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700362 void SetPrimitiveType(Primitive::Type new_type) REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800363 DCHECK_EQ(sizeof(Primitive::Type), sizeof(int32_t));
Mathieu Chartier8261d022016-08-08 09:41:04 -0700364 uint32_t v32 = static_cast<uint32_t>(new_type);
365 DCHECK_EQ(v32 & kPrimitiveTypeMask, v32) << "upper 16 bits aren't zero";
Hiroshi Yamauchif0edfc32014-09-25 11:46:46 -0700366 // Store the component size shift in the upper 16 bits.
Mathieu Chartier8261d022016-08-08 09:41:04 -0700367 v32 |= Primitive::ComponentSizeShift(new_type) << kPrimitiveTypeSizeShiftShift;
Chang Xing6d3e7682017-07-11 10:31:29 -0700368 SetField32Transaction(OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_), v32);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800369 }
370
Hiroshi Yamauchif0edfc32014-09-25 11:46:46 -0700371 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700372 size_t GetPrimitiveTypeSizeShift() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchif0edfc32014-09-25 11:46:46 -0700373
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800374 // Returns true if the class is a primitive type.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800375 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700376 bool IsPrimitive() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800377 return GetPrimitiveType<kVerifyFlags>() != Primitive::kPrimNot;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800378 }
379
Mathieu Chartier4e305412014-02-19 10:54:44 -0800380 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700381 bool IsPrimitiveBoolean() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800382 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimBoolean;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800383 }
384
Mathieu Chartier4e305412014-02-19 10:54:44 -0800385 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700386 bool IsPrimitiveByte() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800387 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimByte;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800388 }
389
Mathieu Chartier4e305412014-02-19 10:54:44 -0800390 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700391 bool IsPrimitiveChar() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800392 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimChar;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800393 }
394
Mathieu Chartier4e305412014-02-19 10:54:44 -0800395 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700396 bool IsPrimitiveShort() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800397 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimShort;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800398 }
399
Mathieu Chartier4e305412014-02-19 10:54:44 -0800400 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700401 bool IsPrimitiveInt() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800402 return GetPrimitiveType() == Primitive::kPrimInt;
403 }
404
Mathieu Chartier4e305412014-02-19 10:54:44 -0800405 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700406 bool IsPrimitiveLong() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800407 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimLong;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800408 }
409
Mathieu Chartier4e305412014-02-19 10:54:44 -0800410 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700411 bool IsPrimitiveFloat() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800412 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimFloat;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800413 }
414
Mathieu Chartier4e305412014-02-19 10:54:44 -0800415 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700416 bool IsPrimitiveDouble() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800417 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimDouble;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800418 }
419
Mathieu Chartier4e305412014-02-19 10:54:44 -0800420 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700421 bool IsPrimitiveVoid() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800422 return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimVoid;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800423 }
424
Mathieu Chartier4e305412014-02-19 10:54:44 -0800425 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700426 bool IsPrimitiveArray() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800427 return IsArrayClass<kVerifyFlags>() &&
428 GetComponentType<static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis)>()->
429 IsPrimitive();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800430 }
431
432 // Depth of class from java.lang.Object
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700433 uint32_t Depth() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800434
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700435 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
436 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700437 bool IsArrayClass() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800438
Hiroshi Yamauchi25023c72014-05-09 11:45:53 -0700439 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
440 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700441 bool IsClassClass() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800442
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700443 bool IsThrowableClass() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800444
Hiroshi Yamauchi4f1ebc22014-06-25 14:30:41 -0700445 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700446 bool IsReferenceClass() const REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih4ee7a662014-07-11 09:59:27 -0700447
Ian Rogersa9a82542013-10-04 11:17:26 -0700448 static MemberOffset ComponentTypeOffset() {
449 return OFFSET_OF_OBJECT_MEMBER(Class, component_type_);
450 }
451
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700452 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
453 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700454 Class* GetComponentType() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800455
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700456 void SetComponentType(ObjPtr<Class> new_component_type) REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700457 DCHECK(GetComponentType() == nullptr);
458 DCHECK(new_component_type != nullptr);
Sebastien Hertzee1d79a2014-02-21 15:46:30 +0100459 // Component type is invariant: use non-transactional mode without check.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700460 SetFieldObject<false, false>(ComponentTypeOffset(), new_component_type);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800461 }
462
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700463 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700464 size_t GetComponentSize() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier5ffa0782016-07-27 10:45:47 -0700465 return 1U << GetComponentSizeShift<kReadBarrierOption>();
Hiroshi Yamauchif0edfc32014-09-25 11:46:46 -0700466 }
467
468 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700469 size_t GetComponentSizeShift() REQUIRES_SHARED(Locks::mutator_lock_) {
Hiroshi Yamauchif0edfc32014-09-25 11:46:46 -0700470 return GetComponentType<kDefaultVerifyFlags, kReadBarrierOption>()->GetPrimitiveTypeSizeShift();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800471 }
472
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700473 bool IsObjectClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700474 return !IsPrimitive() && GetSuperClass() == nullptr;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800475 }
Ian Rogers68d8b422014-07-17 11:09:10 -0700476
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700477 bool IsInstantiableNonArray() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers68d8b422014-07-17 11:09:10 -0700478 return !IsPrimitive() && !IsInterface() && !IsAbstract() && !IsArrayClass();
479 }
480
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800481 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
482 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700483 bool IsInstantiable() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers68d8b422014-07-17 11:09:10 -0700484 return (!IsPrimitive() && !IsInterface() && !IsAbstract()) ||
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800485 (IsAbstract() && IsArrayClass<kVerifyFlags, kReadBarrierOption>());
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800486 }
487
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800488 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
489 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampec6ea7d02017-02-01 16:46:28 -0800490 ALWAYS_INLINE bool IsObjectArrayClass() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700491
492 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700493 bool IsIntArrayClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700494 constexpr auto kNewFlags = static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis);
495 auto* component_type = GetComponentType<kVerifyFlags>();
496 return component_type != nullptr && component_type->template IsPrimitiveInt<kNewFlags>();
497 }
498
499 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700500 bool IsLongArrayClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700501 constexpr auto kNewFlags = static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis);
502 auto* component_type = GetComponentType<kVerifyFlags>();
503 return component_type != nullptr && component_type->template IsPrimitiveLong<kNewFlags>();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800504 }
505
506 // Creates a raw object instance but does not invoke the default constructor.
Mathieu Chartier8668c3c2014-04-24 16:48:11 -0700507 template<bool kIsInstrumented, bool kCheckAddFinalizer = true>
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700508 ALWAYS_INLINE ObjPtr<Object> Alloc(Thread* self, gc::AllocatorType allocator_type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700509 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700510
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700511 ObjPtr<Object> AllocObject(Thread* self)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700512 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700513 ObjPtr<Object> AllocNonMovableObject(Thread* self)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700514 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800515
Hiroshi Yamauchi25023c72014-05-09 11:45:53 -0700516 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
517 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampec6ea7d02017-02-01 16:46:28 -0800518 ALWAYS_INLINE bool IsVariableSize() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800519
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700520 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
521 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700522 uint32_t SizeOf() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700523 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800524 }
525
Mathieu Chartier4e305412014-02-19 10:54:44 -0800526 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700527 uint32_t GetClassSize() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700528 return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800529 }
530
Ian Rogersef7d42f2014-01-06 12:55:46 -0800531 void SetClassSize(uint32_t new_class_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700532 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800533
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700534 // Compute how many bytes would be used a class with the given elements.
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000535 static uint32_t ComputeClassSize(bool has_embedded_vtable,
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700536 uint32_t num_vtable_entries,
Fred Shih37f05ef2014-07-16 18:38:08 -0700537 uint32_t num_8bit_static_fields,
538 uint32_t num_16bit_static_fields,
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700539 uint32_t num_32bit_static_fields,
540 uint32_t num_64bit_static_fields,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700541 uint32_t num_ref_static_fields,
Andreas Gampe542451c2016-07-26 09:02:02 -0700542 PointerSize pointer_size);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700543
544 // The size of java.lang.Class.class.
Andreas Gampe542451c2016-07-26 09:02:02 -0700545 static uint32_t ClassClassSize(PointerSize pointer_size) {
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700546 // The number of vtable entries in java.lang.Class.
Narayan Kamath6b2dc312017-03-14 13:26:12 +0000547 uint32_t vtable_entries = Object::kVTableLength + 67;
Yi Kongff633e22015-11-06 13:33:22 +0000548 return ComputeClassSize(true, vtable_entries, 0, 0, 4, 1, 0, pointer_size);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700549 }
550
551 // The size of a java.lang.Class representing a primitive such as int.class.
Andreas Gampe542451c2016-07-26 09:02:02 -0700552 static uint32_t PrimitiveClassSize(PointerSize pointer_size) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700553 return ComputeClassSize(false, 0, 0, 0, 0, 0, 0, pointer_size);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700554 }
555
Hiroshi Yamauchi25023c72014-05-09 11:45:53 -0700556 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
557 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700558 uint32_t GetObjectSize() REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchie01a5202015-03-19 12:35:04 -0700559 static MemberOffset ObjectSizeOffset() {
560 return OFFSET_OF_OBJECT_MEMBER(Class, object_size_);
561 }
Mathieu Chartier93bbee02016-08-31 09:38:40 -0700562 static MemberOffset ObjectSizeAllocFastPathOffset() {
563 return OFFSET_OF_OBJECT_MEMBER(Class, object_size_alloc_fast_path_);
564 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800565
Andreas Gampec6ea7d02017-02-01 16:46:28 -0800566 ALWAYS_INLINE void SetObjectSize(uint32_t new_object_size) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800567
Mathieu Chartier93bbee02016-08-31 09:38:40 -0700568 void SetObjectSizeAllocFastPath(uint32_t new_object_size) REQUIRES_SHARED(Locks::mutator_lock_);
569
Mathieu Chartier161db1d2016-09-01 14:06:54 -0700570 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
571 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
572 uint32_t GetObjectSizeAllocFastPath() REQUIRES_SHARED(Locks::mutator_lock_);
573
Mathieu Chartier2d721012014-11-10 11:08:06 -0800574 void SetObjectSizeWithoutChecks(uint32_t new_object_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700575 REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier2d721012014-11-10 11:08:06 -0800576 // Not called within a transaction.
577 return SetField32<false, false, kVerifyNone>(
578 OFFSET_OF_OBJECT_MEMBER(Class, object_size_), new_object_size);
579 }
580
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800581 // Returns true if this class is in the same packages as that class.
Mathieu Chartier3398c782016-09-30 10:27:43 -0700582 bool IsInSamePackage(ObjPtr<Class> that) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800583
584 static bool IsInSamePackage(const StringPiece& descriptor1, const StringPiece& descriptor2);
585
586 // Returns true if this class can access that class.
Mathieu Chartier3398c782016-09-30 10:27:43 -0700587 bool CanAccess(ObjPtr<Class> that) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800588
589 // Can this class access a member in the provided class with the provided member access flags?
590 // Note that access to the class isn't checked in case the declaring class is protected and the
591 // method has been exposed by a public sub-class
Mathieu Chartier3398c782016-09-30 10:27:43 -0700592 bool CanAccessMember(ObjPtr<Class> access_to, uint32_t member_flags)
593 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800594
Vladimir Marko23a28212014-01-09 19:24:37 +0000595 // Can this class access a resolved field?
596 // Note that access to field's class is checked and this may require looking up the class
597 // referenced by the FieldId in the DexFile in case the declaring class is inaccessible.
Mathieu Chartier3398c782016-09-30 10:27:43 -0700598 bool CanAccessResolvedField(ObjPtr<Class> access_to,
599 ArtField* field,
600 ObjPtr<DexCache> dex_cache,
601 uint32_t field_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700602 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Markof79aa7f2017-07-04 16:58:55 +0100603 bool CheckResolvedFieldAccess(ObjPtr<Class> access_to,
604 ArtField* field,
605 ObjPtr<DexCache> dex_cache,
606 uint32_t field_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700607 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko23a28212014-01-09 19:24:37 +0000608
609 // Can this class access a resolved method?
610 // Note that access to methods's class is checked and this may require looking up the class
611 // referenced by the MethodId in the DexFile in case the declaring class is inaccessible.
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700612 bool CanAccessResolvedMethod(ObjPtr<Class> access_to,
613 ArtMethod* resolved_method,
614 ObjPtr<DexCache> dex_cache,
615 uint32_t method_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700616 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700617 bool CheckResolvedMethodAccess(ObjPtr<Class> access_to,
618 ArtMethod* resolved_method,
Vladimir Markof79aa7f2017-07-04 16:58:55 +0100619 ObjPtr<DexCache> dex_cache,
620 uint32_t method_idx,
621 InvokeType throw_invoke_type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700622 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko23a28212014-01-09 19:24:37 +0000623
Mathieu Chartier3398c782016-09-30 10:27:43 -0700624 bool IsSubClass(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800625
626 // Can src be assigned to this class? For example, String can be assigned to Object (by an
627 // upcast), however, an Object cannot be assigned to a String as a potentially exception throwing
628 // downcast would be necessary. Similarly for interfaces, a class that implements (or an interface
629 // that extends) another can be assigned to its parent, but not vice-versa. All Classes may assign
630 // to themselves. Classes for primitive types may not assign to each other.
Mathieu Chartier3398c782016-09-30 10:27:43 -0700631 ALWAYS_INLINE bool IsAssignableFrom(ObjPtr<Class> src) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800632
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800633 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
634 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700635 ALWAYS_INLINE Class* GetSuperClass() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800636
Calin Juravle52503d82015-11-11 16:58:31 +0000637 // Get first common super class. It will never return null.
638 // `This` and `klass` must be classes.
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700639 ObjPtr<Class> GetCommonSuperClass(Handle<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_);
Calin Juravle52503d82015-11-11 16:58:31 +0000640
Roland Levillain8ca4e4e2017-02-03 15:12:38 +0000641 void SetSuperClass(ObjPtr<Class> new_super_class) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800642
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700643 bool HasSuperClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700644 return GetSuperClass() != nullptr;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800645 }
646
647 static MemberOffset SuperClassOffset() {
648 return MemberOffset(OFFSETOF_MEMBER(Class, super_class_));
649 }
650
Nicolas Geoffraye51ca8b2016-11-22 14:49:31 +0000651 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
652 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700653 ClassLoader* GetClassLoader() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800654
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700655 void SetClassLoader(ObjPtr<ClassLoader> new_cl) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800656
657 static MemberOffset DexCacheOffset() {
658 return MemberOffset(OFFSETOF_MEMBER(Class, dex_cache_));
659 }
660
Mathieu Chartier2ecfd272016-11-01 10:10:05 -0700661 static MemberOffset IfTableOffset() {
662 return MemberOffset(OFFSETOF_MEMBER(Class, iftable_));
663 }
664
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800665 enum {
666 kDumpClassFullDetail = 1,
667 kDumpClassClassLoader = (1 << 1),
668 kDumpClassInitialized = (1 << 2),
669 };
670
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700671 void DumpClass(std::ostream& os, int flags) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800672
Mathieu Chartier137cdfa2017-01-26 14:03:11 -0800673 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
674 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700675 DexCache* GetDexCache() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800676
Mathieu Chartier91a6dc42014-12-01 10:31:15 -0800677 // Also updates the dex_cache_strings_ variable from new_dex_cache.
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700678 void SetDexCache(ObjPtr<DexCache> new_dex_cache) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800679
Vladimir Marko9ac77492017-06-14 18:07:03 +0100680 ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethods(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700681 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800682
Alex Lighte64300b2015-12-15 15:02:47 -0800683 ALWAYS_INLINE LengthPrefixedArray<ArtMethod>* GetMethodsPtr()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700684 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700685
David Srbecky9b3607d2016-01-14 18:15:54 +0000686 static MemberOffset MethodsOffset() {
687 return MemberOffset(OFFSETOF_MEMBER(Class, methods_));
688 }
689
Vladimir Marko9ac77492017-06-14 18:07:03 +0100690 ALWAYS_INLINE ArraySlice<ArtMethod> GetMethods(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700691 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800692
693 void SetMethodsPtr(LengthPrefixedArray<ArtMethod>* new_methods,
694 uint32_t num_direct,
695 uint32_t num_virtual)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700696 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700697 // Used by image writer.
Alex Lighte64300b2015-12-15 15:02:47 -0800698 void SetMethodsPtrUnchecked(LengthPrefixedArray<ArtMethod>* new_methods,
699 uint32_t num_direct,
700 uint32_t num_virtual)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700701 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800702
703 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampe542451c2016-07-26 09:02:02 -0700704 ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethodsSlice(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700705 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700706
Andreas Gampe542451c2016-07-26 09:02:02 -0700707 ALWAYS_INLINE ArtMethod* GetDirectMethod(size_t i, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700708 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700709
710 // Use only when we are allocating populating the method arrays.
Andreas Gampe542451c2016-07-26 09:02:02 -0700711 ALWAYS_INLINE ArtMethod* GetDirectMethodUnchecked(size_t i, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700712 REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe542451c2016-07-26 09:02:02 -0700713 ALWAYS_INLINE ArtMethod* GetVirtualMethodUnchecked(size_t i, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700714 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700715
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800716 // Returns the number of static, private, and constructor methods.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700717 ALWAYS_INLINE uint32_t NumDirectMethods() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800718
Mathieu Chartier4e305412014-02-19 10:54:44 -0800719 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampe542451c2016-07-26 09:02:02 -0700720 ALWAYS_INLINE ArraySlice<ArtMethod> GetMethodsSlice(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700721 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800722
723 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampe542451c2016-07-26 09:02:02 -0700724 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethodsSlice(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700725 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800726
Vladimir Marko9ac77492017-06-14 18:07:03 +0100727 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethods(
Andreas Gampe542451c2016-07-26 09:02:02 -0700728 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700729 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800730
Andreas Gampe542451c2016-07-26 09:02:02 -0700731 template <PointerSize kPointerSize, bool kTransactionActive>
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700732 static ObjPtr<Method> GetDeclaredMethodInternal(Thread* self,
733 ObjPtr<Class> klass,
734 ObjPtr<String> name,
735 ObjPtr<ObjectArray<Class>> args)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700736 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700737
Andreas Gampe542451c2016-07-26 09:02:02 -0700738 template <PointerSize kPointerSize, bool kTransactionActive>
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700739 static ObjPtr<Constructor> GetDeclaredConstructorInternal(Thread* self,
740 ObjPtr<Class> klass,
741 ObjPtr<ObjectArray<Class>> args)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700742 REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampebc4d2182016-02-22 10:03:12 -0800743
Alex Lighte64300b2015-12-15 15:02:47 -0800744 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampe542451c2016-07-26 09:02:02 -0700745 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethodsSlice(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700746 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800747
Vladimir Marko9ac77492017-06-14 18:07:03 +0100748 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethods(
Andreas Gampe542451c2016-07-26 09:02:02 -0700749 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700750 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800751
752 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampe542451c2016-07-26 09:02:02 -0700753 ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSlice(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700754 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800755
Vladimir Marko9ac77492017-06-14 18:07:03 +0100756 ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethods(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700757 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800758
759 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampe542451c2016-07-26 09:02:02 -0700760 ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethodsSlice(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700761 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700762
Vladimir Marko9ac77492017-06-14 18:07:03 +0100763 ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethods(
Andreas Gampe542451c2016-07-26 09:02:02 -0700764 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700765 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700766
Alex Lighte64300b2015-12-15 15:02:47 -0800767 // Returns the number of non-inherited virtual methods (sum of declared and copied methods).
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700768 ALWAYS_INLINE uint32_t NumVirtualMethods() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800769
Alex Lighte64300b2015-12-15 15:02:47 -0800770 // Returns the number of copied virtual methods.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700771 ALWAYS_INLINE uint32_t NumCopiedVirtualMethods() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800772
773 // Returns the number of declared virtual methods.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700774 ALWAYS_INLINE uint32_t NumDeclaredVirtualMethods() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800775
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700776 ALWAYS_INLINE uint32_t NumMethods() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier2466d622017-09-26 13:52:26 -0700777 static ALWAYS_INLINE uint32_t NumMethods(LengthPrefixedArray<ArtMethod>* methods)
778 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -0800779
Mathieu Chartier4e305412014-02-19 10:54:44 -0800780 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampe542451c2016-07-26 09:02:02 -0700781 ArtMethod* GetVirtualMethod(size_t i, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700782 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800783
Andreas Gampe542451c2016-07-26 09:02:02 -0700784 ArtMethod* GetVirtualMethodDuringLinking(size_t i, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700785 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800786
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800787 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
788 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700789 ALWAYS_INLINE PointerArray* GetVTable() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700790
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700791 ALWAYS_INLINE PointerArray* GetVTableDuringLinking() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700792
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700793 void SetVTable(PointerArray* new_vtable) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800794
795 static MemberOffset VTableOffset() {
796 return OFFSET_OF_OBJECT_MEMBER(Class, vtable_);
797 }
798
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700799 static MemberOffset EmbeddedVTableLengthOffset() {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700800 return MemberOffset(sizeof(Class));
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700801 }
802
Andreas Gampe542451c2016-07-26 09:02:02 -0700803 static MemberOffset ImtPtrOffset(PointerSize pointer_size) {
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000804 return MemberOffset(
Andreas Gampe542451c2016-07-26 09:02:02 -0700805 RoundUp(EmbeddedVTableLengthOffset().Uint32Value() + sizeof(uint32_t),
806 static_cast<size_t>(pointer_size)));
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000807 }
808
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800809 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
810 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700811 bool ShouldHaveImt() REQUIRES_SHARED(Locks::mutator_lock_) {
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000812 return ShouldHaveEmbeddedVTable<kVerifyFlags, kReadBarrierOption>();
813 }
814
815 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
816 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700817 bool ShouldHaveEmbeddedVTable() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800818 return IsInstantiable<kVerifyFlags, kReadBarrierOption>();
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700819 }
820
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700821 bool HasVTable() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700822
Andreas Gampe542451c2016-07-26 09:02:02 -0700823 static MemberOffset EmbeddedVTableEntryOffset(uint32_t i, PointerSize pointer_size);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700824
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700825 int32_t GetVTableLength() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700826
Andreas Gampe542451c2016-07-26 09:02:02 -0700827 ArtMethod* GetVTableEntry(uint32_t i, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700828 REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700829
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700830 int32_t GetEmbeddedVTableLength() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700831
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700832 void SetEmbeddedVTableLength(int32_t len) REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700833
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700834 ImTable* GetImt(PointerSize pointer_size) REQUIRES_SHARED(Locks::mutator_lock_);
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000835
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700836 void SetImt(ImTable* imt, PointerSize pointer_size) REQUIRES_SHARED(Locks::mutator_lock_);
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000837
Andreas Gampe542451c2016-07-26 09:02:02 -0700838 ArtMethod* GetEmbeddedVTableEntry(uint32_t i, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700839 REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700840
Andreas Gampe542451c2016-07-26 09:02:02 -0700841 void SetEmbeddedVTableEntry(uint32_t i, ArtMethod* method, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700842 REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700843
Andreas Gampe542451c2016-07-26 09:02:02 -0700844 inline void SetEmbeddedVTableEntryUnchecked(uint32_t i,
845 ArtMethod* method,
846 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700847 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700848
Andreas Gampe542451c2016-07-26 09:02:02 -0700849 void PopulateEmbeddedVTable(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700850 REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700851
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800852 // Given a method implemented by this class but potentially from a super class, return the
853 // specific implementation method for this class.
Andreas Gampe542451c2016-07-26 09:02:02 -0700854 ArtMethod* FindVirtualMethodForVirtual(ArtMethod* method, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700855 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800856
857 // Given a method implemented by this class' super class, return the specific implementation
858 // method for this class.
Andreas Gampe542451c2016-07-26 09:02:02 -0700859 ArtMethod* FindVirtualMethodForSuper(ArtMethod* method, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700860 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800861
Alex Light705ad492015-09-21 11:36:30 -0700862 // Given a method from some implementor of this interface, return the specific implementation
863 // method for this class.
Andreas Gampe542451c2016-07-26 09:02:02 -0700864 ArtMethod* FindVirtualMethodForInterfaceSuper(ArtMethod* method, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700865 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Light705ad492015-09-21 11:36:30 -0700866
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800867 // Given a method implemented by this class, but potentially from a
868 // super class or interface, return the specific implementation
869 // method for this class.
Andreas Gampe542451c2016-07-26 09:02:02 -0700870 ArtMethod* FindVirtualMethodForInterface(ArtMethod* method, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700871 REQUIRES_SHARED(Locks::mutator_lock_) ALWAYS_INLINE;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800872
Andreas Gampe542451c2016-07-26 09:02:02 -0700873 ArtMethod* FindVirtualMethodForVirtualOrInterface(ArtMethod* method, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700874 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersd91d6d62013-09-25 20:26:14 -0700875
Vladimir Markoba118822017-06-12 15:41:56 +0100876 // Find a method with the given name and signature in an interface class.
877 //
878 // Search for the method declared in the class, then search for a method declared in any
879 // superinterface, then search the superclass java.lang.Object (implicitly declared methods
880 // in an interface without superinterfaces, see JLS 9.2, can be inherited, see JLS 9.4.1).
881 // TODO: Implement search for a unique maximally-specific non-abstract superinterface method.
882
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700883 ArtMethod* FindInterfaceMethod(const StringPiece& name,
884 const StringPiece& signature,
Andreas Gampe542451c2016-07-26 09:02:02 -0700885 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700886 REQUIRES_SHARED(Locks::mutator_lock_);
Brian Carlstrom004644f2014-06-18 08:34:01 -0700887
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700888 ArtMethod* FindInterfaceMethod(const StringPiece& name,
889 const Signature& signature,
Andreas Gampe542451c2016-07-26 09:02:02 -0700890 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700891 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800892
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700893 ArtMethod* FindInterfaceMethod(ObjPtr<DexCache> dex_cache,
894 uint32_t dex_method_idx,
Andreas Gampe542451c2016-07-26 09:02:02 -0700895 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700896 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800897
Vladimir Markoba118822017-06-12 15:41:56 +0100898 // Find a method with the given name and signature in a non-interface class.
899 //
900 // Search for the method in the class, following the JLS rules which conflict with the RI
901 // in some cases. The JLS says that inherited methods are searched (JLS 15.12.2.1) and
902 // these can come from a superclass or a superinterface (JLS 8.4.8). We perform the
903 // following search:
904 // 1. Search the methods declared directly in the class. If we find a method with the
905 // given name and signature, return that method.
906 // 2. Search the methods declared in superclasses until we find a method with the given
907 // signature or complete the search in java.lang.Object. If we find a method with the
908 // given name and signature, check if it's been inherited by the class where we're
909 // performing the lookup (qualifying type). If it's inherited, return it. Otherwise,
910 // just remember the method and its declaring class and proceed to step 3.
911 // 3. Search "copied" methods (containing methods inherited from interfaces) in the class
912 // and its superclass chain. If we found a method in step 2 (which was not inherited,
913 // otherwise we would not be performing step 3), end the search when we reach its
914 // declaring class, otherwise search the entire superclass chain. If we find a method
915 // with the given name and signature, return that method.
916 // 4. Return the method found in step 2 if any (not inherited), or null.
917 //
918 // It's the responsibility of the caller to throw exceptions if the returned method (or null)
919 // does not satisfy the request. Special consideration should be given to the case where this
920 // function returns a method that's not inherited (found in step 2, returned in step 4).
921
922 ArtMethod* FindClassMethod(const StringPiece& name,
923 const StringPiece& signature,
924 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700925 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800926
Vladimir Markoba118822017-06-12 15:41:56 +0100927 ArtMethod* FindClassMethod(const StringPiece& name,
928 const Signature& signature,
929 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700930 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersd91d6d62013-09-25 20:26:14 -0700931
Vladimir Markoba118822017-06-12 15:41:56 +0100932 ArtMethod* FindClassMethod(ObjPtr<DexCache> dex_cache,
933 uint32_t dex_method_idx,
934 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700935 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800936
Vladimir Markoba118822017-06-12 15:41:56 +0100937 ArtMethod* FindConstructor(const StringPiece& signature, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700938 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersd91d6d62013-09-25 20:26:14 -0700939
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700940 ArtMethod* FindDeclaredVirtualMethodByName(const StringPiece& name,
941 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700942 REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Hao13e748b2015-08-25 20:44:19 +0000943
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700944 ArtMethod* FindDeclaredDirectMethodByName(const StringPiece& name,
945 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700946 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffraya42363f2015-12-17 14:57:09 +0000947
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700948 ArtMethod* FindClassInitializer(PointerSize pointer_size) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersd91d6d62013-09-25 20:26:14 -0700949
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700950 bool HasDefaultMethods() REQUIRES_SHARED(Locks::mutator_lock_) {
Alex Lighteb7c1442015-08-31 13:17:42 -0700951 return (GetAccessFlags() & kAccHasDefaultMethod) != 0;
952 }
953
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700954 bool HasBeenRecursivelyInitialized() REQUIRES_SHARED(Locks::mutator_lock_) {
Alex Lighteb7c1442015-08-31 13:17:42 -0700955 return (GetAccessFlags() & kAccRecursivelyInitialized) != 0;
956 }
957
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700958 ALWAYS_INLINE int32_t GetIfTableCount() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800959
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800960 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
961 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700962 ALWAYS_INLINE IfTable* GetIfTable() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800963
Mathieu Chartier28bd2e42016-10-04 13:54:57 -0700964 ALWAYS_INLINE void SetIfTable(ObjPtr<IfTable> new_iftable)
965 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800966
967 // Get instance fields of the class (See also GetSFields).
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700968 LengthPrefixedArray<ArtField>* GetIFieldsPtr() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800969
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700970 ALWAYS_INLINE IterationRange<StrideIterator<ArtField>> GetIFields()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700971 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700972
973 void SetIFieldsPtr(LengthPrefixedArray<ArtField>* new_ifields)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700974 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800975
Mathieu Chartierc7853442015-03-27 14:35:38 -0700976 // Unchecked edition has no verification flags.
Mathieu Chartier54d220e2015-07-30 16:20:06 -0700977 void SetIFieldsPtrUnchecked(LengthPrefixedArray<ArtField>* new_sfields)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700978 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800979
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700980 uint32_t NumInstanceFields() REQUIRES_SHARED(Locks::mutator_lock_);
981 ArtField* GetInstanceField(uint32_t i) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800982
Mathieu Chartier66c2d2d2015-08-25 14:32:32 -0700983 // Returns the number of instance fields containing reference types. Does not count fields in any
984 // super classes.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700985 uint32_t NumReferenceInstanceFields() REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko72ab6842017-01-20 19:32:50 +0000986 DCHECK(IsResolved());
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700987 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800988 }
989
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700990 uint32_t NumReferenceInstanceFieldsDuringLinking() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800991 DCHECK(IsLoaded() || IsErroneous());
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700992 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800993 }
994
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700995 void SetNumReferenceInstanceFields(uint32_t new_num) REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100996 // Not called within a transaction.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700997 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_), new_num);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800998 }
999
Mathieu Chartier4e305412014-02-19 10:54:44 -08001000 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001001 uint32_t GetReferenceInstanceOffsets() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001002
1003 void SetReferenceInstanceOffsets(uint32_t new_reference_offsets)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001004 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001005
Vladimir Marko76649e82014-11-10 18:32:59 +00001006 // Get the offset of the first reference instance field. Other reference instance fields follow.
Hiroshi Yamauchi5496f692016-02-17 13:29:59 -08001007 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1008 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Mathieu Chartiere401d142015-04-22 13:56:20 -07001009 MemberOffset GetFirstReferenceInstanceFieldOffset()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001010 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko76649e82014-11-10 18:32:59 +00001011
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001012 // Returns the number of static fields containing reference types.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001013 uint32_t NumReferenceStaticFields() REQUIRES_SHARED(Locks::mutator_lock_) {
Vladimir Marko72ab6842017-01-20 19:32:50 +00001014 DCHECK(IsResolved());
Ian Rogersb0fa5dc2014-04-28 16:47:08 -07001015 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001016 }
1017
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001018 uint32_t NumReferenceStaticFieldsDuringLinking() REQUIRES_SHARED(Locks::mutator_lock_) {
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001019 DCHECK(IsLoaded() || IsErroneous() || IsRetired());
Ian Rogersb0fa5dc2014-04-28 16:47:08 -07001020 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001021 }
1022
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001023 void SetNumReferenceStaticFields(uint32_t new_num) REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001024 // Not called within a transaction.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -07001025 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_), new_num);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001026 }
1027
Vladimir Marko76649e82014-11-10 18:32:59 +00001028 // Get the offset of the first reference static field. Other reference static fields follow.
Mathieu Chartierdfe02f62016-02-01 20:15:11 -08001029 template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1030 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampe542451c2016-07-26 09:02:02 -07001031 MemberOffset GetFirstReferenceStaticFieldOffset(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001032 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko76649e82014-11-10 18:32:59 +00001033
1034 // Get the offset of the first reference static field. Other reference static fields follow.
Andreas Gampe542451c2016-07-26 09:02:02 -07001035 MemberOffset GetFirstReferenceStaticFieldOffsetDuringLinking(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001036 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko76649e82014-11-10 18:32:59 +00001037
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001038 // Gets the static fields of the class.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001039 LengthPrefixedArray<ArtField>* GetSFieldsPtr() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier54d220e2015-07-30 16:20:06 -07001040 ALWAYS_INLINE IterationRange<StrideIterator<ArtField>> GetSFields()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001041 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001042
Mathieu Chartier54d220e2015-07-30 16:20:06 -07001043 void SetSFieldsPtr(LengthPrefixedArray<ArtField>* new_sfields)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001044 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001045
Mathieu Chartierc7853442015-03-27 14:35:38 -07001046 // Unchecked edition has no verification flags.
Mathieu Chartier54d220e2015-07-30 16:20:06 -07001047 void SetSFieldsPtrUnchecked(LengthPrefixedArray<ArtField>* new_sfields)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001048 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierc7853442015-03-27 14:35:38 -07001049
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001050 uint32_t NumStaticFields() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001051
Ian Rogersef7d42f2014-01-06 12:55:46 -08001052 // TODO: uint16_t
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001053 ArtField* GetStaticField(uint32_t i) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001054
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001055 // Find a static or instance field using the JLS resolution order
Vladimir Marko19a4d372016-12-08 14:41:46 +00001056 static ArtField* FindField(Thread* self,
1057 ObjPtr<Class> klass,
1058 const StringPiece& name,
Mathieu Chartierf8322842014-05-16 10:59:25 -07001059 const StringPiece& type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001060 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001061
1062 // Finds the given instance field in this class or a superclass.
Brian Carlstromea46f952013-07-30 01:26:50 -07001063 ArtField* FindInstanceField(const StringPiece& name, const StringPiece& type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001064 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001065
1066 // Finds the given instance field in this class or a superclass, only searches classes that
1067 // have the same dex cache.
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001068 ArtField* FindInstanceField(ObjPtr<DexCache> dex_cache, uint32_t dex_field_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001069 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001070
Brian Carlstromea46f952013-07-30 01:26:50 -07001071 ArtField* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001072 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001073
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001074 ArtField* FindDeclaredInstanceField(ObjPtr<DexCache> dex_cache, uint32_t dex_field_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001075 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001076
1077 // Finds the given static field in this class or a superclass.
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001078 static ArtField* FindStaticField(Thread* self,
Vladimir Marko19a4d372016-12-08 14:41:46 +00001079 ObjPtr<Class> klass,
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001080 const StringPiece& name,
Mathieu Chartierf8322842014-05-16 10:59:25 -07001081 const StringPiece& type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001082 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001083
1084 // Finds the given static field in this class or superclass, only searches classes that
1085 // have the same dex cache.
Vladimir Markobb268b12016-06-30 15:52:56 +01001086 static ArtField* FindStaticField(Thread* self,
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001087 ObjPtr<Class> klass,
1088 ObjPtr<DexCache> dex_cache,
Mathieu Chartierf8322842014-05-16 10:59:25 -07001089 uint32_t dex_field_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001090 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001091
Brian Carlstromea46f952013-07-30 01:26:50 -07001092 ArtField* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001093 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001094
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001095 ArtField* FindDeclaredStaticField(ObjPtr<DexCache> dex_cache, uint32_t dex_field_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001096 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001097
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001098 pid_t GetClinitThreadId() REQUIRES_SHARED(Locks::mutator_lock_) {
David Sehr709b0702016-10-13 09:12:37 -07001099 DCHECK(IsIdxLoaded() || IsErroneous()) << PrettyClass();
Ian Rogersb0fa5dc2014-04-28 16:47:08 -07001100 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, clinit_thread_id_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001101 }
1102
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001103 void SetClinitThreadId(pid_t new_clinit_thread_id) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001104
Alex Light4f2e9572017-03-16 13:13:31 -07001105 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1106 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Alex Lightd6251582016-10-31 11:12:30 -07001107 ClassExt* GetExtData() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001108
Alex Light0273ad12016-11-02 11:19:31 -07001109 // Returns the ExtData for this class, allocating one if necessary. This should be the only way
1110 // to force ext_data_ to be set. No functions are available for changing an already set ext_data_
1111 // since doing so is not allowed.
1112 ClassExt* EnsureExtDataPresent(Thread* self)
1113 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
1114
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001115 uint16_t GetDexClassDefIndex() REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogersb0fa5dc2014-04-28 16:47:08 -07001116 return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_));
Ian Rogers8b2c0b92013-09-19 02:56:49 -07001117 }
1118
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001119 void SetDexClassDefIndex(uint16_t class_def_idx) REQUIRES_SHARED(Locks::mutator_lock_) {
Chang Xing6d3e7682017-07-11 10:31:29 -07001120 SetField32Transaction(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_), class_def_idx);
Ian Rogers8b2c0b92013-09-19 02:56:49 -07001121 }
1122
Andreas Gampea5b09a62016-11-17 15:21:22 -08001123 dex::TypeIndex GetDexTypeIndex() REQUIRES_SHARED(Locks::mutator_lock_) {
1124 return dex::TypeIndex(
1125 static_cast<uint16_t>(GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_))));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001126 }
1127
Andreas Gampea5b09a62016-11-17 15:21:22 -08001128 void SetDexTypeIndex(dex::TypeIndex type_idx) REQUIRES_SHARED(Locks::mutator_lock_) {
Chang Xing6d3e7682017-07-11 10:31:29 -07001129 SetField32Transaction(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_), type_idx.index_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001130 }
1131
Andreas Gampea5b09a62016-11-17 15:21:22 -08001132 dex::TypeIndex FindTypeIndexInOtherDexFile(const DexFile& dex_file)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001133 REQUIRES_SHARED(Locks::mutator_lock_);
Nicolas Geoffraye4084a52016-02-18 14:43:42 +00001134
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001135 static Class* GetJavaLangClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier31000802015-06-14 14:14:37 -07001136 DCHECK(HasJavaLangClass());
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -07001137 return java_lang_Class_.Read();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001138 }
1139
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001140 static bool HasJavaLangClass() REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier31000802015-06-14 14:14:37 -07001141 return !java_lang_Class_.IsNull();
1142 }
1143
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001144 // Can't call this SetClass or else gets called instead of Object::SetClass in places.
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001145 static void SetClassClass(ObjPtr<Class> java_lang_Class) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001146 static void ResetClass();
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -07001147 static void VisitRoots(RootVisitor* visitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001148 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001149
Mathieu Chartiere401d142015-04-22 13:56:20 -07001150 // Visit native roots visits roots which are keyed off the native pointers such as ArtFields and
1151 // ArtMethods.
Hiroshi Yamauchi7a62e672016-06-10 17:22:48 -07001152 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier, class Visitor>
Andreas Gampe542451c2016-07-26 09:02:02 -07001153 void VisitNativeRoots(Visitor& visitor, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001154 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierc7853442015-03-27 14:35:38 -07001155
Igor Murashkindf707e42016-02-02 16:56:50 -08001156 // When class is verified, set the kAccSkipAccessChecks flag on each method.
Andreas Gampe542451c2016-07-26 09:02:02 -07001157 void SetSkipAccessChecksFlagOnAllMethods(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001158 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz233ea8e2013-06-06 11:57:09 +02001159
Ian Rogers1ff3c982014-08-12 02:30:58 -07001160 // Get the descriptor of the class. In a few cases a std::string is required, rather than
1161 // always create one the storage argument is populated and its internal c_str() returned. We do
1162 // this to avoid memory allocation in the common case.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001163 const char* GetDescriptor(std::string* storage) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers1ff3c982014-08-12 02:30:58 -07001164
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001165 const char* GetArrayDescriptor(std::string* storage) REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001166
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001167 bool DescriptorEquals(const char* match) REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001168
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001169 const DexFile::ClassDef* GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001170
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001171 ALWAYS_INLINE uint32_t NumDirectInterfaces() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001172
Andreas Gampea5b09a62016-11-17 15:21:22 -08001173 dex::TypeIndex GetDirectInterfaceTypeIdx(uint32_t idx) REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001174
Vladimir Marko19a4d372016-12-08 14:41:46 +00001175 // Get the direct interface of the `klass` at index `idx` if resolved, otherwise return null.
1176 // If the caller expects the interface to be resolved, for example for a resolved `klass`,
1177 // that assumption should be checked by `DCHECK(result != nullptr)`.
1178 static ObjPtr<Class> GetDirectInterface(Thread* self, ObjPtr<Class> klass, uint32_t idx)
1179 REQUIRES_SHARED(Locks::mutator_lock_);
1180
1181 // Resolve and get the direct interface of the `klass` at index `idx`.
1182 // Returns null with a pending exception if the resolution fails.
1183 static ObjPtr<Class> ResolveDirectInterface(Thread* self, Handle<Class> klass, uint32_t idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001184 REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001185
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001186 const char* GetSourceFile() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001187
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001188 std::string GetLocation() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001189
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001190 const DexFile& GetDexFile() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001191
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001192 const DexFile::TypeList* GetInterfaceTypeList() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierf8322842014-05-16 10:59:25 -07001193
Sebastien Hertz4e99b3d2014-06-24 14:35:40 +02001194 // Asserts we are initialized or initializing in the given thread.
1195 void AssertInitializedOrInitializingInThread(Thread* self)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001196 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz4e99b3d2014-06-24 14:35:40 +02001197
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001198 Class* CopyOf(Thread* self,
1199 int32_t new_length,
1200 ImTable* imt,
Andreas Gampe542451c2016-07-26 09:02:02 -07001201 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001202 REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001203
Nicolas Geoffraya7a47592015-11-24 09:17:30 +00001204 // For proxy class only.
Narayan Kamath6b2dc312017-03-14 13:26:12 +00001205 ObjectArray<Class>* GetProxyInterfaces() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001206
Nicolas Geoffraya7a47592015-11-24 09:17:30 +00001207 // For proxy class only.
Narayan Kamath6b2dc312017-03-14 13:26:12 +00001208 ObjectArray<ObjectArray<Class>>* GetProxyThrows() REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001209
Fred Shih4ee7a662014-07-11 09:59:27 -07001210 // For reference class only.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001211 MemberOffset GetDisableIntrinsicFlagOffset() REQUIRES_SHARED(Locks::mutator_lock_);
1212 MemberOffset GetSlowPathFlagOffset() REQUIRES_SHARED(Locks::mutator_lock_);
1213 bool GetSlowPathEnabled() REQUIRES_SHARED(Locks::mutator_lock_);
1214 void SetSlowPath(bool enabled) REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih4ee7a662014-07-11 09:59:27 -07001215
Mathieu Chartierfc58af42015-04-16 18:00:39 -07001216 // May cause thread suspension due to EqualParameters.
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001217 ArtMethod* GetDeclaredConstructor(Thread* self,
1218 Handle<ObjectArray<Class>> args,
1219 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001220 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierfc58af42015-04-16 18:00:39 -07001221
Andreas Gampe715fdc22016-04-18 17:07:30 -07001222 static int32_t GetInnerClassFlags(Handle<Class> h_this, int32_t default_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001223 REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe715fdc22016-04-18 17:07:30 -07001224
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001225 // Used to initialize a class in the allocation code path to ensure it is guarded by a StoreStore
1226 // fence.
1227 class InitializeClassVisitor {
1228 public:
1229 explicit InitializeClassVisitor(uint32_t class_size) : class_size_(class_size) {
1230 }
1231
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001232 void operator()(ObjPtr<Object> obj, size_t usable_size) const
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001233 REQUIRES_SHARED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001234
1235 private:
1236 const uint32_t class_size_;
1237
1238 DISALLOW_COPY_AND_ASSIGN(InitializeClassVisitor);
1239 };
1240
Sebastien Hertz6963e442014-11-26 22:11:27 +01001241 // Returns true if the class loader is null, ie the class loader is the boot strap class loader.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001242 bool IsBootStrapClassLoaded() REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertz6963e442014-11-26 22:11:27 +01001243 return GetClassLoader() == nullptr;
1244 }
1245
Andreas Gampe542451c2016-07-26 09:02:02 -07001246 static size_t ImTableEntrySize(PointerSize pointer_size) {
1247 return static_cast<size_t>(pointer_size);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001248 }
1249
Andreas Gampe542451c2016-07-26 09:02:02 -07001250 static size_t VTableEntrySize(PointerSize pointer_size) {
1251 return static_cast<size_t>(pointer_size);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001252 }
1253
Andreas Gampe542451c2016-07-26 09:02:02 -07001254 ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethodsSliceUnchecked(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001255 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001256
Andreas Gampe542451c2016-07-26 09:02:02 -07001257 ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethodsSliceUnchecked(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001258 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -08001259
Andreas Gampe542451c2016-07-26 09:02:02 -07001260 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethodsSliceUnchecked(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001261 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -08001262
Andreas Gampe542451c2016-07-26 09:02:02 -07001263 ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethodsSliceUnchecked(
1264 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001265 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -08001266
Andreas Gampe542451c2016-07-26 09:02:02 -07001267 ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSliceUnchecked(PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001268 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -07001269
David Sehr709b0702016-10-13 09:12:37 -07001270 static std::string PrettyDescriptor(ObjPtr<mirror::Class> klass)
1271 REQUIRES_SHARED(Locks::mutator_lock_);
1272 std::string PrettyDescriptor()
1273 REQUIRES_SHARED(Locks::mutator_lock_);
1274 // Returns a human-readable form of the name of the given class.
1275 // Given String.class, the output would be "java.lang.Class<java.lang.String>".
1276 static std::string PrettyClass(ObjPtr<mirror::Class> c)
1277 REQUIRES_SHARED(Locks::mutator_lock_);
1278 std::string PrettyClass()
1279 REQUIRES_SHARED(Locks::mutator_lock_);
1280 // Returns a human-readable form of the name of the given class with its class loader.
1281 static std::string PrettyClassAndClassLoader(ObjPtr<mirror::Class> c)
1282 REQUIRES_SHARED(Locks::mutator_lock_);
1283 std::string PrettyClassAndClassLoader()
1284 REQUIRES_SHARED(Locks::mutator_lock_);
1285
Mathieu Chartier4b00d342015-11-13 10:42:08 -08001286 // Fix up all of the native pointers in the class by running them through the visitor. Only sets
1287 // the corresponding entry in dest if visitor(obj) != obj to prevent dirty memory. Dest should be
Mathieu Chartierfbc31082016-01-24 11:59:56 -08001288 // initialized to a copy of *this to prevent issues. Does not visit the ArtMethod and ArtField
1289 // roots.
Mathieu Chartierdfe02f62016-02-01 20:15:11 -08001290 template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1291 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
1292 typename Visitor>
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001293 void FixupNativePointers(Class* dest, PointerSize pointer_size, const Visitor& visitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001294 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4b00d342015-11-13 10:42:08 -08001295
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001296 private:
Alex Lighte64300b2015-12-15 15:02:47 -08001297 ALWAYS_INLINE void SetMethodsPtrInternal(LengthPrefixedArray<ArtMethod>* new_methods)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001298 REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -08001299
Mathieu Chartier2466d622017-09-26 13:52:26 -07001300 ALWAYS_INLINE static ArraySlice<ArtMethod> GetMethodsSliceRangeUnchecked(
1301 LengthPrefixedArray<ArtMethod>* methods,
1302 PointerSize pointer_size,
1303 uint32_t start_offset,
1304 uint32_t end_offset)
Vladimir Marko9ac77492017-06-14 18:07:03 +01001305 REQUIRES_SHARED(Locks::mutator_lock_);
1306
Vladimir Markof79aa7f2017-07-04 16:58:55 +01001307 template <bool throw_on_failure>
Mathieu Chartierb8901302016-09-30 10:27:43 -07001308 bool ResolvedFieldAccessTest(ObjPtr<Class> access_to,
Mathieu Chartier3398c782016-09-30 10:27:43 -07001309 ArtField* field,
Vladimir Markof79aa7f2017-07-04 16:58:55 +01001310 ObjPtr<DexCache> dex_cache,
1311 uint32_t field_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001312 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierb8901302016-09-30 10:27:43 -07001313
Vladimir Markof79aa7f2017-07-04 16:58:55 +01001314 template <bool throw_on_failure>
Mathieu Chartierb8901302016-09-30 10:27:43 -07001315 bool ResolvedMethodAccessTest(ObjPtr<Class> access_to,
1316 ArtMethod* resolved_method,
Vladimir Markof79aa7f2017-07-04 16:58:55 +01001317 ObjPtr<DexCache> dex_cache,
Mathieu Chartierb8901302016-09-30 10:27:43 -07001318 uint32_t method_idx,
Vladimir Markof79aa7f2017-07-04 16:58:55 +01001319 InvokeType throw_invoke_type)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001320 REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko89786432014-01-31 15:03:55 +00001321
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001322 bool Implements(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier3398c782016-09-30 10:27:43 -07001323 bool IsArrayAssignableFromArray(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_);
1324 bool IsAssignableFromArray(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001325
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001326 void CheckObjectAlloc() REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -07001327
Mathieu Chartierc7853442015-03-27 14:35:38 -07001328 // Unchecked editions is for root visiting.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001329 LengthPrefixedArray<ArtField>* GetSFieldsPtrUnchecked() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier54d220e2015-07-30 16:20:06 -07001330 IterationRange<StrideIterator<ArtField>> GetSFieldsUnchecked()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001331 REQUIRES_SHARED(Locks::mutator_lock_);
1332 LengthPrefixedArray<ArtField>* GetIFieldsPtrUnchecked() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier54d220e2015-07-30 16:20:06 -07001333 IterationRange<StrideIterator<ArtField>> GetIFieldsUnchecked()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001334 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierc7853442015-03-27 14:35:38 -07001335
Alex Lighte64300b2015-12-15 15:02:47 -08001336 // The index in the methods_ array where the first declared virtual method is.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001337 ALWAYS_INLINE uint32_t GetVirtualMethodsStartOffset() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -08001338
1339 // The index in the methods_ array where the first direct method is.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001340 ALWAYS_INLINE uint32_t GetDirectMethodsStartOffset() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -08001341
1342 // The index in the methods_ array where the first copied method is.
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001343 ALWAYS_INLINE uint32_t GetCopiedMethodsStartOffset() REQUIRES_SHARED(Locks::mutator_lock_);
Alex Lighte64300b2015-12-15 15:02:47 -08001344
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001345 bool ProxyDescriptorEquals(const char* match) REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko3481ba22015-04-13 12:22:36 +01001346
Andreas Gampe90b936d2017-01-31 08:58:55 -08001347 template<VerifyObjectFlags kVerifyFlags>
1348 void GetAccessFlagsDCheck() REQUIRES_SHARED(Locks::mutator_lock_);
1349
Roland Levillain0d5a2812015-11-13 10:07:31 +00001350 // Check that the pointer size matches the one in the class linker.
Andreas Gampe542451c2016-07-26 09:02:02 -07001351 ALWAYS_INLINE static void CheckPointerSize(PointerSize pointer_size);
1352
1353 static MemberOffset EmbeddedVTableOffset(PointerSize pointer_size);
Mathieu Chartierfbc31082016-01-24 11:59:56 -08001354 template <bool kVisitNativeRoots,
1355 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
1356 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
1357 typename Visitor>
Mathieu Chartier28bd2e42016-10-04 13:54:57 -07001358 void VisitReferences(ObjPtr<Class> klass, const Visitor& visitor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001359 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier059ef3d2015-08-18 13:54:21 -07001360
Alex Lighte64300b2015-12-15 15:02:47 -08001361 // 'Class' Object Fields
1362 // Order governed by java field ordering. See art::ClassLinker::LinkFields.
1363
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001364 // Defining class loader, or null for the "bootstrap" system loader.
Ian Rogersef7d42f2014-01-06 12:55:46 -08001365 HeapReference<ClassLoader> class_loader_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001366
1367 // For array classes, the component class object for instanceof/checkcast
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001368 // (for String[][][], this will be String[][]). null for non-array classes.
Ian Rogersef7d42f2014-01-06 12:55:46 -08001369 HeapReference<Class> component_type_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001370
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001371 // DexCache of resolved constant pool entries (will be null for classes generated by the
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001372 // runtime such as arrays and primitive classes).
Ian Rogersef7d42f2014-01-06 12:55:46 -08001373 HeapReference<DexCache> dex_cache_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001374
Alex Lightd6251582016-10-31 11:12:30 -07001375 // Extraneous class data that is not always needed. This field is allocated lazily and may
1376 // only be set with 'this' locked. This is synchronized on 'this'.
1377 // TODO(allight) We should probably synchronize it on something external or handle allocation in
1378 // some other (safe) way to prevent possible deadlocks.
1379 HeapReference<ClassExt> ext_data_;
1380
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001381 // The interface table (iftable_) contains pairs of a interface class and an array of the
1382 // interface methods. There is one pair per interface supported by this class. That means one
1383 // pair for each interface we support directly, indirectly via superclass, or indirectly via a
1384 // superinterface. This will be null if neither we nor our superclass implement any interfaces.
1385 //
1386 // Why we need this: given "class Foo implements Face", declare "Face faceObj = new Foo()".
1387 // Invoke faceObj.blah(), where "blah" is part of the Face interface. We can't easily use a
1388 // single vtable.
1389 //
1390 // For every interface a concrete class implements, we create an array of the concrete vtable_
1391 // methods for the methods in the interface.
Ian Rogersef7d42f2014-01-06 12:55:46 -08001392 HeapReference<IfTable> iftable_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001393
Ian Rogersef7d42f2014-01-06 12:55:46 -08001394 // Descriptor for the class such as "java.lang.Class" or "[C". Lazily initialized by ComputeName
1395 HeapReference<String> name_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001396
Brian Carlstrom08ac9222015-05-22 13:43:00 -07001397 // The superclass, or null if this is java.lang.Object or a primitive type.
1398 //
1399 // Note that interfaces have java.lang.Object as their
1400 // superclass. This doesn't match the expectations in JNI
1401 // GetSuperClass or java.lang.Class.getSuperClass() which need to
1402 // check for interfaces and return null.
Ian Rogersef7d42f2014-01-06 12:55:46 -08001403 HeapReference<Class> super_class_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001404
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001405 // Virtual method table (vtable), for use by "invoke-virtual". The vtable from the superclass is
1406 // copied in, and virtual methods from our class either replace those from the super or are
1407 // appended. For abstract classes, methods may be created in the vtable that aren't in
1408 // virtual_ methods_ for miranda methods.
Mathieu Chartiere401d142015-04-22 13:56:20 -07001409 HeapReference<PointerArray> vtable_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001410
Mathieu Chartierc7853442015-03-27 14:35:38 -07001411 // instance fields
1412 //
1413 // These describe the layout of the contents of an Object.
1414 // Note that only the fields directly declared by this class are
1415 // listed in ifields; fields declared by a superclass are listed in
1416 // the superclass's Class.ifields.
1417 //
Mathieu Chartierc0fe56a2015-08-11 13:01:23 -07001418 // ArtFields are allocated as a length prefixed ArtField array, and not an array of pointers to
1419 // ArtFields.
Mathieu Chartierc7853442015-03-27 14:35:38 -07001420 uint64_t ifields_;
1421
Alex Lighte64300b2015-12-15 15:02:47 -08001422 // Pointer to an ArtMethod length-prefixed array. All the methods where this class is the place
1423 // where they are logically defined. This includes all private, static, final and virtual methods
1424 // as well as inherited default methods and miranda methods.
1425 //
1426 // The slice methods_ [0, virtual_methods_offset_) are the direct (static, private, init) methods
1427 // declared by this class.
1428 //
1429 // The slice methods_ [virtual_methods_offset_, copied_methods_offset_) are the virtual methods
1430 // declared by this class.
1431 //
1432 // The slice methods_ [copied_methods_offset_, |methods_|) are the methods that are copied from
1433 // interfaces such as miranda or default methods. These are copied for resolution purposes as this
1434 // class is where they are (logically) declared as far as the virtual dispatch is concerned.
David Srbecky9b3607d2016-01-14 18:15:54 +00001435 //
1436 // Note that this field is used by the native debugger as the unique identifier for the type.
Alex Lighte64300b2015-12-15 15:02:47 -08001437 uint64_t methods_;
1438
Mathieu Chartier54d220e2015-07-30 16:20:06 -07001439 // Static fields length-prefixed array.
Mathieu Chartierc7853442015-03-27 14:35:38 -07001440 uint64_t sfields_;
1441
Neil Fuller3d0aa882016-08-16 19:53:07 +01001442 // Access flags; low 16 bits are defined by VM spec.
1443 uint32_t access_flags_;
1444
Mathieu Chartier52a7f5c2015-08-18 18:35:52 -07001445 // Class flags to help speed up visiting object references.
1446 uint32_t class_flags_;
1447
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001448 // Total size of the Class instance; used when allocating storage on gc heap.
1449 // See also object_size_.
Ian Rogersef7d42f2014-01-06 12:55:46 -08001450 uint32_t class_size_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001451
Ian Rogers8b2c0b92013-09-19 02:56:49 -07001452 // Tid used to check for recursive <clinit> invocation.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001453 pid_t clinit_thread_id_;
1454
Ian Rogers8b2c0b92013-09-19 02:56:49 -07001455 // ClassDef index in dex file, -1 if no class definition such as an array.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001456 // TODO: really 16bits
Ian Rogers8b2c0b92013-09-19 02:56:49 -07001457 int32_t dex_class_def_idx_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001458
Ian Rogers8b2c0b92013-09-19 02:56:49 -07001459 // Type index in dex file.
1460 // TODO: really 16bits
1461 int32_t dex_type_idx_;
1462
1463 // Number of instance fields that are object refs.
Ian Rogersef7d42f2014-01-06 12:55:46 -08001464 uint32_t num_reference_instance_fields_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001465
Ian Rogers8b2c0b92013-09-19 02:56:49 -07001466 // Number of static fields that are object refs,
Ian Rogersef7d42f2014-01-06 12:55:46 -08001467 uint32_t num_reference_static_fields_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001468
1469 // Total object size; used when allocating storage on gc heap.
1470 // (For interfaces and abstract classes this will be zero.)
1471 // See also class_size_.
Ian Rogersef7d42f2014-01-06 12:55:46 -08001472 uint32_t object_size_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001473
Mathieu Chartier161db1d2016-09-01 14:06:54 -07001474 // Aligned object size for allocation fast path. The value is max uint32_t if the object is
Mathieu Chartier93bbee02016-08-31 09:38:40 -07001475 // uninitialized or finalizable. Not currently used for variable sized objects.
1476 uint32_t object_size_alloc_fast_path_;
1477
Hiroshi Yamauchif0edfc32014-09-25 11:46:46 -07001478 // The lower 16 bits contains a Primitive::Type value. The upper 16
1479 // bits contains the size shift of the primitive type.
1480 uint32_t primitive_type_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001481
1482 // Bitmap of offsets of ifields.
1483 uint32_t reference_instance_offsets_;
1484
Igor Murashkin86083f72017-10-27 10:59:04 -07001485 // See the real definition in subtype_check_bits_and_status.h
1486 // typeof(status_) is actually SubtypeCheckBitsAndStatus.
1487 uint32_t status_;
Igor Murashkincf83aaa2017-09-08 03:21:54 +00001488
Alex Lighte64300b2015-12-15 15:02:47 -08001489 // The offset of the first virtual method that is copied from an interface. This includes miranda,
1490 // default, and default-conflict methods. Having a hard limit of ((2 << 16) - 1) for methods
1491 // defined on a single class is well established in Java so we will use only uint16_t's here.
1492 uint16_t copied_methods_offset_;
1493
1494 // The offset of the first declared virtual methods in the methods_ array.
1495 uint16_t virtual_methods_offset_;
1496
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001497 // TODO: ?
1498 // initiating class loader list
1499 // NOTE: for classes with low serialNumber, these are unused, and the
1500 // values are kept in a table in gDvm.
1501 // InitiatingLoaderList initiating_loader_list_;
1502
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001503 // The following data exist in real class objects.
1504 // Embedded Imtable, for class object that's not an interface, fixed size.
Ian Rogers03b6eaf2014-10-28 09:34:57 -07001505 // ImTableEntry embedded_imtable_[0];
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001506 // Embedded Vtable, for class object that's not an interface, variable size.
Ian Rogers03b6eaf2014-10-28 09:34:57 -07001507 // VTableEntry embedded_vtable_[0];
Mingyao Yang98d1cc82014-05-15 17:02:16 -07001508 // Static fields, variable size.
Ian Rogers03b6eaf2014-10-28 09:34:57 -07001509 // uint32_t fields_[0];
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001510
1511 // java.lang.Class
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -07001512 static GcRoot<Class> java_lang_Class_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001513
Mathieu Chartier279ac5c2016-09-08 17:34:25 -07001514 ART_FRIEND_TEST(DexCacheTest, TestResolvedFieldAccess); // For ResolvedFieldAccessTest
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001515 friend struct art::ClassOffsets; // for verifying offset information
Mathieu Chartier059ef3d2015-08-18 13:54:21 -07001516 friend class Object; // For VisitReferences
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001517 DISALLOW_IMPLICIT_CONSTRUCTORS(Class);
1518};
1519
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001520} // namespace mirror
1521} // namespace art
1522
Brian Carlstromfc0e3212013-07-17 14:40:12 -07001523#endif // ART_RUNTIME_MIRROR_CLASS_H_