blob: 95f82cb1475d73c1f4944eed5a94e2fcc496fbb0 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_MIRROR_OBJECT_H_
18#define ART_RUNTIME_MIRROR_OBJECT_H_
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019
David Sehr8f4b0562018-03-02 12:01:51 -080020#include "base/atomic.h"
Vladimir Markodb8e62d2016-03-30 16:30:21 +010021#include "base/casts.h"
Andreas Gampe542451c2016-07-26 09:02:02 -070022#include "base/enums.h"
Ian Rogerscdc1aaf2014-10-09 13:21:38 -070023#include "globals.h"
Mathieu Chartiera59d9b22016-09-26 18:13:17 -070024#include "obj_ptr.h"
Ian Rogersef7d42f2014-01-06 12:55:46 -080025#include "object_reference.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080026#include "offsets.h"
Andreas Gampe217488a2017-09-18 08:34:42 -070027#include "read_barrier_config.h"
28#include "read_barrier_option.h"
Mathieu Chartier4e305412014-02-19 10:54:44 -080029#include "verify_object.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030
31namespace art {
32
Mathieu Chartierc7853442015-03-27 14:35:38 -070033class ArtField;
Mathieu Chartiere401d142015-04-22 13:56:20 -070034class ArtMethod;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080035class ImageWriter;
Ian Rogersd9c4fc92013-10-01 19:45:43 -070036class LockWord;
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070037class Monitor;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080038struct ObjectOffsets;
39class Thread;
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070040class VoidFunctor;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080041
42namespace mirror {
43
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080044class Array;
45class Class;
Mathieu Chartiere4275c02015-08-06 15:34:15 -070046class ClassLoader;
Vladimir Marko05792b92015-08-03 11:56:49 +010047class DexCache;
Mathieu Chartier8fa2dad2014-03-13 12:22:56 -070048class FinalizerReference;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080049template<class T> class ObjectArray;
50template<class T> class PrimitiveArray;
51typedef PrimitiveArray<uint8_t> BooleanArray;
52typedef PrimitiveArray<int8_t> ByteArray;
53typedef PrimitiveArray<uint16_t> CharArray;
54typedef PrimitiveArray<double> DoubleArray;
55typedef PrimitiveArray<float> FloatArray;
56typedef PrimitiveArray<int32_t> IntArray;
57typedef PrimitiveArray<int64_t> LongArray;
58typedef PrimitiveArray<int16_t> ShortArray;
Mathieu Chartier8fa2dad2014-03-13 12:22:56 -070059class Reference;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080060class String;
61class Throwable;
62
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080063// Fields within mirror objects aren't accessed directly so that the appropriate amount of
64// handshaking is done with GC (for example, read and write barriers). This macro is used to
65// compute an offset for the Set/Get methods defined in Object that can safely access fields.
66#define OFFSET_OF_OBJECT_MEMBER(type, field) \
67 MemberOffset(OFFSETOF_MEMBER(type, field))
68
Mathieu Chartier4e305412014-02-19 10:54:44 -080069// Checks that we don't do field assignments which violate the typing system.
70static constexpr bool kCheckFieldAssignments = false;
Ian Rogers04d7aa92013-03-16 14:29:17 -070071
Ian Rogerscdc1aaf2014-10-09 13:21:38 -070072// Size of Object.
Hiroshi Yamauchi60f63f52015-04-23 16:12:40 -070073static constexpr uint32_t kObjectHeaderSize = kUseBrooksReadBarrier ? 16 : 8;
Ian Rogerscdc1aaf2014-10-09 13:21:38 -070074
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080075// C++ mirror of java.lang.Object
Ian Rogers719d1a32014-03-06 12:13:39 -080076class MANAGED LOCKABLE Object {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080077 public:
Mingyao Yang98d1cc82014-05-15 17:02:16 -070078 // The number of vtable entries in java.lang.Object.
79 static constexpr size_t kVTableLength = 11;
80
81 // The size of the java.lang.Class representing a java.lang.Object.
Andreas Gampe542451c2016-07-26 09:02:02 -070082 static uint32_t ClassSize(PointerSize pointer_size);
Mingyao Yang98d1cc82014-05-15 17:02:16 -070083
84 // Size of an instance of java.lang.Object.
85 static constexpr uint32_t InstanceSize() {
86 return sizeof(Object);
87 }
88
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080089 static MemberOffset ClassOffset() {
90 return OFFSET_OF_OBJECT_MEMBER(Object, klass_);
91 }
92
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -070093 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
94 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070095 ALWAYS_INLINE Class* GetClass() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080096
Mathieu Chartier4e305412014-02-19 10:54:44 -080097 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mathieu Chartiera058fdf2016-10-06 15:13:58 -070098 void SetClass(ObjPtr<Class> new_klass) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080099
Hiroshi Yamauchi12b58b22016-11-01 11:55:29 -0700100 // Get the read barrier state with a fake address dependency.
101 // '*fake_address_dependency' will be set to 0.
102 ALWAYS_INLINE uint32_t GetReadBarrierState(uintptr_t* fake_address_dependency)
103 REQUIRES_SHARED(Locks::mutator_lock_);
104 // This version does not offer any special mechanism to prevent load-load reordering.
105 ALWAYS_INLINE uint32_t GetReadBarrierState() REQUIRES_SHARED(Locks::mutator_lock_);
106 // Get the read barrier state with a load-acquire.
107 ALWAYS_INLINE uint32_t GetReadBarrierStateAcquire() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierc381c362016-08-23 13:27:53 -0700108
Andreas Gampe65b798e2015-04-06 09:35:22 -0700109#ifndef USE_BAKER_OR_BROOKS_READ_BARRIER
110 NO_RETURN
111#endif
Hiroshi Yamauchi12b58b22016-11-01 11:55:29 -0700112 ALWAYS_INLINE void SetReadBarrierState(uint32_t rb_state) REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchied70b4a2015-11-17 17:52:15 -0800113
114 template<bool kCasRelease = false>
Hiroshi Yamauchi12b58b22016-11-01 11:55:29 -0700115 ALWAYS_INLINE bool AtomicSetReadBarrierState(uint32_t expected_rb_state, uint32_t rb_state)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700116 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700117
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700118 ALWAYS_INLINE uint32_t GetMarkBit() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700119
120 ALWAYS_INLINE bool AtomicSetMarkBit(uint32_t expected_mark_bit, uint32_t mark_bit)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700121 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier36a270a2016-07-28 18:08:51 -0700122
Hiroshi Yamauchi12b58b22016-11-01 11:55:29 -0700123 // Assert that the read barrier state is in the default (white) state.
124 ALWAYS_INLINE void AssertReadBarrierState() const REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi9d04a202014-01-31 13:35:49 -0800125
Jeff Haoa3faaf42013-09-03 19:07:00 -0700126 // The verifier treats all interfaces as java.lang.Object and relies on runtime checks in
127 // invoke-interface to detect incompatible interface types.
Mathieu Chartier4e305412014-02-19 10:54:44 -0800128 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mathieu Chartieref41db72016-10-25 15:08:01 -0700129 bool VerifierInstanceOf(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800130 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mathieu Chartiera59d9b22016-09-26 18:13:17 -0700131 ALWAYS_INLINE bool InstanceOf(ObjPtr<Class> klass) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800132
Mathieu Chartierd08f66f2017-04-13 11:47:53 -0700133 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700134 size_t SizeOf() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800135
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700136 Object* Clone(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartier4e2cb092015-07-22 16:17:51 -0700137 REQUIRES(!Roles::uninterruptible_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800138
Mathieu Chartier31e88222016-10-14 18:43:19 -0700139 int32_t IdentityHashCode()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700140 REQUIRES_SHARED(Locks::mutator_lock_)
Mathieu Chartier31e88222016-10-14 18:43:19 -0700141 REQUIRES(!Locks::thread_list_lock_,
142 !Locks::thread_suspend_count_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800143
144 static MemberOffset MonitorOffset() {
145 return OFFSET_OF_OBJECT_MEMBER(Object, monitor_);
146 }
147
Hans Boehmd8434432014-07-11 09:56:07 -0700148 // As_volatile can be false if the mutators are suspended. This is an optimization since it
Mathieu Chartier4d7f61d2014-04-17 14:43:39 -0700149 // avoids the barriers.
Andreas Gampe3b45ef22015-05-26 21:34:09 -0700150 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700151 LockWord GetLockWord(bool as_volatile) REQUIRES_SHARED(Locks::mutator_lock_);
Andreas Gampe3b45ef22015-05-26 21:34:09 -0700152 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700153 void SetLockWord(LockWord new_val, bool as_volatile) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers228602f2014-07-10 02:07:54 -0700154 bool CasLockWordWeakSequentiallyConsistent(LockWord old_val, LockWord new_val)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700155 REQUIRES_SHARED(Locks::mutator_lock_);
Hans Boehmd8434432014-07-11 09:56:07 -0700156 bool CasLockWordWeakRelaxed(LockWord old_val, LockWord new_val)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700157 REQUIRES_SHARED(Locks::mutator_lock_);
Hans Boehmb3da36c2016-12-15 13:12:59 -0800158 bool CasLockWordWeakAcquire(LockWord old_val, LockWord new_val)
159 REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchifed3e2f2015-10-20 11:11:56 -0700160 bool CasLockWordWeakRelease(LockWord old_val, LockWord new_val)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700161 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700162 uint32_t GetLockOwnerThreadId();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800163
Mathieu Chartiera704eda2016-07-13 09:53:35 -0700164 // Try to enter the monitor, returns non null if we succeeded.
165 mirror::Object* MonitorTryEnter(Thread* self)
166 EXCLUSIVE_LOCK_FUNCTION()
167 REQUIRES(!Roles::uninterruptible_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700168 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier2d096c92015-10-12 16:18:20 -0700169 mirror::Object* MonitorEnter(Thread* self)
170 EXCLUSIVE_LOCK_FUNCTION()
171 REQUIRES(!Roles::uninterruptible_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700172 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier2d096c92015-10-12 16:18:20 -0700173 bool MonitorExit(Thread* self)
174 REQUIRES(!Roles::uninterruptible_)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700175 REQUIRES_SHARED(Locks::mutator_lock_)
Ian Rogers719d1a32014-03-06 12:13:39 -0800176 UNLOCK_FUNCTION();
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700177 void Notify(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
178 void NotifyAll(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
179 void Wait(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
180 void Wait(Thread* self, int64_t timeout, int32_t nanos) REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800181
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700182 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
183 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700184 bool IsClass() REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700185 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
186 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700187 Class* AsClass() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800188
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800189 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
190 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700191 bool IsObjectArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800192 template<class T,
193 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
194 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700195 ObjectArray<T>* AsObjectArray() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800196
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800197 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
198 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700199 bool IsClassLoader() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800200 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
201 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700202 ClassLoader* AsClassLoader() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere4275c02015-08-06 15:34:15 -0700203
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800204 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
205 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700206 bool IsDexCache() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800207 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
208 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700209 DexCache* AsDexCache() REQUIRES_SHARED(Locks::mutator_lock_);
Vladimir Marko05792b92015-08-03 11:56:49 +0100210
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700211 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
212 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700213 bool IsArrayInstance() REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700214 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
215 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700216 Array* AsArray() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800217
Mathieu Chartier4e305412014-02-19 10:54:44 -0800218 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700219 BooleanArray* AsBooleanArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800220 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700221 ByteArray* AsByteArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800222 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700223 ByteArray* AsByteSizedArray() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800224
Mathieu Chartier4e305412014-02-19 10:54:44 -0800225 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700226 CharArray* AsCharArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800227 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700228 ShortArray* AsShortArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800229 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700230 ShortArray* AsShortSizedArray() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800231
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800232 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
233 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700234 bool IsIntArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800235 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
236 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700237 IntArray* AsIntArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700238
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800239 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
240 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700241 bool IsLongArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800242 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
243 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700244 LongArray* AsLongArray() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800245
Mathieu Chartier4e305412014-02-19 10:54:44 -0800246 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700247 bool IsFloatArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700248 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700249 FloatArray* AsFloatArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700250
251 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700252 bool IsDoubleArray() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800253 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700254 DoubleArray* AsDoubleArray() REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100255
Jeff Hao848f70a2014-01-15 13:49:50 -0800256 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
257 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700258 bool IsString() REQUIRES_SHARED(Locks::mutator_lock_);
Jeff Hao848f70a2014-01-15 13:49:50 -0800259
260 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
261 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700262 String* AsString() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800263
Mathieu Chartier4e305412014-02-19 10:54:44 -0800264 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700265 Throwable* AsThrowable() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800266
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800267 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
268 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700269 bool IsReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierdfe02f62016-02-01 20:15:11 -0800270 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
271 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700272 Reference* AsReference() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier8fa2dad2014-03-13 12:22:56 -0700273 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700274 bool IsWeakReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800275 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700276 bool IsSoftReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800277 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700278 bool IsFinalizerReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier4e305412014-02-19 10:54:44 -0800279 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700280 FinalizerReference* AsFinalizerReference() REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier8fa2dad2014-03-13 12:22:56 -0700281 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700282 bool IsPhantomReferenceInstance() REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800283
Ian Rogersef7d42f2014-01-06 12:55:46 -0800284 // Accessor for Java type fields.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700285 template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700286 ReadBarrierOption kReadBarrierOption = kWithReadBarrier, bool kIsVolatile = false>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700287 ALWAYS_INLINE T* GetFieldObject(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700288 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700289
290 template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
Hiroshi Yamauchi6e83c172014-05-01 21:25:41 -0700291 ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700292 ALWAYS_INLINE T* GetFieldObjectVolatile(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700293 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700294
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700295 template<bool kTransactionActive,
296 bool kCheckTransaction = true,
297 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
298 bool kIsVolatile = false>
299 ALWAYS_INLINE void SetFieldObjectWithoutWriteBarrier(MemberOffset field_offset,
300 ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700301 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700302
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700303 template<bool kTransactionActive,
304 bool kCheckTransaction = true,
305 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
306 bool kIsVolatile = false>
307 ALWAYS_INLINE void SetFieldObject(MemberOffset field_offset, ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700308 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700309
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700310 template<bool kTransactionActive,
311 bool kCheckTransaction = true,
312 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
313 ALWAYS_INLINE void SetFieldObjectVolatile(MemberOffset field_offset,
314 ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700315 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700316
Chang Xing6d3e7682017-07-11 10:31:29 -0700317 template<bool kCheckTransaction = true, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
318 bool kIsVolatile = false>
319 ALWAYS_INLINE void SetFieldObjectTransaction(MemberOffset field_offset, ObjPtr<Object> new_value)
320 REQUIRES_SHARED(Locks::mutator_lock_);
321
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700322 template<bool kTransactionActive,
323 bool kCheckTransaction = true,
324 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
325 bool CasFieldWeakSequentiallyConsistentObject(MemberOffset field_offset,
326 ObjPtr<Object> old_value,
327 ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700328 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700329 template<bool kTransactionActive,
330 bool kCheckTransaction = true,
331 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800332 bool CasFieldWeakSequentiallyConsistentObjectWithoutWriteBarrier(MemberOffset field_offset,
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700333 ObjPtr<Object> old_value,
334 ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700335 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700336 template<bool kTransactionActive,
337 bool kCheckTransaction = true,
338 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
339 bool CasFieldStrongSequentiallyConsistentObject(MemberOffset field_offset,
340 ObjPtr<Object> old_value,
341 ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700342 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700343 template<bool kTransactionActive,
344 bool kCheckTransaction = true,
345 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800346 bool CasFieldStrongSequentiallyConsistentObjectWithoutWriteBarrier(MemberOffset field_offset,
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700347 ObjPtr<Object> old_value,
348 ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700349 REQUIRES_SHARED(Locks::mutator_lock_);
Orion Hodson928033d2018-02-07 05:30:54 +0000350
351 template<bool kTransactionActive,
352 bool kCheckTransaction = true,
353 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
354 ObjPtr<Object> CompareAndExchangeFieldObject(MemberOffset field_offset,
355 ObjPtr<Object> old_value,
356 ObjPtr<Object> new_value)
357 REQUIRES_SHARED(Locks::mutator_lock_);
358
359 template<bool kTransactionActive,
360 bool kCheckTransaction = true,
361 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
362 ObjPtr<Object> ExchangeFieldObject(MemberOffset field_offset, ObjPtr<Object> new_value)
363 REQUIRES_SHARED(Locks::mutator_lock_);
364
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700365 template<bool kTransactionActive,
366 bool kCheckTransaction = true,
367 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Hiroshi Yamauchifed3e2f2015-10-20 11:11:56 -0700368 bool CasFieldWeakRelaxedObjectWithoutWriteBarrier(MemberOffset field_offset,
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700369 ObjPtr<Object> old_value,
370 ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700371 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700372 template<bool kTransactionActive,
373 bool kCheckTransaction = true,
374 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mathieu Chartierfdd513d2017-06-01 11:26:50 -0700375 bool CasFieldWeakReleaseObjectWithoutWriteBarrier(MemberOffset field_offset,
376 ObjPtr<Object> old_value,
377 ObjPtr<Object> new_value)
378 REQUIRES_SHARED(Locks::mutator_lock_);
379
380 template<bool kTransactionActive,
381 bool kCheckTransaction = true,
382 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Hiroshi Yamauchifed3e2f2015-10-20 11:11:56 -0700383 bool CasFieldStrongRelaxedObjectWithoutWriteBarrier(MemberOffset field_offset,
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700384 ObjPtr<Object> old_value,
385 ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700386 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierfdd513d2017-06-01 11:26:50 -0700387 template<bool kTransactionActive,
388 bool kCheckTransaction = true,
389 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
390 bool CasFieldStrongReleaseObjectWithoutWriteBarrier(MemberOffset field_offset,
391 ObjPtr<Object> old_value,
392 ObjPtr<Object> new_value)
393 REQUIRES_SHARED(Locks::mutator_lock_);
Hans Boehmd8434432014-07-11 09:56:07 -0700394
Mathieu Chartier4e305412014-02-19 10:54:44 -0800395 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
396 HeapReference<Object>* GetFieldObjectReferenceAddr(MemberOffset field_offset);
Mathieu Chartier11409ae2013-09-23 11:49:36 -0700397
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700398 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
Fred Shih37f05ef2014-07-16 18:38:08 -0700399 ALWAYS_INLINE uint8_t GetFieldBoolean(MemberOffset field_offset)
Andreas Gampe895f9222017-07-05 09:53:32 -0700400 REQUIRES_SHARED(Locks::mutator_lock_) {
401 if (kVerifyFlags & kVerifyThis) {
402 VerifyObject(this);
403 }
404 return GetField<uint8_t, kIsVolatile>(field_offset);
405 }
Fred Shih37f05ef2014-07-16 18:38:08 -0700406
407 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
408 ALWAYS_INLINE int8_t GetFieldByte(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700409 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700410
411 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
412 ALWAYS_INLINE uint8_t GetFieldBooleanVolatile(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700413 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700414
415 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
416 ALWAYS_INLINE int8_t GetFieldByteVolatile(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700417 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700418
419 template<bool kTransactionActive, bool kCheckTransaction = true,
420 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
421 ALWAYS_INLINE void SetFieldBoolean(MemberOffset field_offset, uint8_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700422 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700423
424 template<bool kTransactionActive, bool kCheckTransaction = true,
425 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
426 ALWAYS_INLINE void SetFieldByte(MemberOffset field_offset, int8_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700427 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700428
429 template<bool kTransactionActive, bool kCheckTransaction = true,
430 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
431 ALWAYS_INLINE void SetFieldBooleanVolatile(MemberOffset field_offset, uint8_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700432 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700433
434 template<bool kTransactionActive, bool kCheckTransaction = true,
435 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
436 ALWAYS_INLINE void SetFieldByteVolatile(MemberOffset field_offset, int8_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700437 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700438
439 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
440 ALWAYS_INLINE uint16_t GetFieldChar(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700441 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700442
443 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
444 ALWAYS_INLINE int16_t GetFieldShort(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700445 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700446
447 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
448 ALWAYS_INLINE uint16_t GetFieldCharVolatile(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700449 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700450
451 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
452 ALWAYS_INLINE int16_t GetFieldShortVolatile(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700453 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700454
455 template<bool kTransactionActive, bool kCheckTransaction = true,
456 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
457 ALWAYS_INLINE void SetFieldChar(MemberOffset field_offset, uint16_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700458 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700459
460 template<bool kTransactionActive, bool kCheckTransaction = true,
461 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
462 ALWAYS_INLINE void SetFieldShort(MemberOffset field_offset, int16_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700463 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700464
465 template<bool kTransactionActive, bool kCheckTransaction = true,
466 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
467 ALWAYS_INLINE void SetFieldCharVolatile(MemberOffset field_offset, uint16_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700468 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700469
470 template<bool kTransactionActive, bool kCheckTransaction = true,
471 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
472 ALWAYS_INLINE void SetFieldShortVolatile(MemberOffset field_offset, int16_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700473 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700474
475 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700476 ALWAYS_INLINE int32_t GetField32(MemberOffset field_offset)
Andreas Gampe90b936d2017-01-31 08:58:55 -0800477 REQUIRES_SHARED(Locks::mutator_lock_) {
478 if (kVerifyFlags & kVerifyThis) {
479 VerifyObject(this);
480 }
481 return GetField<int32_t, kIsVolatile>(field_offset);
482 }
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700483
Mathieu Chartier4e305412014-02-19 10:54:44 -0800484 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700485 ALWAYS_INLINE int32_t GetField32Volatile(MemberOffset field_offset)
Andreas Gampe90b936d2017-01-31 08:58:55 -0800486 REQUIRES_SHARED(Locks::mutator_lock_) {
487 return GetField32<kVerifyFlags, true>(field_offset);
488 }
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700489
490 template<bool kTransactionActive, bool kCheckTransaction = true,
491 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700492 ALWAYS_INLINE void SetField32(MemberOffset field_offset, int32_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700493 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700494
Mathieu Chartier4e305412014-02-19 10:54:44 -0800495 template<bool kTransactionActive, bool kCheckTransaction = true,
496 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700497 ALWAYS_INLINE void SetField32Volatile(MemberOffset field_offset, int32_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700498 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700499
Chang Xing6d3e7682017-07-11 10:31:29 -0700500 template<bool kCheckTransaction = true,
501 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
502 bool kIsVolatile = false>
503 ALWAYS_INLINE void SetField32Transaction(MemberOffset field_offset, int32_t new_value)
504 REQUIRES_SHARED(Locks::mutator_lock_);
505
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700506 template<bool kTransactionActive, bool kCheckTransaction = true,
507 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700508 ALWAYS_INLINE bool CasFieldWeakSequentiallyConsistent32(MemberOffset field_offset,
509 int32_t old_value, int32_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700510 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700511
Hans Boehmd8434432014-07-11 09:56:07 -0700512 template<bool kTransactionActive, bool kCheckTransaction = true,
513 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
514 bool CasFieldWeakRelaxed32(MemberOffset field_offset, int32_t old_value,
515 int32_t new_value) ALWAYS_INLINE
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700516 REQUIRES_SHARED(Locks::mutator_lock_);
Hans Boehmd8434432014-07-11 09:56:07 -0700517
518 template<bool kTransactionActive, bool kCheckTransaction = true,
519 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Hans Boehmb3da36c2016-12-15 13:12:59 -0800520 bool CasFieldWeakAcquire32(MemberOffset field_offset, int32_t old_value,
521 int32_t new_value) ALWAYS_INLINE
522 REQUIRES_SHARED(Locks::mutator_lock_);
523
524 template<bool kTransactionActive, bool kCheckTransaction = true,
525 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Hiroshi Yamauchifed3e2f2015-10-20 11:11:56 -0700526 bool CasFieldWeakRelease32(MemberOffset field_offset, int32_t old_value,
527 int32_t new_value) ALWAYS_INLINE
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700528 REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchifed3e2f2015-10-20 11:11:56 -0700529
530 template<bool kTransactionActive, bool kCheckTransaction = true,
531 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Hans Boehmd8434432014-07-11 09:56:07 -0700532 bool CasFieldStrongSequentiallyConsistent32(MemberOffset field_offset, int32_t old_value,
533 int32_t new_value) ALWAYS_INLINE
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700534 REQUIRES_SHARED(Locks::mutator_lock_);
Hans Boehmd8434432014-07-11 09:56:07 -0700535
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700536 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700537 ALWAYS_INLINE int64_t GetField64(MemberOffset field_offset)
Andreas Gampec6ea7d02017-02-01 16:46:28 -0800538 REQUIRES_SHARED(Locks::mutator_lock_) {
539 if (kVerifyFlags & kVerifyThis) {
540 VerifyObject(this);
541 }
542 return GetField<int64_t, kIsVolatile>(field_offset);
543 }
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700544
545 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700546 ALWAYS_INLINE int64_t GetField64Volatile(MemberOffset field_offset)
Andreas Gampec6ea7d02017-02-01 16:46:28 -0800547 REQUIRES_SHARED(Locks::mutator_lock_) {
548 return GetField64<kVerifyFlags, true>(field_offset);
549 }
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700550
551 template<bool kTransactionActive, bool kCheckTransaction = true,
552 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700553 ALWAYS_INLINE void SetField64(MemberOffset field_offset, int64_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700554 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700555
556 template<bool kTransactionActive, bool kCheckTransaction = true,
557 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700558 ALWAYS_INLINE void SetField64Volatile(MemberOffset field_offset, int64_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700559 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800560
Chang Xing6d3e7682017-07-11 10:31:29 -0700561 template<bool kCheckTransaction = true,
562 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
563 bool kIsVolatile = false>
564 ALWAYS_INLINE void SetField64Transaction(MemberOffset field_offset, int32_t new_value)
565 REQUIRES_SHARED(Locks::mutator_lock_);
566
Mathieu Chartier4e305412014-02-19 10:54:44 -0800567 template<bool kTransactionActive, bool kCheckTransaction = true,
568 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogers228602f2014-07-10 02:07:54 -0700569 bool CasFieldWeakSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value,
570 int64_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700571 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800572
Mathieu Chartier4e305412014-02-19 10:54:44 -0800573 template<bool kTransactionActive, bool kCheckTransaction = true,
Hans Boehmd8434432014-07-11 09:56:07 -0700574 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
575 bool CasFieldStrongSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value,
576 int64_t new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700577 REQUIRES_SHARED(Locks::mutator_lock_);
Hans Boehmd8434432014-07-11 09:56:07 -0700578
579 template<bool kTransactionActive, bool kCheckTransaction = true,
Mathieu Chartier4e305412014-02-19 10:54:44 -0800580 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700581 void SetFieldPtr(MemberOffset field_offset, T new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700582 REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartier2d721012014-11-10 11:08:06 -0800583 SetFieldPtrWithSize<kTransactionActive, kCheckTransaction, kVerifyFlags>(
Andreas Gampe542451c2016-07-26 09:02:02 -0700584 field_offset, new_value, kRuntimePointerSize);
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800585 }
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800586 template<bool kTransactionActive, bool kCheckTransaction = true,
587 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T>
588 void SetFieldPtr64(MemberOffset field_offset, T new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700589 REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800590 SetFieldPtrWithSize<kTransactionActive, kCheckTransaction, kVerifyFlags>(
591 field_offset, new_value, 8u);
592 }
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800593
Mathieu Chartier2d721012014-11-10 11:08:06 -0800594 template<bool kTransactionActive, bool kCheckTransaction = true,
595 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T>
Andreas Gampe542451c2016-07-26 09:02:02 -0700596 ALWAYS_INLINE void SetFieldPtrWithSize(MemberOffset field_offset,
597 T new_value,
598 PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700599 REQUIRES_SHARED(Locks::mutator_lock_) {
Andreas Gampe542451c2016-07-26 09:02:02 -0700600 if (pointer_size == PointerSize::k32) {
Colin Cross32f53882017-03-15 15:25:24 -0700601 uintptr_t ptr = reinterpret_cast<uintptr_t>(new_value);
602 DCHECK_EQ(static_cast<uint32_t>(ptr), ptr); // Check that we dont lose any non 0 bits.
Mathieu Chartier2d721012014-11-10 11:08:06 -0800603 SetField32<kTransactionActive, kCheckTransaction, kVerifyFlags>(
Colin Cross32f53882017-03-15 15:25:24 -0700604 field_offset, static_cast<int32_t>(static_cast<uint32_t>(ptr)));
Mathieu Chartier2d721012014-11-10 11:08:06 -0800605 } else {
606 SetField64<kTransactionActive, kCheckTransaction, kVerifyFlags>(
Vladimir Markodb8e62d2016-03-30 16:30:21 +0100607 field_offset, reinterpret_cast64<int64_t>(new_value));
Mathieu Chartier2d721012014-11-10 11:08:06 -0800608 }
609 }
Orion Hodson928033d2018-02-07 05:30:54 +0000610
611 // Base class for accessors used to describe accesses performed by VarHandle methods.
612 template <typename T>
613 class Accessor {
614 public:
615 virtual ~Accessor() {
616 static_assert(std::is_arithmetic<T>::value, "unsupported type");
617 }
618 virtual void Access(T* field_address) = 0;
619 };
620
621 // Getter method that exposes the raw address of a primitive value-type field to an Accessor
622 // instance. This are used by VarHandle accessor methods to read fields with a wider range of
623 // memory orderings than usually required.
624 template<typename T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
625 void GetPrimitiveFieldViaAccessor(MemberOffset field_offset, Accessor<T>* accessor)
626 REQUIRES_SHARED(Locks::mutator_lock_);
627
628 // Update methods that expose the raw address of a primitive value-type to an Accessor instance
629 // that will attempt to update the field. These are used by VarHandle accessor methods to
630 // atomically update fields with a wider range of memory orderings than usually required.
631 template<bool kTransactionActive, bool kCheckTransaction = true,
632 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
633 void UpdateFieldBooleanViaAccessor(MemberOffset field_offset, Accessor<uint8_t>* accessor)
634 REQUIRES_SHARED(Locks::mutator_lock_);
635 template<bool kTransactionActive, bool kCheckTransaction = true,
636 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
637 void UpdateFieldByteViaAccessor(MemberOffset field_offset, Accessor<int8_t>* accessor)
638 REQUIRES_SHARED(Locks::mutator_lock_);
639 template<bool kTransactionActive, bool kCheckTransaction = true,
640 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
641 void UpdateFieldCharViaAccessor(MemberOffset field_offset, Accessor<uint16_t>* accessor)
642 REQUIRES_SHARED(Locks::mutator_lock_);
643 template<bool kTransactionActive, bool kCheckTransaction = true,
644 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
645 void UpdateFieldShortViaAccessor(MemberOffset field_offset, Accessor<int16_t>* accessor)
646 REQUIRES_SHARED(Locks::mutator_lock_);
647 template<bool kTransactionActive, bool kCheckTransaction = true,
648 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
649 void UpdateField32ViaAccessor(MemberOffset field_offset, Accessor<int32_t>* accessor)
650 REQUIRES_SHARED(Locks::mutator_lock_);
651 template<bool kTransactionActive, bool kCheckTransaction = true,
652 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
653 void UpdateField64ViaAccessor(MemberOffset field_offset, Accessor<int64_t>* accessor)
654 REQUIRES_SHARED(Locks::mutator_lock_);
655
Mathieu Chartier407f7022014-02-18 14:37:05 -0800656 // TODO fix thread safety analysis broken by the use of template. This should be
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700657 // REQUIRES_SHARED(Locks::mutator_lock_).
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800658 template <bool kVisitNativeRoots = true,
659 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
660 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
Mathieu Chartier059ef3d2015-08-18 13:54:21 -0700661 typename Visitor,
662 typename JavaLangRefVisitor = VoidFunctor>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700663 void VisitReferences(const Visitor& visitor, const JavaLangRefVisitor& ref_visitor)
Mathieu Chartier407f7022014-02-18 14:37:05 -0800664 NO_THREAD_SAFETY_ANALYSIS;
665
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700666 ArtField* FindFieldByOffset(MemberOffset offset) REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchieb2baaf2015-05-13 21:14:22 -0700667
tony.ys_liu7380c312015-01-16 19:16:45 +0800668 // Used by object_test.
669 static void SetHashCodeSeed(uint32_t new_seed);
670 // Generate an identity hash code. Public for object test.
671 static uint32_t GenerateIdentityHashCode();
672
David Sehr709b0702016-10-13 09:12:37 -0700673 // Returns a human-readable form of the name of the *class* of the given object.
674 // So given an instance of java.lang.String, the output would
675 // be "java.lang.String". Given an array of int, the output would be "int[]".
676 // Given String.class, the output would be "java.lang.Class<java.lang.String>".
677 static std::string PrettyTypeOf(ObjPtr<mirror::Object> obj)
678 REQUIRES_SHARED(Locks::mutator_lock_);
679 std::string PrettyTypeOf()
680 REQUIRES_SHARED(Locks::mutator_lock_);
681
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800682 protected:
683 // Accessors for non-Java type fields
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700684 template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
685 T GetFieldPtr(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700686 REQUIRES_SHARED(Locks::mutator_lock_) {
Andreas Gampe542451c2016-07-26 09:02:02 -0700687 return GetFieldPtrWithSize<T, kVerifyFlags, kIsVolatile>(field_offset, kRuntimePointerSize);
Mathieu Chartier2d721012014-11-10 11:08:06 -0800688 }
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800689 template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
690 T GetFieldPtr64(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700691 REQUIRES_SHARED(Locks::mutator_lock_) {
Andreas Gampe542451c2016-07-26 09:02:02 -0700692 return GetFieldPtrWithSize<T, kVerifyFlags, kIsVolatile>(field_offset,
693 PointerSize::k64);
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800694 }
Mathieu Chartier2d721012014-11-10 11:08:06 -0800695
696 template<class T, VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
Andreas Gampe542451c2016-07-26 09:02:02 -0700697 ALWAYS_INLINE T GetFieldPtrWithSize(MemberOffset field_offset, PointerSize pointer_size)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700698 REQUIRES_SHARED(Locks::mutator_lock_) {
Andreas Gampe542451c2016-07-26 09:02:02 -0700699 if (pointer_size == PointerSize::k32) {
Colin Cross32f53882017-03-15 15:25:24 -0700700 uint64_t address = static_cast<uint32_t>(GetField32<kVerifyFlags, kIsVolatile>(field_offset));
701 return reinterpret_cast<T>(static_cast<uintptr_t>(address));
Mathieu Chartier2d721012014-11-10 11:08:06 -0800702 } else {
703 int64_t v = GetField64<kVerifyFlags, kIsVolatile>(field_offset);
Vladimir Markodb8e62d2016-03-30 16:30:21 +0100704 return reinterpret_cast64<T>(v);
Mathieu Chartier2d721012014-11-10 11:08:06 -0800705 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800706 }
707
Mathieu Chartier407f7022014-02-18 14:37:05 -0800708 // TODO: Fixme when anotatalysis works with visitors.
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800709 template<bool kIsStatic,
710 VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
711 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
712 typename Visitor>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700713 void VisitFieldsReferences(uint32_t ref_offsets, const Visitor& visitor) HOT_ATTR
Mathieu Chartier407f7022014-02-18 14:37:05 -0800714 NO_THREAD_SAFETY_ANALYSIS;
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800715 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
716 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
717 typename Visitor>
Mathieu Chartier31e88222016-10-14 18:43:19 -0700718 void VisitInstanceFieldsReferences(ObjPtr<mirror::Class> klass, const Visitor& visitor) HOT_ATTR
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700719 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800720 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags,
721 ReadBarrierOption kReadBarrierOption = kWithReadBarrier,
722 typename Visitor>
Mathieu Chartier31e88222016-10-14 18:43:19 -0700723 void VisitStaticFieldsReferences(ObjPtr<mirror::Class> klass, const Visitor& visitor) HOT_ATTR
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700724 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartier407f7022014-02-18 14:37:05 -0800725
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800726 private:
Fred Shih37f05ef2014-07-16 18:38:08 -0700727 template<typename kSize, bool kIsVolatile>
728 ALWAYS_INLINE void SetField(MemberOffset field_offset, kSize new_value)
Andreas Gampe90b936d2017-01-31 08:58:55 -0800729 REQUIRES_SHARED(Locks::mutator_lock_) {
730 uint8_t* raw_addr = reinterpret_cast<uint8_t*>(this) + field_offset.Int32Value();
731 kSize* addr = reinterpret_cast<kSize*>(raw_addr);
732 if (kIsVolatile) {
733 reinterpret_cast<Atomic<kSize>*>(addr)->StoreSequentiallyConsistent(new_value);
734 } else {
735 reinterpret_cast<Atomic<kSize>*>(addr)->StoreJavaData(new_value);
736 }
737 }
738
Fred Shih37f05ef2014-07-16 18:38:08 -0700739 template<typename kSize, bool kIsVolatile>
740 ALWAYS_INLINE kSize GetField(MemberOffset field_offset)
Andreas Gampe90b936d2017-01-31 08:58:55 -0800741 REQUIRES_SHARED(Locks::mutator_lock_) {
742 const uint8_t* raw_addr = reinterpret_cast<const uint8_t*>(this) + field_offset.Int32Value();
743 const kSize* addr = reinterpret_cast<const kSize*>(raw_addr);
744 if (kIsVolatile) {
745 return reinterpret_cast<const Atomic<kSize>*>(addr)->LoadSequentiallyConsistent();
746 } else {
747 return reinterpret_cast<const Atomic<kSize>*>(addr)->LoadJavaData();
748 }
749 }
750
Mathieu Chartierc381c362016-08-23 13:27:53 -0700751 // Get a field with acquire semantics.
752 template<typename kSize>
753 ALWAYS_INLINE kSize GetFieldAcquire(MemberOffset field_offset)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700754 REQUIRES_SHARED(Locks::mutator_lock_);
Fred Shih37f05ef2014-07-16 18:38:08 -0700755
Ian Rogers04d7aa92013-03-16 14:29:17 -0700756 // Verify the type correctness of stores to fields.
Mathieu Chartier61c5ebc2014-06-05 17:42:53 -0700757 // TODO: This can cause thread suspension and isn't moving GC safe.
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700758 void CheckFieldAssignmentImpl(MemberOffset field_offset, ObjPtr<Object> new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700759 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartiera058fdf2016-10-06 15:13:58 -0700760 void CheckFieldAssignment(MemberOffset field_offset, ObjPtr<Object>new_value)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700761 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers04d7aa92013-03-16 14:29:17 -0700762 if (kCheckFieldAssignments) {
763 CheckFieldAssignmentImpl(field_offset, new_value);
764 }
765 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800766
Mathieu Chartier51eaa7f2016-10-12 16:08:35 -0700767 // A utility function that copies an object in a read barrier and write barrier-aware way.
768 // This is internally used by Clone() and Class::CopyOf(). If the object is finalizable,
769 // it is the callers job to call Heap::AddFinalizerReference.
770 static Object* CopyObject(ObjPtr<mirror::Object> dest,
Mathieu Chartier9d156d52016-10-06 17:44:26 -0700771 ObjPtr<mirror::Object> src,
Hiroshi Yamauchi0fbd6e62014-07-17 16:16:31 -0700772 size_t num_bytes)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700773 REQUIRES_SHARED(Locks::mutator_lock_);
Hiroshi Yamauchi0fbd6e62014-07-17 16:16:31 -0700774
tony.ys_liu7380c312015-01-16 19:16:45 +0800775 static Atomic<uint32_t> hash_code_seed;
776
Ian Rogersef7d42f2014-01-06 12:55:46 -0800777 // The Class representing the type of the object.
778 HeapReference<Class> klass_;
779 // Monitor and hash code information.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800780 uint32_t monitor_;
781
Hiroshi Yamauchi60f63f52015-04-23 16:12:40 -0700782#ifdef USE_BROOKS_READ_BARRIER
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -0700783 // Note names use a 'x' prefix and the x_rb_ptr_ is of type int
Hiroshi Yamauchi9d04a202014-01-31 13:35:49 -0800784 // instead of Object to go with the alphabetical/by-type field order
785 // on the Java side.
Hiroshi Yamauchi60f63f52015-04-23 16:12:40 -0700786 uint32_t x_rb_ptr_; // For the Brooks pointer.
Hiroshi Yamauchi624468c2014-03-31 15:14:47 -0700787 uint32_t x_xpadding_; // For 8-byte alignment. TODO: get rid of this.
Hiroshi Yamauchi9d04a202014-01-31 13:35:49 -0800788#endif
789
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800790 friend class art::ImageWriter;
Mathieu Chartierad2541a2013-10-25 10:05:23 -0700791 friend class art::Monitor;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800792 friend struct art::ObjectOffsets; // for verifying offset information
Hiroshi Yamauchi0fbd6e62014-07-17 16:16:31 -0700793 friend class CopyObjectVisitor; // for CopyObject().
794 friend class CopyClassVisitor; // for CopyObject().
Ian Rogerscf7f1912014-10-22 22:06:39 -0700795 DISALLOW_ALLOCATION();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800796 DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
797};
798
799} // namespace mirror
800} // namespace art
801
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700802#endif // ART_RUNTIME_MIRROR_OBJECT_H_