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