Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_RUNTIME_ART_FIELD_H_ |
| 18 | #define ART_RUNTIME_ART_FIELD_H_ |
| 19 | |
David Sehr | 8c0961f | 2018-01-23 16:11:38 -0800 | [diff] [blame] | 20 | #include "dex/modifiers.h" |
David Sehr | 67bf42e | 2018-02-26 16:43:04 -0800 | [diff] [blame] | 21 | #include "dex/primitive.h" |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 22 | #include "gc_root.h" |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 23 | #include "obj_ptr.h" |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 24 | #include "offsets.h" |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 25 | #include "read_barrier_option.h" |
| 26 | |
| 27 | namespace art { |
| 28 | |
| 29 | class DexFile; |
| 30 | class ScopedObjectAccessAlreadyRunnable; |
| 31 | |
| 32 | namespace mirror { |
| 33 | class Class; |
Andreas Gampe | 4835d21 | 2018-11-21 14:55:10 -0800 | [diff] [blame] | 34 | class ClassLoader; |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 35 | class DexCache; |
| 36 | class Object; |
| 37 | class String; |
| 38 | } // namespace mirror |
| 39 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 40 | class ArtField final { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 41 | public: |
Hiroshi Yamauchi | 7a62e67 | 2016-06-10 17:22:48 -0700 | [diff] [blame] | 42 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 43 | ObjPtr<mirror::Class> GetDeclaringClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 44 | |
Vladimir Marko | c524e9e | 2019-03-26 10:54:50 +0000 | [diff] [blame] | 45 | ObjPtr<mirror::ClassLoader> GetClassLoader() REQUIRES_SHARED(Locks::mutator_lock_); |
Andreas Gampe | 4835d21 | 2018-11-21 14:55:10 -0800 | [diff] [blame] | 46 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 47 | void SetDeclaringClass(ObjPtr<mirror::Class> new_declaring_class) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 48 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 49 | |
Mathieu Chartier | 8c19d24 | 2017-03-06 12:35:10 -0800 | [diff] [blame] | 50 | mirror::CompressedReference<mirror::Object>* GetDeclaringClassAddressWithoutBarrier() { |
| 51 | return declaring_class_.AddressWithoutBarrier(); |
| 52 | } |
| 53 | |
Vladimir Marko | f9625ec | 2022-02-11 17:19:45 +0000 | [diff] [blame] | 54 | uint32_t GetAccessFlags() { |
Andreas Gampe | a1d2f95 | 2017-04-20 22:53:58 -0700 | [diff] [blame] | 55 | return access_flags_; |
| 56 | } |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 57 | |
Vladimir Marko | b6e0e02 | 2022-04-14 10:13:15 +0100 | [diff] [blame] | 58 | void SetAccessFlags(uint32_t new_access_flags) { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 59 | // Not called within a transaction. |
| 60 | access_flags_ = new_access_flags; |
| 61 | } |
| 62 | |
Vladimir Marko | b6e0e02 | 2022-04-14 10:13:15 +0100 | [diff] [blame] | 63 | bool IsPublic() { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 64 | return (GetAccessFlags() & kAccPublic) != 0; |
| 65 | } |
| 66 | |
Vladimir Marko | b6e0e02 | 2022-04-14 10:13:15 +0100 | [diff] [blame] | 67 | bool IsStatic() { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 68 | return (GetAccessFlags() & kAccStatic) != 0; |
| 69 | } |
| 70 | |
Vladimir Marko | b6e0e02 | 2022-04-14 10:13:15 +0100 | [diff] [blame] | 71 | bool IsFinal() { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 72 | return (GetAccessFlags() & kAccFinal) != 0; |
| 73 | } |
| 74 | |
Vladimir Marko | b6e0e02 | 2022-04-14 10:13:15 +0100 | [diff] [blame] | 75 | bool IsPrivate() { |
Alex Light | 2462789 | 2019-11-06 10:28:21 -0800 | [diff] [blame] | 76 | return (GetAccessFlags() & kAccPrivate) != 0; |
| 77 | } |
| 78 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 79 | uint32_t GetDexFieldIndex() { |
| 80 | return field_dex_idx_; |
| 81 | } |
| 82 | |
| 83 | void SetDexFieldIndex(uint32_t new_idx) { |
| 84 | // Not called within a transaction. |
| 85 | field_dex_idx_ = new_idx; |
| 86 | } |
| 87 | |
| 88 | // Offset to field within an Object. |
Vladimir Marko | b6e0e02 | 2022-04-14 10:13:15 +0100 | [diff] [blame] | 89 | MemberOffset GetOffset() { |
Andreas Gampe | a1d2f95 | 2017-04-20 22:53:58 -0700 | [diff] [blame] | 90 | return MemberOffset(offset_); |
| 91 | } |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 92 | |
Nicolas Geoffray | a00b54b | 2019-12-03 14:36:42 +0000 | [diff] [blame] | 93 | static constexpr MemberOffset OffsetOffset() { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 94 | return MemberOffset(OFFSETOF_MEMBER(ArtField, offset_)); |
| 95 | } |
| 96 | |
Nicolas Geoffray | a00b54b | 2019-12-03 14:36:42 +0000 | [diff] [blame] | 97 | static constexpr MemberOffset DeclaringClassOffset() { |
| 98 | return MemberOffset(OFFSETOF_MEMBER(ArtField, declaring_class_)); |
| 99 | } |
| 100 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 101 | MemberOffset GetOffsetDuringLinking() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 102 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 103 | void SetOffset(MemberOffset num_bytes) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 104 | |
| 105 | // field access, null object for static fields |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 106 | uint8_t GetBoolean(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 107 | |
| 108 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 109 | void SetBoolean(ObjPtr<mirror::Object> object, uint8_t z) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 110 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 111 | int8_t GetByte(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 112 | |
| 113 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 114 | void SetByte(ObjPtr<mirror::Object> object, int8_t b) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 115 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 116 | uint16_t GetChar(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 117 | |
| 118 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 119 | void SetChar(ObjPtr<mirror::Object> object, uint16_t c) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 120 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 121 | int16_t GetShort(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 122 | |
| 123 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 124 | void SetShort(ObjPtr<mirror::Object> object, int16_t s) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 125 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 126 | int32_t GetInt(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 127 | |
| 128 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 129 | void SetInt(ObjPtr<mirror::Object> object, int32_t i) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 130 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 131 | int64_t GetLong(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 132 | |
| 133 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 134 | void SetLong(ObjPtr<mirror::Object> object, int64_t j) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 135 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 136 | float GetFloat(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 137 | |
| 138 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 139 | void SetFloat(ObjPtr<mirror::Object> object, float f) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 140 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 141 | double GetDouble(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 142 | |
| 143 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 144 | void SetDouble(ObjPtr<mirror::Object> object, double d) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 145 | |
Vladimir Marko | 5f958f6 | 2022-02-08 12:01:07 +0000 | [diff] [blame] | 146 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 147 | ObjPtr<mirror::Object> GetObject(ObjPtr<mirror::Object> object) |
| 148 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 149 | |
| 150 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 151 | void SetObject(ObjPtr<mirror::Object> object, ObjPtr<mirror::Object> l) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 152 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 153 | |
| 154 | // Raw field accesses. |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 155 | uint32_t Get32(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 156 | |
| 157 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 158 | void Set32(ObjPtr<mirror::Object> object, uint32_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 159 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 160 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 161 | uint64_t Get64(ObjPtr<mirror::Object> object) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 162 | |
| 163 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 164 | void Set64(ObjPtr<mirror::Object> object, uint64_t new_value) |
| 165 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 166 | |
Vladimir Marko | 5f958f6 | 2022-02-08 12:01:07 +0000 | [diff] [blame] | 167 | template<class MirrorType = mirror::Object, |
| 168 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 169 | ObjPtr<MirrorType> GetObj(ObjPtr<mirror::Object> object) |
| 170 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 171 | |
| 172 | template<bool kTransactionActive> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 173 | void SetObj(ObjPtr<mirror::Object> object, ObjPtr<mirror::Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 174 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 175 | |
Mathieu Chartier | da7c650 | 2015-07-23 16:01:26 -0700 | [diff] [blame] | 176 | // NO_THREAD_SAFETY_ANALYSIS since we don't know what the callback requires. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 177 | template<typename RootVisitorType> |
Andreas Gampe | d490129 | 2017-05-30 18:41:34 -0700 | [diff] [blame] | 178 | ALWAYS_INLINE inline void VisitRoots(RootVisitorType& visitor) NO_THREAD_SAFETY_ANALYSIS { |
| 179 | visitor.VisitRoot(declaring_class_.AddressWithoutBarrier()); |
| 180 | } |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 181 | |
Vladimir Marko | b6e0e02 | 2022-04-14 10:13:15 +0100 | [diff] [blame] | 182 | bool IsVolatile() { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 183 | return (GetAccessFlags() & kAccVolatile) != 0; |
| 184 | } |
| 185 | |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 186 | // Returns an instance field with this offset in the given class or null if not found. |
Mathieu Chartier | cb044bc | 2016-04-01 13:56:41 -0700 | [diff] [blame] | 187 | // If kExactOffset is true then we only find the matching offset, not the field containing the |
| 188 | // offset. |
| 189 | template <bool kExactOffset = true> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 190 | static ArtField* FindInstanceFieldWithOffset(ObjPtr<mirror::Class> klass, uint32_t field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 191 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | cb044bc | 2016-04-01 13:56:41 -0700 | [diff] [blame] | 192 | |
Hiroshi Yamauchi | eb2baaf | 2015-05-13 21:14:22 -0700 | [diff] [blame] | 193 | // Returns a static field with this offset in the given class or null if not found. |
Mathieu Chartier | cb044bc | 2016-04-01 13:56:41 -0700 | [diff] [blame] | 194 | // If kExactOffset is true then we only find the matching offset, not the field containing the |
| 195 | // offset. |
| 196 | template <bool kExactOffset = true> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 197 | static ArtField* FindStaticFieldWithOffset(ObjPtr<mirror::Class> klass, uint32_t field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 198 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 199 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 200 | const char* GetName() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 201 | |
| 202 | // Resolves / returns the name from the dex cache. |
Vladimir Marko | 18090d1 | 2018-06-01 16:53:12 +0100 | [diff] [blame] | 203 | ObjPtr<mirror::String> ResolveNameString() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 204 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 205 | const char* GetTypeDescriptor() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 206 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 207 | Primitive::Type GetTypeAsPrimitiveType() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 208 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 209 | bool IsPrimitiveType() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 210 | |
Vladimir Marko | 208f670 | 2017-12-08 12:00:50 +0000 | [diff] [blame] | 211 | ObjPtr<mirror::Class> LookupResolvedType() REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 4098a7a | 2017-11-06 16:00:51 +0000 | [diff] [blame] | 212 | ObjPtr<mirror::Class> ResolveType() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 213 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 214 | size_t FieldSize() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 215 | |
Vladimir Marko | 09c5ca4 | 2018-05-31 15:15:31 +0100 | [diff] [blame] | 216 | template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 217 | ObjPtr<mirror::DexCache> GetDexCache() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 218 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 219 | const DexFile* GetDexFile() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 220 | |
| 221 | GcRoot<mirror::Class>& DeclaringClassRoot() { |
| 222 | return declaring_class_; |
| 223 | } |
| 224 | |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 225 | // Returns a human-readable signature. Something like "a.b.C.f" or |
| 226 | // "int a.b.C.f" (depending on the value of 'with_type'). |
| 227 | static std::string PrettyField(ArtField* f, bool with_type = true) |
| 228 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 229 | std::string PrettyField(bool with_type = true) |
| 230 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 231 | |
Alex Light | c9af14e | 2019-12-12 09:51:38 -0800 | [diff] [blame] | 232 | // Returns true if a set-* instruction in the given method is allowable. |
| 233 | ALWAYS_INLINE inline bool CanBeChangedBy(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_); |
| 234 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 235 | private: |
Vladimir Marko | 09c5ca4 | 2018-05-31 15:15:31 +0100 | [diff] [blame] | 236 | bool IsProxyField() REQUIRES_SHARED(Locks::mutator_lock_); |
| 237 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 238 | ObjPtr<mirror::Class> ProxyFindSystemClass(const char* descriptor) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 239 | REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 3481ba2 | 2015-04-13 12:22:36 +0100 | [diff] [blame] | 240 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 241 | GcRoot<mirror::Class> declaring_class_; |
| 242 | |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 243 | uint32_t access_flags_ = 0; |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 244 | |
| 245 | // Dex cache index of field id |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 246 | uint32_t field_dex_idx_ = 0; |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 247 | |
| 248 | // Offset of field within an instance or in the Class' static fields |
Mathieu Chartier | 3398c78 | 2016-09-30 10:27:43 -0700 | [diff] [blame] | 249 | uint32_t offset_ = 0; |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 250 | }; |
| 251 | |
| 252 | } // namespace art |
| 253 | |
| 254 | #endif // ART_RUNTIME_ART_FIELD_H_ |