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