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_OBJECT_H_ |
| 18 | #define ART_RUNTIME_MIRROR_OBJECT_H_ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 19 | |
David Sehr | 8f4b056 | 2018-03-02 12:01:51 -0800 | [diff] [blame] | 20 | #include "base/atomic.h" |
Vladimir Marko | db8e62d | 2016-03-30 16:30:21 +0100 | [diff] [blame] | 21 | #include "base/casts.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 22 | #include "base/enums.h" |
Ian Rogers | cdc1aaf | 2014-10-09 13:21:38 -0700 | [diff] [blame] | 23 | #include "globals.h" |
Mathieu Chartier | a59d9b2 | 2016-09-26 18:13:17 -0700 | [diff] [blame] | 24 | #include "obj_ptr.h" |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 25 | #include "object_reference.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 26 | #include "offsets.h" |
Andreas Gampe | 217488a | 2017-09-18 08:34:42 -0700 | [diff] [blame] | 27 | #include "read_barrier_config.h" |
| 28 | #include "read_barrier_option.h" |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 29 | #include "verify_object.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 30 | |
| 31 | namespace art { |
| 32 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 33 | class ArtField; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 34 | class ArtMethod; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 35 | class ImageWriter; |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 36 | class LockWord; |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 37 | class Monitor; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 38 | struct ObjectOffsets; |
| 39 | class Thread; |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 40 | class VoidFunctor; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 41 | |
| 42 | namespace mirror { |
| 43 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 44 | class Array; |
| 45 | class Class; |
Mathieu Chartier | e4275c0 | 2015-08-06 15:34:15 -0700 | [diff] [blame] | 46 | class ClassLoader; |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 47 | class DexCache; |
Mathieu Chartier | 8fa2dad | 2014-03-13 12:22:56 -0700 | [diff] [blame] | 48 | class FinalizerReference; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 49 | template<class T> class ObjectArray; |
| 50 | template<class T> class PrimitiveArray; |
| 51 | typedef PrimitiveArray<uint8_t> BooleanArray; |
| 52 | typedef PrimitiveArray<int8_t> ByteArray; |
| 53 | typedef PrimitiveArray<uint16_t> CharArray; |
| 54 | typedef PrimitiveArray<double> DoubleArray; |
| 55 | typedef PrimitiveArray<float> FloatArray; |
| 56 | typedef PrimitiveArray<int32_t> IntArray; |
| 57 | typedef PrimitiveArray<int64_t> LongArray; |
| 58 | typedef PrimitiveArray<int16_t> ShortArray; |
Mathieu Chartier | 8fa2dad | 2014-03-13 12:22:56 -0700 | [diff] [blame] | 59 | class Reference; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 60 | class String; |
| 61 | class Throwable; |
| 62 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 63 | // Fields within mirror objects aren't accessed directly so that the appropriate amount of |
| 64 | // handshaking is done with GC (for example, read and write barriers). This macro is used to |
| 65 | // compute an offset for the Set/Get methods defined in Object that can safely access fields. |
| 66 | #define OFFSET_OF_OBJECT_MEMBER(type, field) \ |
| 67 | MemberOffset(OFFSETOF_MEMBER(type, field)) |
| 68 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 69 | // Checks that we don't do field assignments which violate the typing system. |
| 70 | static constexpr bool kCheckFieldAssignments = false; |
Ian Rogers | 04d7aa9 | 2013-03-16 14:29:17 -0700 | [diff] [blame] | 71 | |
Ian Rogers | cdc1aaf | 2014-10-09 13:21:38 -0700 | [diff] [blame] | 72 | // Size of Object. |
Hiroshi Yamauchi | 60f63f5 | 2015-04-23 16:12:40 -0700 | [diff] [blame] | 73 | static constexpr uint32_t kObjectHeaderSize = kUseBrooksReadBarrier ? 16 : 8; |
Ian Rogers | cdc1aaf | 2014-10-09 13:21:38 -0700 | [diff] [blame] | 74 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 75 | // C++ mirror of java.lang.Object |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 76 | class MANAGED LOCKABLE Object { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 77 | public: |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 78 | // The number of vtable entries in java.lang.Object. |
| 79 | static constexpr size_t kVTableLength = 11; |
| 80 | |
| 81 | // The size of the java.lang.Class representing a java.lang.Object. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 82 | static uint32_t ClassSize(PointerSize pointer_size); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 83 | |
| 84 | // Size of an instance of java.lang.Object. |
| 85 | static constexpr uint32_t InstanceSize() { |
| 86 | return sizeof(Object); |
| 87 | } |
| 88 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 89 | static MemberOffset ClassOffset() { |
| 90 | return OFFSET_OF_OBJECT_MEMBER(Object, klass_); |
| 91 | } |
| 92 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 93 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 94 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 95 | ALWAYS_INLINE Class* GetClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 96 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 97 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 98 | void SetClass(ObjPtr<Class> new_klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 99 | |
Hiroshi Yamauchi | 12b58b2 | 2016-11-01 11:55:29 -0700 | [diff] [blame] | 100 | // Get the read barrier state with a fake address dependency. |
| 101 | // '*fake_address_dependency' will be set to 0. |
| 102 | ALWAYS_INLINE uint32_t GetReadBarrierState(uintptr_t* fake_address_dependency) |
| 103 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 104 | // This version does not offer any special mechanism to prevent load-load reordering. |
| 105 | ALWAYS_INLINE uint32_t GetReadBarrierState() REQUIRES_SHARED(Locks::mutator_lock_); |
| 106 | // Get the read barrier state with a load-acquire. |
| 107 | ALWAYS_INLINE uint32_t GetReadBarrierStateAcquire() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c381c36 | 2016-08-23 13:27:53 -0700 | [diff] [blame] | 108 | |
Andreas Gampe | 65b798e | 2015-04-06 09:35:22 -0700 | [diff] [blame] | 109 | #ifndef USE_BAKER_OR_BROOKS_READ_BARRIER |
| 110 | NO_RETURN |
| 111 | #endif |
Hiroshi Yamauchi | 12b58b2 | 2016-11-01 11:55:29 -0700 | [diff] [blame] | 112 | ALWAYS_INLINE void SetReadBarrierState(uint32_t rb_state) REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | ed70b4a | 2015-11-17 17:52:15 -0800 | [diff] [blame] | 113 | |
| 114 | template<bool kCasRelease = false> |
Hiroshi Yamauchi | 12b58b2 | 2016-11-01 11:55:29 -0700 | [diff] [blame] | 115 | ALWAYS_INLINE bool AtomicSetReadBarrierState(uint32_t expected_rb_state, uint32_t rb_state) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 116 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 117 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 118 | ALWAYS_INLINE uint32_t GetMarkBit() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 119 | |
| 120 | ALWAYS_INLINE bool AtomicSetMarkBit(uint32_t expected_mark_bit, uint32_t mark_bit) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 121 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 122 | |
Hiroshi Yamauchi | 12b58b2 | 2016-11-01 11:55:29 -0700 | [diff] [blame] | 123 | // Assert that the read barrier state is in the default (white) state. |
| 124 | ALWAYS_INLINE void AssertReadBarrierState() const REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 9d04a20 | 2014-01-31 13:35:49 -0800 | [diff] [blame] | 125 | |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 126 | // The verifier treats all interfaces as java.lang.Object and relies on runtime checks in |
| 127 | // invoke-interface to detect incompatible interface types. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 128 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 129 | bool VerifierInstanceOf(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 130 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | a59d9b2 | 2016-09-26 18:13:17 -0700 | [diff] [blame] | 131 | ALWAYS_INLINE bool InstanceOf(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 132 | |
Mathieu Chartier | d08f66f | 2017-04-13 11:47:53 -0700 | [diff] [blame] | 133 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 134 | size_t SizeOf() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 135 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 136 | Object* Clone(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 137 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 138 | |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 139 | int32_t IdentityHashCode() |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 140 | REQUIRES_SHARED(Locks::mutator_lock_) |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 141 | REQUIRES(!Locks::thread_list_lock_, |
| 142 | !Locks::thread_suspend_count_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 143 | |
| 144 | static MemberOffset MonitorOffset() { |
| 145 | return OFFSET_OF_OBJECT_MEMBER(Object, monitor_); |
| 146 | } |
| 147 | |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 148 | // As_volatile can be false if the mutators are suspended. This is an optimization since it |
Mathieu Chartier | 4d7f61d | 2014-04-17 14:43:39 -0700 | [diff] [blame] | 149 | // avoids the barriers. |
Andreas Gampe | 3b45ef2 | 2015-05-26 21:34:09 -0700 | [diff] [blame] | 150 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 151 | LockWord GetLockWord(bool as_volatile) REQUIRES_SHARED(Locks::mutator_lock_); |
Andreas Gampe | 3b45ef2 | 2015-05-26 21:34:09 -0700 | [diff] [blame] | 152 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 153 | void SetLockWord(LockWord new_val, bool as_volatile) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 228602f | 2014-07-10 02:07:54 -0700 | [diff] [blame] | 154 | bool CasLockWordWeakSequentiallyConsistent(LockWord old_val, LockWord new_val) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 155 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 156 | bool CasLockWordWeakRelaxed(LockWord old_val, LockWord new_val) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 157 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | b3da36c | 2016-12-15 13:12:59 -0800 | [diff] [blame] | 158 | bool CasLockWordWeakAcquire(LockWord old_val, LockWord new_val) |
| 159 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 160 | bool CasLockWordWeakRelease(LockWord old_val, LockWord new_val) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 161 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 162 | uint32_t GetLockOwnerThreadId(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 163 | |
Mathieu Chartier | a704eda | 2016-07-13 09:53:35 -0700 | [diff] [blame] | 164 | // Try to enter the monitor, returns non null if we succeeded. |
| 165 | mirror::Object* MonitorTryEnter(Thread* self) |
| 166 | EXCLUSIVE_LOCK_FUNCTION() |
| 167 | REQUIRES(!Roles::uninterruptible_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 168 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 2d096c9 | 2015-10-12 16:18:20 -0700 | [diff] [blame] | 169 | mirror::Object* MonitorEnter(Thread* self) |
| 170 | EXCLUSIVE_LOCK_FUNCTION() |
| 171 | REQUIRES(!Roles::uninterruptible_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 172 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 2d096c9 | 2015-10-12 16:18:20 -0700 | [diff] [blame] | 173 | bool MonitorExit(Thread* self) |
| 174 | REQUIRES(!Roles::uninterruptible_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 175 | REQUIRES_SHARED(Locks::mutator_lock_) |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 176 | UNLOCK_FUNCTION(); |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 177 | void Notify(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); |
| 178 | void NotifyAll(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); |
| 179 | void Wait(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); |
| 180 | void Wait(Thread* self, int64_t timeout, int32_t nanos) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 181 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 182 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 183 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 184 | bool IsClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 185 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 186 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 187 | Class* AsClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 188 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 189 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 190 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 191 | bool IsObjectArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 192 | template<class T, |
| 193 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 194 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 195 | ObjectArray<T>* AsObjectArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 196 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 197 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 198 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 199 | bool IsClassLoader() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 200 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 201 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 202 | ClassLoader* AsClassLoader() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e4275c0 | 2015-08-06 15:34:15 -0700 | [diff] [blame] | 203 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 204 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 205 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 206 | bool IsDexCache() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 207 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 208 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 209 | DexCache* AsDexCache() REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 210 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 211 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 212 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 213 | bool IsArrayInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 214 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 215 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 216 | Array* AsArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 217 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 218 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 219 | BooleanArray* AsBooleanArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 220 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 221 | ByteArray* AsByteArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 222 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 223 | ByteArray* AsByteSizedArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 224 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 225 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 226 | CharArray* AsCharArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 227 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 228 | ShortArray* AsShortArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 229 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 230 | ShortArray* AsShortSizedArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 231 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 232 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 233 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 234 | bool IsIntArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 235 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 236 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 237 | IntArray* AsIntArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 238 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 239 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 240 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 241 | bool IsLongArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 242 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 243 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 244 | LongArray* AsLongArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 245 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 246 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 247 | bool IsFloatArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 248 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 249 | FloatArray* AsFloatArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 250 | |
| 251 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 252 | bool IsDoubleArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 253 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 254 | DoubleArray* AsDoubleArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 255 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 256 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 257 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 258 | bool IsString() REQUIRES_SHARED(Locks::mutator_lock_); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 259 | |
| 260 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 261 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 262 | String* AsString() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 263 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 264 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 265 | Throwable* AsThrowable() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 266 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 267 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 268 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 269 | bool IsReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 270 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 271 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 272 | Reference* AsReference() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 8fa2dad | 2014-03-13 12:22:56 -0700 | [diff] [blame] | 273 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 274 | bool IsWeakReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 275 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 276 | bool IsSoftReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 277 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 278 | bool IsFinalizerReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 279 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 280 | FinalizerReference* AsFinalizerReference() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 8fa2dad | 2014-03-13 12:22:56 -0700 | [diff] [blame] | 281 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 282 | bool IsPhantomReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 283 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 284 | // Accessor for Java type fields. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 285 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 286 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 287 | ALWAYS_INLINE T* GetFieldObject(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 288 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 289 | |
| 290 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 291 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 292 | ALWAYS_INLINE T* GetFieldObjectVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 293 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 294 | |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 295 | template<bool kTransactionActive, |
| 296 | bool kCheckTransaction = true, |
| 297 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 298 | bool kIsVolatile = false> |
| 299 | ALWAYS_INLINE void SetFieldObjectWithoutWriteBarrier(MemberOffset field_offset, |
| 300 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 301 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 302 | |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 303 | template<bool kTransactionActive, |
| 304 | bool kCheckTransaction = true, |
| 305 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 306 | bool kIsVolatile = false> |
| 307 | ALWAYS_INLINE void SetFieldObject(MemberOffset field_offset, ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 308 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 309 | |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 310 | template<bool kTransactionActive, |
| 311 | bool kCheckTransaction = true, |
| 312 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 313 | ALWAYS_INLINE void SetFieldObjectVolatile(MemberOffset field_offset, |
| 314 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 315 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 316 | |
Chang Xing | 6d3e768 | 2017-07-11 10:31:29 -0700 | [diff] [blame] | 317 | template<bool kCheckTransaction = true, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 318 | bool kIsVolatile = false> |
| 319 | ALWAYS_INLINE void SetFieldObjectTransaction(MemberOffset field_offset, ObjPtr<Object> new_value) |
| 320 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 321 | |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 322 | template<bool kTransactionActive, |
| 323 | bool kCheckTransaction = true, |
| 324 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 325 | bool CasFieldWeakSequentiallyConsistentObject(MemberOffset field_offset, |
| 326 | ObjPtr<Object> old_value, |
| 327 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 328 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 329 | template<bool kTransactionActive, |
| 330 | bool kCheckTransaction = true, |
| 331 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | 2cd334a | 2015-01-09 14:03:35 -0800 | [diff] [blame] | 332 | bool CasFieldWeakSequentiallyConsistentObjectWithoutWriteBarrier(MemberOffset field_offset, |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 333 | ObjPtr<Object> old_value, |
| 334 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 335 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 336 | template<bool kTransactionActive, |
| 337 | bool kCheckTransaction = true, |
| 338 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 339 | bool CasFieldStrongSequentiallyConsistentObject(MemberOffset field_offset, |
| 340 | ObjPtr<Object> old_value, |
| 341 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 342 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 343 | template<bool kTransactionActive, |
| 344 | bool kCheckTransaction = true, |
| 345 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | 2cd334a | 2015-01-09 14:03:35 -0800 | [diff] [blame] | 346 | bool CasFieldStrongSequentiallyConsistentObjectWithoutWriteBarrier(MemberOffset field_offset, |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 347 | ObjPtr<Object> old_value, |
| 348 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 349 | REQUIRES_SHARED(Locks::mutator_lock_); |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 350 | |
| 351 | template<bool kTransactionActive, |
| 352 | bool kCheckTransaction = true, |
| 353 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 354 | ObjPtr<Object> CompareAndExchangeFieldObject(MemberOffset field_offset, |
| 355 | ObjPtr<Object> old_value, |
| 356 | ObjPtr<Object> new_value) |
| 357 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 358 | |
| 359 | template<bool kTransactionActive, |
| 360 | bool kCheckTransaction = true, |
| 361 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 362 | ObjPtr<Object> ExchangeFieldObject(MemberOffset field_offset, ObjPtr<Object> new_value) |
| 363 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 364 | |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 365 | template<bool kTransactionActive, |
| 366 | bool kCheckTransaction = true, |
| 367 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 368 | bool CasFieldWeakRelaxedObjectWithoutWriteBarrier(MemberOffset field_offset, |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 369 | ObjPtr<Object> old_value, |
| 370 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 371 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 372 | template<bool kTransactionActive, |
| 373 | bool kCheckTransaction = true, |
| 374 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | fdd513d | 2017-06-01 11:26:50 -0700 | [diff] [blame] | 375 | bool CasFieldWeakReleaseObjectWithoutWriteBarrier(MemberOffset field_offset, |
| 376 | ObjPtr<Object> old_value, |
| 377 | ObjPtr<Object> new_value) |
| 378 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 379 | |
| 380 | template<bool kTransactionActive, |
| 381 | bool kCheckTransaction = true, |
| 382 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 383 | bool CasFieldStrongRelaxedObjectWithoutWriteBarrier(MemberOffset field_offset, |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 384 | ObjPtr<Object> old_value, |
| 385 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 386 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | fdd513d | 2017-06-01 11:26:50 -0700 | [diff] [blame] | 387 | template<bool kTransactionActive, |
| 388 | bool kCheckTransaction = true, |
| 389 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 390 | bool CasFieldStrongReleaseObjectWithoutWriteBarrier(MemberOffset field_offset, |
| 391 | ObjPtr<Object> old_value, |
| 392 | ObjPtr<Object> new_value) |
| 393 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 394 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 395 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 396 | HeapReference<Object>* GetFieldObjectReferenceAddr(MemberOffset field_offset); |
Mathieu Chartier | 11409ae | 2013-09-23 11:49:36 -0700 | [diff] [blame] | 397 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 398 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 399 | ALWAYS_INLINE uint8_t GetFieldBoolean(MemberOffset field_offset) |
Andreas Gampe | 895f922 | 2017-07-05 09:53:32 -0700 | [diff] [blame] | 400 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 401 | if (kVerifyFlags & kVerifyThis) { |
| 402 | VerifyObject(this); |
| 403 | } |
| 404 | return GetField<uint8_t, kIsVolatile>(field_offset); |
| 405 | } |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 406 | |
| 407 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 408 | ALWAYS_INLINE int8_t GetFieldByte(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 409 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 410 | |
| 411 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 412 | ALWAYS_INLINE uint8_t GetFieldBooleanVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 413 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 414 | |
| 415 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 416 | ALWAYS_INLINE int8_t GetFieldByteVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 417 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 418 | |
| 419 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 420 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 421 | ALWAYS_INLINE void SetFieldBoolean(MemberOffset field_offset, uint8_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 422 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 423 | |
| 424 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 425 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 426 | ALWAYS_INLINE void SetFieldByte(MemberOffset field_offset, int8_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 427 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 428 | |
| 429 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 430 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 431 | ALWAYS_INLINE void SetFieldBooleanVolatile(MemberOffset field_offset, uint8_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 432 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 433 | |
| 434 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 435 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 436 | ALWAYS_INLINE void SetFieldByteVolatile(MemberOffset field_offset, int8_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 437 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 438 | |
| 439 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 440 | ALWAYS_INLINE uint16_t GetFieldChar(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 441 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 442 | |
| 443 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 444 | ALWAYS_INLINE int16_t GetFieldShort(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 445 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 446 | |
| 447 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 448 | ALWAYS_INLINE uint16_t GetFieldCharVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 449 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 450 | |
| 451 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 452 | ALWAYS_INLINE int16_t GetFieldShortVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 453 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 454 | |
| 455 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 456 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 457 | ALWAYS_INLINE void SetFieldChar(MemberOffset field_offset, uint16_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 458 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 459 | |
| 460 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 461 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 462 | ALWAYS_INLINE void SetFieldShort(MemberOffset field_offset, int16_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 463 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 464 | |
| 465 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 466 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 467 | ALWAYS_INLINE void SetFieldCharVolatile(MemberOffset field_offset, uint16_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 468 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 469 | |
| 470 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 471 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 472 | ALWAYS_INLINE void SetFieldShortVolatile(MemberOffset field_offset, int16_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 473 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 474 | |
| 475 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 476 | ALWAYS_INLINE int32_t GetField32(MemberOffset field_offset) |
Andreas Gampe | 90b936d | 2017-01-31 08:58:55 -0800 | [diff] [blame] | 477 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 478 | if (kVerifyFlags & kVerifyThis) { |
| 479 | VerifyObject(this); |
| 480 | } |
| 481 | return GetField<int32_t, kIsVolatile>(field_offset); |
| 482 | } |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 483 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 484 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 485 | ALWAYS_INLINE int32_t GetField32Volatile(MemberOffset field_offset) |
Andreas Gampe | 90b936d | 2017-01-31 08:58:55 -0800 | [diff] [blame] | 486 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 487 | return GetField32<kVerifyFlags, true>(field_offset); |
| 488 | } |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 489 | |
| 490 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 491 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 492 | ALWAYS_INLINE void SetField32(MemberOffset field_offset, int32_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 493 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 494 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 495 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 496 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 497 | ALWAYS_INLINE void SetField32Volatile(MemberOffset field_offset, int32_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 498 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 499 | |
Chang Xing | 6d3e768 | 2017-07-11 10:31:29 -0700 | [diff] [blame] | 500 | template<bool kCheckTransaction = true, |
| 501 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 502 | bool kIsVolatile = false> |
| 503 | ALWAYS_INLINE void SetField32Transaction(MemberOffset field_offset, int32_t new_value) |
| 504 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 505 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 506 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 507 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 508 | ALWAYS_INLINE bool CasFieldWeakSequentiallyConsistent32(MemberOffset field_offset, |
| 509 | int32_t old_value, int32_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 510 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 511 | |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 512 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 513 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 514 | bool CasFieldWeakRelaxed32(MemberOffset field_offset, int32_t old_value, |
| 515 | int32_t new_value) ALWAYS_INLINE |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 516 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 517 | |
| 518 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 519 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hans Boehm | b3da36c | 2016-12-15 13:12:59 -0800 | [diff] [blame] | 520 | bool CasFieldWeakAcquire32(MemberOffset field_offset, int32_t old_value, |
| 521 | int32_t new_value) ALWAYS_INLINE |
| 522 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 523 | |
| 524 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 525 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 526 | bool CasFieldWeakRelease32(MemberOffset field_offset, int32_t old_value, |
| 527 | int32_t new_value) ALWAYS_INLINE |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 528 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 529 | |
| 530 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 531 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 532 | bool CasFieldStrongSequentiallyConsistent32(MemberOffset field_offset, int32_t old_value, |
| 533 | int32_t new_value) ALWAYS_INLINE |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 534 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 535 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 536 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 537 | ALWAYS_INLINE int64_t GetField64(MemberOffset field_offset) |
Andreas Gampe | c6ea7d0 | 2017-02-01 16:46:28 -0800 | [diff] [blame] | 538 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 539 | if (kVerifyFlags & kVerifyThis) { |
| 540 | VerifyObject(this); |
| 541 | } |
| 542 | return GetField<int64_t, kIsVolatile>(field_offset); |
| 543 | } |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 544 | |
| 545 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 546 | ALWAYS_INLINE int64_t GetField64Volatile(MemberOffset field_offset) |
Andreas Gampe | c6ea7d0 | 2017-02-01 16:46:28 -0800 | [diff] [blame] | 547 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 548 | return GetField64<kVerifyFlags, true>(field_offset); |
| 549 | } |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 550 | |
| 551 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 552 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 553 | ALWAYS_INLINE void SetField64(MemberOffset field_offset, int64_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 554 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 555 | |
| 556 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 557 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 558 | ALWAYS_INLINE void SetField64Volatile(MemberOffset field_offset, int64_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 559 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 560 | |
Chang Xing | 6d3e768 | 2017-07-11 10:31:29 -0700 | [diff] [blame] | 561 | template<bool kCheckTransaction = true, |
| 562 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 563 | bool kIsVolatile = false> |
| 564 | ALWAYS_INLINE void SetField64Transaction(MemberOffset field_offset, int32_t new_value) |
| 565 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 566 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 567 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 568 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | 228602f | 2014-07-10 02:07:54 -0700 | [diff] [blame] | 569 | bool CasFieldWeakSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value, |
| 570 | int64_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 571 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 572 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 573 | template<bool kTransactionActive, bool kCheckTransaction = true, |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 574 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 575 | bool CasFieldStrongSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value, |
| 576 | int64_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 577 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 578 | |
| 579 | template<bool kTransactionActive, bool kCheckTransaction = true, |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 580 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 581 | void SetFieldPtr(MemberOffset field_offset, T new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 582 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 583 | SetFieldPtrWithSize<kTransactionActive, kCheckTransaction, kVerifyFlags>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 584 | field_offset, new_value, kRuntimePointerSize); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 585 | } |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 586 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 587 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T> |
| 588 | void SetFieldPtr64(MemberOffset field_offset, T new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 589 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 590 | SetFieldPtrWithSize<kTransactionActive, kCheckTransaction, kVerifyFlags>( |
| 591 | field_offset, new_value, 8u); |
| 592 | } |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 593 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 594 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 595 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 596 | ALWAYS_INLINE void SetFieldPtrWithSize(MemberOffset field_offset, |
| 597 | T new_value, |
| 598 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 599 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 600 | if (pointer_size == PointerSize::k32) { |
Colin Cross | 32f5388 | 2017-03-15 15:25:24 -0700 | [diff] [blame] | 601 | uintptr_t ptr = reinterpret_cast<uintptr_t>(new_value); |
| 602 | DCHECK_EQ(static_cast<uint32_t>(ptr), ptr); // Check that we dont lose any non 0 bits. |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 603 | SetField32<kTransactionActive, kCheckTransaction, kVerifyFlags>( |
Colin Cross | 32f5388 | 2017-03-15 15:25:24 -0700 | [diff] [blame] | 604 | field_offset, static_cast<int32_t>(static_cast<uint32_t>(ptr))); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 605 | } else { |
| 606 | SetField64<kTransactionActive, kCheckTransaction, kVerifyFlags>( |
Vladimir Marko | db8e62d | 2016-03-30 16:30:21 +0100 | [diff] [blame] | 607 | field_offset, reinterpret_cast64<int64_t>(new_value)); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 608 | } |
| 609 | } |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 610 | |
| 611 | // Base class for accessors used to describe accesses performed by VarHandle methods. |
| 612 | template <typename T> |
| 613 | class Accessor { |
| 614 | public: |
| 615 | virtual ~Accessor() { |
| 616 | static_assert(std::is_arithmetic<T>::value, "unsupported type"); |
| 617 | } |
| 618 | virtual void Access(T* field_address) = 0; |
| 619 | }; |
| 620 | |
| 621 | // Getter method that exposes the raw address of a primitive value-type field to an Accessor |
| 622 | // instance. This are used by VarHandle accessor methods to read fields with a wider range of |
| 623 | // memory orderings than usually required. |
| 624 | template<typename T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 625 | void GetPrimitiveFieldViaAccessor(MemberOffset field_offset, Accessor<T>* accessor) |
| 626 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 627 | |
| 628 | // Update methods that expose the raw address of a primitive value-type to an Accessor instance |
| 629 | // that will attempt to update the field. These are used by VarHandle accessor methods to |
| 630 | // atomically update fields with a wider range of memory orderings than usually required. |
| 631 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 632 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 633 | void UpdateFieldBooleanViaAccessor(MemberOffset field_offset, Accessor<uint8_t>* accessor) |
| 634 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 635 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 636 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 637 | void UpdateFieldByteViaAccessor(MemberOffset field_offset, Accessor<int8_t>* accessor) |
| 638 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 639 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 640 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 641 | void UpdateFieldCharViaAccessor(MemberOffset field_offset, Accessor<uint16_t>* accessor) |
| 642 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 643 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 644 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 645 | void UpdateFieldShortViaAccessor(MemberOffset field_offset, Accessor<int16_t>* accessor) |
| 646 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 647 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 648 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 649 | void UpdateField32ViaAccessor(MemberOffset field_offset, Accessor<int32_t>* accessor) |
| 650 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 651 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 652 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 653 | void UpdateField64ViaAccessor(MemberOffset field_offset, Accessor<int64_t>* accessor) |
| 654 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 655 | |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 656 | // TODO fix thread safety analysis broken by the use of template. This should be |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 657 | // REQUIRES_SHARED(Locks::mutator_lock_). |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 658 | template <bool kVisitNativeRoots = true, |
| 659 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 660 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
Mathieu Chartier | 059ef3d | 2015-08-18 13:54:21 -0700 | [diff] [blame] | 661 | typename Visitor, |
| 662 | typename JavaLangRefVisitor = VoidFunctor> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 663 | void VisitReferences(const Visitor& visitor, const JavaLangRefVisitor& ref_visitor) |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 664 | NO_THREAD_SAFETY_ANALYSIS; |
| 665 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 666 | ArtField* FindFieldByOffset(MemberOffset offset) REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | eb2baaf | 2015-05-13 21:14:22 -0700 | [diff] [blame] | 667 | |
tony.ys_liu | 7380c31 | 2015-01-16 19:16:45 +0800 | [diff] [blame] | 668 | // Used by object_test. |
| 669 | static void SetHashCodeSeed(uint32_t new_seed); |
| 670 | // Generate an identity hash code. Public for object test. |
| 671 | static uint32_t GenerateIdentityHashCode(); |
| 672 | |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 673 | // Returns a human-readable form of the name of the *class* of the given object. |
| 674 | // So given an instance of java.lang.String, the output would |
| 675 | // be "java.lang.String". Given an array of int, the output would be "int[]". |
| 676 | // Given String.class, the output would be "java.lang.Class<java.lang.String>". |
| 677 | static std::string PrettyTypeOf(ObjPtr<mirror::Object> obj) |
| 678 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 679 | std::string PrettyTypeOf() |
| 680 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 681 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 682 | protected: |
| 683 | // Accessors for non-Java type fields |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 684 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 685 | T GetFieldPtr(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 686 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 687 | return GetFieldPtrWithSize<T, kVerifyFlags, kIsVolatile>(field_offset, kRuntimePointerSize); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 688 | } |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 689 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 690 | T GetFieldPtr64(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 691 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 692 | return GetFieldPtrWithSize<T, kVerifyFlags, kIsVolatile>(field_offset, |
| 693 | PointerSize::k64); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 694 | } |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 695 | |
| 696 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 697 | ALWAYS_INLINE T GetFieldPtrWithSize(MemberOffset field_offset, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 698 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 699 | if (pointer_size == PointerSize::k32) { |
Colin Cross | 32f5388 | 2017-03-15 15:25:24 -0700 | [diff] [blame] | 700 | uint64_t address = static_cast<uint32_t>(GetField32<kVerifyFlags, kIsVolatile>(field_offset)); |
| 701 | return reinterpret_cast<T>(static_cast<uintptr_t>(address)); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 702 | } else { |
| 703 | int64_t v = GetField64<kVerifyFlags, kIsVolatile>(field_offset); |
Vladimir Marko | db8e62d | 2016-03-30 16:30:21 +0100 | [diff] [blame] | 704 | return reinterpret_cast64<T>(v); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 705 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 706 | } |
| 707 | |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 708 | // TODO: Fixme when anotatalysis works with visitors. |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 709 | template<bool kIsStatic, |
| 710 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 711 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
| 712 | typename Visitor> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 713 | void VisitFieldsReferences(uint32_t ref_offsets, const Visitor& visitor) HOT_ATTR |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 714 | NO_THREAD_SAFETY_ANALYSIS; |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 715 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 716 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
| 717 | typename Visitor> |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 718 | void VisitInstanceFieldsReferences(ObjPtr<mirror::Class> klass, const Visitor& visitor) HOT_ATTR |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 719 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 720 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 721 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
| 722 | typename Visitor> |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 723 | void VisitStaticFieldsReferences(ObjPtr<mirror::Class> klass, const Visitor& visitor) HOT_ATTR |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 724 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 725 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 726 | private: |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 727 | template<typename kSize, bool kIsVolatile> |
| 728 | ALWAYS_INLINE void SetField(MemberOffset field_offset, kSize new_value) |
Andreas Gampe | 90b936d | 2017-01-31 08:58:55 -0800 | [diff] [blame] | 729 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 730 | uint8_t* raw_addr = reinterpret_cast<uint8_t*>(this) + field_offset.Int32Value(); |
| 731 | kSize* addr = reinterpret_cast<kSize*>(raw_addr); |
| 732 | if (kIsVolatile) { |
| 733 | reinterpret_cast<Atomic<kSize>*>(addr)->StoreSequentiallyConsistent(new_value); |
| 734 | } else { |
| 735 | reinterpret_cast<Atomic<kSize>*>(addr)->StoreJavaData(new_value); |
| 736 | } |
| 737 | } |
| 738 | |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 739 | template<typename kSize, bool kIsVolatile> |
| 740 | ALWAYS_INLINE kSize GetField(MemberOffset field_offset) |
Andreas Gampe | 90b936d | 2017-01-31 08:58:55 -0800 | [diff] [blame] | 741 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 742 | const uint8_t* raw_addr = reinterpret_cast<const uint8_t*>(this) + field_offset.Int32Value(); |
| 743 | const kSize* addr = reinterpret_cast<const kSize*>(raw_addr); |
| 744 | if (kIsVolatile) { |
| 745 | return reinterpret_cast<const Atomic<kSize>*>(addr)->LoadSequentiallyConsistent(); |
| 746 | } else { |
| 747 | return reinterpret_cast<const Atomic<kSize>*>(addr)->LoadJavaData(); |
| 748 | } |
| 749 | } |
| 750 | |
Mathieu Chartier | c381c36 | 2016-08-23 13:27:53 -0700 | [diff] [blame] | 751 | // Get a field with acquire semantics. |
| 752 | template<typename kSize> |
| 753 | ALWAYS_INLINE kSize GetFieldAcquire(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 754 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 755 | |
Ian Rogers | 04d7aa9 | 2013-03-16 14:29:17 -0700 | [diff] [blame] | 756 | // Verify the type correctness of stores to fields. |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 757 | // TODO: This can cause thread suspension and isn't moving GC safe. |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 758 | void CheckFieldAssignmentImpl(MemberOffset field_offset, ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 759 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 760 | void CheckFieldAssignment(MemberOffset field_offset, ObjPtr<Object>new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 761 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 04d7aa9 | 2013-03-16 14:29:17 -0700 | [diff] [blame] | 762 | if (kCheckFieldAssignments) { |
| 763 | CheckFieldAssignmentImpl(field_offset, new_value); |
| 764 | } |
| 765 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 766 | |
Mathieu Chartier | 51eaa7f | 2016-10-12 16:08:35 -0700 | [diff] [blame] | 767 | // A utility function that copies an object in a read barrier and write barrier-aware way. |
| 768 | // This is internally used by Clone() and Class::CopyOf(). If the object is finalizable, |
| 769 | // it is the callers job to call Heap::AddFinalizerReference. |
| 770 | static Object* CopyObject(ObjPtr<mirror::Object> dest, |
Mathieu Chartier | 9d156d5 | 2016-10-06 17:44:26 -0700 | [diff] [blame] | 771 | ObjPtr<mirror::Object> src, |
Hiroshi Yamauchi | 0fbd6e6 | 2014-07-17 16:16:31 -0700 | [diff] [blame] | 772 | size_t num_bytes) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 773 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 0fbd6e6 | 2014-07-17 16:16:31 -0700 | [diff] [blame] | 774 | |
tony.ys_liu | 7380c31 | 2015-01-16 19:16:45 +0800 | [diff] [blame] | 775 | static Atomic<uint32_t> hash_code_seed; |
| 776 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 777 | // The Class representing the type of the object. |
| 778 | HeapReference<Class> klass_; |
| 779 | // Monitor and hash code information. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 780 | uint32_t monitor_; |
| 781 | |
Hiroshi Yamauchi | 60f63f5 | 2015-04-23 16:12:40 -0700 | [diff] [blame] | 782 | #ifdef USE_BROOKS_READ_BARRIER |
Hiroshi Yamauchi | 624468c | 2014-03-31 15:14:47 -0700 | [diff] [blame] | 783 | // Note names use a 'x' prefix and the x_rb_ptr_ is of type int |
Hiroshi Yamauchi | 9d04a20 | 2014-01-31 13:35:49 -0800 | [diff] [blame] | 784 | // instead of Object to go with the alphabetical/by-type field order |
| 785 | // on the Java side. |
Hiroshi Yamauchi | 60f63f5 | 2015-04-23 16:12:40 -0700 | [diff] [blame] | 786 | uint32_t x_rb_ptr_; // For the Brooks pointer. |
Hiroshi Yamauchi | 624468c | 2014-03-31 15:14:47 -0700 | [diff] [blame] | 787 | uint32_t x_xpadding_; // For 8-byte alignment. TODO: get rid of this. |
Hiroshi Yamauchi | 9d04a20 | 2014-01-31 13:35:49 -0800 | [diff] [blame] | 788 | #endif |
| 789 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 790 | friend class art::ImageWriter; |
Mathieu Chartier | ad2541a | 2013-10-25 10:05:23 -0700 | [diff] [blame] | 791 | friend class art::Monitor; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 792 | friend struct art::ObjectOffsets; // for verifying offset information |
Hiroshi Yamauchi | 0fbd6e6 | 2014-07-17 16:16:31 -0700 | [diff] [blame] | 793 | friend class CopyObjectVisitor; // for CopyObject(). |
| 794 | friend class CopyClassVisitor; // for CopyObject(). |
Ian Rogers | cf7f191 | 2014-10-22 22:06:39 -0700 | [diff] [blame] | 795 | DISALLOW_ALLOCATION(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 796 | DISALLOW_IMPLICIT_CONSTRUCTORS(Object); |
| 797 | }; |
| 798 | |
| 799 | } // namespace mirror |
| 800 | } // namespace art |
| 801 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 802 | #endif // ART_RUNTIME_MIRROR_OBJECT_H_ |