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
17 #ifndef ART_RUNTIME_ASM_SUPPORT_H_
18 #define ART_RUNTIME_ASM_SUPPORT_H_
19
20 #if defined(__cplusplus)
21 #include "art_method.h"
22 #include "gc/allocator/rosalloc.h"
23 #include "jit/jit.h"
24 #include "lock_word.h"
25 #include "mirror/class.h"
26 #include "mirror/string.h"
27 #include "runtime.h"
28 #include "thread.h"
29 #endif
30
31 #include "read_barrier_c.h"
32
33 #if defined(__arm__) || defined(__mips__)
34 // In quick code for ARM and MIPS we make poor use of registers and perform frequent suspend
35 // checks in the event of loop back edges. The SUSPEND_CHECK_INTERVAL constant is loaded into a
36 // register at the point of an up-call or after handling a suspend check. It reduces the number of
37 // loads of the TLS suspend check value by the given amount (turning it into a decrement and compare
38 // of a register). This increases the time for a thread to respond to requests from GC and the
39 // debugger, damaging GC performance and creating other unwanted artifacts. For example, this count
40 // has the effect of making loops and Java code look cold in profilers, where the count is reset
41 // impacts where samples will occur. Reducing the count as much as possible improves profiler
42 // accuracy in tools like traceview.
43 // TODO: get a compiler that can do a proper job of loop optimization and remove this.
44 #define SUSPEND_CHECK_INTERVAL 96
45 #endif
46
47 #if defined(__cplusplus)
48
49 #ifndef ADD_TEST_EQ // Allow #include-r to replace with their own.
50 #define ADD_TEST_EQ(x, y) CHECK_EQ(x, y);
51 #endif
52
CheckAsmSupportOffsetsAndSizes()53 static inline void CheckAsmSupportOffsetsAndSizes() {
54 #else
55 #define ADD_TEST_EQ(x, y)
56 #endif
57
58 #if defined(__LP64__)
59 #define POINTER_SIZE_SHIFT 3
60 #else
61 #define POINTER_SIZE_SHIFT 2
62 #endif
63 ADD_TEST_EQ(static_cast<size_t>(1U << POINTER_SIZE_SHIFT),
64 static_cast<size_t>(__SIZEOF_POINTER__))
65
66 // Size of references to the heap on the stack.
67 #define STACK_REFERENCE_SIZE 4
68 ADD_TEST_EQ(static_cast<size_t>(STACK_REFERENCE_SIZE), sizeof(art::StackReference<art::mirror::Object>))
69
70 // Size of heap references
71 #define COMPRESSED_REFERENCE_SIZE 4
72 ADD_TEST_EQ(static_cast<size_t>(COMPRESSED_REFERENCE_SIZE),
73 sizeof(art::mirror::CompressedReference<art::mirror::Object>))
74
75 #define COMPRESSED_REFERENCE_SIZE_SHIFT 2
76 ADD_TEST_EQ(static_cast<size_t>(1U << COMPRESSED_REFERENCE_SIZE_SHIFT),
77 static_cast<size_t>(COMPRESSED_REFERENCE_SIZE))
78
79 // Note: these callee save methods loads require read barriers.
80 // Offset of field Runtime::callee_save_methods_[kSaveAll]
81 #define RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET 0
82 ADD_TEST_EQ(static_cast<size_t>(RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET),
83 art::Runtime::GetCalleeSaveMethodOffset(art::Runtime::kSaveAll))
84
85 // Offset of field Runtime::callee_save_methods_[kRefsOnly]
86 #define RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET 8
87 ADD_TEST_EQ(static_cast<size_t>(RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET),
88 art::Runtime::GetCalleeSaveMethodOffset(art::Runtime::kRefsOnly))
89
90 // Offset of field Runtime::callee_save_methods_[kRefsAndArgs]
91 #define RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET (2 * 8)
92 ADD_TEST_EQ(static_cast<size_t>(RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET),
93 art::Runtime::GetCalleeSaveMethodOffset(art::Runtime::kRefsAndArgs))
94
95 // Offset of field Thread::tls32_.state_and_flags.
96 #define THREAD_FLAGS_OFFSET 0
97 ADD_TEST_EQ(THREAD_FLAGS_OFFSET,
98 art::Thread::ThreadFlagsOffset<__SIZEOF_POINTER__>().Int32Value())
99
100 // Offset of field Thread::tls32_.thin_lock_thread_id.
101 #define THREAD_ID_OFFSET 12
102 ADD_TEST_EQ(THREAD_ID_OFFSET,
103 art::Thread::ThinLockIdOffset<__SIZEOF_POINTER__>().Int32Value())
104
105 // Offset of field Thread::tls32_.is_gc_marking.
106 #define THREAD_IS_GC_MARKING_OFFSET 52
107 ADD_TEST_EQ(THREAD_IS_GC_MARKING_OFFSET,
108 art::Thread::IsGcMarkingOffset<__SIZEOF_POINTER__>().Int32Value())
109
110 // Offset of field Thread::tlsPtr_.card_table.
111 #define THREAD_CARD_TABLE_OFFSET 128
112 ADD_TEST_EQ(THREAD_CARD_TABLE_OFFSET,
113 art::Thread::CardTableOffset<__SIZEOF_POINTER__>().Int32Value())
114
115 // Offset of field Thread::tlsPtr_.exception.
116 #define THREAD_EXCEPTION_OFFSET (THREAD_CARD_TABLE_OFFSET + __SIZEOF_POINTER__)
117 ADD_TEST_EQ(THREAD_EXCEPTION_OFFSET,
118 art::Thread::ExceptionOffset<__SIZEOF_POINTER__>().Int32Value())
119
120 // Offset of field Thread::tlsPtr_.managed_stack.top_quick_frame_.
121 #define THREAD_TOP_QUICK_FRAME_OFFSET (THREAD_CARD_TABLE_OFFSET + (3 * __SIZEOF_POINTER__))
122 ADD_TEST_EQ(THREAD_TOP_QUICK_FRAME_OFFSET,
123 art::Thread::TopOfManagedStackOffset<__SIZEOF_POINTER__>().Int32Value())
124
125 // Offset of field Thread::tlsPtr_.self.
126 #define THREAD_SELF_OFFSET (THREAD_CARD_TABLE_OFFSET + (9 * __SIZEOF_POINTER__))
127 ADD_TEST_EQ(THREAD_SELF_OFFSET,
128 art::Thread::SelfOffset<__SIZEOF_POINTER__>().Int32Value())
129
130 // Offset of field Thread::tlsPtr_.thread_local_objects.
131 #define THREAD_LOCAL_OBJECTS_OFFSET (THREAD_CARD_TABLE_OFFSET + 168 * __SIZEOF_POINTER__)
132 ADD_TEST_EQ(THREAD_LOCAL_OBJECTS_OFFSET,
133 art::Thread::ThreadLocalObjectsOffset<__SIZEOF_POINTER__>().Int32Value())
134 // Offset of field Thread::tlsPtr_.thread_local_pos.
135 #define THREAD_LOCAL_POS_OFFSET (THREAD_LOCAL_OBJECTS_OFFSET + 2 * __SIZEOF_POINTER__)
136 ADD_TEST_EQ(THREAD_LOCAL_POS_OFFSET,
137 art::Thread::ThreadLocalPosOffset<__SIZEOF_POINTER__>().Int32Value())
138 // Offset of field Thread::tlsPtr_.thread_local_end.
139 #define THREAD_LOCAL_END_OFFSET (THREAD_LOCAL_POS_OFFSET + __SIZEOF_POINTER__)
140 ADD_TEST_EQ(THREAD_LOCAL_END_OFFSET,
141 art::Thread::ThreadLocalEndOffset<__SIZEOF_POINTER__>().Int32Value())
142 // Offset of field Thread::tlsPtr_.mterp_current_ibase.
143 #define THREAD_CURRENT_IBASE_OFFSET (THREAD_LOCAL_POS_OFFSET + 2 * __SIZEOF_POINTER__)
144 ADD_TEST_EQ(THREAD_CURRENT_IBASE_OFFSET,
145 art::Thread::MterpCurrentIBaseOffset<__SIZEOF_POINTER__>().Int32Value())
146 // Offset of field Thread::tlsPtr_.mterp_default_ibase.
147 #define THREAD_DEFAULT_IBASE_OFFSET (THREAD_LOCAL_POS_OFFSET + 3 * __SIZEOF_POINTER__)
148 ADD_TEST_EQ(THREAD_DEFAULT_IBASE_OFFSET,
149 art::Thread::MterpDefaultIBaseOffset<__SIZEOF_POINTER__>().Int32Value())
150 // Offset of field Thread::tlsPtr_.mterp_alt_ibase.
151 #define THREAD_ALT_IBASE_OFFSET (THREAD_LOCAL_POS_OFFSET + 4 * __SIZEOF_POINTER__)
152 ADD_TEST_EQ(THREAD_ALT_IBASE_OFFSET,
153 art::Thread::MterpAltIBaseOffset<__SIZEOF_POINTER__>().Int32Value())
154 // Offset of field Thread::tlsPtr_.rosalloc_runs.
155 #define THREAD_ROSALLOC_RUNS_OFFSET (THREAD_LOCAL_POS_OFFSET + 5 * __SIZEOF_POINTER__)
156 ADD_TEST_EQ(THREAD_ROSALLOC_RUNS_OFFSET,
157 art::Thread::RosAllocRunsOffset<__SIZEOF_POINTER__>().Int32Value())
158 // Offset of field Thread::tlsPtr_.thread_local_alloc_stack_top.
159 #define THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET (THREAD_ROSALLOC_RUNS_OFFSET + 16 * __SIZEOF_POINTER__)
160 ADD_TEST_EQ(THREAD_LOCAL_ALLOC_STACK_TOP_OFFSET,
161 art::Thread::ThreadLocalAllocStackTopOffset<__SIZEOF_POINTER__>().Int32Value())
162 // Offset of field Thread::tlsPtr_.thread_local_alloc_stack_end.
163 #define THREAD_LOCAL_ALLOC_STACK_END_OFFSET (THREAD_ROSALLOC_RUNS_OFFSET + 17 * __SIZEOF_POINTER__)
164 ADD_TEST_EQ(THREAD_LOCAL_ALLOC_STACK_END_OFFSET,
165 art::Thread::ThreadLocalAllocStackEndOffset<__SIZEOF_POINTER__>().Int32Value())
166
167 // Offsets within ShadowFrame.
168 #define SHADOWFRAME_LINK_OFFSET 0
169 ADD_TEST_EQ(SHADOWFRAME_LINK_OFFSET,
170 static_cast<int32_t>(art::ShadowFrame::LinkOffset()))
171 #define SHADOWFRAME_METHOD_OFFSET (SHADOWFRAME_LINK_OFFSET + 1 * __SIZEOF_POINTER__)
172 ADD_TEST_EQ(SHADOWFRAME_METHOD_OFFSET,
173 static_cast<int32_t>(art::ShadowFrame::MethodOffset()))
174 #define SHADOWFRAME_RESULT_REGISTER_OFFSET (SHADOWFRAME_LINK_OFFSET + 2 * __SIZEOF_POINTER__)
175 ADD_TEST_EQ(SHADOWFRAME_RESULT_REGISTER_OFFSET,
176 static_cast<int32_t>(art::ShadowFrame::ResultRegisterOffset()))
177 #define SHADOWFRAME_DEX_PC_PTR_OFFSET (SHADOWFRAME_LINK_OFFSET + 3 * __SIZEOF_POINTER__)
178 ADD_TEST_EQ(SHADOWFRAME_DEX_PC_PTR_OFFSET,
179 static_cast<int32_t>(art::ShadowFrame::DexPCPtrOffset()))
180 #define SHADOWFRAME_CODE_ITEM_OFFSET (SHADOWFRAME_LINK_OFFSET + 4 * __SIZEOF_POINTER__)
181 ADD_TEST_EQ(SHADOWFRAME_CODE_ITEM_OFFSET,
182 static_cast<int32_t>(art::ShadowFrame::CodeItemOffset()))
183 #define SHADOWFRAME_LOCK_COUNT_DATA_OFFSET (SHADOWFRAME_LINK_OFFSET + 5 * __SIZEOF_POINTER__)
184 ADD_TEST_EQ(SHADOWFRAME_LOCK_COUNT_DATA_OFFSET,
185 static_cast<int32_t>(art::ShadowFrame::LockCountDataOffset()))
186 #define SHADOWFRAME_NUMBER_OF_VREGS_OFFSET (SHADOWFRAME_LINK_OFFSET + 6 * __SIZEOF_POINTER__)
187 ADD_TEST_EQ(SHADOWFRAME_NUMBER_OF_VREGS_OFFSET,
188 static_cast<int32_t>(art::ShadowFrame::NumberOfVRegsOffset()))
189 #define SHADOWFRAME_DEX_PC_OFFSET (SHADOWFRAME_NUMBER_OF_VREGS_OFFSET + 4)
190 ADD_TEST_EQ(SHADOWFRAME_DEX_PC_OFFSET,
191 static_cast<int32_t>(art::ShadowFrame::DexPCOffset()))
192 #define SHADOWFRAME_CACHED_HOTNESS_COUNTDOWN_OFFSET (SHADOWFRAME_NUMBER_OF_VREGS_OFFSET + 8)
193 ADD_TEST_EQ(SHADOWFRAME_CACHED_HOTNESS_COUNTDOWN_OFFSET,
194 static_cast<int32_t>(art::ShadowFrame::CachedHotnessCountdownOffset()))
195 #define SHADOWFRAME_HOTNESS_COUNTDOWN_OFFSET (SHADOWFRAME_NUMBER_OF_VREGS_OFFSET + 10)
196 ADD_TEST_EQ(SHADOWFRAME_HOTNESS_COUNTDOWN_OFFSET,
197 static_cast<int32_t>(art::ShadowFrame::HotnessCountdownOffset()))
198 #define SHADOWFRAME_VREGS_OFFSET (SHADOWFRAME_NUMBER_OF_VREGS_OFFSET + 12)
199 ADD_TEST_EQ(SHADOWFRAME_VREGS_OFFSET,
200 static_cast<int32_t>(art::ShadowFrame::VRegsOffset()))
201
202 // Offsets within CodeItem
203 #define CODEITEM_INSNS_OFFSET 16
204 ADD_TEST_EQ(CODEITEM_INSNS_OFFSET,
205 static_cast<int32_t>(OFFSETOF_MEMBER(art::DexFile::CodeItem, insns_)))
206
207 // Offsets within java.lang.Object.
208 #define MIRROR_OBJECT_CLASS_OFFSET 0
209 ADD_TEST_EQ(MIRROR_OBJECT_CLASS_OFFSET, art::mirror::Object::ClassOffset().Int32Value())
210 #define MIRROR_OBJECT_LOCK_WORD_OFFSET 4
211 ADD_TEST_EQ(MIRROR_OBJECT_LOCK_WORD_OFFSET, art::mirror::Object::MonitorOffset().Int32Value())
212
213 #if defined(USE_BROOKS_READ_BARRIER)
214 #define MIRROR_OBJECT_HEADER_SIZE 16
215 #else
216 #define MIRROR_OBJECT_HEADER_SIZE 8
217 #endif
218 ADD_TEST_EQ(size_t(MIRROR_OBJECT_HEADER_SIZE), sizeof(art::mirror::Object))
219
220 // Offsets within java.lang.Class.
221 #define MIRROR_CLASS_COMPONENT_TYPE_OFFSET (8 + MIRROR_OBJECT_HEADER_SIZE)
222 ADD_TEST_EQ(MIRROR_CLASS_COMPONENT_TYPE_OFFSET,
223 art::mirror::Class::ComponentTypeOffset().Int32Value())
224 #define MIRROR_CLASS_ACCESS_FLAGS_OFFSET (36 + MIRROR_OBJECT_HEADER_SIZE)
225 ADD_TEST_EQ(MIRROR_CLASS_ACCESS_FLAGS_OFFSET,
226 art::mirror::Class::AccessFlagsOffset().Int32Value())
227 #define MIRROR_CLASS_OBJECT_SIZE_OFFSET (100 + MIRROR_OBJECT_HEADER_SIZE)
228 ADD_TEST_EQ(MIRROR_CLASS_OBJECT_SIZE_OFFSET,
229 art::mirror::Class::ObjectSizeOffset().Int32Value())
230 #define MIRROR_CLASS_STATUS_OFFSET (112 + MIRROR_OBJECT_HEADER_SIZE)
231 ADD_TEST_EQ(MIRROR_CLASS_STATUS_OFFSET,
232 art::mirror::Class::StatusOffset().Int32Value())
233
234 #define MIRROR_CLASS_STATUS_INITIALIZED 10
235 ADD_TEST_EQ(static_cast<uint32_t>(MIRROR_CLASS_STATUS_INITIALIZED),
236 static_cast<uint32_t>(art::mirror::Class::kStatusInitialized))
237 #define ACCESS_FLAGS_CLASS_IS_FINALIZABLE 0x80000000
238 ADD_TEST_EQ(static_cast<uint32_t>(ACCESS_FLAGS_CLASS_IS_FINALIZABLE),
239 static_cast<uint32_t>(art::kAccClassIsFinalizable))
240 #define ACCESS_FLAGS_CLASS_IS_FINALIZABLE_BIT 31
241 ADD_TEST_EQ(static_cast<uint32_t>(ACCESS_FLAGS_CLASS_IS_FINALIZABLE),
242 static_cast<uint32_t>(1U << ACCESS_FLAGS_CLASS_IS_FINALIZABLE_BIT))
243
244 // Array offsets.
245 #define MIRROR_ARRAY_LENGTH_OFFSET MIRROR_OBJECT_HEADER_SIZE
246 ADD_TEST_EQ(MIRROR_ARRAY_LENGTH_OFFSET, art::mirror::Array::LengthOffset().Int32Value())
247
248 #define MIRROR_CHAR_ARRAY_DATA_OFFSET (4 + MIRROR_OBJECT_HEADER_SIZE)
249 ADD_TEST_EQ(MIRROR_CHAR_ARRAY_DATA_OFFSET,
250 art::mirror::Array::DataOffset(sizeof(uint16_t)).Int32Value())
251
252 #define MIRROR_BOOLEAN_ARRAY_DATA_OFFSET MIRROR_CHAR_ARRAY_DATA_OFFSET
253 ADD_TEST_EQ(MIRROR_BOOLEAN_ARRAY_DATA_OFFSET,
254 art::mirror::Array::DataOffset(sizeof(uint8_t)).Int32Value())
255
256 #define MIRROR_BYTE_ARRAY_DATA_OFFSET MIRROR_CHAR_ARRAY_DATA_OFFSET
257 ADD_TEST_EQ(MIRROR_BYTE_ARRAY_DATA_OFFSET,
258 art::mirror::Array::DataOffset(sizeof(int8_t)).Int32Value())
259
260 #define MIRROR_SHORT_ARRAY_DATA_OFFSET MIRROR_CHAR_ARRAY_DATA_OFFSET
261 ADD_TEST_EQ(MIRROR_SHORT_ARRAY_DATA_OFFSET,
262 art::mirror::Array::DataOffset(sizeof(int16_t)).Int32Value())
263
264 #define MIRROR_INT_ARRAY_DATA_OFFSET MIRROR_CHAR_ARRAY_DATA_OFFSET
265 ADD_TEST_EQ(MIRROR_INT_ARRAY_DATA_OFFSET,
266 art::mirror::Array::DataOffset(sizeof(int32_t)).Int32Value())
267
268 #define MIRROR_WIDE_ARRAY_DATA_OFFSET (8 + MIRROR_OBJECT_HEADER_SIZE)
269 ADD_TEST_EQ(MIRROR_WIDE_ARRAY_DATA_OFFSET,
270 art::mirror::Array::DataOffset(sizeof(uint64_t)).Int32Value())
271
272 #define MIRROR_OBJECT_ARRAY_DATA_OFFSET (4 + MIRROR_OBJECT_HEADER_SIZE)
273 ADD_TEST_EQ(MIRROR_OBJECT_ARRAY_DATA_OFFSET,
274 art::mirror::Array::DataOffset(
275 sizeof(art::mirror::HeapReference<art::mirror::Object>)).Int32Value())
276
277 #define MIRROR_OBJECT_ARRAY_COMPONENT_SIZE 4
278 ADD_TEST_EQ(static_cast<size_t>(MIRROR_OBJECT_ARRAY_COMPONENT_SIZE),
279 sizeof(art::mirror::HeapReference<art::mirror::Object>))
280
281 #define MIRROR_LONG_ARRAY_DATA_OFFSET (8 + MIRROR_OBJECT_HEADER_SIZE)
282 ADD_TEST_EQ(MIRROR_LONG_ARRAY_DATA_OFFSET,
283 art::mirror::Array::DataOffset(sizeof(uint64_t)).Int32Value())
284
285 // Offsets within java.lang.String.
286 #define MIRROR_STRING_COUNT_OFFSET MIRROR_OBJECT_HEADER_SIZE
287 ADD_TEST_EQ(MIRROR_STRING_COUNT_OFFSET, art::mirror::String::CountOffset().Int32Value())
288
289 #define MIRROR_STRING_VALUE_OFFSET (8 + MIRROR_OBJECT_HEADER_SIZE)
290 ADD_TEST_EQ(MIRROR_STRING_VALUE_OFFSET, art::mirror::String::ValueOffset().Int32Value())
291
292 // Offsets within java.lang.reflect.ArtMethod.
293 #define ART_METHOD_DEX_CACHE_METHODS_OFFSET_32 20
294 ADD_TEST_EQ(ART_METHOD_DEX_CACHE_METHODS_OFFSET_32,
295 art::ArtMethod::DexCacheResolvedMethodsOffset(4).Int32Value())
296
297 #define ART_METHOD_DEX_CACHE_METHODS_OFFSET_64 24
298 ADD_TEST_EQ(ART_METHOD_DEX_CACHE_METHODS_OFFSET_64,
299 art::ArtMethod::DexCacheResolvedMethodsOffset(8).Int32Value())
300
301 #define ART_METHOD_DEX_CACHE_TYPES_OFFSET_32 24
302 ADD_TEST_EQ(ART_METHOD_DEX_CACHE_TYPES_OFFSET_32,
303 art::ArtMethod::DexCacheResolvedTypesOffset(4).Int32Value())
304
305 #define ART_METHOD_DEX_CACHE_TYPES_OFFSET_64 32
306 ADD_TEST_EQ(ART_METHOD_DEX_CACHE_TYPES_OFFSET_64,
307 art::ArtMethod::DexCacheResolvedTypesOffset(8).Int32Value())
308
309 #define ART_METHOD_JNI_OFFSET_32 28
310 ADD_TEST_EQ(ART_METHOD_JNI_OFFSET_32,
311 art::ArtMethod::EntryPointFromJniOffset(4).Int32Value())
312
313 #define ART_METHOD_JNI_OFFSET_64 40
314 ADD_TEST_EQ(ART_METHOD_JNI_OFFSET_64,
315 art::ArtMethod::EntryPointFromJniOffset(8).Int32Value())
316
317 #define ART_METHOD_QUICK_CODE_OFFSET_32 32
318 ADD_TEST_EQ(ART_METHOD_QUICK_CODE_OFFSET_32,
319 art::ArtMethod::EntryPointFromQuickCompiledCodeOffset(4).Int32Value())
320
321 #define ART_METHOD_QUICK_CODE_OFFSET_64 48
322 ADD_TEST_EQ(ART_METHOD_QUICK_CODE_OFFSET_64,
323 art::ArtMethod::EntryPointFromQuickCompiledCodeOffset(8).Int32Value())
324
325 #define LOCK_WORD_STATE_SHIFT 30
326 ADD_TEST_EQ(LOCK_WORD_STATE_SHIFT, static_cast<int32_t>(art::LockWord::kStateShift))
327
328 #define LOCK_WORD_STATE_MASK 0xC0000000
329 ADD_TEST_EQ(LOCK_WORD_STATE_MASK, static_cast<uint32_t>(art::LockWord::kStateMaskShifted))
330
331 #define LOCK_WORD_READ_BARRIER_STATE_SHIFT 28
332 ADD_TEST_EQ(LOCK_WORD_READ_BARRIER_STATE_SHIFT,
333 static_cast<int32_t>(art::LockWord::kReadBarrierStateShift))
334
335 #define LOCK_WORD_READ_BARRIER_STATE_MASK 0x30000000
336 ADD_TEST_EQ(LOCK_WORD_READ_BARRIER_STATE_MASK,
337 static_cast<int32_t>(art::LockWord::kReadBarrierStateMaskShifted))
338
339 #define LOCK_WORD_READ_BARRIER_STATE_MASK_TOGGLED 0xCFFFFFFF
340 ADD_TEST_EQ(LOCK_WORD_READ_BARRIER_STATE_MASK_TOGGLED,
341 static_cast<uint32_t>(art::LockWord::kReadBarrierStateMaskShiftedToggled))
342
343 #define LOCK_WORD_THIN_LOCK_COUNT_ONE 65536
344 ADD_TEST_EQ(LOCK_WORD_THIN_LOCK_COUNT_ONE, static_cast<int32_t>(art::LockWord::kThinLockCountOne))
345
346 #define OBJECT_ALIGNMENT_MASK 7
347 ADD_TEST_EQ(static_cast<size_t>(OBJECT_ALIGNMENT_MASK), art::kObjectAlignment - 1)
348
349 #define OBJECT_ALIGNMENT_MASK_TOGGLED 0xFFFFFFF8
350 ADD_TEST_EQ(static_cast<uint32_t>(OBJECT_ALIGNMENT_MASK_TOGGLED),
351 ~static_cast<uint32_t>(art::kObjectAlignment - 1))
352
353 #define ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE 128
354 ADD_TEST_EQ(ROSALLOC_MAX_THREAD_LOCAL_BRACKET_SIZE,
355 static_cast<int32_t>(art::gc::allocator::RosAlloc::kMaxThreadLocalBracketSize))
356
357 #define ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT 3
358 ADD_TEST_EQ(ROSALLOC_BRACKET_QUANTUM_SIZE_SHIFT,
359 static_cast<int32_t>(art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSizeShift))
360
361 #define ROSALLOC_BRACKET_QUANTUM_SIZE_MASK 7
362 ADD_TEST_EQ(ROSALLOC_BRACKET_QUANTUM_SIZE_MASK,
363 static_cast<int32_t>(art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1))
364
365 #define ROSALLOC_BRACKET_QUANTUM_SIZE_MASK_TOGGLED32 0xfffffff8
366 ADD_TEST_EQ(static_cast<uint32_t>(ROSALLOC_BRACKET_QUANTUM_SIZE_MASK_TOGGLED32),
367 ~static_cast<uint32_t>(
368 art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1))
369
370 #define ROSALLOC_BRACKET_QUANTUM_SIZE_MASK_TOGGLED64 0xfffffffffffffff8
371 ADD_TEST_EQ(static_cast<uint64_t>(ROSALLOC_BRACKET_QUANTUM_SIZE_MASK_TOGGLED64),
372 ~static_cast<uint64_t>(
373 art::gc::allocator::RosAlloc::kThreadLocalBracketQuantumSize - 1))
374
375 #define ROSALLOC_RUN_FREE_LIST_OFFSET 8
376 ADD_TEST_EQ(ROSALLOC_RUN_FREE_LIST_OFFSET,
377 static_cast<int32_t>(art::gc::allocator::RosAlloc::RunFreeListOffset()))
378
379 #define ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET 0
380 ADD_TEST_EQ(ROSALLOC_RUN_FREE_LIST_HEAD_OFFSET,
381 static_cast<int32_t>(art::gc::allocator::RosAlloc::RunFreeListHeadOffset()))
382
383 #define ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET 16
384 ADD_TEST_EQ(ROSALLOC_RUN_FREE_LIST_SIZE_OFFSET,
385 static_cast<int32_t>(art::gc::allocator::RosAlloc::RunFreeListSizeOffset()))
386
387 #define ROSALLOC_SLOT_NEXT_OFFSET 0
388 ADD_TEST_EQ(ROSALLOC_SLOT_NEXT_OFFSET,
389 static_cast<int32_t>(art::gc::allocator::RosAlloc::RunSlotNextOffset()))
390 // Assert this so that we can avoid zeroing the next field by installing the class pointer.
391 ADD_TEST_EQ(ROSALLOC_SLOT_NEXT_OFFSET, MIRROR_OBJECT_CLASS_OFFSET)
392
393 #define THREAD_SUSPEND_REQUEST 1
394 ADD_TEST_EQ(THREAD_SUSPEND_REQUEST, static_cast<int32_t>(art::kSuspendRequest))
395
396 #define THREAD_CHECKPOINT_REQUEST 2
397 ADD_TEST_EQ(THREAD_CHECKPOINT_REQUEST, static_cast<int32_t>(art::kCheckpointRequest))
398
399 #define JIT_CHECK_OSR -1
400 ADD_TEST_EQ(JIT_CHECK_OSR, static_cast<int32_t>(art::jit::kJitCheckForOSR))
401
402 #define JIT_HOTNESS_DISABLE -2
403 ADD_TEST_EQ(JIT_HOTNESS_DISABLE, static_cast<int32_t>(art::jit::kJitHotnessDisabled))
404
405 #if defined(__cplusplus)
406 } // End of CheckAsmSupportOffsets.
407 #endif
408
409 #endif // ART_RUNTIME_ASM_SUPPORT_H_
410