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