Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_MIRROR_CLASS_H_ |
| 18 | #define ART_RUNTIME_MIRROR_CLASS_H_ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 19 | |
Andreas Gampe | 3b7dc35 | 2017-06-06 20:02:03 -0700 | [diff] [blame] | 20 | #include "base/bit_utils.h" |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 21 | #include "base/casts.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 22 | #include "base/enums.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 23 | #include "base/iteration_range.h" |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 24 | #include "class_flags.h" |
Andreas Gampe | ee5303f | 2017-08-31 15:34:42 -0700 | [diff] [blame] | 25 | #include "class_status.h" |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 26 | #include "dex_file.h" |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 27 | #include "dex_file_types.h" |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 28 | #include "gc/allocator_type.h" |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 29 | #include "gc_root.h" |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 30 | #include "imtable.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 31 | #include "modifiers.h" |
| 32 | #include "object.h" |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 33 | #include "object_array.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 34 | #include "primitive.h" |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 35 | #include "read_barrier_option.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 36 | #include "stride_iterator.h" |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 37 | #include "thread.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 38 | #include "utils.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 39 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 40 | namespace art { |
| 41 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 42 | class ArtField; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 43 | class ArtMethod; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 44 | struct ClassOffsets; |
Andreas Gampe | 5a4b8a2 | 2014-09-11 08:30:08 -0700 | [diff] [blame] | 45 | template<class T> class Handle; |
Andreas Gampe | 04c6ab9 | 2017-06-08 21:49:14 -0700 | [diff] [blame] | 46 | enum InvokeType : uint32_t; |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 47 | template<typename T> class LengthPrefixedArray; |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 48 | template<typename T> class ArraySlice; |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 49 | class Signature; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 50 | class StringPiece; |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 51 | template<size_t kNumReferences> class PACKED(4) StackHandleScope; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 52 | |
| 53 | namespace mirror { |
| 54 | |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 55 | class ClassExt; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 56 | class ClassLoader; |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 57 | class Constructor; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 58 | class DexCache; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 59 | class IfTable; |
Andreas Gampe | bc4d218 | 2016-02-22 10:03:12 -0800 | [diff] [blame] | 60 | class Method; |
Narayan Kamath | c38a6f8 | 2016-09-29 17:07:20 +0100 | [diff] [blame] | 61 | template <typename T> struct PACKED(8) DexCachePair; |
Christina Wadsworth | bf44e0e | 2016-08-18 10:37:42 -0700 | [diff] [blame] | 62 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 63 | using StringDexCachePair = DexCachePair<String>; |
Narayan Kamath | c38a6f8 | 2016-09-29 17:07:20 +0100 | [diff] [blame] | 64 | using StringDexCacheType = std::atomic<StringDexCachePair>; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 65 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 66 | // C++ mirror of java.lang.Class |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 67 | class MANAGED Class FINAL : public Object { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 68 | public: |
Ian Rogers | cdc1aaf | 2014-10-09 13:21:38 -0700 | [diff] [blame] | 69 | // A magic value for reference_instance_offsets_. Ignore the bits and walk the super chain when |
| 70 | // this is the value. |
| 71 | // [This is an unlikely "natural" value, since it would be 30 non-ref instance fields followed by |
| 72 | // 2 ref instance fields.] |
| 73 | static constexpr uint32_t kClassWalkSuper = 0xC0000000; |
| 74 | |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 75 | // Shift primitive type by kPrimitiveTypeSizeShiftShift to get the component type size shift |
| 76 | // Used for computing array size as follows: |
| 77 | // array_bytes = header_size + (elements << (primitive_type >> kPrimitiveTypeSizeShiftShift)) |
| 78 | static constexpr uint32_t kPrimitiveTypeSizeShiftShift = 16; |
| 79 | static constexpr uint32_t kPrimitiveTypeMask = (1u << kPrimitiveTypeSizeShiftShift) - 1; |
| 80 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 81 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 82 | ClassStatus GetStatus() REQUIRES_SHARED(Locks::mutator_lock_) { |
Igor Murashkin | 86083f7 | 2017-10-27 10:59:04 -0700 | [diff] [blame] | 83 | // Avoid including "subtype_check_bits_and_status.h" to get the field. |
| 84 | // The ClassStatus is always in the least-significant bits of status_. |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 85 | return enum_cast<ClassStatus>( |
| 86 | static_cast<uint32_t>(GetField32Volatile<kVerifyFlags>(StatusOffset())) & 0xff); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Hiroshi Yamauchi | 5b783e6 | 2015-03-18 17:20:11 -0700 | [diff] [blame] | 89 | // This is static because 'this' may be moved by GC. |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 90 | static void SetStatus(Handle<Class> h_this, ClassStatus new_status, Thread* self) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 91 | REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 92 | |
Ian Rogers | 5ddb410 | 2014-01-07 08:58:46 -0800 | [diff] [blame] | 93 | static MemberOffset StatusOffset() { |
Igor Murashkin | 86083f7 | 2017-10-27 10:59:04 -0700 | [diff] [blame] | 94 | return MemberOffset(OFFSET_OF_OBJECT_MEMBER(Class, status_)); |
Ian Rogers | 5ddb410 | 2014-01-07 08:58:46 -0800 | [diff] [blame] | 95 | } |
| 96 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 97 | // Returns true if the class has been retired. |
| 98 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 99 | bool IsRetired() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 100 | return GetStatus<kVerifyFlags>() == ClassStatus::kRetired; |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 103 | // Returns true if the class has failed to link. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 104 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Vladimir Marko | 72ab684 | 2017-01-20 19:32:50 +0000 | [diff] [blame] | 105 | bool IsErroneousUnresolved() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 106 | return GetStatus<kVerifyFlags>() == ClassStatus::kErrorUnresolved; |
Vladimir Marko | 72ab684 | 2017-01-20 19:32:50 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | // Returns true if the class has failed to initialize. |
| 110 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 111 | bool IsErroneousResolved() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 112 | return GetStatus<kVerifyFlags>() == ClassStatus::kErrorResolved; |
Vladimir Marko | 72ab684 | 2017-01-20 19:32:50 +0000 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | // Returns true if the class status indicets that the class has failed to link or initialize. |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 116 | static bool IsErroneous(ClassStatus status) { |
| 117 | return status == ClassStatus::kErrorUnresolved || status == ClassStatus::kErrorResolved; |
Vladimir Marko | 72ab684 | 2017-01-20 19:32:50 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | // Returns true if the class has failed to link or initialize. |
| 121 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 122 | bool IsErroneous() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 72ab684 | 2017-01-20 19:32:50 +0000 | [diff] [blame] | 123 | return IsErroneous(GetStatus<kVerifyFlags>()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | // Returns true if the class has been loaded. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 127 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 128 | bool IsIdxLoaded() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 129 | return GetStatus<kVerifyFlags>() >= ClassStatus::kIdx; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | // Returns true if the class has been loaded. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 133 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 134 | bool IsLoaded() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 135 | return GetStatus<kVerifyFlags>() >= ClassStatus::kLoaded; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | // Returns true if the class has been linked. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 139 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 140 | bool IsResolved() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 141 | ClassStatus status = GetStatus<kVerifyFlags>(); |
| 142 | return status >= ClassStatus::kResolved || status == ClassStatus::kErrorResolved; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 143 | } |
| 144 | |
Nicolas Geoffray | 7cc3ae5 | 2017-03-07 14:33:37 +0000 | [diff] [blame] | 145 | // Returns true if the class should be verified at runtime. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 146 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Nicolas Geoffray | 7cc3ae5 | 2017-03-07 14:33:37 +0000 | [diff] [blame] | 147 | bool ShouldVerifyAtRuntime() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 148 | return GetStatus<kVerifyFlags>() == ClassStatus::kRetryVerificationAtRuntime; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | // Returns true if the class has been verified. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 152 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 153 | bool IsVerified() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 154 | return GetStatus<kVerifyFlags>() >= ClassStatus::kVerified; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | // Returns true if the class is initializing. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 158 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 159 | bool IsInitializing() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 160 | return GetStatus<kVerifyFlags>() >= ClassStatus::kInitializing; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | // Returns true if the class is initialized. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 164 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 165 | bool IsInitialized() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 166 | return GetStatus<kVerifyFlags>() == ClassStatus::kInitialized; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 167 | } |
| 168 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 169 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | 90b936d | 2017-01-31 08:58:55 -0800 | [diff] [blame] | 170 | ALWAYS_INLINE uint32_t GetAccessFlags() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 171 | if (kIsDebugBuild) { |
| 172 | GetAccessFlagsDCheck<kVerifyFlags>(); |
| 173 | } |
| 174 | return GetField32<kVerifyFlags>(AccessFlagsOffset()); |
| 175 | } |
| 176 | |
Hiroshi Yamauchi | e01a520 | 2015-03-19 12:35:04 -0700 | [diff] [blame] | 177 | static MemberOffset AccessFlagsOffset() { |
| 178 | return OFFSET_OF_OBJECT_MEMBER(Class, access_flags_); |
| 179 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 180 | |
Mathieu Chartier | 52a7f5c | 2015-08-18 18:35:52 -0700 | [diff] [blame] | 181 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 182 | ALWAYS_INLINE uint32_t GetClassFlags() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 52a7f5c | 2015-08-18 18:35:52 -0700 | [diff] [blame] | 183 | return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_flags_)); |
| 184 | } |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 185 | void SetClassFlags(uint32_t new_flags) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 52a7f5c | 2015-08-18 18:35:52 -0700 | [diff] [blame] | 186 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 187 | void SetAccessFlags(uint32_t new_access_flags) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 188 | |
| 189 | // Returns true if the class is an interface. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 190 | ALWAYS_INLINE bool IsInterface() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 191 | return (GetAccessFlags() & kAccInterface) != 0; |
| 192 | } |
| 193 | |
| 194 | // Returns true if the class is declared public. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 195 | ALWAYS_INLINE bool IsPublic() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 196 | return (GetAccessFlags() & kAccPublic) != 0; |
| 197 | } |
| 198 | |
| 199 | // Returns true if the class is declared final. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 200 | ALWAYS_INLINE bool IsFinal() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 201 | return (GetAccessFlags() & kAccFinal) != 0; |
| 202 | } |
| 203 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 204 | ALWAYS_INLINE bool IsFinalizable() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 205 | return (GetAccessFlags() & kAccClassIsFinalizable) != 0; |
| 206 | } |
| 207 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 208 | ALWAYS_INLINE void SetRecursivelyInitialized() REQUIRES_SHARED(Locks::mutator_lock_) { |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 209 | DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId()); |
| 210 | uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_)); |
| 211 | SetAccessFlags(flags | kAccRecursivelyInitialized); |
| 212 | } |
| 213 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 214 | ALWAYS_INLINE void SetHasDefaultMethods() REQUIRES_SHARED(Locks::mutator_lock_) { |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 215 | DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId()); |
| 216 | uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_)); |
| 217 | SetAccessFlags(flags | kAccHasDefaultMethod); |
| 218 | } |
| 219 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 220 | ALWAYS_INLINE void SetFinalizable() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 221 | uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 222 | SetAccessFlags(flags | kAccClassIsFinalizable); |
| 223 | } |
| 224 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 225 | ALWAYS_INLINE bool IsStringClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 52a7f5c | 2015-08-18 18:35:52 -0700 | [diff] [blame] | 226 | return (GetClassFlags() & kClassFlagString) != 0; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 227 | } |
| 228 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 229 | ALWAYS_INLINE void SetStringClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 66c2d2d | 2015-08-25 14:32:32 -0700 | [diff] [blame] | 230 | SetClassFlags(kClassFlagString | kClassFlagNoReferenceFields); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 231 | } |
| 232 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 233 | ALWAYS_INLINE bool IsClassLoaderClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 66c2d2d | 2015-08-25 14:32:32 -0700 | [diff] [blame] | 234 | return GetClassFlags() == kClassFlagClassLoader; |
Mathieu Chartier | e4275c0 | 2015-08-06 15:34:15 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 237 | ALWAYS_INLINE void SetClassLoaderClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 66c2d2d | 2015-08-25 14:32:32 -0700 | [diff] [blame] | 238 | SetClassFlags(kClassFlagClassLoader); |
Mathieu Chartier | e4275c0 | 2015-08-06 15:34:15 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 241 | ALWAYS_INLINE bool IsDexCacheClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 242 | return (GetClassFlags() & kClassFlagDexCache) != 0; |
| 243 | } |
| 244 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 245 | ALWAYS_INLINE void SetDexCacheClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 246 | SetClassFlags(GetClassFlags() | kClassFlagDexCache); |
| 247 | } |
| 248 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 249 | // Returns true if the class is abstract. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 250 | ALWAYS_INLINE bool IsAbstract() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 251 | return (GetAccessFlags() & kAccAbstract) != 0; |
| 252 | } |
| 253 | |
| 254 | // Returns true if the class is an annotation. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 255 | ALWAYS_INLINE bool IsAnnotation() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 256 | return (GetAccessFlags() & kAccAnnotation) != 0; |
| 257 | } |
| 258 | |
| 259 | // Returns true if the class is synthetic. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 260 | ALWAYS_INLINE bool IsSynthetic() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 261 | return (GetAccessFlags() & kAccSynthetic) != 0; |
| 262 | } |
| 263 | |
Igor Murashkin | 8d1da85 | 2016-02-04 11:01:21 -0800 | [diff] [blame] | 264 | // Return whether the class had run the verifier at least once. |
Igor Murashkin | df707e4 | 2016-02-02 16:56:50 -0800 | [diff] [blame] | 265 | // This does not necessarily mean that access checks are avoidable, |
| 266 | // since the class methods might still need to be run with access checks. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 267 | bool WasVerificationAttempted() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | b0a6aee | 2017-10-27 10:34:04 +0100 | [diff] [blame] | 268 | return (GetAccessFlags() & kAccVerificationAttempted) != 0; |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Igor Murashkin | df707e4 | 2016-02-02 16:56:50 -0800 | [diff] [blame] | 271 | // Mark the class as having gone through a verification attempt. |
| 272 | // Mutually exclusive from whether or not each method is allowed to skip access checks. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 273 | void SetVerificationAttempted() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 274 | uint32_t flags = GetField32(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_)); |
Mathieu Chartier | 085a072 | 2016-04-01 17:33:31 -0700 | [diff] [blame] | 275 | if ((flags & kAccVerificationAttempted) == 0) { |
| 276 | SetAccessFlags(flags | kAccVerificationAttempted); |
| 277 | } |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 280 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 281 | bool IsTypeOfReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 52a7f5c | 2015-08-18 18:35:52 -0700 | [diff] [blame] | 282 | return (GetClassFlags<kVerifyFlags>() & kClassFlagReference) != 0; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 283 | } |
| 284 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 285 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 286 | bool IsWeakReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 66c2d2d | 2015-08-25 14:32:32 -0700 | [diff] [blame] | 287 | return GetClassFlags<kVerifyFlags>() == kClassFlagWeakReference; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 288 | } |
| 289 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 290 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 291 | bool IsSoftReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 66c2d2d | 2015-08-25 14:32:32 -0700 | [diff] [blame] | 292 | return GetClassFlags<kVerifyFlags>() == kClassFlagSoftReference; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 293 | } |
| 294 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 295 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 296 | bool IsFinalizerReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 66c2d2d | 2015-08-25 14:32:32 -0700 | [diff] [blame] | 297 | return GetClassFlags<kVerifyFlags>() == kClassFlagFinalizerReference; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 298 | } |
| 299 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 300 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 301 | bool IsPhantomReferenceClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 66c2d2d | 2015-08-25 14:32:32 -0700 | [diff] [blame] | 302 | return GetClassFlags<kVerifyFlags>() == kClassFlagPhantomReference; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 303 | } |
| 304 | |
Ian Rogers | 04f94f4 | 2013-06-10 15:09:26 -0700 | [diff] [blame] | 305 | // Can references of this type be assigned to by things of another type? For non-array types |
| 306 | // this is a matter of whether sub-classes may exist - which they can't if the type is final. |
| 307 | // For array classes, where all the classes are final due to there being no sub-classes, an |
| 308 | // Object[] may be assigned to by a String[] but a String[] may not be assigned to by other |
| 309 | // types as the component is final. |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 310 | bool CannotBeAssignedFromOtherTypes() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 311 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 312 | // Returns true if this class is the placeholder and should retire and |
| 313 | // be replaced with a class with the right size for embedded imt/vtable. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 314 | bool IsTemp() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame^] | 315 | ClassStatus s = GetStatus(); |
| 316 | return s < ClassStatus::kResolving && |
| 317 | s != ClassStatus::kErrorResolved && |
| 318 | ShouldHaveEmbeddedVTable(); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 319 | } |
| 320 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 321 | String* GetName() REQUIRES_SHARED(Locks::mutator_lock_); // Returns the cached name. |
Mathieu Chartier | 1a5337f | 2016-10-13 13:48:23 -0700 | [diff] [blame] | 322 | void SetName(ObjPtr<String> name) REQUIRES_SHARED(Locks::mutator_lock_); // Sets the cached name. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 323 | // Computes the name, then sets the cached value. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 324 | static String* ComputeName(Handle<Class> h_this) REQUIRES_SHARED(Locks::mutator_lock_) |
Mathieu Chartier | ed8990a | 2015-07-23 14:11:16 -0700 | [diff] [blame] | 325 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 326 | |
Mathieu Chartier | c2f4d02 | 2014-03-03 16:11:42 -0800 | [diff] [blame] | 327 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 328 | bool IsProxyClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 329 | // Read access flags without using getter as whether something is a proxy can be check in |
| 330 | // any loaded state |
| 331 | // TODO: switch to a check if the super class is java.lang.reflect.Proxy? |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 332 | uint32_t access_flags = GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, access_flags_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 333 | return (access_flags & kAccClassIsProxy) != 0; |
| 334 | } |
| 335 | |
Nicolas Geoffray | 85c7bab | 2015-09-18 13:40:46 +0000 | [diff] [blame] | 336 | static MemberOffset PrimitiveTypeOffset() { |
| 337 | return OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_); |
| 338 | } |
| 339 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 340 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 341 | Primitive::Type GetPrimitiveType() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 342 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 343 | void SetPrimitiveType(Primitive::Type new_type) REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 344 | DCHECK_EQ(sizeof(Primitive::Type), sizeof(int32_t)); |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 345 | uint32_t v32 = static_cast<uint32_t>(new_type); |
| 346 | DCHECK_EQ(v32 & kPrimitiveTypeMask, v32) << "upper 16 bits aren't zero"; |
Hiroshi Yamauchi | f0edfc3 | 2014-09-25 11:46:46 -0700 | [diff] [blame] | 347 | // Store the component size shift in the upper 16 bits. |
Mathieu Chartier | 8261d02 | 2016-08-08 09:41:04 -0700 | [diff] [blame] | 348 | v32 |= Primitive::ComponentSizeShift(new_type) << kPrimitiveTypeSizeShiftShift; |
Chang Xing | 6d3e768 | 2017-07-11 10:31:29 -0700 | [diff] [blame] | 349 | SetField32Transaction(OFFSET_OF_OBJECT_MEMBER(Class, primitive_type_), v32); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 350 | } |
| 351 | |
Hiroshi Yamauchi | f0edfc3 | 2014-09-25 11:46:46 -0700 | [diff] [blame] | 352 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 353 | size_t GetPrimitiveTypeSizeShift() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | f0edfc3 | 2014-09-25 11:46:46 -0700 | [diff] [blame] | 354 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 355 | // Returns true if the class is a primitive type. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 356 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 357 | bool IsPrimitive() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 358 | return GetPrimitiveType<kVerifyFlags>() != Primitive::kPrimNot; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 359 | } |
| 360 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 361 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 362 | bool IsPrimitiveBoolean() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 363 | return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimBoolean; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 364 | } |
| 365 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 366 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 367 | bool IsPrimitiveByte() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 368 | return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimByte; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 369 | } |
| 370 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 371 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 372 | bool IsPrimitiveChar() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 373 | return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimChar; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 374 | } |
| 375 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 376 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 377 | bool IsPrimitiveShort() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 378 | return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimShort; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 379 | } |
| 380 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 381 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 382 | bool IsPrimitiveInt() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 383 | return GetPrimitiveType() == Primitive::kPrimInt; |
| 384 | } |
| 385 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 386 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 387 | bool IsPrimitiveLong() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 388 | return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimLong; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 389 | } |
| 390 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 391 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 392 | bool IsPrimitiveFloat() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 393 | return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimFloat; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 394 | } |
| 395 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 396 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 397 | bool IsPrimitiveDouble() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 398 | return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimDouble; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 399 | } |
| 400 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 401 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 402 | bool IsPrimitiveVoid() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 403 | return GetPrimitiveType<kVerifyFlags>() == Primitive::kPrimVoid; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 404 | } |
| 405 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 406 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 407 | bool IsPrimitiveArray() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 408 | return IsArrayClass<kVerifyFlags>() && |
| 409 | GetComponentType<static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis)>()-> |
| 410 | IsPrimitive(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | // Depth of class from java.lang.Object |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 414 | uint32_t Depth() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 415 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 416 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 417 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 418 | bool IsArrayClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 419 | |
Hiroshi Yamauchi | 25023c7 | 2014-05-09 11:45:53 -0700 | [diff] [blame] | 420 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 421 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 422 | bool IsClassClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 423 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 424 | bool IsThrowableClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 425 | |
Hiroshi Yamauchi | 4f1ebc2 | 2014-06-25 14:30:41 -0700 | [diff] [blame] | 426 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 427 | bool IsReferenceClass() const REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 4ee7a66 | 2014-07-11 09:59:27 -0700 | [diff] [blame] | 428 | |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 429 | static MemberOffset ComponentTypeOffset() { |
| 430 | return OFFSET_OF_OBJECT_MEMBER(Class, component_type_); |
| 431 | } |
| 432 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 433 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 434 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 435 | Class* GetComponentType() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 436 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 437 | void SetComponentType(ObjPtr<Class> new_component_type) REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 438 | DCHECK(GetComponentType() == nullptr); |
| 439 | DCHECK(new_component_type != nullptr); |
Sebastien Hertz | ee1d79a | 2014-02-21 15:46:30 +0100 | [diff] [blame] | 440 | // Component type is invariant: use non-transactional mode without check. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 441 | SetFieldObject<false, false>(ComponentTypeOffset(), new_component_type); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 442 | } |
| 443 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 444 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 445 | size_t GetComponentSize() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 5ffa078 | 2016-07-27 10:45:47 -0700 | [diff] [blame] | 446 | return 1U << GetComponentSizeShift<kReadBarrierOption>(); |
Hiroshi Yamauchi | f0edfc3 | 2014-09-25 11:46:46 -0700 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 450 | size_t GetComponentSizeShift() REQUIRES_SHARED(Locks::mutator_lock_) { |
Hiroshi Yamauchi | f0edfc3 | 2014-09-25 11:46:46 -0700 | [diff] [blame] | 451 | return GetComponentType<kDefaultVerifyFlags, kReadBarrierOption>()->GetPrimitiveTypeSizeShift(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 452 | } |
| 453 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 454 | bool IsObjectClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 455 | return !IsPrimitive() && GetSuperClass() == nullptr; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 456 | } |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 457 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 458 | bool IsInstantiableNonArray() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 459 | return !IsPrimitive() && !IsInterface() && !IsAbstract() && !IsArrayClass(); |
| 460 | } |
| 461 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 462 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 463 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 464 | bool IsInstantiable() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 465 | return (!IsPrimitive() && !IsInterface() && !IsAbstract()) || |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 466 | (IsAbstract() && IsArrayClass<kVerifyFlags, kReadBarrierOption>()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 467 | } |
| 468 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 469 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 470 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | c6ea7d0 | 2017-02-01 16:46:28 -0800 | [diff] [blame] | 471 | ALWAYS_INLINE bool IsObjectArrayClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 472 | |
| 473 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 474 | bool IsIntArrayClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 475 | constexpr auto kNewFlags = static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis); |
| 476 | auto* component_type = GetComponentType<kVerifyFlags>(); |
| 477 | return component_type != nullptr && component_type->template IsPrimitiveInt<kNewFlags>(); |
| 478 | } |
| 479 | |
| 480 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 481 | bool IsLongArrayClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 482 | constexpr auto kNewFlags = static_cast<VerifyObjectFlags>(kVerifyFlags & ~kVerifyThis); |
| 483 | auto* component_type = GetComponentType<kVerifyFlags>(); |
| 484 | return component_type != nullptr && component_type->template IsPrimitiveLong<kNewFlags>(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | // Creates a raw object instance but does not invoke the default constructor. |
Mathieu Chartier | 8668c3c | 2014-04-24 16:48:11 -0700 | [diff] [blame] | 488 | template<bool kIsInstrumented, bool kCheckAddFinalizer = true> |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 489 | ALWAYS_INLINE ObjPtr<Object> Alloc(Thread* self, gc::AllocatorType allocator_type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 490 | REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Hiroshi Yamauchi | 3b4c189 | 2013-09-12 21:33:12 -0700 | [diff] [blame] | 491 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 492 | ObjPtr<Object> AllocObject(Thread* self) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 493 | REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 494 | ObjPtr<Object> AllocNonMovableObject(Thread* self) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 495 | REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 496 | |
Hiroshi Yamauchi | 25023c7 | 2014-05-09 11:45:53 -0700 | [diff] [blame] | 497 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 498 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | c6ea7d0 | 2017-02-01 16:46:28 -0800 | [diff] [blame] | 499 | ALWAYS_INLINE bool IsVariableSize() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 500 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 501 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 502 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 503 | uint32_t SizeOf() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 504 | return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 505 | } |
| 506 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 507 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 508 | uint32_t GetClassSize() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 509 | return GetField32<kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(Class, class_size_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 510 | } |
| 511 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 512 | void SetClassSize(uint32_t new_class_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 513 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 514 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 515 | // Compute how many bytes would be used a class with the given elements. |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 516 | static uint32_t ComputeClassSize(bool has_embedded_vtable, |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 517 | uint32_t num_vtable_entries, |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 518 | uint32_t num_8bit_static_fields, |
| 519 | uint32_t num_16bit_static_fields, |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 520 | uint32_t num_32bit_static_fields, |
| 521 | uint32_t num_64bit_static_fields, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 522 | uint32_t num_ref_static_fields, |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 523 | PointerSize pointer_size); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 524 | |
| 525 | // The size of java.lang.Class.class. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 526 | static uint32_t ClassClassSize(PointerSize pointer_size) { |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 527 | // The number of vtable entries in java.lang.Class. |
Narayan Kamath | 6b2dc31 | 2017-03-14 13:26:12 +0000 | [diff] [blame] | 528 | uint32_t vtable_entries = Object::kVTableLength + 67; |
Yi Kong | ff633e2 | 2015-11-06 13:33:22 +0000 | [diff] [blame] | 529 | return ComputeClassSize(true, vtable_entries, 0, 0, 4, 1, 0, pointer_size); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | // The size of a java.lang.Class representing a primitive such as int.class. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 533 | static uint32_t PrimitiveClassSize(PointerSize pointer_size) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 534 | return ComputeClassSize(false, 0, 0, 0, 0, 0, 0, pointer_size); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 535 | } |
| 536 | |
Hiroshi Yamauchi | 25023c7 | 2014-05-09 11:45:53 -0700 | [diff] [blame] | 537 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 538 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 539 | uint32_t GetObjectSize() REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | e01a520 | 2015-03-19 12:35:04 -0700 | [diff] [blame] | 540 | static MemberOffset ObjectSizeOffset() { |
| 541 | return OFFSET_OF_OBJECT_MEMBER(Class, object_size_); |
| 542 | } |
Mathieu Chartier | 93bbee0 | 2016-08-31 09:38:40 -0700 | [diff] [blame] | 543 | static MemberOffset ObjectSizeAllocFastPathOffset() { |
| 544 | return OFFSET_OF_OBJECT_MEMBER(Class, object_size_alloc_fast_path_); |
| 545 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 546 | |
Andreas Gampe | c6ea7d0 | 2017-02-01 16:46:28 -0800 | [diff] [blame] | 547 | ALWAYS_INLINE void SetObjectSize(uint32_t new_object_size) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 548 | |
Mathieu Chartier | 93bbee0 | 2016-08-31 09:38:40 -0700 | [diff] [blame] | 549 | void SetObjectSizeAllocFastPath(uint32_t new_object_size) REQUIRES_SHARED(Locks::mutator_lock_); |
| 550 | |
Mathieu Chartier | 161db1d | 2016-09-01 14:06:54 -0700 | [diff] [blame] | 551 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 552 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
| 553 | uint32_t GetObjectSizeAllocFastPath() REQUIRES_SHARED(Locks::mutator_lock_); |
| 554 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 555 | void SetObjectSizeWithoutChecks(uint32_t new_object_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 556 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 557 | // Not called within a transaction. |
| 558 | return SetField32<false, false, kVerifyNone>( |
| 559 | OFFSET_OF_OBJECT_MEMBER(Class, object_size_), new_object_size); |
| 560 | } |
| 561 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 562 | // Returns true if this class is in the same packages as that class. |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 563 | bool IsInSamePackage(ObjPtr<Class> that) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 564 | |
| 565 | static bool IsInSamePackage(const StringPiece& descriptor1, const StringPiece& descriptor2); |
| 566 | |
| 567 | // Returns true if this class can access that class. |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 568 | bool CanAccess(ObjPtr<Class> that) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 569 | |
| 570 | // Can this class access a member in the provided class with the provided member access flags? |
| 571 | // Note that access to the class isn't checked in case the declaring class is protected and the |
| 572 | // method has been exposed by a public sub-class |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 573 | bool CanAccessMember(ObjPtr<Class> access_to, uint32_t member_flags) |
| 574 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 575 | |
Vladimir Marko | 23a2821 | 2014-01-09 19:24:37 +0000 | [diff] [blame] | 576 | // Can this class access a resolved field? |
| 577 | // Note that access to field's class is checked and this may require looking up the class |
| 578 | // referenced by the FieldId in the DexFile in case the declaring class is inaccessible. |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 579 | bool CanAccessResolvedField(ObjPtr<Class> access_to, |
| 580 | ArtField* field, |
| 581 | ObjPtr<DexCache> dex_cache, |
| 582 | uint32_t field_idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 583 | REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | f79aa7f | 2017-07-04 16:58:55 +0100 | [diff] [blame] | 584 | bool CheckResolvedFieldAccess(ObjPtr<Class> access_to, |
| 585 | ArtField* field, |
| 586 | ObjPtr<DexCache> dex_cache, |
| 587 | uint32_t field_idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 588 | REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 23a2821 | 2014-01-09 19:24:37 +0000 | [diff] [blame] | 589 | |
| 590 | // Can this class access a resolved method? |
| 591 | // Note that access to methods's class is checked and this may require looking up the class |
| 592 | // referenced by the MethodId in the DexFile in case the declaring class is inaccessible. |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 593 | bool CanAccessResolvedMethod(ObjPtr<Class> access_to, |
| 594 | ArtMethod* resolved_method, |
| 595 | ObjPtr<DexCache> dex_cache, |
| 596 | uint32_t method_idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 597 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 598 | bool CheckResolvedMethodAccess(ObjPtr<Class> access_to, |
| 599 | ArtMethod* resolved_method, |
Vladimir Marko | f79aa7f | 2017-07-04 16:58:55 +0100 | [diff] [blame] | 600 | ObjPtr<DexCache> dex_cache, |
| 601 | uint32_t method_idx, |
| 602 | InvokeType throw_invoke_type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 603 | REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 23a2821 | 2014-01-09 19:24:37 +0000 | [diff] [blame] | 604 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 605 | bool IsSubClass(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 606 | |
| 607 | // Can src be assigned to this class? For example, String can be assigned to Object (by an |
| 608 | // upcast), however, an Object cannot be assigned to a String as a potentially exception throwing |
| 609 | // downcast would be necessary. Similarly for interfaces, a class that implements (or an interface |
| 610 | // that extends) another can be assigned to its parent, but not vice-versa. All Classes may assign |
| 611 | // to themselves. Classes for primitive types may not assign to each other. |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 612 | ALWAYS_INLINE bool IsAssignableFrom(ObjPtr<Class> src) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 613 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 614 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 615 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 616 | ALWAYS_INLINE Class* GetSuperClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 617 | |
Calin Juravle | 52503d8 | 2015-11-11 16:58:31 +0000 | [diff] [blame] | 618 | // Get first common super class. It will never return null. |
| 619 | // `This` and `klass` must be classes. |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 620 | ObjPtr<Class> GetCommonSuperClass(Handle<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Calin Juravle | 52503d8 | 2015-11-11 16:58:31 +0000 | [diff] [blame] | 621 | |
Roland Levillain | 8ca4e4e | 2017-02-03 15:12:38 +0000 | [diff] [blame] | 622 | void SetSuperClass(ObjPtr<Class> new_super_class) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 623 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 624 | bool HasSuperClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 625 | return GetSuperClass() != nullptr; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | static MemberOffset SuperClassOffset() { |
| 629 | return MemberOffset(OFFSETOF_MEMBER(Class, super_class_)); |
| 630 | } |
| 631 | |
Nicolas Geoffray | e51ca8b | 2016-11-22 14:49:31 +0000 | [diff] [blame] | 632 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 633 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 634 | ClassLoader* GetClassLoader() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 635 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 636 | void SetClassLoader(ObjPtr<ClassLoader> new_cl) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 637 | |
| 638 | static MemberOffset DexCacheOffset() { |
| 639 | return MemberOffset(OFFSETOF_MEMBER(Class, dex_cache_)); |
| 640 | } |
| 641 | |
Mathieu Chartier | 2ecfd27 | 2016-11-01 10:10:05 -0700 | [diff] [blame] | 642 | static MemberOffset IfTableOffset() { |
| 643 | return MemberOffset(OFFSETOF_MEMBER(Class, iftable_)); |
| 644 | } |
| 645 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 646 | enum { |
| 647 | kDumpClassFullDetail = 1, |
| 648 | kDumpClassClassLoader = (1 << 1), |
| 649 | kDumpClassInitialized = (1 << 2), |
| 650 | }; |
| 651 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 652 | void DumpClass(std::ostream& os, int flags) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 653 | |
Mathieu Chartier | 137cdfa | 2017-01-26 14:03:11 -0800 | [diff] [blame] | 654 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 655 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 656 | DexCache* GetDexCache() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 657 | |
Mathieu Chartier | 91a6dc4 | 2014-12-01 10:31:15 -0800 | [diff] [blame] | 658 | // Also updates the dex_cache_strings_ variable from new_dex_cache. |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 659 | void SetDexCache(ObjPtr<DexCache> new_dex_cache) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 660 | |
Vladimir Marko | 9ac7749 | 2017-06-14 18:07:03 +0100 | [diff] [blame] | 661 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethods(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 662 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 663 | |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 664 | ALWAYS_INLINE LengthPrefixedArray<ArtMethod>* GetMethodsPtr() |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 665 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 666 | |
David Srbecky | 9b3607d | 2016-01-14 18:15:54 +0000 | [diff] [blame] | 667 | static MemberOffset MethodsOffset() { |
| 668 | return MemberOffset(OFFSETOF_MEMBER(Class, methods_)); |
| 669 | } |
| 670 | |
Vladimir Marko | 9ac7749 | 2017-06-14 18:07:03 +0100 | [diff] [blame] | 671 | ALWAYS_INLINE ArraySlice<ArtMethod> GetMethods(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 672 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 673 | |
| 674 | void SetMethodsPtr(LengthPrefixedArray<ArtMethod>* new_methods, |
| 675 | uint32_t num_direct, |
| 676 | uint32_t num_virtual) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 677 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 678 | // Used by image writer. |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 679 | void SetMethodsPtrUnchecked(LengthPrefixedArray<ArtMethod>* new_methods, |
| 680 | uint32_t num_direct, |
| 681 | uint32_t num_virtual) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 682 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 683 | |
| 684 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 685 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethodsSlice(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 686 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 687 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 688 | ALWAYS_INLINE ArtMethod* GetDirectMethod(size_t i, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 689 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 690 | |
| 691 | // Use only when we are allocating populating the method arrays. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 692 | ALWAYS_INLINE ArtMethod* GetDirectMethodUnchecked(size_t i, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 693 | REQUIRES_SHARED(Locks::mutator_lock_); |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 694 | ALWAYS_INLINE ArtMethod* GetVirtualMethodUnchecked(size_t i, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 695 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 696 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 697 | // Returns the number of static, private, and constructor methods. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 698 | ALWAYS_INLINE uint32_t NumDirectMethods() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 699 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 700 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 701 | ALWAYS_INLINE ArraySlice<ArtMethod> GetMethodsSlice(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 702 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 703 | |
| 704 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 705 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethodsSlice(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 706 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 707 | |
Vladimir Marko | 9ac7749 | 2017-06-14 18:07:03 +0100 | [diff] [blame] | 708 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethods( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 709 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 710 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 711 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 712 | template <PointerSize kPointerSize, bool kTransactionActive> |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 713 | static ObjPtr<Method> GetDeclaredMethodInternal(Thread* self, |
| 714 | ObjPtr<Class> klass, |
| 715 | ObjPtr<String> name, |
| 716 | ObjPtr<ObjectArray<Class>> args) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 717 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 718 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 719 | template <PointerSize kPointerSize, bool kTransactionActive> |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 720 | static ObjPtr<Constructor> GetDeclaredConstructorInternal(Thread* self, |
| 721 | ObjPtr<Class> klass, |
| 722 | ObjPtr<ObjectArray<Class>> args) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 723 | REQUIRES_SHARED(Locks::mutator_lock_); |
Andreas Gampe | bc4d218 | 2016-02-22 10:03:12 -0800 | [diff] [blame] | 724 | |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 725 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 726 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethodsSlice(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 727 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 728 | |
Vladimir Marko | 9ac7749 | 2017-06-14 18:07:03 +0100 | [diff] [blame] | 729 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethods( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 730 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 731 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 732 | |
| 733 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 734 | ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSlice(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 735 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 736 | |
Vladimir Marko | 9ac7749 | 2017-06-14 18:07:03 +0100 | [diff] [blame] | 737 | ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethods(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 738 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 739 | |
| 740 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 741 | ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethodsSlice(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 742 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 743 | |
Vladimir Marko | 9ac7749 | 2017-06-14 18:07:03 +0100 | [diff] [blame] | 744 | ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethods( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 745 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 746 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 747 | |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 748 | // Returns the number of non-inherited virtual methods (sum of declared and copied methods). |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 749 | ALWAYS_INLINE uint32_t NumVirtualMethods() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 750 | |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 751 | // Returns the number of copied virtual methods. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 752 | ALWAYS_INLINE uint32_t NumCopiedVirtualMethods() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 753 | |
| 754 | // Returns the number of declared virtual methods. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 755 | ALWAYS_INLINE uint32_t NumDeclaredVirtualMethods() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 756 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 757 | ALWAYS_INLINE uint32_t NumMethods() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 2466d62 | 2017-09-26 13:52:26 -0700 | [diff] [blame] | 758 | static ALWAYS_INLINE uint32_t NumMethods(LengthPrefixedArray<ArtMethod>* methods) |
| 759 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 760 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 761 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 762 | ArtMethod* GetVirtualMethod(size_t i, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 763 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 764 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 765 | ArtMethod* GetVirtualMethodDuringLinking(size_t i, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 766 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 767 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 768 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 769 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 770 | ALWAYS_INLINE PointerArray* GetVTable() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 771 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 772 | ALWAYS_INLINE PointerArray* GetVTableDuringLinking() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 773 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 774 | void SetVTable(PointerArray* new_vtable) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 775 | |
| 776 | static MemberOffset VTableOffset() { |
| 777 | return OFFSET_OF_OBJECT_MEMBER(Class, vtable_); |
| 778 | } |
| 779 | |
Mingyao Yang | 2cdbad7 | 2014-07-16 10:44:41 -0700 | [diff] [blame] | 780 | static MemberOffset EmbeddedVTableLengthOffset() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 781 | return MemberOffset(sizeof(Class)); |
Mingyao Yang | 2cdbad7 | 2014-07-16 10:44:41 -0700 | [diff] [blame] | 782 | } |
| 783 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 784 | static MemberOffset ImtPtrOffset(PointerSize pointer_size) { |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 785 | return MemberOffset( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 786 | RoundUp(EmbeddedVTableLengthOffset().Uint32Value() + sizeof(uint32_t), |
| 787 | static_cast<size_t>(pointer_size))); |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 788 | } |
| 789 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 790 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 791 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 792 | bool ShouldHaveImt() REQUIRES_SHARED(Locks::mutator_lock_) { |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 793 | return ShouldHaveEmbeddedVTable<kVerifyFlags, kReadBarrierOption>(); |
| 794 | } |
| 795 | |
| 796 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 797 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 798 | bool ShouldHaveEmbeddedVTable() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 799 | return IsInstantiable<kVerifyFlags, kReadBarrierOption>(); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 800 | } |
| 801 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 802 | bool HasVTable() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 2cdbad7 | 2014-07-16 10:44:41 -0700 | [diff] [blame] | 803 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 804 | static MemberOffset EmbeddedVTableEntryOffset(uint32_t i, PointerSize pointer_size); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 805 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 806 | int32_t GetVTableLength() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 2cdbad7 | 2014-07-16 10:44:41 -0700 | [diff] [blame] | 807 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 808 | ArtMethod* GetVTableEntry(uint32_t i, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 809 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 2cdbad7 | 2014-07-16 10:44:41 -0700 | [diff] [blame] | 810 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 811 | int32_t GetEmbeddedVTableLength() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 2cdbad7 | 2014-07-16 10:44:41 -0700 | [diff] [blame] | 812 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 813 | void SetEmbeddedVTableLength(int32_t len) REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 2cdbad7 | 2014-07-16 10:44:41 -0700 | [diff] [blame] | 814 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 815 | ImTable* GetImt(PointerSize pointer_size) REQUIRES_SHARED(Locks::mutator_lock_); |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 816 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 817 | void SetImt(ImTable* imt, PointerSize pointer_size) REQUIRES_SHARED(Locks::mutator_lock_); |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 818 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 819 | ArtMethod* GetEmbeddedVTableEntry(uint32_t i, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 820 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 2cdbad7 | 2014-07-16 10:44:41 -0700 | [diff] [blame] | 821 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 822 | void SetEmbeddedVTableEntry(uint32_t i, ArtMethod* method, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 823 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 824 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 825 | inline void SetEmbeddedVTableEntryUnchecked(uint32_t i, |
| 826 | ArtMethod* method, |
| 827 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 828 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 829 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 830 | void PopulateEmbeddedVTable(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 831 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 832 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 833 | // Given a method implemented by this class but potentially from a super class, return the |
| 834 | // specific implementation method for this class. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 835 | ArtMethod* FindVirtualMethodForVirtual(ArtMethod* method, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 836 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 837 | |
| 838 | // Given a method implemented by this class' super class, return the specific implementation |
| 839 | // method for this class. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 840 | ArtMethod* FindVirtualMethodForSuper(ArtMethod* method, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 841 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 842 | |
Alex Light | 705ad49 | 2015-09-21 11:36:30 -0700 | [diff] [blame] | 843 | // Given a method from some implementor of this interface, return the specific implementation |
| 844 | // method for this class. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 845 | ArtMethod* FindVirtualMethodForInterfaceSuper(ArtMethod* method, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 846 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | 705ad49 | 2015-09-21 11:36:30 -0700 | [diff] [blame] | 847 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 848 | // Given a method implemented by this class, but potentially from a |
| 849 | // super class or interface, return the specific implementation |
| 850 | // method for this class. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 851 | ArtMethod* FindVirtualMethodForInterface(ArtMethod* method, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 852 | REQUIRES_SHARED(Locks::mutator_lock_) ALWAYS_INLINE; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 853 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 854 | ArtMethod* FindVirtualMethodForVirtualOrInterface(ArtMethod* method, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 855 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 856 | |
Vladimir Marko | ba11882 | 2017-06-12 15:41:56 +0100 | [diff] [blame] | 857 | // Find a method with the given name and signature in an interface class. |
| 858 | // |
| 859 | // Search for the method declared in the class, then search for a method declared in any |
| 860 | // superinterface, then search the superclass java.lang.Object (implicitly declared methods |
| 861 | // in an interface without superinterfaces, see JLS 9.2, can be inherited, see JLS 9.4.1). |
| 862 | // TODO: Implement search for a unique maximally-specific non-abstract superinterface method. |
| 863 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 864 | ArtMethod* FindInterfaceMethod(const StringPiece& name, |
| 865 | const StringPiece& signature, |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 866 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 867 | REQUIRES_SHARED(Locks::mutator_lock_); |
Brian Carlstrom | 004644f | 2014-06-18 08:34:01 -0700 | [diff] [blame] | 868 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 869 | ArtMethod* FindInterfaceMethod(const StringPiece& name, |
| 870 | const Signature& signature, |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 871 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 872 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 873 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 874 | ArtMethod* FindInterfaceMethod(ObjPtr<DexCache> dex_cache, |
| 875 | uint32_t dex_method_idx, |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 876 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 877 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 878 | |
Vladimir Marko | ba11882 | 2017-06-12 15:41:56 +0100 | [diff] [blame] | 879 | // Find a method with the given name and signature in a non-interface class. |
| 880 | // |
| 881 | // Search for the method in the class, following the JLS rules which conflict with the RI |
| 882 | // in some cases. The JLS says that inherited methods are searched (JLS 15.12.2.1) and |
| 883 | // these can come from a superclass or a superinterface (JLS 8.4.8). We perform the |
| 884 | // following search: |
| 885 | // 1. Search the methods declared directly in the class. If we find a method with the |
| 886 | // given name and signature, return that method. |
| 887 | // 2. Search the methods declared in superclasses until we find a method with the given |
| 888 | // signature or complete the search in java.lang.Object. If we find a method with the |
| 889 | // given name and signature, check if it's been inherited by the class where we're |
| 890 | // performing the lookup (qualifying type). If it's inherited, return it. Otherwise, |
| 891 | // just remember the method and its declaring class and proceed to step 3. |
| 892 | // 3. Search "copied" methods (containing methods inherited from interfaces) in the class |
| 893 | // and its superclass chain. If we found a method in step 2 (which was not inherited, |
| 894 | // otherwise we would not be performing step 3), end the search when we reach its |
| 895 | // declaring class, otherwise search the entire superclass chain. If we find a method |
| 896 | // with the given name and signature, return that method. |
| 897 | // 4. Return the method found in step 2 if any (not inherited), or null. |
| 898 | // |
| 899 | // It's the responsibility of the caller to throw exceptions if the returned method (or null) |
| 900 | // does not satisfy the request. Special consideration should be given to the case where this |
| 901 | // function returns a method that's not inherited (found in step 2, returned in step 4). |
| 902 | |
| 903 | ArtMethod* FindClassMethod(const StringPiece& name, |
| 904 | const StringPiece& signature, |
| 905 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 906 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 907 | |
Vladimir Marko | ba11882 | 2017-06-12 15:41:56 +0100 | [diff] [blame] | 908 | ArtMethod* FindClassMethod(const StringPiece& name, |
| 909 | const Signature& signature, |
| 910 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 911 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 912 | |
Vladimir Marko | ba11882 | 2017-06-12 15:41:56 +0100 | [diff] [blame] | 913 | ArtMethod* FindClassMethod(ObjPtr<DexCache> dex_cache, |
| 914 | uint32_t dex_method_idx, |
| 915 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 916 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 917 | |
Vladimir Marko | ba11882 | 2017-06-12 15:41:56 +0100 | [diff] [blame] | 918 | ArtMethod* FindConstructor(const StringPiece& signature, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 919 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 920 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 921 | ArtMethod* FindDeclaredVirtualMethodByName(const StringPiece& name, |
| 922 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 923 | REQUIRES_SHARED(Locks::mutator_lock_); |
Jeff Hao | 13e748b | 2015-08-25 20:44:19 +0000 | [diff] [blame] | 924 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 925 | ArtMethod* FindDeclaredDirectMethodByName(const StringPiece& name, |
| 926 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 927 | REQUIRES_SHARED(Locks::mutator_lock_); |
Nicolas Geoffray | a42363f | 2015-12-17 14:57:09 +0000 | [diff] [blame] | 928 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 929 | ArtMethod* FindClassInitializer(PointerSize pointer_size) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | d91d6d6 | 2013-09-25 20:26:14 -0700 | [diff] [blame] | 930 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 931 | bool HasDefaultMethods() REQUIRES_SHARED(Locks::mutator_lock_) { |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 932 | return (GetAccessFlags() & kAccHasDefaultMethod) != 0; |
| 933 | } |
| 934 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 935 | bool HasBeenRecursivelyInitialized() REQUIRES_SHARED(Locks::mutator_lock_) { |
Alex Light | eb7c144 | 2015-08-31 13:17:42 -0700 | [diff] [blame] | 936 | return (GetAccessFlags() & kAccRecursivelyInitialized) != 0; |
| 937 | } |
| 938 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 939 | ALWAYS_INLINE int32_t GetIfTableCount() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 940 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 941 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 942 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 943 | ALWAYS_INLINE IfTable* GetIfTable() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 944 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 945 | ALWAYS_INLINE void SetIfTable(ObjPtr<IfTable> new_iftable) |
| 946 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 947 | |
| 948 | // Get instance fields of the class (See also GetSFields). |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 949 | LengthPrefixedArray<ArtField>* GetIFieldsPtr() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 950 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 951 | ALWAYS_INLINE IterationRange<StrideIterator<ArtField>> GetIFields() |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 952 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 953 | |
| 954 | void SetIFieldsPtr(LengthPrefixedArray<ArtField>* new_ifields) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 955 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 956 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 957 | // Unchecked edition has no verification flags. |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 958 | void SetIFieldsPtrUnchecked(LengthPrefixedArray<ArtField>* new_sfields) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 959 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 960 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 961 | uint32_t NumInstanceFields() REQUIRES_SHARED(Locks::mutator_lock_); |
| 962 | ArtField* GetInstanceField(uint32_t i) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 963 | |
Mathieu Chartier | 66c2d2d | 2015-08-25 14:32:32 -0700 | [diff] [blame] | 964 | // Returns the number of instance fields containing reference types. Does not count fields in any |
| 965 | // super classes. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 966 | uint32_t NumReferenceInstanceFields() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 72ab684 | 2017-01-20 19:32:50 +0000 | [diff] [blame] | 967 | DCHECK(IsResolved()); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 968 | return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 969 | } |
| 970 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 971 | uint32_t NumReferenceInstanceFieldsDuringLinking() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 972 | DCHECK(IsLoaded() || IsErroneous()); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 973 | return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 974 | } |
| 975 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 976 | void SetNumReferenceInstanceFields(uint32_t new_num) REQUIRES_SHARED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 977 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 978 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_instance_fields_), new_num); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 979 | } |
| 980 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 981 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 982 | uint32_t GetReferenceInstanceOffsets() ALWAYS_INLINE REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 983 | |
| 984 | void SetReferenceInstanceOffsets(uint32_t new_reference_offsets) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 985 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 986 | |
Vladimir Marko | 76649e8 | 2014-11-10 18:32:59 +0000 | [diff] [blame] | 987 | // Get the offset of the first reference instance field. Other reference instance fields follow. |
Hiroshi Yamauchi | 5496f69 | 2016-02-17 13:29:59 -0800 | [diff] [blame] | 988 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 989 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 990 | MemberOffset GetFirstReferenceInstanceFieldOffset() |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 991 | REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 76649e8 | 2014-11-10 18:32:59 +0000 | [diff] [blame] | 992 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 993 | // Returns the number of static fields containing reference types. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 994 | uint32_t NumReferenceStaticFields() REQUIRES_SHARED(Locks::mutator_lock_) { |
Vladimir Marko | 72ab684 | 2017-01-20 19:32:50 +0000 | [diff] [blame] | 995 | DCHECK(IsResolved()); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 996 | return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 997 | } |
| 998 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 999 | uint32_t NumReferenceStaticFieldsDuringLinking() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1000 | DCHECK(IsLoaded() || IsErroneous() || IsRetired()); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 1001 | return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1002 | } |
| 1003 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1004 | void SetNumReferenceStaticFields(uint32_t new_num) REQUIRES_SHARED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1005 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 1006 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(Class, num_reference_static_fields_), new_num); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1007 | } |
| 1008 | |
Vladimir Marko | 76649e8 | 2014-11-10 18:32:59 +0000 | [diff] [blame] | 1009 | // Get the offset of the first reference static field. Other reference static fields follow. |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 1010 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 1011 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1012 | MemberOffset GetFirstReferenceStaticFieldOffset(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1013 | REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 76649e8 | 2014-11-10 18:32:59 +0000 | [diff] [blame] | 1014 | |
| 1015 | // Get the offset of the first reference static field. Other reference static fields follow. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1016 | MemberOffset GetFirstReferenceStaticFieldOffsetDuringLinking(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1017 | REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 76649e8 | 2014-11-10 18:32:59 +0000 | [diff] [blame] | 1018 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1019 | // Gets the static fields of the class. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1020 | LengthPrefixedArray<ArtField>* GetSFieldsPtr() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 1021 | ALWAYS_INLINE IterationRange<StrideIterator<ArtField>> GetSFields() |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1022 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1023 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 1024 | void SetSFieldsPtr(LengthPrefixedArray<ArtField>* new_sfields) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1025 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1026 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1027 | // Unchecked edition has no verification flags. |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 1028 | void SetSFieldsPtrUnchecked(LengthPrefixedArray<ArtField>* new_sfields) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1029 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1030 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1031 | uint32_t NumStaticFields() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1032 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1033 | // TODO: uint16_t |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1034 | ArtField* GetStaticField(uint32_t i) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1035 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1036 | // Find a static or instance field using the JLS resolution order |
Vladimir Marko | 19a4d37 | 2016-12-08 14:41:46 +0000 | [diff] [blame] | 1037 | static ArtField* FindField(Thread* self, |
| 1038 | ObjPtr<Class> klass, |
| 1039 | const StringPiece& name, |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 1040 | const StringPiece& type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1041 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1042 | |
| 1043 | // Finds the given instance field in this class or a superclass. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 1044 | ArtField* FindInstanceField(const StringPiece& name, const StringPiece& type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1045 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1046 | |
| 1047 | // Finds the given instance field in this class or a superclass, only searches classes that |
| 1048 | // have the same dex cache. |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1049 | ArtField* FindInstanceField(ObjPtr<DexCache> dex_cache, uint32_t dex_field_idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1050 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1051 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 1052 | ArtField* FindDeclaredInstanceField(const StringPiece& name, const StringPiece& type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1053 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1054 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1055 | ArtField* FindDeclaredInstanceField(ObjPtr<DexCache> dex_cache, uint32_t dex_field_idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1056 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1057 | |
| 1058 | // Finds the given static field in this class or a superclass. |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1059 | static ArtField* FindStaticField(Thread* self, |
Vladimir Marko | 19a4d37 | 2016-12-08 14:41:46 +0000 | [diff] [blame] | 1060 | ObjPtr<Class> klass, |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1061 | const StringPiece& name, |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 1062 | const StringPiece& type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1063 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1064 | |
| 1065 | // Finds the given static field in this class or superclass, only searches classes that |
| 1066 | // have the same dex cache. |
Vladimir Marko | bb268b1 | 2016-06-30 15:52:56 +0100 | [diff] [blame] | 1067 | static ArtField* FindStaticField(Thread* self, |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1068 | ObjPtr<Class> klass, |
| 1069 | ObjPtr<DexCache> dex_cache, |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 1070 | uint32_t dex_field_idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1071 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1072 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 1073 | ArtField* FindDeclaredStaticField(const StringPiece& name, const StringPiece& type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1074 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1075 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1076 | ArtField* FindDeclaredStaticField(ObjPtr<DexCache> dex_cache, uint32_t dex_field_idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1077 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1078 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1079 | pid_t GetClinitThreadId() REQUIRES_SHARED(Locks::mutator_lock_) { |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 1080 | DCHECK(IsIdxLoaded() || IsErroneous()) << PrettyClass(); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 1081 | return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, clinit_thread_id_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1082 | } |
| 1083 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1084 | void SetClinitThreadId(pid_t new_clinit_thread_id) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1085 | |
Alex Light | 4f2e957 | 2017-03-16 13:13:31 -0700 | [diff] [blame] | 1086 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 1087 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 1088 | ClassExt* GetExtData() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1089 | |
Alex Light | 0273ad1 | 2016-11-02 11:19:31 -0700 | [diff] [blame] | 1090 | // Returns the ExtData for this class, allocating one if necessary. This should be the only way |
| 1091 | // to force ext_data_ to be set. No functions are available for changing an already set ext_data_ |
| 1092 | // since doing so is not allowed. |
| 1093 | ClassExt* EnsureExtDataPresent(Thread* self) |
| 1094 | REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
| 1095 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1096 | uint16_t GetDexClassDefIndex() REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 1097 | return GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_)); |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 1098 | } |
| 1099 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1100 | void SetDexClassDefIndex(uint16_t class_def_idx) REQUIRES_SHARED(Locks::mutator_lock_) { |
Chang Xing | 6d3e768 | 2017-07-11 10:31:29 -0700 | [diff] [blame] | 1101 | SetField32Transaction(OFFSET_OF_OBJECT_MEMBER(Class, dex_class_def_idx_), class_def_idx); |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 1102 | } |
| 1103 | |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 1104 | dex::TypeIndex GetDexTypeIndex() REQUIRES_SHARED(Locks::mutator_lock_) { |
| 1105 | return dex::TypeIndex( |
| 1106 | static_cast<uint16_t>(GetField32(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_)))); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1107 | } |
| 1108 | |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 1109 | void SetDexTypeIndex(dex::TypeIndex type_idx) REQUIRES_SHARED(Locks::mutator_lock_) { |
Chang Xing | 6d3e768 | 2017-07-11 10:31:29 -0700 | [diff] [blame] | 1110 | SetField32Transaction(OFFSET_OF_OBJECT_MEMBER(Class, dex_type_idx_), type_idx.index_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1111 | } |
| 1112 | |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 1113 | dex::TypeIndex FindTypeIndexInOtherDexFile(const DexFile& dex_file) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1114 | REQUIRES_SHARED(Locks::mutator_lock_); |
Nicolas Geoffray | e4084a5 | 2016-02-18 14:43:42 +0000 | [diff] [blame] | 1115 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1116 | static Class* GetJavaLangClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 3100080 | 2015-06-14 14:14:37 -0700 | [diff] [blame] | 1117 | DCHECK(HasJavaLangClass()); |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 1118 | return java_lang_Class_.Read(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1119 | } |
| 1120 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1121 | static bool HasJavaLangClass() REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 3100080 | 2015-06-14 14:14:37 -0700 | [diff] [blame] | 1122 | return !java_lang_Class_.IsNull(); |
| 1123 | } |
| 1124 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1125 | // Can't call this SetClass or else gets called instead of Object::SetClass in places. |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1126 | static void SetClassClass(ObjPtr<Class> java_lang_Class) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1127 | static void ResetClass(); |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 1128 | static void VisitRoots(RootVisitor* visitor) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1129 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1130 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1131 | // Visit native roots visits roots which are keyed off the native pointers such as ArtFields and |
| 1132 | // ArtMethods. |
Hiroshi Yamauchi | 7a62e67 | 2016-06-10 17:22:48 -0700 | [diff] [blame] | 1133 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier, class Visitor> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1134 | void VisitNativeRoots(Visitor& visitor, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1135 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1136 | |
Igor Murashkin | df707e4 | 2016-02-02 16:56:50 -0800 | [diff] [blame] | 1137 | // When class is verified, set the kAccSkipAccessChecks flag on each method. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1138 | void SetSkipAccessChecksFlagOnAllMethods(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1139 | REQUIRES_SHARED(Locks::mutator_lock_); |
Sebastien Hertz | 233ea8e | 2013-06-06 11:57:09 +0200 | [diff] [blame] | 1140 | |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 1141 | // Get the descriptor of the class. In a few cases a std::string is required, rather than |
| 1142 | // always create one the storage argument is populated and its internal c_str() returned. We do |
| 1143 | // this to avoid memory allocation in the common case. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1144 | const char* GetDescriptor(std::string* storage) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 1145 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1146 | const char* GetArrayDescriptor(std::string* storage) REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1147 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1148 | bool DescriptorEquals(const char* match) REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1149 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1150 | const DexFile::ClassDef* GetClassDef() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1151 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1152 | ALWAYS_INLINE uint32_t NumDirectInterfaces() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1153 | |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 1154 | dex::TypeIndex GetDirectInterfaceTypeIdx(uint32_t idx) REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1155 | |
Vladimir Marko | 19a4d37 | 2016-12-08 14:41:46 +0000 | [diff] [blame] | 1156 | // Get the direct interface of the `klass` at index `idx` if resolved, otherwise return null. |
| 1157 | // If the caller expects the interface to be resolved, for example for a resolved `klass`, |
| 1158 | // that assumption should be checked by `DCHECK(result != nullptr)`. |
| 1159 | static ObjPtr<Class> GetDirectInterface(Thread* self, ObjPtr<Class> klass, uint32_t idx) |
| 1160 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1161 | |
| 1162 | // Resolve and get the direct interface of the `klass` at index `idx`. |
| 1163 | // Returns null with a pending exception if the resolution fails. |
| 1164 | static ObjPtr<Class> ResolveDirectInterface(Thread* self, Handle<Class> klass, uint32_t idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1165 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1166 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1167 | const char* GetSourceFile() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1168 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1169 | std::string GetLocation() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1170 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1171 | const DexFile& GetDexFile() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1172 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1173 | const DexFile::TypeList* GetInterfaceTypeList() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 1174 | |
Sebastien Hertz | 4e99b3d | 2014-06-24 14:35:40 +0200 | [diff] [blame] | 1175 | // Asserts we are initialized or initializing in the given thread. |
| 1176 | void AssertInitializedOrInitializingInThread(Thread* self) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1177 | REQUIRES_SHARED(Locks::mutator_lock_); |
Sebastien Hertz | 4e99b3d | 2014-06-24 14:35:40 +0200 | [diff] [blame] | 1178 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1179 | Class* CopyOf(Thread* self, |
| 1180 | int32_t new_length, |
| 1181 | ImTable* imt, |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1182 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1183 | REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1184 | |
Nicolas Geoffray | a7a4759 | 2015-11-24 09:17:30 +0000 | [diff] [blame] | 1185 | // For proxy class only. |
Narayan Kamath | 6b2dc31 | 2017-03-14 13:26:12 +0000 | [diff] [blame] | 1186 | ObjectArray<Class>* GetProxyInterfaces() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1187 | |
Nicolas Geoffray | a7a4759 | 2015-11-24 09:17:30 +0000 | [diff] [blame] | 1188 | // For proxy class only. |
Narayan Kamath | 6b2dc31 | 2017-03-14 13:26:12 +0000 | [diff] [blame] | 1189 | ObjectArray<ObjectArray<Class>>* GetProxyThrows() REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1190 | |
Fred Shih | 4ee7a66 | 2014-07-11 09:59:27 -0700 | [diff] [blame] | 1191 | // For reference class only. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1192 | MemberOffset GetDisableIntrinsicFlagOffset() REQUIRES_SHARED(Locks::mutator_lock_); |
| 1193 | MemberOffset GetSlowPathFlagOffset() REQUIRES_SHARED(Locks::mutator_lock_); |
| 1194 | bool GetSlowPathEnabled() REQUIRES_SHARED(Locks::mutator_lock_); |
| 1195 | void SetSlowPath(bool enabled) REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 4ee7a66 | 2014-07-11 09:59:27 -0700 | [diff] [blame] | 1196 | |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 1197 | // May cause thread suspension due to EqualParameters. |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1198 | ArtMethod* GetDeclaredConstructor(Thread* self, |
| 1199 | Handle<ObjectArray<Class>> args, |
| 1200 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1201 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 1202 | |
Andreas Gampe | 715fdc2 | 2016-04-18 17:07:30 -0700 | [diff] [blame] | 1203 | static int32_t GetInnerClassFlags(Handle<Class> h_this, int32_t default_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1204 | REQUIRES_SHARED(Locks::mutator_lock_); |
Andreas Gampe | 715fdc2 | 2016-04-18 17:07:30 -0700 | [diff] [blame] | 1205 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1206 | // Used to initialize a class in the allocation code path to ensure it is guarded by a StoreStore |
| 1207 | // fence. |
| 1208 | class InitializeClassVisitor { |
| 1209 | public: |
| 1210 | explicit InitializeClassVisitor(uint32_t class_size) : class_size_(class_size) { |
| 1211 | } |
| 1212 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1213 | void operator()(ObjPtr<Object> obj, size_t usable_size) const |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1214 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1215 | |
| 1216 | private: |
| 1217 | const uint32_t class_size_; |
| 1218 | |
| 1219 | DISALLOW_COPY_AND_ASSIGN(InitializeClassVisitor); |
| 1220 | }; |
| 1221 | |
Sebastien Hertz | 6963e44 | 2014-11-26 22:11:27 +0100 | [diff] [blame] | 1222 | // Returns true if the class loader is null, ie the class loader is the boot strap class loader. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1223 | bool IsBootStrapClassLoaded() REQUIRES_SHARED(Locks::mutator_lock_) { |
Sebastien Hertz | 6963e44 | 2014-11-26 22:11:27 +0100 | [diff] [blame] | 1224 | return GetClassLoader() == nullptr; |
| 1225 | } |
| 1226 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1227 | static size_t ImTableEntrySize(PointerSize pointer_size) { |
| 1228 | return static_cast<size_t>(pointer_size); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1229 | } |
| 1230 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1231 | static size_t VTableEntrySize(PointerSize pointer_size) { |
| 1232 | return static_cast<size_t>(pointer_size); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1233 | } |
| 1234 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1235 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDirectMethodsSliceUnchecked(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1236 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1237 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1238 | ALWAYS_INLINE ArraySlice<ArtMethod> GetVirtualMethodsSliceUnchecked(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1239 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1240 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1241 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredMethodsSliceUnchecked(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1242 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1243 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1244 | ALWAYS_INLINE ArraySlice<ArtMethod> GetDeclaredVirtualMethodsSliceUnchecked( |
| 1245 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1246 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1247 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1248 | ALWAYS_INLINE ArraySlice<ArtMethod> GetCopiedMethodsSliceUnchecked(PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1249 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1250 | |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 1251 | static std::string PrettyDescriptor(ObjPtr<mirror::Class> klass) |
| 1252 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1253 | std::string PrettyDescriptor() |
| 1254 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1255 | // Returns a human-readable form of the name of the given class. |
| 1256 | // Given String.class, the output would be "java.lang.Class<java.lang.String>". |
| 1257 | static std::string PrettyClass(ObjPtr<mirror::Class> c) |
| 1258 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1259 | std::string PrettyClass() |
| 1260 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1261 | // Returns a human-readable form of the name of the given class with its class loader. |
| 1262 | static std::string PrettyClassAndClassLoader(ObjPtr<mirror::Class> c) |
| 1263 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1264 | std::string PrettyClassAndClassLoader() |
| 1265 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1266 | |
Mathieu Chartier | 4b00d34 | 2015-11-13 10:42:08 -0800 | [diff] [blame] | 1267 | // Fix up all of the native pointers in the class by running them through the visitor. Only sets |
| 1268 | // the corresponding entry in dest if visitor(obj) != obj to prevent dirty memory. Dest should be |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 1269 | // initialized to a copy of *this to prevent issues. Does not visit the ArtMethod and ArtField |
| 1270 | // roots. |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 1271 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 1272 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
| 1273 | typename Visitor> |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1274 | void FixupNativePointers(Class* dest, PointerSize pointer_size, const Visitor& visitor) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1275 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4b00d34 | 2015-11-13 10:42:08 -0800 | [diff] [blame] | 1276 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1277 | private: |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1278 | ALWAYS_INLINE void SetMethodsPtrInternal(LengthPrefixedArray<ArtMethod>* new_methods) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1279 | REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1280 | |
Mathieu Chartier | 2466d62 | 2017-09-26 13:52:26 -0700 | [diff] [blame] | 1281 | ALWAYS_INLINE static ArraySlice<ArtMethod> GetMethodsSliceRangeUnchecked( |
| 1282 | LengthPrefixedArray<ArtMethod>* methods, |
| 1283 | PointerSize pointer_size, |
| 1284 | uint32_t start_offset, |
| 1285 | uint32_t end_offset) |
Vladimir Marko | 9ac7749 | 2017-06-14 18:07:03 +0100 | [diff] [blame] | 1286 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1287 | |
Vladimir Marko | f79aa7f | 2017-07-04 16:58:55 +0100 | [diff] [blame] | 1288 | template <bool throw_on_failure> |
Mathieu Chartier | b890130 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 1289 | bool ResolvedFieldAccessTest(ObjPtr<Class> access_to, |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 1290 | ArtField* field, |
Vladimir Marko | f79aa7f | 2017-07-04 16:58:55 +0100 | [diff] [blame] | 1291 | ObjPtr<DexCache> dex_cache, |
| 1292 | uint32_t field_idx) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1293 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | b890130 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 1294 | |
Vladimir Marko | f79aa7f | 2017-07-04 16:58:55 +0100 | [diff] [blame] | 1295 | template <bool throw_on_failure> |
Mathieu Chartier | b890130 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 1296 | bool ResolvedMethodAccessTest(ObjPtr<Class> access_to, |
| 1297 | ArtMethod* resolved_method, |
Vladimir Marko | f79aa7f | 2017-07-04 16:58:55 +0100 | [diff] [blame] | 1298 | ObjPtr<DexCache> dex_cache, |
Mathieu Chartier | b890130 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 1299 | uint32_t method_idx, |
Vladimir Marko | f79aa7f | 2017-07-04 16:58:55 +0100 | [diff] [blame] | 1300 | InvokeType throw_invoke_type) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1301 | REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 8978643 | 2014-01-31 15:03:55 +0000 | [diff] [blame] | 1302 | |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1303 | bool Implements(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 1304 | bool IsArrayAssignableFromArray(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
| 1305 | bool IsAssignableFromArray(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1306 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1307 | void CheckObjectAlloc() REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 3b4c189 | 2013-09-12 21:33:12 -0700 | [diff] [blame] | 1308 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1309 | // Unchecked editions is for root visiting. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1310 | LengthPrefixedArray<ArtField>* GetSFieldsPtrUnchecked() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 1311 | IterationRange<StrideIterator<ArtField>> GetSFieldsUnchecked() |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1312 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 1313 | LengthPrefixedArray<ArtField>* GetIFieldsPtrUnchecked() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 1314 | IterationRange<StrideIterator<ArtField>> GetIFieldsUnchecked() |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1315 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1316 | |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1317 | // The index in the methods_ array where the first declared virtual method is. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1318 | ALWAYS_INLINE uint32_t GetVirtualMethodsStartOffset() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1319 | |
| 1320 | // The index in the methods_ array where the first direct method is. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1321 | ALWAYS_INLINE uint32_t GetDirectMethodsStartOffset() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1322 | |
| 1323 | // The index in the methods_ array where the first copied method is. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1324 | ALWAYS_INLINE uint32_t GetCopiedMethodsStartOffset() REQUIRES_SHARED(Locks::mutator_lock_); |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1325 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1326 | bool ProxyDescriptorEquals(const char* match) REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 3481ba2 | 2015-04-13 12:22:36 +0100 | [diff] [blame] | 1327 | |
Andreas Gampe | 90b936d | 2017-01-31 08:58:55 -0800 | [diff] [blame] | 1328 | template<VerifyObjectFlags kVerifyFlags> |
| 1329 | void GetAccessFlagsDCheck() REQUIRES_SHARED(Locks::mutator_lock_); |
| 1330 | |
Roland Levillain | 0d5a281 | 2015-11-13 10:07:31 +0000 | [diff] [blame] | 1331 | // Check that the pointer size matches the one in the class linker. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1332 | ALWAYS_INLINE static void CheckPointerSize(PointerSize pointer_size); |
| 1333 | |
| 1334 | static MemberOffset EmbeddedVTableOffset(PointerSize pointer_size); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 1335 | template <bool kVisitNativeRoots, |
| 1336 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 1337 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
| 1338 | typename Visitor> |
Mathieu Chartier | 28bd2e4 | 2016-10-04 13:54:57 -0700 | [diff] [blame] | 1339 | void VisitReferences(ObjPtr<Class> klass, const Visitor& visitor) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1340 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 059ef3d | 2015-08-18 13:54:21 -0700 | [diff] [blame] | 1341 | |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1342 | // 'Class' Object Fields |
| 1343 | // Order governed by java field ordering. See art::ClassLinker::LinkFields. |
| 1344 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 1345 | // Defining class loader, or null for the "bootstrap" system loader. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1346 | HeapReference<ClassLoader> class_loader_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1347 | |
| 1348 | // For array classes, the component class object for instanceof/checkcast |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 1349 | // (for String[][][], this will be String[][]). null for non-array classes. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1350 | HeapReference<Class> component_type_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1351 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 1352 | // DexCache of resolved constant pool entries (will be null for classes generated by the |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1353 | // runtime such as arrays and primitive classes). |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1354 | HeapReference<DexCache> dex_cache_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1355 | |
Alex Light | d625158 | 2016-10-31 11:12:30 -0700 | [diff] [blame] | 1356 | // Extraneous class data that is not always needed. This field is allocated lazily and may |
| 1357 | // only be set with 'this' locked. This is synchronized on 'this'. |
| 1358 | // TODO(allight) We should probably synchronize it on something external or handle allocation in |
| 1359 | // some other (safe) way to prevent possible deadlocks. |
| 1360 | HeapReference<ClassExt> ext_data_; |
| 1361 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1362 | // The interface table (iftable_) contains pairs of a interface class and an array of the |
| 1363 | // interface methods. There is one pair per interface supported by this class. That means one |
| 1364 | // pair for each interface we support directly, indirectly via superclass, or indirectly via a |
| 1365 | // superinterface. This will be null if neither we nor our superclass implement any interfaces. |
| 1366 | // |
| 1367 | // Why we need this: given "class Foo implements Face", declare "Face faceObj = new Foo()". |
| 1368 | // Invoke faceObj.blah(), where "blah" is part of the Face interface. We can't easily use a |
| 1369 | // single vtable. |
| 1370 | // |
| 1371 | // For every interface a concrete class implements, we create an array of the concrete vtable_ |
| 1372 | // methods for the methods in the interface. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1373 | HeapReference<IfTable> iftable_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1374 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1375 | // Descriptor for the class such as "java.lang.Class" or "[C". Lazily initialized by ComputeName |
| 1376 | HeapReference<String> name_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1377 | |
Brian Carlstrom | 08ac922 | 2015-05-22 13:43:00 -0700 | [diff] [blame] | 1378 | // The superclass, or null if this is java.lang.Object or a primitive type. |
| 1379 | // |
| 1380 | // Note that interfaces have java.lang.Object as their |
| 1381 | // superclass. This doesn't match the expectations in JNI |
| 1382 | // GetSuperClass or java.lang.Class.getSuperClass() which need to |
| 1383 | // check for interfaces and return null. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1384 | HeapReference<Class> super_class_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1385 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1386 | // Virtual method table (vtable), for use by "invoke-virtual". The vtable from the superclass is |
| 1387 | // copied in, and virtual methods from our class either replace those from the super or are |
| 1388 | // appended. For abstract classes, methods may be created in the vtable that aren't in |
| 1389 | // virtual_ methods_ for miranda methods. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1390 | HeapReference<PointerArray> vtable_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1391 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1392 | // instance fields |
| 1393 | // |
| 1394 | // These describe the layout of the contents of an Object. |
| 1395 | // Note that only the fields directly declared by this class are |
| 1396 | // listed in ifields; fields declared by a superclass are listed in |
| 1397 | // the superclass's Class.ifields. |
| 1398 | // |
Mathieu Chartier | c0fe56a | 2015-08-11 13:01:23 -0700 | [diff] [blame] | 1399 | // ArtFields are allocated as a length prefixed ArtField array, and not an array of pointers to |
| 1400 | // ArtFields. |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1401 | uint64_t ifields_; |
| 1402 | |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1403 | // Pointer to an ArtMethod length-prefixed array. All the methods where this class is the place |
| 1404 | // where they are logically defined. This includes all private, static, final and virtual methods |
| 1405 | // as well as inherited default methods and miranda methods. |
| 1406 | // |
| 1407 | // The slice methods_ [0, virtual_methods_offset_) are the direct (static, private, init) methods |
| 1408 | // declared by this class. |
| 1409 | // |
| 1410 | // The slice methods_ [virtual_methods_offset_, copied_methods_offset_) are the virtual methods |
| 1411 | // declared by this class. |
| 1412 | // |
| 1413 | // The slice methods_ [copied_methods_offset_, |methods_|) are the methods that are copied from |
| 1414 | // interfaces such as miranda or default methods. These are copied for resolution purposes as this |
| 1415 | // class is where they are (logically) declared as far as the virtual dispatch is concerned. |
David Srbecky | 9b3607d | 2016-01-14 18:15:54 +0000 | [diff] [blame] | 1416 | // |
| 1417 | // Note that this field is used by the native debugger as the unique identifier for the type. |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1418 | uint64_t methods_; |
| 1419 | |
Mathieu Chartier | 54d220e | 2015-07-30 16:20:06 -0700 | [diff] [blame] | 1420 | // Static fields length-prefixed array. |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1421 | uint64_t sfields_; |
| 1422 | |
Neil Fuller | 3d0aa88 | 2016-08-16 19:53:07 +0100 | [diff] [blame] | 1423 | // Access flags; low 16 bits are defined by VM spec. |
| 1424 | uint32_t access_flags_; |
| 1425 | |
Mathieu Chartier | 52a7f5c | 2015-08-18 18:35:52 -0700 | [diff] [blame] | 1426 | // Class flags to help speed up visiting object references. |
| 1427 | uint32_t class_flags_; |
| 1428 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1429 | // Total size of the Class instance; used when allocating storage on gc heap. |
| 1430 | // See also object_size_. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1431 | uint32_t class_size_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1432 | |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 1433 | // Tid used to check for recursive <clinit> invocation. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1434 | pid_t clinit_thread_id_; |
| 1435 | |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 1436 | // ClassDef index in dex file, -1 if no class definition such as an array. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1437 | // TODO: really 16bits |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 1438 | int32_t dex_class_def_idx_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1439 | |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 1440 | // Type index in dex file. |
| 1441 | // TODO: really 16bits |
| 1442 | int32_t dex_type_idx_; |
| 1443 | |
| 1444 | // Number of instance fields that are object refs. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1445 | uint32_t num_reference_instance_fields_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1446 | |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 1447 | // Number of static fields that are object refs, |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1448 | uint32_t num_reference_static_fields_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1449 | |
| 1450 | // Total object size; used when allocating storage on gc heap. |
| 1451 | // (For interfaces and abstract classes this will be zero.) |
| 1452 | // See also class_size_. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1453 | uint32_t object_size_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1454 | |
Mathieu Chartier | 161db1d | 2016-09-01 14:06:54 -0700 | [diff] [blame] | 1455 | // Aligned object size for allocation fast path. The value is max uint32_t if the object is |
Mathieu Chartier | 93bbee0 | 2016-08-31 09:38:40 -0700 | [diff] [blame] | 1456 | // uninitialized or finalizable. Not currently used for variable sized objects. |
| 1457 | uint32_t object_size_alloc_fast_path_; |
| 1458 | |
Hiroshi Yamauchi | f0edfc3 | 2014-09-25 11:46:46 -0700 | [diff] [blame] | 1459 | // The lower 16 bits contains a Primitive::Type value. The upper 16 |
| 1460 | // bits contains the size shift of the primitive type. |
| 1461 | uint32_t primitive_type_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1462 | |
| 1463 | // Bitmap of offsets of ifields. |
| 1464 | uint32_t reference_instance_offsets_; |
| 1465 | |
Igor Murashkin | 86083f7 | 2017-10-27 10:59:04 -0700 | [diff] [blame] | 1466 | // See the real definition in subtype_check_bits_and_status.h |
| 1467 | // typeof(status_) is actually SubtypeCheckBitsAndStatus. |
| 1468 | uint32_t status_; |
Igor Murashkin | cf83aaa | 2017-09-08 03:21:54 +0000 | [diff] [blame] | 1469 | |
Alex Light | e64300b | 2015-12-15 15:02:47 -0800 | [diff] [blame] | 1470 | // The offset of the first virtual method that is copied from an interface. This includes miranda, |
| 1471 | // default, and default-conflict methods. Having a hard limit of ((2 << 16) - 1) for methods |
| 1472 | // defined on a single class is well established in Java so we will use only uint16_t's here. |
| 1473 | uint16_t copied_methods_offset_; |
| 1474 | |
| 1475 | // The offset of the first declared virtual methods in the methods_ array. |
| 1476 | uint16_t virtual_methods_offset_; |
| 1477 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1478 | // TODO: ? |
| 1479 | // initiating class loader list |
| 1480 | // NOTE: for classes with low serialNumber, these are unused, and the |
| 1481 | // values are kept in a table in gDvm. |
| 1482 | // InitiatingLoaderList initiating_loader_list_; |
| 1483 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1484 | // The following data exist in real class objects. |
| 1485 | // Embedded Imtable, for class object that's not an interface, fixed size. |
Ian Rogers | 03b6eaf | 2014-10-28 09:34:57 -0700 | [diff] [blame] | 1486 | // ImTableEntry embedded_imtable_[0]; |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1487 | // Embedded Vtable, for class object that's not an interface, variable size. |
Ian Rogers | 03b6eaf | 2014-10-28 09:34:57 -0700 | [diff] [blame] | 1488 | // VTableEntry embedded_vtable_[0]; |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 1489 | // Static fields, variable size. |
Ian Rogers | 03b6eaf | 2014-10-28 09:34:57 -0700 | [diff] [blame] | 1490 | // uint32_t fields_[0]; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1491 | |
| 1492 | // java.lang.Class |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 1493 | static GcRoot<Class> java_lang_Class_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1494 | |
Mathieu Chartier | 279ac5c | 2016-09-08 17:34:25 -0700 | [diff] [blame] | 1495 | ART_FRIEND_TEST(DexCacheTest, TestResolvedFieldAccess); // For ResolvedFieldAccessTest |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1496 | friend struct art::ClassOffsets; // for verifying offset information |
Mathieu Chartier | 059ef3d | 2015-08-18 13:54:21 -0700 | [diff] [blame] | 1497 | friend class Object; // For VisitReferences |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1498 | DISALLOW_IMPLICIT_CONSTRUCTORS(Class); |
| 1499 | }; |
| 1500 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1501 | } // namespace mirror |
| 1502 | } // namespace art |
| 1503 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 1504 | #endif // ART_RUNTIME_MIRROR_CLASS_H_ |