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" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 28 | |
| 29 | namespace art { |
| 30 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 31 | struct ArtMethodOffsets; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 32 | struct ConstructorMethodOffsets; |
| 33 | union JValue; |
Jeff Hao | 790ad90 | 2013-05-22 15:02:08 -0700 | [diff] [blame] | 34 | class MethodHelper; |
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 | |
Jeff Hao | 790ad90 | 2013-05-22 15:02:08 -0700 | [diff] [blame] | 41 | typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper& mh, |
| 42 | const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result); |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 43 | |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 44 | // C++ mirror of java.lang.reflect.ArtMethod. |
| 45 | class MANAGED ArtMethod FINAL : public Object { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 46 | public: |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 47 | // Size of java.lang.reflect.ArtMethod.class. |
| 48 | static uint32_t ClassSize(); |
| 49 | |
| 50 | // Size of an instance of java.lang.reflect.ArtMethod not including its value array. |
| 51 | static constexpr uint32_t InstanceSize() { |
| 52 | return sizeof(ArtMethod); |
| 53 | } |
| 54 | |
Mathieu Chartier | 2b7c4d1 | 2014-05-19 10:52:16 -0700 | [diff] [blame] | 55 | static ArtMethod* FromReflectedMethod(const ScopedObjectAccessAlreadyRunnable& soa, |
| 56 | jobject jlr_method) |
Ian Rogers | 62f0512 | 2014-03-21 11:21:29 -0700 | [diff] [blame] | 57 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 58 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 59 | Class* GetDeclaringClass() ALWAYS_INLINE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 60 | |
| 61 | void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 62 | |
| 63 | static MemberOffset DeclaringClassOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 64 | return MemberOffset(OFFSETOF_MEMBER(ArtMethod, declaring_class_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 67 | uint32_t GetAccessFlags() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Jeff Hao | 5d91730 | 2013-02-27 17:57:33 -0800 | [diff] [blame] | 68 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 69 | 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] | 70 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 71 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), new_access_flags); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | // Approximate what kind of method call would be used for this method. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 75 | InvokeType GetInvokeType() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 76 | |
| 77 | // Returns true if the method is declared public. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 78 | bool IsPublic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 79 | return (GetAccessFlags() & kAccPublic) != 0; |
| 80 | } |
| 81 | |
| 82 | // Returns true if the method is declared private. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 83 | bool IsPrivate() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 84 | return (GetAccessFlags() & kAccPrivate) != 0; |
| 85 | } |
| 86 | |
| 87 | // Returns true if the method is declared static. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 88 | bool IsStatic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 89 | return (GetAccessFlags() & kAccStatic) != 0; |
| 90 | } |
| 91 | |
| 92 | // Returns true if the method is a constructor. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 93 | bool IsConstructor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 94 | return (GetAccessFlags() & kAccConstructor) != 0; |
| 95 | } |
| 96 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 97 | // Returns true if the method is a class initializer. |
| 98 | bool IsClassInitializer() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 99 | return IsConstructor() && IsStatic(); |
| 100 | } |
| 101 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 102 | // Returns true if the method is static, private, or a constructor. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 103 | bool IsDirect() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 104 | return IsDirect(GetAccessFlags()); |
| 105 | } |
| 106 | |
| 107 | static bool IsDirect(uint32_t access_flags) { |
| 108 | return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0; |
| 109 | } |
| 110 | |
| 111 | // Returns true if the method is declared synchronized. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 112 | bool IsSynchronized() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 113 | uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized; |
| 114 | return (GetAccessFlags() & synchonized) != 0; |
| 115 | } |
| 116 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 117 | bool IsFinal() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 118 | return (GetAccessFlags() & kAccFinal) != 0; |
| 119 | } |
| 120 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 121 | bool IsMiranda() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 122 | return (GetAccessFlags() & kAccMiranda) != 0; |
| 123 | } |
| 124 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 125 | bool IsNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 126 | return (GetAccessFlags() & kAccNative) != 0; |
| 127 | } |
| 128 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 129 | bool IsFastNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 16ce092 | 2014-01-10 14:59:36 -0800 | [diff] [blame] | 130 | uint32_t mask = kAccFastNative | kAccNative; |
| 131 | return (GetAccessFlags() & mask) == mask; |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 134 | bool IsAbstract() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 135 | return (GetAccessFlags() & kAccAbstract) != 0; |
| 136 | } |
| 137 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 138 | bool IsSynthetic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 139 | return (GetAccessFlags() & kAccSynthetic) != 0; |
| 140 | } |
| 141 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 142 | bool IsProxyMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 143 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 144 | bool IsPreverified() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | 233ea8e | 2013-06-06 11:57:09 +0200 | [diff] [blame] | 145 | return (GetAccessFlags() & kAccPreverified) != 0; |
| 146 | } |
| 147 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 148 | void SetPreverified() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 149 | DCHECK(!IsPreverified()); |
Sebastien Hertz | 233ea8e | 2013-06-06 11:57:09 +0200 | [diff] [blame] | 150 | SetAccessFlags(GetAccessFlags() | kAccPreverified); |
| 151 | } |
| 152 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 153 | bool IsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 154 | return (GetAccessFlags() & kAccPortableCompiled) != 0; |
| 155 | } |
| 156 | |
| 157 | void SetIsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 158 | DCHECK(!IsPortableCompiled()); |
| 159 | SetAccessFlags(GetAccessFlags() | kAccPortableCompiled); |
| 160 | } |
| 161 | |
| 162 | void ClearIsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 163 | DCHECK(IsPortableCompiled()); |
| 164 | SetAccessFlags(GetAccessFlags() & ~kAccPortableCompiled); |
| 165 | } |
| 166 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 167 | bool CheckIncompatibleClassChange(InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 168 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 169 | uint16_t GetMethodIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 170 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 171 | size_t GetVtableIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 172 | return GetMethodIndex(); |
| 173 | } |
| 174 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 175 | 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] | 176 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 177 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), new_method_index); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | static MemberOffset MethodIndexOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 181 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 182 | } |
| 183 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 184 | uint32_t GetCodeItemOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 185 | return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_code_item_offset_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 186 | } |
| 187 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 188 | 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] | 189 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 190 | 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] | 191 | } |
| 192 | |
| 193 | // Number of 32bit registers that would be required to hold all the arguments |
| 194 | static size_t NumArgRegisters(const StringPiece& shorty); |
| 195 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 196 | uint32_t GetDexMethodIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 197 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 198 | void SetDexMethodIndex(uint32_t new_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 199 | // Not called within a transaction. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 200 | SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_method_index_), new_idx); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 201 | } |
| 202 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 203 | ObjectArray<String>* GetDexCacheStrings() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 204 | void SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) |
| 205 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 206 | |
| 207 | static MemberOffset DexCacheStringsOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 208 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | static MemberOffset DexCacheResolvedMethodsOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 212 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | static MemberOffset DexCacheResolvedTypesOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 216 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 217 | } |
| 218 | |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 219 | ArtMethod* GetDexCacheResolvedMethod(uint16_t method_idx) |
| 220 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 221 | void SetDexCacheResolvedMethod(uint16_t method_idx, ArtMethod* new_method) |
| 222 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 223 | void SetDexCacheResolvedMethods(ObjectArray<ArtMethod>* new_dex_cache_methods) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 224 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 225 | bool HasDexCacheResolvedMethods() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 226 | bool HasSameDexCacheResolvedMethods(ArtMethod* other) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 227 | bool HasSameDexCacheResolvedMethods(ObjectArray<ArtMethod>* other_cache) |
| 228 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 229 | |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 230 | template <bool kWithCheck = true> |
| 231 | Class* GetDexCacheResolvedType(uint32_t type_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 232 | void SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_types) |
| 233 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 234 | bool HasDexCacheResolvedTypes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 235 | bool HasSameDexCacheResolvedTypes(ArtMethod* other) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 236 | bool HasSameDexCacheResolvedTypes(ObjectArray<Class>* other_cache) |
| 237 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 238 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 239 | // Find the method that this method overrides |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 240 | ArtMethod* FindOverriddenMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 241 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 242 | void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, const char* shorty) |
| 243 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 244 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 245 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 246 | EntryPointFromInterpreter* GetEntryPointFromInterpreter() |
| 247 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 248 | return GetFieldPtr<EntryPointFromInterpreter*, kVerifyFlags>( |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 249 | OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_)); |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 250 | } |
| 251 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 252 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 253 | void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter) |
| 254 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 255 | SetFieldPtr<false, true, kVerifyFlags>( |
| 256 | OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 257 | entry_point_from_interpreter); |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 258 | } |
| 259 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 260 | static MemberOffset EntryPointFromPortableCompiledCodeOffset() { |
| 261 | return MemberOffset(OFFSETOF_MEMBER(ArtMethod, entry_point_from_portable_compiled_code_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 264 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 265 | const void* GetEntryPointFromPortableCompiledCode() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 266 | return GetFieldPtr<const void*, kVerifyFlags>( |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 267 | EntryPointFromPortableCompiledCodeOffset()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 268 | } |
| 269 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 270 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 271 | void SetEntryPointFromPortableCompiledCode(const void* entry_point_from_portable_compiled_code) |
| 272 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 273 | SetFieldPtr<false, true, kVerifyFlags>( |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 274 | EntryPointFromPortableCompiledCodeOffset(), entry_point_from_portable_compiled_code); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 275 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 276 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 277 | static MemberOffset EntryPointFromQuickCompiledCodeOffset() { |
| 278 | return MemberOffset(OFFSETOF_MEMBER(ArtMethod, entry_point_from_quick_compiled_code_)); |
| 279 | } |
| 280 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 281 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 282 | const void* GetEntryPointFromQuickCompiledCode() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 283 | return GetFieldPtr<const void*, kVerifyFlags>(EntryPointFromQuickCompiledCodeOffset()); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 284 | } |
| 285 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 286 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 287 | void SetEntryPointFromQuickCompiledCode(const void* entry_point_from_quick_compiled_code) |
| 288 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 289 | SetFieldPtr<false, true, kVerifyFlags>( |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 290 | EntryPointFromQuickCompiledCodeOffset(), entry_point_from_quick_compiled_code); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 291 | } |
| 292 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 293 | uint32_t GetCodeSize() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 294 | |
| 295 | bool IsWithinQuickCode(uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 296 | uintptr_t code = reinterpret_cast<uintptr_t>(GetEntryPointFromQuickCompiledCode()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 297 | if (code == 0) { |
| 298 | return pc == 0; |
| 299 | } |
| 300 | /* |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 301 | * During a stack walk, a return PC may point past-the-end of the code |
| 302 | * 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] | 303 | * return. Thus, we check <= code + GetCodeSize(). |
Vladimir Marko | 96c6ab9 | 2014-04-08 14:00:50 +0100 | [diff] [blame] | 304 | * |
| 305 | * 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] | 306 | */ |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 307 | return code <= pc && pc <= code + GetCodeSize(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 308 | } |
| 309 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 310 | void AssertPcIsWithinQuickCode(uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 311 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 312 | uint32_t GetQuickOatCodeOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 313 | uint32_t GetPortableOatCodeOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 314 | void SetQuickOatCodeOffset(uint32_t code_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 315 | void SetPortableOatCodeOffset(uint32_t code_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 316 | |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 317 | static const void* EntryPointToCodePointer(const void* entry_point) ALWAYS_INLINE { |
| 318 | uintptr_t code = reinterpret_cast<uintptr_t>(entry_point); |
| 319 | code &= ~0x1; // TODO: Make this Thumb2 specific. |
| 320 | return reinterpret_cast<const void*>(code); |
| 321 | } |
| 322 | |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 323 | // Actual entry point pointer to compiled oat code or nullptr. |
| 324 | const void* GetQuickOatEntryPoint() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 325 | // Actual pointer to compiled oat code or nullptr. |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 326 | const void* GetQuickOatCodePointer() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 327 | |
Ian Rogers | 1809a72 | 2013-08-09 22:05:32 -0700 | [diff] [blame] | 328 | // Callers should wrap the uint8_t* in a MappingTable instance for convenient access. |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 329 | const uint8_t* GetMappingTable() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 330 | const uint8_t* GetMappingTable(const void* code_pointer) |
| 331 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 332 | |
Ian Rogers | 1809a72 | 2013-08-09 22:05:32 -0700 | [diff] [blame] | 333 | // Callers should wrap the uint8_t* in a VmapTable instance for convenient access. |
Vladimir Marko | 8a63057 | 2014-04-09 18:45:35 +0100 | [diff] [blame] | 334 | const uint8_t* GetVmapTable() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 335 | const uint8_t* GetVmapTable(const void* code_pointer) |
| 336 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 337 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 338 | const uint8_t* GetNativeGcMap() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 339 | return GetFieldPtr<uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_)); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 340 | } |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 341 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 342 | void SetNativeGcMap(const uint8_t* data) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 343 | SetFieldPtr<false, true, kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), data); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | // When building the oat need a convenient place to stuff the offset of the native GC map. |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 347 | void SetOatNativeGcMapOffset(uint32_t gc_map_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 348 | uint32_t GetOatNativeGcMapOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 349 | |
Andreas Gampe | 9054683 | 2014-03-12 18:07:19 -0700 | [diff] [blame] | 350 | template <bool kCheckFrameSize = true> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 351 | uint32_t GetFrameSizeInBytes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 352 | uint32_t result = GetQuickFrameInfo().FrameSizeInBytes(); |
Andreas Gampe | 9054683 | 2014-03-12 18:07:19 -0700 | [diff] [blame] | 353 | if (kCheckFrameSize) { |
| 354 | DCHECK_LE(static_cast<size_t>(kStackAlignment), result); |
| 355 | } |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 356 | return result; |
| 357 | } |
| 358 | |
Vladimir Marko | 7624d25 | 2014-05-02 14:40:15 +0100 | [diff] [blame] | 359 | QuickMethodFrameInfo GetQuickFrameInfo() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 360 | QuickMethodFrameInfo GetQuickFrameInfo(const void* code_pointer) |
| 361 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 362 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 363 | size_t GetReturnPcOffsetInBytes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 364 | return GetReturnPcOffsetInBytes(GetFrameSizeInBytes()); |
| 365 | } |
| 366 | |
| 367 | size_t GetReturnPcOffsetInBytes(uint32_t frame_size_in_bytes) |
| 368 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 369 | DCHECK_EQ(frame_size_in_bytes, GetFrameSizeInBytes()); |
| 370 | return frame_size_in_bytes - kPointerSize; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 371 | } |
| 372 | |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 373 | size_t GetHandleScopeOffsetInBytes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 374 | return kPointerSize; |
| 375 | } |
| 376 | |
Ian Rogers | 1eb512d | 2013-10-18 15:42:20 -0700 | [diff] [blame] | 377 | void RegisterNative(Thread* self, const void* native_method, bool is_fast) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 378 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 379 | |
| 380 | void UnregisterNative(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 381 | |
| 382 | static MemberOffset NativeMethodOffset() { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 383 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_jni_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 384 | } |
| 385 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 386 | const void* GetNativeMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 387 | return GetFieldPtr<const void*>(NativeMethodOffset()); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 388 | } |
| 389 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 390 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 391 | void SetNativeMethod(const void*) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 392 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 393 | static MemberOffset GetMethodIndexOffset() { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 394 | return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 395 | } |
| 396 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 397 | // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal |
| 398 | // conventions for a method of managed code. Returns false for Proxy methods. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 399 | bool IsRuntimeMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 400 | |
| 401 | // 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] | 402 | bool IsCalleeSaveMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 403 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 404 | bool IsResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 405 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 406 | bool IsImtConflictMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 407 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 408 | uintptr_t NativePcOffset(const uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Vladimir Marko | 4c1c510 | 2014-05-14 16:51:16 +0100 | [diff] [blame] | 409 | uintptr_t NativePcOffset(const uintptr_t pc, const void* quick_entry_point) |
| 410 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 411 | |
| 412 | // Converts a native PC to a dex PC. |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 413 | uint32_t ToDexPc(const uintptr_t pc, bool abort_on_failure = true) |
| 414 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 415 | |
| 416 | // Converts a dex PC to a native PC. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 417 | uintptr_t ToNativePc(const uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 418 | |
Ian Rogers | c449aa8 | 2013-07-29 14:35:46 -0700 | [diff] [blame] | 419 | // Find the catch block for the given exception type and dex_pc. When a catch block is found, |
| 420 | // indicates whether the found catch block is responsible for clearing the exception or whether |
| 421 | // a move-exception instruction is present. |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 422 | static uint32_t FindCatchBlock(Handle<ArtMethod> h_this, Handle<Class> exception_type, |
| 423 | uint32_t dex_pc, bool* has_no_move_exception) |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 424 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 425 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 426 | static void SetClass(Class* java_lang_reflect_ArtMethod); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 427 | |
Hiroshi Yamauchi | 4f1ebc2 | 2014-06-25 14:30:41 -0700 | [diff] [blame] | 428 | template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier> |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 429 | static Class* GetJavaLangReflectArtMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 430 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 431 | static void ResetClass(); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 432 | |
Mathieu Chartier | 83c8ee0 | 2014-01-28 14:50:23 -0800 | [diff] [blame] | 433 | static void VisitRoots(RootCallback* callback, void* arg) |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 434 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 435 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 436 | const DexFile* GetDexFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 437 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 438 | const char* GetDeclaringClassDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 439 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 440 | const char* GetShorty() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 441 | uint32_t unused_length; |
| 442 | return GetShorty(&unused_length); |
| 443 | } |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 444 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 445 | 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] | 446 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 447 | const Signature GetSignature() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 448 | |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame^] | 449 | ALWAYS_INLINE const char* GetName() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 450 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 451 | const DexFile::CodeItem* GetCodeItem() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 452 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 453 | bool IsResolvedTypeIdx(uint16_t type_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 454 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 455 | 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] | 456 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 457 | const DexFile::ProtoId& GetPrototype() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 458 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 459 | const DexFile::TypeList* GetParameterTypeList() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 460 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 461 | const char* GetDeclaringClassSourceFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 462 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 463 | uint16_t GetClassDefIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 464 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 465 | const DexFile::ClassDef& GetClassDef() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 466 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 467 | const char* GetReturnTypeDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 468 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 469 | const char* GetTypeDescriptorFromTypeIdx(uint16_t type_idx) |
| 470 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 471 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 472 | mirror::ClassLoader* GetClassLoader() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 473 | |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 474 | mirror::DexCache* GetDexCache() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 475 | |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame^] | 476 | ALWAYS_INLINE ArtMethod* GetInterfaceMethodIfProxy() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 477 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 478 | protected: |
| 479 | // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses". |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 480 | // The class we are a part of. |
| 481 | HeapReference<Class> declaring_class_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 482 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 483 | // 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] | 484 | HeapReference<ObjectArray<ArtMethod>> dex_cache_resolved_methods_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 485 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 486 | // 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] | 487 | HeapReference<ObjectArray<Class>> dex_cache_resolved_types_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 488 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 489 | // 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] | 490 | HeapReference<ObjectArray<String>> dex_cache_strings_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 491 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 492 | // Method dispatch from the interpreter invokes this pointer which may cause a bridge into |
| 493 | // compiled code. |
| 494 | uint64_t entry_point_from_interpreter_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 495 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 496 | // Pointer to JNI function registered to this method, or a function to resolve the JNI function. |
| 497 | uint64_t entry_point_from_jni_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 498 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 499 | // Method dispatch from portable compiled code invokes this pointer which may cause bridging into |
| 500 | // quick compiled code or the interpreter. |
| 501 | uint64_t entry_point_from_portable_compiled_code_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 502 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 503 | // Method dispatch from quick compiled code invokes this pointer which may cause bridging into |
| 504 | // portable compiled code or the interpreter. |
| 505 | uint64_t entry_point_from_quick_compiled_code_; |
Jeff Hao | aa4a793 | 2013-05-13 11:28:27 -0700 | [diff] [blame] | 506 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 507 | // Pointer to a data structure created by the compiler and used by the garbage collector to |
| 508 | // determine which registers hold live references to objects within the heap. Keyed by native PC |
| 509 | // offsets for the quick compiler and dex PCs for the portable. |
| 510 | uint64_t gc_map_; |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 511 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 512 | // Access flags; low 16 bits are defined by spec. |
| 513 | uint32_t access_flags_; |
| 514 | |
| 515 | /* Dex file fields. The defining dex file is available via declaring_class_->dex_cache_ */ |
| 516 | |
| 517 | // Offset to the CodeItem. |
| 518 | uint32_t dex_code_item_offset_; |
| 519 | |
| 520 | // Index into method_ids of the dex file associated with this method. |
| 521 | uint32_t dex_method_index_; |
| 522 | |
| 523 | /* End of dex file fields. */ |
| 524 | |
| 525 | // Entry within a dispatch table for this method. For static/direct methods the index is into |
| 526 | // the declaringClass.directMethods, for virtual methods the vtable and for interface methods the |
| 527 | // ifTable. |
| 528 | uint32_t method_index_; |
| 529 | |
Hiroshi Yamauchi | 94f7b49 | 2014-07-22 18:08:23 -0700 | [diff] [blame] | 530 | static GcRoot<Class> java_lang_reflect_ArtMethod_; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 531 | |
Mathieu Chartier | 02e2511 | 2013-08-14 16:14:24 -0700 | [diff] [blame] | 532 | private: |
Andreas Gampe | 58a5af8 | 2014-07-31 16:23:49 -0700 | [diff] [blame] | 533 | ObjectArray<ArtMethod>* GetDexCacheResolvedMethods() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 534 | |
| 535 | ObjectArray<Class>* GetDexCacheResolvedTypes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 536 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 537 | friend struct art::ArtMethodOffsets; // for verifying offset information |
| 538 | DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethod); |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 539 | }; |
| 540 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 541 | } // namespace mirror |
| 542 | } // namespace art |
| 543 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 544 | #endif // ART_RUNTIME_MIRROR_ART_METHOD_H_ |