Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_ART_METHOD_INL_H_ |
| 18 | #define ART_RUNTIME_ART_METHOD_INL_H_ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 19 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 20 | #include "art_method.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 21 | |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 22 | #include "art_field.h" |
Mathieu Chartier | 7c0fe5e | 2015-07-17 19:53:47 -0700 | [diff] [blame] | 23 | #include "base/logging.h" |
Hiroshi Yamauchi | 0037082 | 2015-08-18 14:47:25 -0700 | [diff] [blame^] | 24 | #include "class_linker-inl.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 25 | #include "dex_file.h" |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 26 | #include "dex_file-inl.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 27 | #include "gc_root-inl.h" |
| 28 | #include "mirror/class-inl.h" |
| 29 | #include "mirror/dex_cache.h" |
| 30 | #include "mirror/object-inl.h" |
| 31 | #include "mirror/object_array.h" |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 32 | #include "oat.h" |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 33 | #include "quick/quick_method_frame_info.h" |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 34 | #include "read_barrier-inl.h" |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 35 | #include "runtime-inl.h" |
Vladimir Marko | 80afd02 | 2015-05-19 18:08:00 +0100 | [diff] [blame] | 36 | #include "utils.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 37 | |
| 38 | namespace art { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 39 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 40 | inline mirror::Class* ArtMethod::GetDeclaringClassUnchecked() { |
Hiroshi Yamauchi | 3f64f25 | 2015-06-12 18:35:06 -0700 | [diff] [blame] | 41 | GcRootSource gc_root_source(this); |
| 42 | return declaring_class_.Read(&gc_root_source); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 45 | inline mirror::Class* ArtMethod::GetDeclaringClassNoBarrier() { |
| 46 | return declaring_class_.Read<kWithoutReadBarrier>(); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 49 | inline mirror::Class* ArtMethod::GetDeclaringClass() { |
| 50 | mirror::Class* result = GetDeclaringClassUnchecked(); |
| 51 | if (kIsDebugBuild) { |
| 52 | if (!IsRuntimeMethod()) { |
| 53 | CHECK(result != nullptr) << this; |
| 54 | CHECK(result->IsIdxLoaded() || result->IsErroneous()) |
| 55 | << result->GetStatus() << " " << PrettyClass(result); |
| 56 | } else { |
| 57 | CHECK(result == nullptr) << this; |
| 58 | } |
| 59 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 60 | return result; |
| 61 | } |
| 62 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 63 | inline void ArtMethod::SetDeclaringClass(mirror::Class* new_declaring_class) { |
| 64 | declaring_class_ = GcRoot<mirror::Class>(new_declaring_class); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Mathieu Chartier | 10e5ea9 | 2015-08-13 12:56:31 -0700 | [diff] [blame] | 67 | inline bool ArtMethod::CASDeclaringClass(mirror::Class* expected_class, |
| 68 | mirror::Class* desired_class) { |
| 69 | GcRoot<mirror::Class> expected_root(expected_class); |
| 70 | GcRoot<mirror::Class> desired_root(desired_class); |
| 71 | return reinterpret_cast<Atomic<GcRoot<mirror::Class>>*>(&declaring_class_)-> |
| 72 | CompareExchangeStrongSequentiallyConsistent( |
| 73 | expected_root, desired_root); |
| 74 | } |
| 75 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 76 | inline uint32_t ArtMethod::GetAccessFlags() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 77 | DCHECK(IsRuntimeMethod() || GetDeclaringClass()->IsIdxLoaded() || |
| 78 | GetDeclaringClass()->IsErroneous()); |
| 79 | return access_flags_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 80 | } |
| 81 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 82 | inline uint16_t ArtMethod::GetMethodIndex() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 83 | DCHECK(IsRuntimeMethod() || GetDeclaringClass()->IsResolved() || |
| 84 | GetDeclaringClass()->IsErroneous()); |
| 85 | return method_index_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 86 | } |
| 87 | |
Mathieu Chartier | 9f3629d | 2014-10-28 18:23:02 -0700 | [diff] [blame] | 88 | inline uint16_t ArtMethod::GetMethodIndexDuringLinking() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 89 | return method_index_; |
Mathieu Chartier | 9f3629d | 2014-10-28 18:23:02 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 92 | inline uint32_t ArtMethod::GetDexMethodIndex() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 93 | DCHECK(IsRuntimeMethod() || GetDeclaringClass()->IsIdxLoaded() || |
| 94 | GetDeclaringClass()->IsErroneous()); |
| 95 | return dex_method_index_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 96 | } |
| 97 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 98 | inline mirror::PointerArray* ArtMethod::GetDexCacheResolvedMethods() { |
Hiroshi Yamauchi | 3f64f25 | 2015-06-12 18:35:06 -0700 | [diff] [blame] | 99 | GcRootSource gc_root_source(this); |
| 100 | return dex_cache_resolved_methods_.Read(&gc_root_source); |
Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 103 | inline ArtMethod* ArtMethod::GetDexCacheResolvedMethod(uint16_t method_index, size_t ptr_size) { |
| 104 | auto* method = GetDexCacheResolvedMethods()->GetElementPtrSize<ArtMethod*>( |
| 105 | method_index, ptr_size); |
| 106 | if (LIKELY(method != nullptr)) { |
| 107 | auto* declaring_class = method->GetDeclaringClass(); |
| 108 | if (LIKELY(declaring_class == nullptr || !declaring_class->IsErroneous())) { |
| 109 | return method; |
| 110 | } |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 111 | } |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 112 | return nullptr; |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 115 | inline void ArtMethod::SetDexCacheResolvedMethod(uint16_t method_idx, ArtMethod* new_method, |
| 116 | size_t ptr_size) { |
| 117 | DCHECK(new_method == nullptr || new_method->GetDeclaringClass() != nullptr); |
| 118 | GetDexCacheResolvedMethods()->SetElementPtrSize(method_idx, new_method, ptr_size); |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | inline bool ArtMethod::HasDexCacheResolvedMethods() { |
| 122 | return GetDexCacheResolvedMethods() != nullptr; |
| 123 | } |
| 124 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 125 | inline bool ArtMethod::HasSameDexCacheResolvedMethods(mirror::PointerArray* other_cache) { |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 126 | return GetDexCacheResolvedMethods() == other_cache; |
| 127 | } |
| 128 | |
| 129 | inline bool ArtMethod::HasSameDexCacheResolvedMethods(ArtMethod* other) { |
| 130 | return GetDexCacheResolvedMethods() == other->GetDexCacheResolvedMethods(); |
| 131 | } |
| 132 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 133 | inline mirror::ObjectArray<mirror::Class>* ArtMethod::GetDexCacheResolvedTypes() { |
Hiroshi Yamauchi | 3f64f25 | 2015-06-12 18:35:06 -0700 | [diff] [blame] | 134 | GcRootSource gc_root_source(this); |
| 135 | return dex_cache_resolved_types_.Read(&gc_root_source); |
Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 138 | template <bool kWithCheck> |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 139 | inline mirror::Class* ArtMethod::GetDexCacheResolvedType(uint32_t type_index) { |
| 140 | mirror::Class* klass = kWithCheck ? |
| 141 | GetDexCacheResolvedTypes()->Get(type_index) : |
| 142 | GetDexCacheResolvedTypes()->GetWithoutChecks(type_index); |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 143 | return (klass != nullptr && !klass->IsErroneous()) ? klass : nullptr; |
| 144 | } |
| 145 | |
| 146 | inline bool ArtMethod::HasDexCacheResolvedTypes() { |
| 147 | return GetDexCacheResolvedTypes() != nullptr; |
| 148 | } |
| 149 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 150 | inline bool ArtMethod::HasSameDexCacheResolvedTypes( |
| 151 | mirror::ObjectArray<mirror::Class>* other_cache) { |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 152 | return GetDexCacheResolvedTypes() == other_cache; |
| 153 | } |
| 154 | |
| 155 | inline bool ArtMethod::HasSameDexCacheResolvedTypes(ArtMethod* other) { |
| 156 | return GetDexCacheResolvedTypes() == other->GetDexCacheResolvedTypes(); |
| 157 | } |
| 158 | |
Ian Rogers | a048560 | 2014-12-02 15:48:04 -0800 | [diff] [blame] | 159 | inline mirror::Class* ArtMethod::GetClassFromTypeIndex(uint16_t type_idx, bool resolve) { |
| 160 | mirror::Class* type = GetDexCacheResolvedType(type_idx); |
| 161 | if (type == nullptr && resolve) { |
| 162 | type = Runtime::Current()->GetClassLinker()->ResolveType(type_idx, this); |
| 163 | CHECK(type != nullptr || Thread::Current()->IsExceptionPending()); |
| 164 | } |
| 165 | return type; |
| 166 | } |
| 167 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 168 | inline uint32_t ArtMethod::GetCodeSize() { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 169 | DCHECK(!IsRuntimeMethod() && !IsProxyMethod()) << PrettyMethod(this); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 170 | return GetCodeSize(EntryPointToCodePointer(GetEntryPointFromQuickCompiledCode())); |
| 171 | } |
| 172 | |
| 173 | inline uint32_t ArtMethod::GetCodeSize(const void* code) { |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 174 | if (code == nullptr) { |
| 175 | return 0u; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 176 | } |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 177 | return reinterpret_cast<const OatQuickMethodHeader*>(code)[-1].code_size_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 178 | } |
| 179 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 180 | inline bool ArtMethod::CheckIncompatibleClassChange(InvokeType type) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 181 | switch (type) { |
| 182 | case kStatic: |
| 183 | return !IsStatic(); |
| 184 | case kDirect: |
| 185 | return !IsDirect() || IsStatic(); |
| 186 | case kVirtual: { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 187 | mirror::Class* methods_class = GetDeclaringClass(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 188 | return IsDirect() || (methods_class->IsInterface() && !IsMiranda()); |
| 189 | } |
| 190 | case kSuper: |
Andreas Gampe | 8f252e6 | 2014-08-25 20:46:31 -0700 | [diff] [blame] | 191 | // Constructors and static methods are called with invoke-direct. |
| 192 | // Interface methods cannot be invoked with invoke-super. |
| 193 | return IsConstructor() || IsStatic() || GetDeclaringClass()->IsInterface(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 194 | case kInterface: { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 195 | mirror::Class* methods_class = GetDeclaringClass(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 196 | return IsDirect() || !(methods_class->IsInterface() || methods_class->IsObjectClass()); |
| 197 | } |
| 198 | default: |
| 199 | LOG(FATAL) << "Unreachable - invocation type: " << type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 200 | UNREACHABLE(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 204 | inline uint32_t ArtMethod::GetQuickOatCodeOffset() { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 205 | DCHECK(!Runtime::Current()->IsStarted()); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 206 | return PointerToLowMemUInt32(GetEntryPointFromQuickCompiledCode()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 207 | } |
| 208 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 209 | inline void ArtMethod::SetQuickOatCodeOffset(uint32_t code_offset) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 210 | DCHECK(!Runtime::Current()->IsStarted()); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 211 | SetEntryPointFromQuickCompiledCode(reinterpret_cast<void*>(code_offset)); |
| 212 | } |
| 213 | |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 214 | inline const uint8_t* ArtMethod::GetMappingTable(size_t pointer_size) { |
| 215 | const void* code_pointer = GetQuickOatCodePointer(pointer_size); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 216 | if (code_pointer == nullptr) { |
| 217 | return nullptr; |
| 218 | } |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 219 | return GetMappingTable(code_pointer, pointer_size); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 220 | } |
| 221 | |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 222 | inline const uint8_t* ArtMethod::GetMappingTable(const void* code_pointer, size_t pointer_size) { |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 223 | DCHECK(code_pointer != nullptr); |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 224 | DCHECK_EQ(code_pointer, GetQuickOatCodePointer(pointer_size)); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 225 | uint32_t offset = |
| 226 | reinterpret_cast<const OatQuickMethodHeader*>(code_pointer)[-1].mapping_table_offset_; |
| 227 | if (UNLIKELY(offset == 0u)) { |
| 228 | return nullptr; |
| 229 | } |
| 230 | return reinterpret_cast<const uint8_t*>(code_pointer) - offset; |
| 231 | } |
| 232 | |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 233 | inline const uint8_t* ArtMethod::GetVmapTable(size_t pointer_size) { |
| 234 | const void* code_pointer = GetQuickOatCodePointer(pointer_size); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 235 | if (code_pointer == nullptr) { |
| 236 | return nullptr; |
| 237 | } |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 238 | return GetVmapTable(code_pointer, pointer_size); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 239 | } |
| 240 | |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 241 | inline const uint8_t* ArtMethod::GetVmapTable(const void* code_pointer, size_t pointer_size) { |
| 242 | CHECK(!IsOptimized(pointer_size)) << "Unimplemented vmap table for optimized compiler"; |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 243 | DCHECK(code_pointer != nullptr); |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 244 | DCHECK_EQ(code_pointer, GetQuickOatCodePointer(pointer_size)); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 245 | uint32_t offset = |
| 246 | reinterpret_cast<const OatQuickMethodHeader*>(code_pointer)[-1].vmap_table_offset_; |
| 247 | if (UNLIKELY(offset == 0u)) { |
| 248 | return nullptr; |
| 249 | } |
| 250 | return reinterpret_cast<const uint8_t*>(code_pointer) - offset; |
| 251 | } |
| 252 | |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 253 | inline CodeInfo ArtMethod::GetOptimizedCodeInfo() { |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 254 | DCHECK(IsOptimized(sizeof(void*))); |
| 255 | const void* code_pointer = GetQuickOatCodePointer(sizeof(void*)); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 256 | DCHECK(code_pointer != nullptr); |
| 257 | uint32_t offset = |
| 258 | reinterpret_cast<const OatQuickMethodHeader*>(code_pointer)[-1].vmap_table_offset_; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 259 | const void* data = |
| 260 | reinterpret_cast<const void*>(reinterpret_cast<const uint8_t*>(code_pointer) - offset); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 261 | return CodeInfo(data); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 262 | } |
| 263 | |
Mathieu Chartier | 957ca1c | 2014-11-21 16:51:29 -0800 | [diff] [blame] | 264 | inline const uint8_t* ArtMethod::GetNativeGcMap(size_t pointer_size) { |
| 265 | const void* code_pointer = GetQuickOatCodePointer(pointer_size); |
| 266 | if (code_pointer == nullptr) { |
| 267 | return nullptr; |
| 268 | } |
| 269 | return GetNativeGcMap(code_pointer, pointer_size); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 270 | } |
| 271 | |
Mathieu Chartier | 957ca1c | 2014-11-21 16:51:29 -0800 | [diff] [blame] | 272 | inline const uint8_t* ArtMethod::GetNativeGcMap(const void* code_pointer, size_t pointer_size) { |
| 273 | DCHECK(code_pointer != nullptr); |
| 274 | DCHECK_EQ(code_pointer, GetQuickOatCodePointer(pointer_size)); |
| 275 | uint32_t offset = |
| 276 | reinterpret_cast<const OatQuickMethodHeader*>(code_pointer)[-1].gc_map_offset_; |
| 277 | if (UNLIKELY(offset == 0u)) { |
| 278 | return nullptr; |
| 279 | } |
| 280 | return reinterpret_cast<const uint8_t*>(code_pointer) - offset; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 281 | } |
| 282 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 283 | inline bool ArtMethod::IsRuntimeMethod() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 284 | return dex_method_index_ == DexFile::kDexNoIndex; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 285 | } |
| 286 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 287 | inline bool ArtMethod::IsCalleeSaveMethod() { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 288 | if (!IsRuntimeMethod()) { |
| 289 | return false; |
| 290 | } |
| 291 | Runtime* runtime = Runtime::Current(); |
| 292 | bool result = false; |
| 293 | for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) { |
| 294 | if (this == runtime->GetCalleeSaveMethod(Runtime::CalleeSaveType(i))) { |
| 295 | result = true; |
| 296 | break; |
| 297 | } |
| 298 | } |
| 299 | return result; |
| 300 | } |
| 301 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 302 | inline bool ArtMethod::IsResolutionMethod() { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 303 | bool result = this == Runtime::Current()->GetResolutionMethod(); |
| 304 | // Check that if we do think it is phony it looks like the resolution method. |
| 305 | DCHECK(!result || IsRuntimeMethod()); |
| 306 | return result; |
| 307 | } |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 308 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 309 | inline bool ArtMethod::IsImtConflictMethod() { |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 310 | bool result = this == Runtime::Current()->GetImtConflictMethod(); |
| 311 | // Check that if we do think it is phony it looks like the imt conflict method. |
| 312 | DCHECK(!result || IsRuntimeMethod()); |
| 313 | return result; |
| 314 | } |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 315 | |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 316 | inline bool ArtMethod::IsImtUnimplementedMethod() { |
| 317 | bool result = this == Runtime::Current()->GetImtUnimplementedMethod(); |
| 318 | // Check that if we do think it is phony it looks like the imt unimplemented method. |
| 319 | DCHECK(!result || IsRuntimeMethod()); |
| 320 | return result; |
| 321 | } |
| 322 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 323 | inline uintptr_t ArtMethod::NativeQuickPcOffset(const uintptr_t pc) { |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 324 | const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor( |
| 325 | this, sizeof(void*)); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 326 | return pc - reinterpret_cast<uintptr_t>(code); |
| 327 | } |
| 328 | |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 329 | inline QuickMethodFrameInfo ArtMethod::GetQuickFrameInfo(const void* code_pointer) { |
| 330 | DCHECK(code_pointer != nullptr); |
Mathieu Chartier | 7c0fe5e | 2015-07-17 19:53:47 -0700 | [diff] [blame] | 331 | if (kIsDebugBuild && !IsProxyMethod()) { |
| 332 | CHECK_EQ(code_pointer, GetQuickOatCodePointer(sizeof(void*))); |
| 333 | } |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 334 | return reinterpret_cast<const OatQuickMethodHeader*>(code_pointer)[-1].frame_info_; |
| 335 | } |
| 336 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 337 | inline const DexFile* ArtMethod::GetDexFile() { |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 338 | return GetDexCache()->GetDexFile(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | inline const char* ArtMethod::GetDeclaringClassDescriptor() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 342 | uint32_t dex_method_idx = GetDexMethodIndex(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 343 | if (UNLIKELY(dex_method_idx == DexFile::kDexNoIndex)) { |
| 344 | return "<runtime method>"; |
| 345 | } |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 346 | DCHECK(!IsProxyMethod()); |
| 347 | const DexFile* dex_file = GetDexFile(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 348 | return dex_file->GetMethodDeclaringClassDescriptor(dex_file->GetMethodId(dex_method_idx)); |
| 349 | } |
| 350 | |
| 351 | inline const char* ArtMethod::GetShorty(uint32_t* out_length) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 352 | DCHECK(!IsProxyMethod()); |
| 353 | const DexFile* dex_file = GetDexFile(); |
| 354 | return dex_file->GetMethodShorty(dex_file->GetMethodId(GetDexMethodIndex()), out_length); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | inline const Signature ArtMethod::GetSignature() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 358 | uint32_t dex_method_idx = GetDexMethodIndex(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 359 | if (dex_method_idx != DexFile::kDexNoIndex) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 360 | DCHECK(!IsProxyMethod()); |
| 361 | const DexFile* dex_file = GetDexFile(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 362 | return dex_file->GetMethodSignature(dex_file->GetMethodId(dex_method_idx)); |
| 363 | } |
| 364 | return Signature::NoSignature(); |
| 365 | } |
| 366 | |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 367 | inline const char* ArtMethod::GetName() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 368 | uint32_t dex_method_idx = GetDexMethodIndex(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 369 | if (LIKELY(dex_method_idx != DexFile::kDexNoIndex)) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 370 | DCHECK(!IsProxyMethod()); |
| 371 | const DexFile* dex_file = GetDexFile(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 372 | return dex_file->GetMethodName(dex_file->GetMethodId(dex_method_idx)); |
| 373 | } |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 374 | Runtime* const runtime = Runtime::Current(); |
| 375 | if (this == runtime->GetResolutionMethod()) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 376 | return "<runtime internal resolution method>"; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 377 | } else if (this == runtime->GetImtConflictMethod()) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 378 | return "<runtime internal imt conflict method>"; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 379 | } else if (this == runtime->GetCalleeSaveMethod(Runtime::kSaveAll)) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 380 | return "<runtime internal callee-save all registers method>"; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 381 | } else if (this == runtime->GetCalleeSaveMethod(Runtime::kRefsOnly)) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 382 | return "<runtime internal callee-save reference registers method>"; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 383 | } else if (this == runtime->GetCalleeSaveMethod(Runtime::kRefsAndArgs)) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 384 | return "<runtime internal callee-save reference and argument registers method>"; |
| 385 | } else { |
| 386 | return "<unknown runtime internal method>"; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | inline const DexFile::CodeItem* ArtMethod::GetCodeItem() { |
Mathieu Chartier | 12b3dd7 | 2014-12-11 13:25:33 -0800 | [diff] [blame] | 391 | return GetDeclaringClass()->GetDexFile().GetCodeItem(GetCodeItemOffset()); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | inline bool ArtMethod::IsResolvedTypeIdx(uint16_t type_idx) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 395 | DCHECK(!IsProxyMethod()); |
| 396 | return GetDexCacheResolvedType(type_idx) != nullptr; |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | inline int32_t ArtMethod::GetLineNumFromDexPC(uint32_t dex_pc) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 400 | DCHECK(!IsProxyMethod()); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 401 | if (dex_pc == DexFile::kDexNoIndex) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 402 | return IsNative() ? -2 : -1; |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 403 | } |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 404 | return GetDexFile()->GetLineNumFromPC(this, dex_pc); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | inline const DexFile::ProtoId& ArtMethod::GetPrototype() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 408 | DCHECK(!IsProxyMethod()); |
| 409 | const DexFile* dex_file = GetDexFile(); |
| 410 | return dex_file->GetMethodPrototype(dex_file->GetMethodId(GetDexMethodIndex())); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | inline const DexFile::TypeList* ArtMethod::GetParameterTypeList() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 414 | DCHECK(!IsProxyMethod()); |
| 415 | const DexFile* dex_file = GetDexFile(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 416 | const DexFile::ProtoId& proto = dex_file->GetMethodPrototype( |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 417 | dex_file->GetMethodId(GetDexMethodIndex())); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 418 | return dex_file->GetProtoParameters(proto); |
| 419 | } |
| 420 | |
| 421 | inline const char* ArtMethod::GetDeclaringClassSourceFile() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 422 | DCHECK(!IsProxyMethod()); |
| 423 | return GetDeclaringClass()->GetSourceFile(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | inline uint16_t ArtMethod::GetClassDefIndex() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 427 | DCHECK(!IsProxyMethod()); |
| 428 | return GetDeclaringClass()->GetDexClassDefIndex(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | inline const DexFile::ClassDef& ArtMethod::GetClassDef() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 432 | DCHECK(!IsProxyMethod()); |
| 433 | return GetDexFile()->GetClassDef(GetClassDefIndex()); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | inline const char* ArtMethod::GetReturnTypeDescriptor() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 437 | DCHECK(!IsProxyMethod()); |
| 438 | const DexFile* dex_file = GetDexFile(); |
| 439 | const DexFile::MethodId& method_id = dex_file->GetMethodId(GetDexMethodIndex()); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 440 | const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id); |
| 441 | uint16_t return_type_idx = proto_id.return_type_idx_; |
| 442 | return dex_file->GetTypeDescriptor(dex_file->GetTypeId(return_type_idx)); |
| 443 | } |
| 444 | |
| 445 | inline const char* ArtMethod::GetTypeDescriptorFromTypeIdx(uint16_t type_idx) { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 446 | DCHECK(!IsProxyMethod()); |
| 447 | const DexFile* dex_file = GetDexFile(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 448 | return dex_file->GetTypeDescriptor(dex_file->GetTypeId(type_idx)); |
| 449 | } |
| 450 | |
| 451 | inline mirror::ClassLoader* ArtMethod::GetClassLoader() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 452 | DCHECK(!IsProxyMethod()); |
| 453 | return GetDeclaringClass()->GetClassLoader(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | inline mirror::DexCache* ArtMethod::GetDexCache() { |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 457 | DCHECK(!IsProxyMethod()); |
| 458 | return GetDeclaringClass()->GetDexCache(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 459 | } |
| 460 | |
Ian Rogers | 03b6eaf | 2014-10-28 09:34:57 -0700 | [diff] [blame] | 461 | inline bool ArtMethod::IsProxyMethod() { |
| 462 | return GetDeclaringClass()->IsProxyClass(); |
| 463 | } |
| 464 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 465 | inline ArtMethod* ArtMethod::GetInterfaceMethodIfProxy(size_t pointer_size) { |
Ian Rogers | 03b6eaf | 2014-10-28 09:34:57 -0700 | [diff] [blame] | 466 | if (LIKELY(!IsProxyMethod())) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 467 | return this; |
| 468 | } |
Ian Rogers | 03b6eaf | 2014-10-28 09:34:57 -0700 | [diff] [blame] | 469 | mirror::Class* klass = GetDeclaringClass(); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 470 | auto interface_method = GetDexCacheResolvedMethods()->GetElementPtrSize<ArtMethod*>( |
| 471 | GetDexMethodIndex(), pointer_size); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 472 | DCHECK(interface_method != nullptr); |
| 473 | DCHECK_EQ(interface_method, |
| 474 | Runtime::Current()->GetClassLinker()->FindMethodForProxy(klass, this)); |
| 475 | return interface_method; |
| 476 | } |
| 477 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 478 | inline void ArtMethod::SetDexCacheResolvedMethods(mirror::PointerArray* new_dex_cache_methods) { |
| 479 | dex_cache_resolved_methods_ = GcRoot<mirror::PointerArray>(new_dex_cache_methods); |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 480 | } |
| 481 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 482 | inline void ArtMethod::SetDexCacheResolvedTypes( |
| 483 | mirror::ObjectArray<mirror::Class>* new_dex_cache_types) { |
| 484 | dex_cache_resolved_types_ = GcRoot<mirror::ObjectArray<mirror::Class>>(new_dex_cache_types); |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 485 | } |
| 486 | |
Ian Rogers | ded66a0 | 2014-10-28 18:12:55 -0700 | [diff] [blame] | 487 | inline mirror::Class* ArtMethod::GetReturnType(bool resolve) { |
| 488 | DCHECK(!IsProxyMethod()); |
| 489 | const DexFile* dex_file = GetDexFile(); |
| 490 | const DexFile::MethodId& method_id = dex_file->GetMethodId(GetDexMethodIndex()); |
| 491 | const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id); |
| 492 | uint16_t return_type_idx = proto_id.return_type_idx_; |
| 493 | mirror::Class* type = GetDexCacheResolvedType(return_type_idx); |
| 494 | if (type == nullptr && resolve) { |
| 495 | type = Runtime::Current()->GetClassLinker()->ResolveType(return_type_idx, this); |
| 496 | CHECK(type != nullptr || Thread::Current()->IsExceptionPending()); |
| 497 | } |
| 498 | return type; |
| 499 | } |
| 500 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 501 | template<typename RootVisitorType> |
| 502 | void ArtMethod::VisitRoots(RootVisitorType& visitor) { |
Mathieu Chartier | e3b034a | 2015-05-31 14:29:23 -0700 | [diff] [blame] | 503 | visitor.VisitRootIfNonNull(declaring_class_.AddressWithoutBarrier()); |
| 504 | visitor.VisitRootIfNonNull(dex_cache_resolved_methods_.AddressWithoutBarrier()); |
| 505 | visitor.VisitRootIfNonNull(dex_cache_resolved_types_.AddressWithoutBarrier()); |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 506 | } |
| 507 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 508 | inline void ArtMethod::CopyFrom(const ArtMethod* src, size_t image_pointer_size) { |
| 509 | memcpy(reinterpret_cast<void*>(this), reinterpret_cast<const void*>(src), |
Vladimir Marko | 1463285 | 2015-08-17 12:07:23 +0100 | [diff] [blame] | 510 | Size(image_pointer_size)); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 511 | declaring_class_ = GcRoot<mirror::Class>(const_cast<ArtMethod*>(src)->GetDeclaringClass()); |
| 512 | dex_cache_resolved_methods_ = GcRoot<mirror::PointerArray>( |
| 513 | const_cast<ArtMethod*>(src)->GetDexCacheResolvedMethods()); |
| 514 | dex_cache_resolved_types_ = GcRoot<mirror::ObjectArray<mirror::Class>>( |
| 515 | const_cast<ArtMethod*>(src)->GetDexCacheResolvedTypes()); |
| 516 | } |
| 517 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 518 | } // namespace art |
| 519 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 520 | #endif // ART_RUNTIME_ART_METHOD_INL_H_ |