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 | |
Vladimir Marko | db8e62d | 2016-03-30 16:30:21 +0100 | [diff] [blame] | 20 | #include "base/casts.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 21 | #include "base/enums.h" |
Ian Rogers | cdc1aaf | 2014-10-09 13:21:38 -0700 | [diff] [blame] | 22 | #include "globals.h" |
Mathieu Chartier | a59d9b2 | 2016-09-26 18:13:17 -0700 | [diff] [blame] | 23 | #include "obj_ptr.h" |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 24 | #include "object_reference.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 25 | #include "offsets.h" |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 26 | #include "verify_object.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 27 | |
| 28 | namespace art { |
| 29 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 30 | class ArtField; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 31 | class ArtMethod; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 32 | class ImageWriter; |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 33 | class LockWord; |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 34 | class Monitor; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 35 | struct ObjectOffsets; |
| 36 | class Thread; |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 37 | class VoidFunctor; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 38 | |
| 39 | namespace mirror { |
| 40 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 41 | class Array; |
| 42 | class Class; |
Mathieu Chartier | e4275c0 | 2015-08-06 15:34:15 -0700 | [diff] [blame] | 43 | class ClassLoader; |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 44 | class DexCache; |
Mathieu Chartier | 8fa2dad | 2014-03-13 12:22:56 -0700 | [diff] [blame] | 45 | class FinalizerReference; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 46 | template<class T> class ObjectArray; |
| 47 | template<class T> class PrimitiveArray; |
| 48 | typedef PrimitiveArray<uint8_t> BooleanArray; |
| 49 | typedef PrimitiveArray<int8_t> ByteArray; |
| 50 | typedef PrimitiveArray<uint16_t> CharArray; |
| 51 | typedef PrimitiveArray<double> DoubleArray; |
| 52 | typedef PrimitiveArray<float> FloatArray; |
| 53 | typedef PrimitiveArray<int32_t> IntArray; |
| 54 | typedef PrimitiveArray<int64_t> LongArray; |
| 55 | typedef PrimitiveArray<int16_t> ShortArray; |
Mathieu Chartier | 8fa2dad | 2014-03-13 12:22:56 -0700 | [diff] [blame] | 56 | class Reference; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 57 | class String; |
| 58 | class Throwable; |
| 59 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 60 | // Fields within mirror objects aren't accessed directly so that the appropriate amount of |
| 61 | // handshaking is done with GC (for example, read and write barriers). This macro is used to |
| 62 | // compute an offset for the Set/Get methods defined in Object that can safely access fields. |
| 63 | #define OFFSET_OF_OBJECT_MEMBER(type, field) \ |
| 64 | MemberOffset(OFFSETOF_MEMBER(type, field)) |
| 65 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 66 | // Checks that we don't do field assignments which violate the typing system. |
| 67 | static constexpr bool kCheckFieldAssignments = false; |
Ian Rogers | 04d7aa9 | 2013-03-16 14:29:17 -0700 | [diff] [blame] | 68 | |
Ian Rogers | cdc1aaf | 2014-10-09 13:21:38 -0700 | [diff] [blame] | 69 | // Size of Object. |
Hiroshi Yamauchi | 60f63f5 | 2015-04-23 16:12:40 -0700 | [diff] [blame] | 70 | static constexpr uint32_t kObjectHeaderSize = kUseBrooksReadBarrier ? 16 : 8; |
Ian Rogers | cdc1aaf | 2014-10-09 13:21:38 -0700 | [diff] [blame] | 71 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 72 | // C++ mirror of java.lang.Object |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 73 | class MANAGED LOCKABLE Object { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 74 | public: |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 75 | // The number of vtable entries in java.lang.Object. |
| 76 | static constexpr size_t kVTableLength = 11; |
| 77 | |
| 78 | // The size of the java.lang.Class representing a java.lang.Object. |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 79 | static uint32_t ClassSize(PointerSize pointer_size); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 80 | |
| 81 | // Size of an instance of java.lang.Object. |
| 82 | static constexpr uint32_t InstanceSize() { |
| 83 | return sizeof(Object); |
| 84 | } |
| 85 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 86 | static MemberOffset ClassOffset() { |
| 87 | return OFFSET_OF_OBJECT_MEMBER(Object, klass_); |
| 88 | } |
| 89 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 90 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 91 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 92 | ALWAYS_INLINE Class* GetClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 93 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 94 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 95 | void SetClass(ObjPtr<Class> new_klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 96 | |
Mathieu Chartier | c381c36 | 2016-08-23 13:27:53 -0700 | [diff] [blame] | 97 | // TODO: Clean these up and change to return int32_t |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 98 | Object* GetReadBarrierPointer() REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | ed70b4a | 2015-11-17 17:52:15 -0800 | [diff] [blame] | 99 | |
Mathieu Chartier | c381c36 | 2016-08-23 13:27:53 -0700 | [diff] [blame] | 100 | // Get the read barrier pointer with release semantics, only supported for baker. |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 101 | Object* GetReadBarrierPointerAcquire() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c381c36 | 2016-08-23 13:27:53 -0700 | [diff] [blame] | 102 | |
Andreas Gampe | 65b798e | 2015-04-06 09:35:22 -0700 | [diff] [blame] | 103 | #ifndef USE_BAKER_OR_BROOKS_READ_BARRIER |
| 104 | NO_RETURN |
| 105 | #endif |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 106 | void SetReadBarrierPointer(Object* rb_ptr) REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | ed70b4a | 2015-11-17 17:52:15 -0800 | [diff] [blame] | 107 | |
| 108 | template<bool kCasRelease = false> |
Hiroshi Yamauchi | 723e6ce | 2015-10-28 20:59:47 -0700 | [diff] [blame] | 109 | ALWAYS_INLINE bool AtomicSetReadBarrierPointer(Object* expected_rb_ptr, Object* rb_ptr) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 110 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 111 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 112 | ALWAYS_INLINE uint32_t GetMarkBit() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 113 | |
| 114 | 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] | 115 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 36a270a | 2016-07-28 18:08:51 -0700 | [diff] [blame] | 116 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 117 | void AssertReadBarrierPointer() const REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 9d04a20 | 2014-01-31 13:35:49 -0800 | [diff] [blame] | 118 | |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 119 | // The verifier treats all interfaces as java.lang.Object and relies on runtime checks in |
| 120 | // invoke-interface to detect incompatible interface types. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 121 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame^] | 122 | bool VerifierInstanceOf(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 123 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | a59d9b2 | 2016-09-26 18:13:17 -0700 | [diff] [blame] | 124 | ALWAYS_INLINE bool InstanceOf(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 125 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 126 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 127 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 128 | size_t SizeOf() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 129 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 130 | Object* Clone(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_) |
Mathieu Chartier | 4e2cb09 | 2015-07-22 16:17:51 -0700 | [diff] [blame] | 131 | REQUIRES(!Roles::uninterruptible_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 132 | |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 133 | int32_t IdentityHashCode() |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 134 | REQUIRES_SHARED(Locks::mutator_lock_) |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 135 | REQUIRES(!Locks::thread_list_lock_, |
| 136 | !Locks::thread_suspend_count_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 137 | |
| 138 | static MemberOffset MonitorOffset() { |
| 139 | return OFFSET_OF_OBJECT_MEMBER(Object, monitor_); |
| 140 | } |
| 141 | |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 142 | // 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] | 143 | // avoids the barriers. |
Andreas Gampe | 3b45ef2 | 2015-05-26 21:34:09 -0700 | [diff] [blame] | 144 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 145 | LockWord GetLockWord(bool as_volatile) REQUIRES_SHARED(Locks::mutator_lock_); |
Andreas Gampe | 3b45ef2 | 2015-05-26 21:34:09 -0700 | [diff] [blame] | 146 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 147 | 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] | 148 | bool CasLockWordWeakSequentiallyConsistent(LockWord old_val, LockWord new_val) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 149 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 150 | bool CasLockWordWeakRelaxed(LockWord old_val, LockWord new_val) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 151 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 152 | bool CasLockWordWeakRelease(LockWord old_val, LockWord new_val) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 153 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 154 | uint32_t GetLockOwnerThreadId(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 155 | |
Mathieu Chartier | a704eda | 2016-07-13 09:53:35 -0700 | [diff] [blame] | 156 | // Try to enter the monitor, returns non null if we succeeded. |
| 157 | mirror::Object* MonitorTryEnter(Thread* self) |
| 158 | EXCLUSIVE_LOCK_FUNCTION() |
| 159 | REQUIRES(!Roles::uninterruptible_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 160 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 2d096c9 | 2015-10-12 16:18:20 -0700 | [diff] [blame] | 161 | mirror::Object* MonitorEnter(Thread* self) |
| 162 | EXCLUSIVE_LOCK_FUNCTION() |
| 163 | REQUIRES(!Roles::uninterruptible_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 164 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 2d096c9 | 2015-10-12 16:18:20 -0700 | [diff] [blame] | 165 | bool MonitorExit(Thread* self) |
| 166 | REQUIRES(!Roles::uninterruptible_) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 167 | REQUIRES_SHARED(Locks::mutator_lock_) |
Ian Rogers | 719d1a3 | 2014-03-06 12:13:39 -0800 | [diff] [blame] | 168 | UNLOCK_FUNCTION(); |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 169 | void Notify(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); |
| 170 | void NotifyAll(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); |
| 171 | void Wait(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_); |
| 172 | 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] | 173 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 174 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 175 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 176 | bool IsClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 177 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 178 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 179 | Class* AsClass() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 180 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 181 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 182 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 183 | bool IsObjectArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 184 | template<class T, |
| 185 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 186 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 187 | ObjectArray<T>* AsObjectArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 188 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -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 IsClassLoader() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 192 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 193 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 194 | ClassLoader* AsClassLoader() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e4275c0 | 2015-08-06 15:34:15 -0700 | [diff] [blame] | 195 | |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 196 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 197 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 198 | bool IsDexCache() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 199 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 200 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 201 | DexCache* AsDexCache() REQUIRES_SHARED(Locks::mutator_lock_); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 202 | |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 203 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 204 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 205 | bool IsArrayInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 206 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 207 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 208 | Array* AsArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 209 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 210 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 211 | BooleanArray* AsBooleanArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 212 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 213 | ByteArray* AsByteArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 214 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 215 | ByteArray* AsByteSizedArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 216 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 217 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 218 | CharArray* AsCharArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 219 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 220 | ShortArray* AsShortArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 221 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 222 | ShortArray* AsShortSizedArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 223 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 224 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 225 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 226 | bool IsIntArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 227 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 228 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 229 | IntArray* AsIntArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 230 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 231 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 232 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 233 | bool IsLongArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 234 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 235 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 236 | LongArray* AsLongArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 237 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 238 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 239 | bool IsFloatArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 240 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 241 | FloatArray* AsFloatArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 242 | |
| 243 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 244 | bool IsDoubleArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 245 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 246 | DoubleArray* AsDoubleArray() REQUIRES_SHARED(Locks::mutator_lock_); |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 247 | |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 248 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 249 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 250 | bool IsString() REQUIRES_SHARED(Locks::mutator_lock_); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 251 | |
| 252 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 253 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 254 | String* AsString() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 255 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 256 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 257 | Throwable* AsThrowable() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 258 | |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 259 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 260 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 261 | bool IsReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | dfe02f6 | 2016-02-01 20:15:11 -0800 | [diff] [blame] | 262 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 263 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 264 | Reference* AsReference() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 8fa2dad | 2014-03-13 12:22:56 -0700 | [diff] [blame] | 265 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 266 | bool IsWeakReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 267 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 268 | bool IsSoftReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 269 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 270 | bool IsFinalizerReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 271 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 272 | FinalizerReference* AsFinalizerReference() 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 IsPhantomReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 275 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 276 | // Accessor for Java type fields. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 277 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 278 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 279 | ALWAYS_INLINE T* GetFieldObject(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 280 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 281 | |
| 282 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
Hiroshi Yamauchi | 6e83c17 | 2014-05-01 21:25:41 -0700 | [diff] [blame] | 283 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 284 | ALWAYS_INLINE T* GetFieldObjectVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 285 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 286 | |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 287 | template<bool kTransactionActive, |
| 288 | bool kCheckTransaction = true, |
| 289 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 290 | bool kIsVolatile = false> |
| 291 | ALWAYS_INLINE void SetFieldObjectWithoutWriteBarrier(MemberOffset field_offset, |
| 292 | ObjPtr<Object> new_value) |
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 SetFieldObject(MemberOffset field_offset, ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 300 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 301 | |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 302 | template<bool kTransactionActive, |
| 303 | bool kCheckTransaction = true, |
| 304 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 305 | ALWAYS_INLINE void SetFieldObjectVolatile(MemberOffset field_offset, |
| 306 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 307 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 308 | |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 309 | template<bool kTransactionActive, |
| 310 | bool kCheckTransaction = true, |
| 311 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 312 | bool CasFieldWeakSequentiallyConsistentObject(MemberOffset field_offset, |
| 313 | ObjPtr<Object> old_value, |
| 314 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 315 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 316 | template<bool kTransactionActive, |
| 317 | bool kCheckTransaction = true, |
| 318 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | 2cd334a | 2015-01-09 14:03:35 -0800 | [diff] [blame] | 319 | bool CasFieldWeakSequentiallyConsistentObjectWithoutWriteBarrier(MemberOffset field_offset, |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 320 | ObjPtr<Object> old_value, |
| 321 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 322 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 323 | template<bool kTransactionActive, |
| 324 | bool kCheckTransaction = true, |
| 325 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 326 | bool CasFieldStrongSequentiallyConsistentObject(MemberOffset field_offset, |
| 327 | ObjPtr<Object> old_value, |
| 328 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 329 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 330 | template<bool kTransactionActive, |
| 331 | bool kCheckTransaction = true, |
| 332 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | 2cd334a | 2015-01-09 14:03:35 -0800 | [diff] [blame] | 333 | bool CasFieldStrongSequentiallyConsistentObjectWithoutWriteBarrier(MemberOffset field_offset, |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 334 | ObjPtr<Object> old_value, |
| 335 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 336 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 337 | template<bool kTransactionActive, |
| 338 | bool kCheckTransaction = true, |
| 339 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 340 | bool CasFieldWeakRelaxedObjectWithoutWriteBarrier(MemberOffset field_offset, |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 341 | ObjPtr<Object> old_value, |
| 342 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 343 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 344 | template<bool kTransactionActive, |
| 345 | bool kCheckTransaction = true, |
| 346 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 347 | bool CasFieldStrongRelaxedObjectWithoutWriteBarrier(MemberOffset field_offset, |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 348 | ObjPtr<Object> old_value, |
| 349 | ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 350 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 351 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 352 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 353 | HeapReference<Object>* GetFieldObjectReferenceAddr(MemberOffset field_offset); |
Mathieu Chartier | 11409ae | 2013-09-23 11:49:36 -0700 | [diff] [blame] | 354 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 355 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 356 | ALWAYS_INLINE uint8_t GetFieldBoolean(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 357 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 358 | |
| 359 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 360 | ALWAYS_INLINE int8_t GetFieldByte(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 361 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 362 | |
| 363 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 364 | ALWAYS_INLINE uint8_t GetFieldBooleanVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 365 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 366 | |
| 367 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 368 | ALWAYS_INLINE int8_t GetFieldByteVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 369 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 370 | |
| 371 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 372 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 373 | ALWAYS_INLINE void SetFieldBoolean(MemberOffset field_offset, uint8_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 374 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 375 | |
| 376 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 377 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 378 | ALWAYS_INLINE void SetFieldByte(MemberOffset field_offset, int8_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 379 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 380 | |
| 381 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 382 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 383 | ALWAYS_INLINE void SetFieldBooleanVolatile(MemberOffset field_offset, uint8_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 384 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 385 | |
| 386 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 387 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 388 | ALWAYS_INLINE void SetFieldByteVolatile(MemberOffset field_offset, int8_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 389 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 390 | |
| 391 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 392 | ALWAYS_INLINE uint16_t GetFieldChar(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 393 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 394 | |
| 395 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 396 | ALWAYS_INLINE int16_t GetFieldShort(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 397 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 398 | |
| 399 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 400 | ALWAYS_INLINE uint16_t GetFieldCharVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 401 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 402 | |
| 403 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 404 | ALWAYS_INLINE int16_t GetFieldShortVolatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 405 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 406 | |
| 407 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 408 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 409 | ALWAYS_INLINE void SetFieldChar(MemberOffset field_offset, uint16_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 410 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 411 | |
| 412 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 413 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 414 | ALWAYS_INLINE void SetFieldShort(MemberOffset field_offset, int16_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 415 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 416 | |
| 417 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 418 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 419 | ALWAYS_INLINE void SetFieldCharVolatile(MemberOffset field_offset, uint16_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 420 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 421 | |
| 422 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 423 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 424 | ALWAYS_INLINE void SetFieldShortVolatile(MemberOffset field_offset, int16_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 425 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 426 | |
| 427 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 428 | ALWAYS_INLINE int32_t GetField32(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 429 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | d9c4fc9 | 2013-10-01 19:45:43 -0700 | [diff] [blame] | 430 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 431 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 432 | ALWAYS_INLINE int32_t GetField32Volatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 433 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 434 | |
| 435 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 436 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 437 | ALWAYS_INLINE void SetField32(MemberOffset field_offset, int32_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 438 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 439 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 440 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 441 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 442 | ALWAYS_INLINE void SetField32Volatile(MemberOffset field_offset, int32_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 443 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 444 | |
| 445 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 446 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 447 | ALWAYS_INLINE bool CasFieldWeakSequentiallyConsistent32(MemberOffset field_offset, |
| 448 | int32_t old_value, int32_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 449 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 450 | |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 451 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 452 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 453 | bool CasFieldWeakRelaxed32(MemberOffset field_offset, int32_t old_value, |
| 454 | int32_t new_value) ALWAYS_INLINE |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 455 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 456 | |
| 457 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 458 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 459 | bool CasFieldWeakRelease32(MemberOffset field_offset, int32_t old_value, |
| 460 | int32_t new_value) ALWAYS_INLINE |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 461 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | fed3e2f | 2015-10-20 11:11:56 -0700 | [diff] [blame] | 462 | |
| 463 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 464 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 465 | bool CasFieldStrongSequentiallyConsistent32(MemberOffset field_offset, int32_t old_value, |
| 466 | int32_t new_value) ALWAYS_INLINE |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 467 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 468 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 469 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 470 | ALWAYS_INLINE int64_t GetField64(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 471 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 472 | |
| 473 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 474 | ALWAYS_INLINE int64_t GetField64Volatile(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 475 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 476 | |
| 477 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 478 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 479 | ALWAYS_INLINE void SetField64(MemberOffset field_offset, int64_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 480 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 481 | |
| 482 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 483 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 484 | ALWAYS_INLINE void SetField64Volatile(MemberOffset field_offset, int64_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 485 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 486 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 487 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 488 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | 228602f | 2014-07-10 02:07:54 -0700 | [diff] [blame] | 489 | bool CasFieldWeakSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value, |
| 490 | int64_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 491 | REQUIRES_SHARED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 492 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 493 | template<bool kTransactionActive, bool kCheckTransaction = true, |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 494 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 495 | bool CasFieldStrongSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value, |
| 496 | int64_t new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 497 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hans Boehm | d843443 | 2014-07-11 09:56:07 -0700 | [diff] [blame] | 498 | |
| 499 | template<bool kTransactionActive, bool kCheckTransaction = true, |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 500 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 501 | void SetFieldPtr(MemberOffset field_offset, T new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 502 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 503 | SetFieldPtrWithSize<kTransactionActive, kCheckTransaction, kVerifyFlags>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 504 | field_offset, new_value, kRuntimePointerSize); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 505 | } |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 506 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 507 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T> |
| 508 | void SetFieldPtr64(MemberOffset field_offset, T new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 509 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 510 | SetFieldPtrWithSize<kTransactionActive, kCheckTransaction, kVerifyFlags>( |
| 511 | field_offset, new_value, 8u); |
| 512 | } |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 513 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 514 | template<bool kTransactionActive, bool kCheckTransaction = true, |
| 515 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 516 | ALWAYS_INLINE void SetFieldPtrWithSize(MemberOffset field_offset, |
| 517 | T new_value, |
| 518 | PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 519 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 520 | if (pointer_size == PointerSize::k32) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 521 | intptr_t ptr = reinterpret_cast<intptr_t>(new_value); |
| 522 | DCHECK_EQ(static_cast<int32_t>(ptr), ptr); // Check that we dont lose any non 0 bits. |
| 523 | SetField32<kTransactionActive, kCheckTransaction, kVerifyFlags>( |
| 524 | field_offset, static_cast<int32_t>(ptr)); |
| 525 | } else { |
| 526 | SetField64<kTransactionActive, kCheckTransaction, kVerifyFlags>( |
Vladimir Marko | db8e62d | 2016-03-30 16:30:21 +0100 | [diff] [blame] | 527 | field_offset, reinterpret_cast64<int64_t>(new_value)); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 528 | } |
| 529 | } |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 530 | // 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] | 531 | // REQUIRES_SHARED(Locks::mutator_lock_). |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 532 | template <bool kVisitNativeRoots = true, |
| 533 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 534 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
Mathieu Chartier | 059ef3d | 2015-08-18 13:54:21 -0700 | [diff] [blame] | 535 | typename Visitor, |
| 536 | typename JavaLangRefVisitor = VoidFunctor> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 537 | void VisitReferences(const Visitor& visitor, const JavaLangRefVisitor& ref_visitor) |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 538 | NO_THREAD_SAFETY_ANALYSIS; |
| 539 | |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 540 | ArtField* FindFieldByOffset(MemberOffset offset) REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | eb2baaf | 2015-05-13 21:14:22 -0700 | [diff] [blame] | 541 | |
tony.ys_liu | 7380c31 | 2015-01-16 19:16:45 +0800 | [diff] [blame] | 542 | // Used by object_test. |
| 543 | static void SetHashCodeSeed(uint32_t new_seed); |
| 544 | // Generate an identity hash code. Public for object test. |
| 545 | static uint32_t GenerateIdentityHashCode(); |
| 546 | |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 547 | // Returns a human-readable form of the name of the *class* of the given object. |
| 548 | // So given an instance of java.lang.String, the output would |
| 549 | // be "java.lang.String". Given an array of int, the output would be "int[]". |
| 550 | // Given String.class, the output would be "java.lang.Class<java.lang.String>". |
| 551 | static std::string PrettyTypeOf(ObjPtr<mirror::Object> obj) |
| 552 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 553 | std::string PrettyTypeOf() |
| 554 | REQUIRES_SHARED(Locks::mutator_lock_); |
| 555 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 556 | protected: |
| 557 | // Accessors for non-Java type fields |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 558 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 559 | T GetFieldPtr(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 560 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 561 | return GetFieldPtrWithSize<T, kVerifyFlags, kIsVolatile>(field_offset, kRuntimePointerSize); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 562 | } |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 563 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
| 564 | T GetFieldPtr64(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 565 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 566 | return GetFieldPtrWithSize<T, kVerifyFlags, kIsVolatile>(field_offset, |
| 567 | PointerSize::k64); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 568 | } |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 569 | |
| 570 | template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false> |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 571 | ALWAYS_INLINE T GetFieldPtrWithSize(MemberOffset field_offset, PointerSize pointer_size) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 572 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 573 | if (pointer_size == PointerSize::k32) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 574 | return reinterpret_cast<T>(GetField32<kVerifyFlags, kIsVolatile>(field_offset)); |
| 575 | } else { |
| 576 | int64_t v = GetField64<kVerifyFlags, kIsVolatile>(field_offset); |
Vladimir Marko | db8e62d | 2016-03-30 16:30:21 +0100 | [diff] [blame] | 577 | return reinterpret_cast64<T>(v); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 578 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 579 | } |
| 580 | |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 581 | // TODO: Fixme when anotatalysis works with visitors. |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 582 | template<bool kIsStatic, |
| 583 | VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 584 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
| 585 | typename Visitor> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 586 | void VisitFieldsReferences(uint32_t ref_offsets, const Visitor& visitor) HOT_ATTR |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 587 | NO_THREAD_SAFETY_ANALYSIS; |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 588 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 589 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
| 590 | typename Visitor> |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 591 | void VisitInstanceFieldsReferences(ObjPtr<mirror::Class> klass, const Visitor& visitor) HOT_ATTR |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 592 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | fbc3108 | 2016-01-24 11:59:56 -0800 | [diff] [blame] | 593 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, |
| 594 | ReadBarrierOption kReadBarrierOption = kWithReadBarrier, |
| 595 | typename Visitor> |
Mathieu Chartier | 31e8822 | 2016-10-14 18:43:19 -0700 | [diff] [blame] | 596 | void VisitStaticFieldsReferences(ObjPtr<mirror::Class> klass, const Visitor& visitor) HOT_ATTR |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 597 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | 407f702 | 2014-02-18 14:37:05 -0800 | [diff] [blame] | 598 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 599 | private: |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 600 | template<typename kSize, bool kIsVolatile> |
| 601 | ALWAYS_INLINE void SetField(MemberOffset field_offset, kSize new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 602 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 603 | template<typename kSize, bool kIsVolatile> |
| 604 | ALWAYS_INLINE kSize GetField(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 605 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | c381c36 | 2016-08-23 13:27:53 -0700 | [diff] [blame] | 606 | // Get a field with acquire semantics. |
| 607 | template<typename kSize> |
| 608 | ALWAYS_INLINE kSize GetFieldAcquire(MemberOffset field_offset) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 609 | REQUIRES_SHARED(Locks::mutator_lock_); |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 610 | |
Ian Rogers | 04d7aa9 | 2013-03-16 14:29:17 -0700 | [diff] [blame] | 611 | // Verify the type correctness of stores to fields. |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 612 | // TODO: This can cause thread suspension and isn't moving GC safe. |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 613 | void CheckFieldAssignmentImpl(MemberOffset field_offset, ObjPtr<Object> new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 614 | REQUIRES_SHARED(Locks::mutator_lock_); |
Mathieu Chartier | a058fdf | 2016-10-06 15:13:58 -0700 | [diff] [blame] | 615 | void CheckFieldAssignment(MemberOffset field_offset, ObjPtr<Object>new_value) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 616 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 04d7aa9 | 2013-03-16 14:29:17 -0700 | [diff] [blame] | 617 | if (kCheckFieldAssignments) { |
| 618 | CheckFieldAssignmentImpl(field_offset, new_value); |
| 619 | } |
| 620 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 621 | |
Mathieu Chartier | 51eaa7f | 2016-10-12 16:08:35 -0700 | [diff] [blame] | 622 | // A utility function that copies an object in a read barrier and write barrier-aware way. |
| 623 | // This is internally used by Clone() and Class::CopyOf(). If the object is finalizable, |
| 624 | // it is the callers job to call Heap::AddFinalizerReference. |
| 625 | static Object* CopyObject(ObjPtr<mirror::Object> dest, |
Mathieu Chartier | 9d156d5 | 2016-10-06 17:44:26 -0700 | [diff] [blame] | 626 | ObjPtr<mirror::Object> src, |
Hiroshi Yamauchi | 0fbd6e6 | 2014-07-17 16:16:31 -0700 | [diff] [blame] | 627 | size_t num_bytes) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 628 | REQUIRES_SHARED(Locks::mutator_lock_); |
Hiroshi Yamauchi | 0fbd6e6 | 2014-07-17 16:16:31 -0700 | [diff] [blame] | 629 | |
tony.ys_liu | 7380c31 | 2015-01-16 19:16:45 +0800 | [diff] [blame] | 630 | static Atomic<uint32_t> hash_code_seed; |
| 631 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 632 | // The Class representing the type of the object. |
| 633 | HeapReference<Class> klass_; |
| 634 | // Monitor and hash code information. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 635 | uint32_t monitor_; |
| 636 | |
Hiroshi Yamauchi | 60f63f5 | 2015-04-23 16:12:40 -0700 | [diff] [blame] | 637 | #ifdef USE_BROOKS_READ_BARRIER |
Hiroshi Yamauchi | 624468c | 2014-03-31 15:14:47 -0700 | [diff] [blame] | 638 | // 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] | 639 | // instead of Object to go with the alphabetical/by-type field order |
| 640 | // on the Java side. |
Hiroshi Yamauchi | 60f63f5 | 2015-04-23 16:12:40 -0700 | [diff] [blame] | 641 | uint32_t x_rb_ptr_; // For the Brooks pointer. |
Hiroshi Yamauchi | 624468c | 2014-03-31 15:14:47 -0700 | [diff] [blame] | 642 | 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] | 643 | #endif |
| 644 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 645 | friend class art::ImageWriter; |
Mathieu Chartier | ad2541a | 2013-10-25 10:05:23 -0700 | [diff] [blame] | 646 | friend class art::Monitor; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 647 | friend struct art::ObjectOffsets; // for verifying offset information |
Hiroshi Yamauchi | 0fbd6e6 | 2014-07-17 16:16:31 -0700 | [diff] [blame] | 648 | friend class CopyObjectVisitor; // for CopyObject(). |
| 649 | friend class CopyClassVisitor; // for CopyObject(). |
Ian Rogers | cf7f191 | 2014-10-22 22:06:39 -0700 | [diff] [blame] | 650 | DISALLOW_ALLOCATION(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 651 | DISALLOW_IMPLICIT_CONSTRUCTORS(Object); |
| 652 | }; |
| 653 | |
| 654 | } // namespace mirror |
| 655 | } // namespace art |
| 656 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 657 | #endif // ART_RUNTIME_MIRROR_OBJECT_H_ |