Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_MIRROR_ART_METHOD_H_ |
| 18 | #define ART_RUNTIME_MIRROR_ART_METHOD_H_ |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 19 | |
Jeff Hao | 790ad90 | 2013-05-22 15:02:08 -0700 | [diff] [blame] | 20 | #include "dex_file.h" |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 21 | #include "gc_root.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 22 | #include "invoke_type.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 23 | #include "modifiers.h" |
| 24 | #include "object.h" |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 25 | #include "object_callbacks.h" |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 26 | #include "quick/quick_method_frame_info.h" |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 27 | #include "read_barrier_option.h" |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 28 | #include "stack_map.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 29 | |
| 30 | namespace art { |
| 31 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 32 | struct ArtMethodOffsets; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 33 | struct ConstructorMethodOffsets; |
| 34 | union JValue; |
Mathieu Chartier | 2b7c4d1 | 2014-05-19 10:52:16 -0700 | [diff] [blame] | 35 | class ScopedObjectAccessAlreadyRunnable; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 36 | class StringPiece; |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 37 | class ShadowFrame; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 38 | |
| 39 | namespace mirror { |
| 40 | |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 41 | typedef void (EntryPointFromInterpreter)(Thread* self, const DexFile::CodeItem* code_item, |
| 42 | ShadowFrame* shadow_frame, JValue* result); |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 43 | |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 44 | #define ART_METHOD_HAS_PADDING_FIELD_ON_64_BIT |
| 45 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 46 | // C++ mirror of java.lang.reflect.ArtMethod. |
| 47 | class MANAGED ArtMethod FINAL : public Object { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 48 | public: |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 49 | // Size of java.lang.reflect.ArtMethod.class. |
| 50 | static uint32_t ClassSize(); |
| 51 | |
Mathieu Chartier | 2b7c4d1 | 2014-05-19 10:52:16 -0700 | [diff] [blame] | 52 | static ArtMethod* FromReflectedMethod(const ScopedObjectAccessAlreadyRunnable& soa, |
| 53 | jobject jlr_method) |
Ian Rogers | 62f0512 | 2014-03-21 11:21:29 -0700 | [diff] [blame] | 54 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 55 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 56 | Class* GetDeclaringClass() ALWAYS_INLINE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 57 | |
| 58 | void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 59 | |
| 60 | static MemberOffset DeclaringClassOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 61 | return MemberOffset(OFFSETOF_MEMBER(ArtMethod, declaring_class_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 62 | } |
| 63 | |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 64 | ALWAYS_INLINE uint32_t GetAccessFlags() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 65 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 66 | void SetAccessFlags(uint32_t new_access_flags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 67 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 68 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), new_access_flags); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | // Approximate what kind of method call would be used for this method. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 72 | InvokeType GetInvokeType() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 73 | |
| 74 | // Returns true if the method is declared public. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 75 | bool IsPublic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 76 | return (GetAccessFlags() & kAccPublic) != 0; |
| 77 | } |
| 78 | |
| 79 | // Returns true if the method is declared private. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 80 | bool IsPrivate() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 81 | return (GetAccessFlags() & kAccPrivate) != 0; |
| 82 | } |
| 83 | |
| 84 | // Returns true if the method is declared static. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 85 | bool IsStatic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 86 | return (GetAccessFlags() & kAccStatic) != 0; |
| 87 | } |
| 88 | |
| 89 | // Returns true if the method is a constructor. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 90 | bool IsConstructor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 91 | return (GetAccessFlags() & kAccConstructor) != 0; |
| 92 | } |
| 93 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 94 | // Returns true if the method is a class initializer. |
| 95 | bool IsClassInitializer() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 96 | return IsConstructor() && IsStatic(); |
| 97 | } |
| 98 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 99 | // Returns true if the method is static, private, or a constructor. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 100 | bool IsDirect() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 101 | return IsDirect(GetAccessFlags()); |
| 102 | } |
| 103 | |
| 104 | static bool IsDirect(uint32_t access_flags) { |
| 105 | return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0; |
| 106 | } |
| 107 | |
| 108 | // Returns true if the method is declared synchronized. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 109 | bool IsSynchronized() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 110 | uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized; |
| 111 | return (GetAccessFlags() & synchonized) != 0; |
| 112 | } |
| 113 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 114 | bool IsFinal() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 115 | return (GetAccessFlags() & kAccFinal) != 0; |
| 116 | } |
| 117 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 118 | bool IsMiranda() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 119 | return (GetAccessFlags() & kAccMiranda) != 0; |
| 120 | } |
| 121 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 122 | bool IsNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 123 | return (GetAccessFlags() & kAccNative) != 0; |
| 124 | } |
| 125 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 126 | bool IsFastNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 16ce092 | 2014-01-10 14:59:36 -0800 | [diff] [blame] | 127 | uint32_t mask = kAccFastNative | kAccNative; |
| 128 | return (GetAccessFlags() & mask) == mask; |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 131 | bool IsAbstract() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 132 | return (GetAccessFlags() & kAccAbstract) != 0; |
| 133 | } |
| 134 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 135 | bool IsSynthetic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 136 | return (GetAccessFlags() & kAccSynthetic) != 0; |
| 137 | } |
| 138 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 139 | bool IsProxyMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 140 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 141 | bool IsPreverified() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | 233ea8e | 2013-06-06 11:57:09 +0200 | [diff] [blame] | 142 | return (GetAccessFlags() & kAccPreverified) != 0; |
| 143 | } |
| 144 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 145 | void SetPreverified() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 146 | DCHECK(!IsPreverified()); |
Sebastien Hertz | 233ea8e | 2013-06-06 11:57:09 +0200 | [diff] [blame] | 147 | SetAccessFlags(GetAccessFlags() | kAccPreverified); |
| 148 | } |
| 149 | |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 150 | bool IsOptimized(size_t pointer_size) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 151 | // Temporary solution for detecting if a method has been optimized: the compiler |
| 152 | // does not create a GC map. Instead, the vmap table contains the stack map |
| 153 | // (as in stack_map.h). |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 154 | return GetEntryPointFromQuickCompiledCodePtrSize(pointer_size) != nullptr |
| 155 | && GetQuickOatCodePointer(pointer_size) != nullptr |
Mathieu Chartier | 957ca1c | 2014-11-21 16:51:29 -0800 | [diff] [blame] | 156 | && GetNativeGcMap(pointer_size) == nullptr; |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 157 | } |
| 158 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 159 | bool IsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 160 | return (GetAccessFlags() & kAccPortableCompiled) != 0; |
| 161 | } |
| 162 | |
| 163 | void SetIsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 164 | DCHECK(!IsPortableCompiled()); |
| 165 | SetAccessFlags(GetAccessFlags() | kAccPortableCompiled); |
| 166 | } |
| 167 | |
| 168 | void ClearIsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 169 | DCHECK(IsPortableCompiled()); |
| 170 | SetAccessFlags(GetAccessFlags() & ~kAccPortableCompiled); |
| 171 | } |
| 172 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 173 | bool CheckIncompatibleClassChange(InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 174 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 175 | uint16_t GetMethodIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 176 | |
Mathieu Chartier | 9f3629d | 2014-10-28 18:23:02 -0700 | [diff] [blame] | 177 | // Doesn't do erroneous / unresolved class checks. |
| 178 | uint16_t GetMethodIndexDuringLinking() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 179 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 180 | size_t GetVtableIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 181 | return GetMethodIndex(); |
| 182 | } |
| 183 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 184 | void SetMethodIndex(uint16_t new_method_index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 185 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 186 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), new_method_index); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | static MemberOffset MethodIndexOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 190 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 191 | } |
| 192 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 193 | uint32_t GetCodeItemOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 194 | return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_code_item_offset_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 195 | } |
| 196 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 197 | void SetCodeItemOffset(uint32_t new_code_off) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 198 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 199 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_code_item_offset_), new_code_off); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | // Number of 32bit registers that would be required to hold all the arguments |
| 203 | static size_t NumArgRegisters(const StringPiece& shorty); |
| 204 | |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 205 | ALWAYS_INLINE uint32_t GetDexMethodIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 206 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 207 | void SetDexMethodIndex(uint32_t new_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 208 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 209 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_method_index_), new_idx); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 210 | } |
| 211 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 212 | static MemberOffset DexCacheResolvedMethodsOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 213 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | static MemberOffset DexCacheResolvedTypesOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 217 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 218 | } |
| 219 | |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 220 | ALWAYS_INLINE ArtMethod* GetDexCacheResolvedMethod(uint16_t method_idx) |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 221 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 222 | ALWAYS_INLINE void SetDexCacheResolvedMethod(uint16_t method_idx, ArtMethod* new_method) |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 223 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 224 | ALWAYS_INLINE void SetDexCacheResolvedMethods(ObjectArray<ArtMethod>* new_dex_cache_methods) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 225 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 226 | bool HasDexCacheResolvedMethods() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 227 | bool HasSameDexCacheResolvedMethods(ArtMethod* other) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 228 | bool HasSameDexCacheResolvedMethods(ObjectArray<ArtMethod>* other_cache) |
| 229 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 230 | |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 231 | template <bool kWithCheck = true> |
| 232 | Class* GetDexCacheResolvedType(uint32_t type_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 233 | void SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_types) |
| 234 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 235 | bool HasDexCacheResolvedTypes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 236 | bool HasSameDexCacheResolvedTypes(ArtMethod* other) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 237 | bool HasSameDexCacheResolvedTypes(ObjectArray<Class>* other_cache) |
| 238 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 239 | |
Ian Rogers | e0a02da | 2014-12-02 14:10:53 -0800 | [diff] [blame] | 240 | // Find the method that this method overrides. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 241 | ArtMethod* FindOverriddenMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 242 | |
Ian Rogers | e0a02da | 2014-12-02 14:10:53 -0800 | [diff] [blame] | 243 | // Find the method index for this method within other_dexfile. If this method isn't present then |
| 244 | // return DexFile::kDexNoIndex. The name_and_signature_idx MUST refer to a MethodId with the same |
| 245 | // name and signature in the other_dexfile, such as the method index used to resolve this method |
| 246 | // in the other_dexfile. |
| 247 | uint32_t FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile, |
| 248 | uint32_t name_and_signature_idx) |
| 249 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 250 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 251 | void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, const char* shorty) |
| 252 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 253 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 254 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 255 | EntryPointFromInterpreter* GetEntryPointFromInterpreter() |
| 256 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 257 | CheckObjectSizeEqualsMirrorSize(); |
| 258 | return GetEntryPointFromInterpreterPtrSize(sizeof(void*)); |
| 259 | } |
| 260 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 261 | EntryPointFromInterpreter* GetEntryPointFromInterpreterPtrSize(size_t pointer_size) |
| 262 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 263 | return GetFieldPtrWithSize<EntryPointFromInterpreter*, kVerifyFlags>( |
| 264 | EntryPointFromInterpreterOffset(pointer_size), pointer_size); |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 267 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 268 | void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter) |
| 269 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 270 | CheckObjectSizeEqualsMirrorSize(); |
| 271 | SetEntryPointFromInterpreterPtrSize(entry_point_from_interpreter, sizeof(void*)); |
| 272 | } |
| 273 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 274 | void SetEntryPointFromInterpreterPtrSize(EntryPointFromInterpreter* entry_point_from_interpreter, |
| 275 | size_t pointer_size) |
| 276 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 277 | SetFieldPtrWithSize<false, true, kVerifyFlags>( |
| 278 | EntryPointFromInterpreterOffset(pointer_size), entry_point_from_interpreter, pointer_size); |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 281 | ALWAYS_INLINE static MemberOffset EntryPointFromPortableCompiledCodeOffset(size_t pointer_size) { |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 282 | return MemberOffset(PtrSizedFieldsOffset(pointer_size) + OFFSETOF_MEMBER( |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 283 | PtrSizedFields, entry_point_from_portable_compiled_code_) / sizeof(void*) * pointer_size); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 284 | } |
| 285 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 286 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 287 | const void* GetEntryPointFromPortableCompiledCode() |
| 288 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 289 | CheckObjectSizeEqualsMirrorSize(); |
| 290 | return GetEntryPointFromPortableCompiledCodePtrSize(sizeof(void*)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 291 | } |
| 292 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 293 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 294 | ALWAYS_INLINE const void* GetEntryPointFromPortableCompiledCodePtrSize(size_t pointer_size) |
| 295 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 296 | return GetFieldPtrWithSize<const void*, kVerifyFlags>( |
| 297 | EntryPointFromPortableCompiledCodeOffset(pointer_size), pointer_size); |
| 298 | } |
| 299 | |
| 300 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 301 | void SetEntryPointFromPortableCompiledCode(const void* entry_point_from_portable_compiled_code) |
| 302 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 303 | CheckObjectSizeEqualsMirrorSize(); |
| 304 | return SetEntryPointFromPortableCompiledCodePtrSize(entry_point_from_portable_compiled_code, |
| 305 | sizeof(void*)); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 306 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 307 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 308 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 309 | void SetEntryPointFromPortableCompiledCodePtrSize( |
| 310 | const void* entry_point_from_portable_compiled_code, size_t pointer_size) |
| 311 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 312 | SetFieldPtrWithSize<false, true, kVerifyFlags>( |
| 313 | EntryPointFromPortableCompiledCodeOffset(pointer_size), |
| 314 | entry_point_from_portable_compiled_code, pointer_size); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 315 | } |
| 316 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 317 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 318 | const void* GetEntryPointFromQuickCompiledCode() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 319 | CheckObjectSizeEqualsMirrorSize(); |
| 320 | return GetEntryPointFromQuickCompiledCodePtrSize(sizeof(void*)); |
| 321 | } |
| 322 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 323 | ALWAYS_INLINE const void* GetEntryPointFromQuickCompiledCodePtrSize(size_t pointer_size) |
| 324 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 325 | return GetFieldPtrWithSize<const void*, kVerifyFlags>( |
| 326 | EntryPointFromQuickCompiledCodeOffset(pointer_size), pointer_size); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 327 | } |
| 328 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 329 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 330 | void SetEntryPointFromQuickCompiledCode(const void* entry_point_from_quick_compiled_code) |
| 331 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 332 | CheckObjectSizeEqualsMirrorSize(); |
| 333 | SetEntryPointFromQuickCompiledCodePtrSize(entry_point_from_quick_compiled_code, |
| 334 | sizeof(void*)); |
| 335 | } |
| 336 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 337 | ALWAYS_INLINE void SetEntryPointFromQuickCompiledCodePtrSize( |
| 338 | const void* entry_point_from_quick_compiled_code, size_t pointer_size) |
| 339 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 340 | SetFieldPtrWithSize<false, true, kVerifyFlags>( |
| 341 | EntryPointFromQuickCompiledCodeOffset(pointer_size), entry_point_from_quick_compiled_code, |
| 342 | pointer_size); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 343 | } |
| 344 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 345 | uint32_t GetCodeSize() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 346 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 347 | // Check whether the given PC is within the quick compiled code associated with this method's |
| 348 | // quick entrypoint. This code isn't robust for instrumentation, etc. and is only used for |
| 349 | // debug purposes. |
| 350 | bool PcIsWithinQuickCode(uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 351 | uintptr_t code = reinterpret_cast<uintptr_t>(GetEntryPointFromQuickCompiledCode()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 352 | if (code == 0) { |
| 353 | return pc == 0; |
| 354 | } |
| 355 | /* |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 356 | * During a stack walk, a return PC may point past-the-end of the code |
| 357 | * in the case that the last instruction is a call that isn't expected to |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 358 | * return. Thus, we check <= code + GetCodeSize(). |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 359 | * |
| 360 | * NOTE: For Thumb both pc and code are offset by 1 indicating the Thumb state. |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 361 | */ |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 362 | return code <= pc && pc <= code + GetCodeSize(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 363 | } |
| 364 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 365 | void AssertPcIsWithinQuickCode(uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 366 | |
Hiroshi Yamauchi | 9bdec88 | 2014-08-15 17:11:12 -0700 | [diff] [blame] | 367 | // Returns true if the entrypoint points to the interpreter, as |
| 368 | // opposed to the compiled code, that is, this method will be |
| 369 | // interpretered on invocation. |
| 370 | bool IsEntrypointInterpreter() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 371 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 372 | uint32_t GetQuickOatCodeOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 373 | uint32_t GetPortableOatCodeOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 374 | void SetQuickOatCodeOffset(uint32_t code_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 375 | void SetPortableOatCodeOffset(uint32_t code_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 376 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 377 | ALWAYS_INLINE static const void* EntryPointToCodePointer(const void* entry_point) { |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 378 | uintptr_t code = reinterpret_cast<uintptr_t>(entry_point); |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 379 | // TODO: Make this Thumb2 specific. It is benign on other architectures as code is always at |
| 380 | // least 2 byte aligned. |
| 381 | code &= ~0x1; |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 382 | return reinterpret_cast<const void*>(code); |
| 383 | } |
| 384 | |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 385 | // Actual entry point pointer to compiled oat code or nullptr. |
| 386 | const void* GetQuickOatEntryPoint(size_t pointer_size) |
| 387 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 388 | // Actual pointer to compiled oat code or nullptr. |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 389 | const void* GetQuickOatCodePointer(size_t pointer_size) |
| 390 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 391 | return EntryPointToCodePointer(GetQuickOatEntryPoint(pointer_size)); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 392 | } |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 393 | |
Ian Rogers | 1809a72 | 2013-08-09 22:05:32 -0700 | [diff] [blame] | 394 | // Callers should wrap the uint8_t* in a MappingTable instance for convenient access. |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 395 | const uint8_t* GetMappingTable(size_t pointer_size) |
| 396 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 397 | const uint8_t* GetMappingTable(const void* code_pointer, size_t pointer_size) |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 398 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 399 | |
Ian Rogers | 1809a72 | 2013-08-09 22:05:32 -0700 | [diff] [blame] | 400 | // Callers should wrap the uint8_t* in a VmapTable instance for convenient access. |
Mathieu Chartier | a7dd038 | 2014-11-20 17:08:58 -0800 | [diff] [blame] | 401 | const uint8_t* GetVmapTable(size_t pointer_size) |
| 402 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 403 | const uint8_t* GetVmapTable(const void* code_pointer, size_t pointer_size) |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 404 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 405 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 406 | StackMap GetStackMap(uint32_t native_pc_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Nicolas Geoffray | e982f0b | 2014-08-13 02:11:24 +0100 | [diff] [blame] | 407 | CodeInfo GetOptimizedCodeInfo() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 408 | |
Mathieu Chartier | 957ca1c | 2014-11-21 16:51:29 -0800 | [diff] [blame] | 409 | // Callers should wrap the uint8_t* in a GcMap instance for convenient access. |
| 410 | const uint8_t* GetNativeGcMap(size_t pointer_size) |
| 411 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 412 | const uint8_t* GetNativeGcMap(const void* code_pointer, size_t pointer_size) |
| 413 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 414 | |
Andreas Gampe | 9054683 | 2014-03-12 18:07:19 -0700 | [diff] [blame] | 415 | template <bool kCheckFrameSize = true> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 416 | uint32_t GetFrameSizeInBytes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 417 | uint32_t result = GetQuickFrameInfo().FrameSizeInBytes(); |
Andreas Gampe | 9054683 | 2014-03-12 18:07:19 -0700 | [diff] [blame] | 418 | if (kCheckFrameSize) { |
| 419 | DCHECK_LE(static_cast<size_t>(kStackAlignment), result); |
| 420 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 421 | return result; |
| 422 | } |
| 423 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 424 | QuickMethodFrameInfo GetQuickFrameInfo() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 425 | QuickMethodFrameInfo GetQuickFrameInfo(const void* code_pointer) |
| 426 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 427 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 428 | FrameOffset GetReturnPcOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 429 | return GetReturnPcOffset(GetFrameSizeInBytes()); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 430 | } |
| 431 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 432 | FrameOffset GetReturnPcOffset(uint32_t frame_size_in_bytes) |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 433 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 434 | DCHECK_EQ(frame_size_in_bytes, GetFrameSizeInBytes()); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 435 | return FrameOffset(frame_size_in_bytes - sizeof(void*)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 436 | } |
| 437 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 438 | FrameOffset GetHandleScopeOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 439 | DCHECK_LT(sizeof(void*), GetFrameSizeInBytes()); |
| 440 | return FrameOffset(sizeof(void*)); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 441 | } |
| 442 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 443 | void RegisterNative(const void* native_method, bool is_fast) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 444 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 445 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 446 | void UnregisterNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 447 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 448 | static MemberOffset EntryPointFromInterpreterOffset(size_t pointer_size) { |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 449 | return MemberOffset(PtrSizedFieldsOffset(pointer_size) + OFFSETOF_MEMBER( |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 450 | PtrSizedFields, entry_point_from_interpreter_) / sizeof(void*) * pointer_size); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 451 | } |
| 452 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 453 | static MemberOffset EntryPointFromJniOffset(size_t pointer_size) { |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 454 | return MemberOffset(PtrSizedFieldsOffset(pointer_size) + OFFSETOF_MEMBER( |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 455 | PtrSizedFields, entry_point_from_jni_) / sizeof(void*) * pointer_size); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 456 | } |
| 457 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 458 | static MemberOffset EntryPointFromQuickCompiledCodeOffset(size_t pointer_size) { |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 459 | return MemberOffset(PtrSizedFieldsOffset(pointer_size) + OFFSETOF_MEMBER( |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 460 | PtrSizedFields, entry_point_from_quick_compiled_code_) / sizeof(void*) * pointer_size); |
| 461 | } |
| 462 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 463 | void* GetEntryPointFromJni() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 464 | CheckObjectSizeEqualsMirrorSize(); |
| 465 | return GetEntryPointFromJniPtrSize(sizeof(void*)); |
| 466 | } |
| 467 | ALWAYS_INLINE void* GetEntryPointFromJniPtrSize(size_t pointer_size) |
| 468 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 469 | return GetFieldPtrWithSize<void*>(EntryPointFromJniOffset(pointer_size), pointer_size); |
| 470 | } |
| 471 | |
| 472 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 473 | void SetEntryPointFromJni(const void* entrypoint) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 474 | CheckObjectSizeEqualsMirrorSize(); |
| 475 | SetEntryPointFromJniPtrSize<kVerifyFlags>(entrypoint, sizeof(void*)); |
| 476 | } |
| 477 | template <VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
| 478 | ALWAYS_INLINE void SetEntryPointFromJniPtrSize(const void* entrypoint, size_t pointer_size) |
| 479 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 480 | SetFieldPtrWithSize<false, true, kVerifyFlags>( |
| 481 | EntryPointFromJniOffset(pointer_size), entrypoint, pointer_size); |
| 482 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 483 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 484 | static MemberOffset GetMethodIndexOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 485 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 486 | } |
| 487 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 488 | // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal |
| 489 | // conventions for a method of managed code. Returns false for Proxy methods. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 490 | bool IsRuntimeMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 491 | |
| 492 | // Is this a hand crafted method used for something like describing callee saves? |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 493 | bool IsCalleeSaveMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 494 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 495 | bool IsResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 496 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 497 | bool IsImtConflictMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 498 | |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 499 | bool IsImtUnimplementedMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 500 | |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 501 | uintptr_t NativeQuickPcOffset(const uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 502 | #ifdef NDEBUG |
| 503 | uintptr_t NativeQuickPcOffset(const uintptr_t pc, const void* quick_entry_point) |
| 504 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 505 | return pc - reinterpret_cast<uintptr_t>(quick_entry_point); |
| 506 | } |
| 507 | #else |
| 508 | uintptr_t NativeQuickPcOffset(const uintptr_t pc, const void* quick_entry_point) |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 509 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 6f3dbba | 2014-10-14 17:41:57 -0700 | [diff] [blame] | 510 | #endif |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 511 | |
| 512 | // Converts a native PC to a dex PC. |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 513 | uint32_t ToDexPc(const uintptr_t pc, bool abort_on_failure = true) |
| 514 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 515 | |
| 516 | // Converts a dex PC to a native PC. |
Nicolas Geoffray | de58ab2 | 2014-11-05 12:46:03 +0000 | [diff] [blame] | 517 | uintptr_t ToNativeQuickPc(const uint32_t dex_pc, bool abort_on_failure = true) |
| 518 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 519 | |
Ian Rogers | c449aa8 | 2013-07-29 14:35:46 -0700 | [diff] [blame] | 520 | // Find the catch block for the given exception type and dex_pc. When a catch block is found, |
| 521 | // indicates whether the found catch block is responsible for clearing the exception or whether |
| 522 | // a move-exception instruction is present. |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 523 | static uint32_t FindCatchBlock(Handle<ArtMethod> h_this, Handle<Class> exception_type, |
| 524 | uint32_t dex_pc, bool* has_no_move_exception) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 525 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 526 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 527 | static void SetClass(Class* java_lang_reflect_ArtMethod); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 528 | |
Hiroshi Yamauchi | 4f1ebc2 | 2014-06-25 14:30:41 -0700 | [diff] [blame] | 529 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 530 | static Class* GetJavaLangReflectArtMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 531 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 532 | static void ResetClass(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 533 | |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 534 | static void VisitRoots(RootCallback* callback, void* arg) |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 535 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 536 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 537 | const DexFile* GetDexFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 538 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 539 | const char* GetDeclaringClassDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 540 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 541 | const char* GetShorty() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 542 | uint32_t unused_length; |
| 543 | return GetShorty(&unused_length); |
| 544 | } |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 545 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 546 | const char* GetShorty(uint32_t* out_length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 547 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 548 | const Signature GetSignature() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 549 | |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 550 | ALWAYS_INLINE const char* GetName() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 551 | |
Ian Rogers | 6b14d55 | 2014-10-28 21:50:58 -0700 | [diff] [blame] | 552 | mirror::String* GetNameAsString(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 553 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 554 | const DexFile::CodeItem* GetCodeItem() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 555 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 556 | bool IsResolvedTypeIdx(uint16_t type_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 557 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 558 | int32_t GetLineNumFromDexPC(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 559 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 560 | const DexFile::ProtoId& GetPrototype() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 561 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 562 | const DexFile::TypeList* GetParameterTypeList() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 563 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 564 | const char* GetDeclaringClassSourceFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 565 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 566 | uint16_t GetClassDefIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 567 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 568 | const DexFile::ClassDef& GetClassDef() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 569 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 570 | const char* GetReturnTypeDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 571 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 572 | const char* GetTypeDescriptorFromTypeIdx(uint16_t type_idx) |
| 573 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 574 | |
Ian Rogers | ded66a0 | 2014-10-28 18:12:55 -0700 | [diff] [blame] | 575 | // May cause thread suspension due to GetClassFromTypeIdx calling ResolveType this caused a large |
| 576 | // number of bugs at call sites. |
| 577 | mirror::Class* GetReturnType(bool resolve = true) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 578 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 579 | mirror::ClassLoader* GetClassLoader() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 580 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 581 | mirror::DexCache* GetDexCache() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 582 | |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 583 | ALWAYS_INLINE ArtMethod* GetInterfaceMethodIfProxy() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 584 | |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 585 | static size_t SizeWithoutPointerFields(size_t pointer_size) { |
| 586 | size_t total = sizeof(ArtMethod) - sizeof(PtrSizedFields); |
| 587 | #ifdef ART_METHOD_HAS_PADDING_FIELD_ON_64_BIT |
| 588 | // Add 4 bytes if 64 bit, otherwise 0. |
| 589 | total += pointer_size - sizeof(uint32_t); |
| 590 | #endif |
| 591 | return total; |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | // Size of an instance of java.lang.reflect.ArtMethod not including its value array. |
| 595 | static size_t InstanceSize(size_t pointer_size) { |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 596 | return SizeWithoutPointerFields(pointer_size) + |
| 597 | (sizeof(PtrSizedFields) / sizeof(void*)) * pointer_size; |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | protected: |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 601 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 602 | // The class we are a part of. |
| 603 | HeapReference<Class> declaring_class_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 604 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 605 | // Short cuts to declaring_class_->dex_cache_ member for fast compiled code access. |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 606 | HeapReference<ObjectArray<ArtMethod>> dex_cache_resolved_methods_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 607 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 608 | // Short cuts to declaring_class_->dex_cache_ member for fast compiled code access. |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 609 | HeapReference<ObjectArray<Class>> dex_cache_resolved_types_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 610 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 611 | // Access flags; low 16 bits are defined by spec. |
| 612 | uint32_t access_flags_; |
| 613 | |
| 614 | /* Dex file fields. The defining dex file is available via declaring_class_->dex_cache_ */ |
| 615 | |
| 616 | // Offset to the CodeItem. |
| 617 | uint32_t dex_code_item_offset_; |
| 618 | |
| 619 | // Index into method_ids of the dex file associated with this method. |
| 620 | uint32_t dex_method_index_; |
| 621 | |
| 622 | /* End of dex file fields. */ |
| 623 | |
| 624 | // Entry within a dispatch table for this method. For static/direct methods the index is into |
| 625 | // the declaringClass.directMethods, for virtual methods the vtable and for interface methods the |
| 626 | // ifTable. |
| 627 | uint32_t method_index_; |
| 628 | |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 629 | // Fake padding field gets inserted here. |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 630 | |
| 631 | // Must be the last fields in the method. |
| 632 | struct PACKED(4) PtrSizedFields { |
| 633 | // Method dispatch from the interpreter invokes this pointer which may cause a bridge into |
| 634 | // compiled code. |
| 635 | void* entry_point_from_interpreter_; |
| 636 | |
| 637 | // Pointer to JNI function registered to this method, or a function to resolve the JNI function. |
| 638 | void* entry_point_from_jni_; |
| 639 | |
| 640 | // Method dispatch from quick compiled code invokes this pointer which may cause bridging into |
| 641 | // portable compiled code or the interpreter. |
| 642 | void* entry_point_from_quick_compiled_code_; |
| 643 | |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 644 | // Method dispatch from portable compiled code invokes this pointer which may cause bridging |
| 645 | // into quick compiled code or the interpreter. Last to simplify entrypoint logic. |
| 646 | void* entry_point_from_portable_compiled_code_; |
| 647 | } ptr_sized_fields_; |
| 648 | |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 649 | static GcRoot<Class> java_lang_reflect_ArtMethod_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 650 | |
Mathieu Chartier | 02e2511 | 2013-08-14 16:14:24 -0700 | [diff] [blame] | 651 | private: |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 652 | ALWAYS_INLINE void CheckObjectSizeEqualsMirrorSize() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 653 | |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 654 | ALWAYS_INLINE ObjectArray<ArtMethod>* GetDexCacheResolvedMethods() |
| 655 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 656 | |
Mathieu Chartier | 2d2621a | 2014-10-23 16:48:06 -0700 | [diff] [blame] | 657 | ALWAYS_INLINE ObjectArray<Class>* GetDexCacheResolvedTypes() |
| 658 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 659 | |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 660 | static size_t PtrSizedFieldsOffset(size_t pointer_size) { |
| 661 | size_t offset = OFFSETOF_MEMBER(ArtMethod, ptr_sized_fields_); |
| 662 | #ifdef ART_METHOD_HAS_PADDING_FIELD_ON_64_BIT |
| 663 | // Add 4 bytes if 64 bit, otherwise 0. |
| 664 | offset += pointer_size - sizeof(uint32_t); |
| 665 | #endif |
| 666 | return offset; |
Mathieu Chartier | 2d72101 | 2014-11-10 11:08:06 -0800 | [diff] [blame] | 667 | } |
| 668 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 669 | friend struct art::ArtMethodOffsets; // for verifying offset information |
| 670 | DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethod); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 671 | }; |
| 672 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 673 | } // namespace mirror |
| 674 | } // namespace art |
| 675 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 676 | #endif // ART_RUNTIME_MIRROR_ART_METHOD_H_ |