blob: 92b2c306c6c0faea534eee96448d3373057e64a5 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
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 Carlstromea46f952013-07-30 01:26:50 -070017#ifndef ART_RUNTIME_MIRROR_ART_METHOD_H_
18#define ART_RUNTIME_MIRROR_ART_METHOD_H_
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080019
Jeff Hao790ad902013-05-22 15:02:08 -070020#include "dex_file.h"
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070021#include "gc_root.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080022#include "invoke_type.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080023#include "modifiers.h"
24#include "object.h"
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080025#include "object_callbacks.h"
Vladimir Marko7624d252014-05-02 14:40:15 +010026#include "quick/quick_method_frame_info.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070027#include "read_barrier_option.h"
Nicolas Geoffray39468442014-09-02 15:17:15 +010028#include "stack_map.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080029
30namespace art {
31
Brian Carlstromea46f952013-07-30 01:26:50 -070032struct ArtMethodOffsets;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080033struct ConstructorMethodOffsets;
34union JValue;
Jeff Hao790ad902013-05-22 15:02:08 -070035class MethodHelper;
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070036class ScopedObjectAccessAlreadyRunnable;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080037class StringPiece;
Jeff Hao16743632013-05-08 10:59:04 -070038class ShadowFrame;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080039
40namespace mirror {
41
Ian Rogers6f3dbba2014-10-14 17:41:57 -070042typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper* mh,
Jeff Hao790ad902013-05-22 15:02:08 -070043 const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result);
Jeff Hao16743632013-05-08 10:59:04 -070044
Mingyao Yang98d1cc82014-05-15 17:02:16 -070045// C++ mirror of java.lang.reflect.ArtMethod.
46class MANAGED ArtMethod FINAL : public Object {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080047 public:
Mingyao Yang98d1cc82014-05-15 17:02:16 -070048 // Size of java.lang.reflect.ArtMethod.class.
49 static uint32_t ClassSize();
50
51 // Size of an instance of java.lang.reflect.ArtMethod not including its value array.
52 static constexpr uint32_t InstanceSize() {
53 return sizeof(ArtMethod);
54 }
55
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070056 static ArtMethod* FromReflectedMethod(const ScopedObjectAccessAlreadyRunnable& soa,
57 jobject jlr_method)
Ian Rogers62f05122014-03-21 11:21:29 -070058 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
59
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070060 Class* GetDeclaringClass() ALWAYS_INLINE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080061
62 void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
63
64 static MemberOffset DeclaringClassOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -070065 return MemberOffset(OFFSETOF_MEMBER(ArtMethod, declaring_class_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080066 }
67
Mathieu Chartier2d2621a2014-10-23 16:48:06 -070068 ALWAYS_INLINE uint32_t GetAccessFlags() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Jeff Hao5d917302013-02-27 17:57:33 -080069
Ian Rogersef7d42f2014-01-06 12:55:46 -080070 void SetAccessFlags(uint32_t new_access_flags) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010071 // Not called within a transaction.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070072 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), new_access_flags);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080073 }
74
75 // Approximate what kind of method call would be used for this method.
Ian Rogersef7d42f2014-01-06 12:55:46 -080076 InvokeType GetInvokeType() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080077
78 // Returns true if the method is declared public.
Ian Rogersef7d42f2014-01-06 12:55:46 -080079 bool IsPublic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080080 return (GetAccessFlags() & kAccPublic) != 0;
81 }
82
83 // Returns true if the method is declared private.
Ian Rogersef7d42f2014-01-06 12:55:46 -080084 bool IsPrivate() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080085 return (GetAccessFlags() & kAccPrivate) != 0;
86 }
87
88 // Returns true if the method is declared static.
Ian Rogersef7d42f2014-01-06 12:55:46 -080089 bool IsStatic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080090 return (GetAccessFlags() & kAccStatic) != 0;
91 }
92
93 // Returns true if the method is a constructor.
Ian Rogersef7d42f2014-01-06 12:55:46 -080094 bool IsConstructor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080095 return (GetAccessFlags() & kAccConstructor) != 0;
96 }
97
Mathieu Chartierbfd9a432014-05-21 17:43:44 -070098 // Returns true if the method is a class initializer.
99 bool IsClassInitializer() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
100 return IsConstructor() && IsStatic();
101 }
102
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800103 // Returns true if the method is static, private, or a constructor.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800104 bool IsDirect() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800105 return IsDirect(GetAccessFlags());
106 }
107
108 static bool IsDirect(uint32_t access_flags) {
109 return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0;
110 }
111
112 // Returns true if the method is declared synchronized.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800113 bool IsSynchronized() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800114 uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized;
115 return (GetAccessFlags() & synchonized) != 0;
116 }
117
Ian Rogersef7d42f2014-01-06 12:55:46 -0800118 bool IsFinal() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800119 return (GetAccessFlags() & kAccFinal) != 0;
120 }
121
Ian Rogersef7d42f2014-01-06 12:55:46 -0800122 bool IsMiranda() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800123 return (GetAccessFlags() & kAccMiranda) != 0;
124 }
125
Ian Rogersef7d42f2014-01-06 12:55:46 -0800126 bool IsNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800127 return (GetAccessFlags() & kAccNative) != 0;
128 }
129
Ian Rogersef7d42f2014-01-06 12:55:46 -0800130 bool IsFastNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers16ce0922014-01-10 14:59:36 -0800131 uint32_t mask = kAccFastNative | kAccNative;
132 return (GetAccessFlags() & mask) == mask;
Ian Rogers1eb512d2013-10-18 15:42:20 -0700133 }
134
Ian Rogersef7d42f2014-01-06 12:55:46 -0800135 bool IsAbstract() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800136 return (GetAccessFlags() & kAccAbstract) != 0;
137 }
138
Ian Rogersef7d42f2014-01-06 12:55:46 -0800139 bool IsSynthetic() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800140 return (GetAccessFlags() & kAccSynthetic) != 0;
141 }
142
Ian Rogersef7d42f2014-01-06 12:55:46 -0800143 bool IsProxyMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800144
Ian Rogersef7d42f2014-01-06 12:55:46 -0800145 bool IsPreverified() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Sebastien Hertz233ea8e2013-06-06 11:57:09 +0200146 return (GetAccessFlags() & kAccPreverified) != 0;
147 }
148
Ian Rogersef7d42f2014-01-06 12:55:46 -0800149 void SetPreverified() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
150 DCHECK(!IsPreverified());
Sebastien Hertz233ea8e2013-06-06 11:57:09 +0200151 SetAccessFlags(GetAccessFlags() | kAccPreverified);
152 }
153
Nicolas Geoffray39468442014-09-02 15:17:15 +0100154 bool IsOptimized() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
155 // Temporary solution for detecting if a method has been optimized: the compiler
156 // does not create a GC map. Instead, the vmap table contains the stack map
157 // (as in stack_map.h).
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100158 return (GetEntryPointFromQuickCompiledCode() != nullptr)
159 && (GetQuickOatCodePointer() != nullptr)
160 && (GetNativeGcMap() == nullptr);
Nicolas Geoffray39468442014-09-02 15:17:15 +0100161 }
162
Ian Rogersef7d42f2014-01-06 12:55:46 -0800163 bool IsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
164 return (GetAccessFlags() & kAccPortableCompiled) != 0;
165 }
166
167 void SetIsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
168 DCHECK(!IsPortableCompiled());
169 SetAccessFlags(GetAccessFlags() | kAccPortableCompiled);
170 }
171
172 void ClearIsPortableCompiled() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
173 DCHECK(IsPortableCompiled());
174 SetAccessFlags(GetAccessFlags() & ~kAccPortableCompiled);
175 }
176
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800177 bool CheckIncompatibleClassChange(InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
178
Ian Rogersef7d42f2014-01-06 12:55:46 -0800179 uint16_t GetMethodIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800180
Ian Rogersef7d42f2014-01-06 12:55:46 -0800181 size_t GetVtableIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800182 return GetMethodIndex();
183 }
184
Ian Rogersef7d42f2014-01-06 12:55:46 -0800185 void SetMethodIndex(uint16_t new_method_index) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100186 // Not called within a transaction.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700187 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), new_method_index);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800188 }
189
190 static MemberOffset MethodIndexOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700191 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800192 }
193
Ian Rogersef7d42f2014-01-06 12:55:46 -0800194 uint32_t GetCodeItemOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700195 return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_code_item_offset_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800196 }
197
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700198 void SetCodeItemOffset(uint32_t new_code_off) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100199 // Not called within a transaction.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700200 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_code_item_offset_), new_code_off);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800201 }
202
203 // Number of 32bit registers that would be required to hold all the arguments
204 static size_t NumArgRegisters(const StringPiece& shorty);
205
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700206 ALWAYS_INLINE uint32_t GetDexMethodIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800207
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700208 void SetDexMethodIndex(uint32_t new_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100209 // Not called within a transaction.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700210 SetField32<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_method_index_), new_idx);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800211 }
212
Ian Rogersef7d42f2014-01-06 12:55:46 -0800213 ObjectArray<String>* GetDexCacheStrings() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800214 void SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings)
215 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
216
217 static MemberOffset DexCacheStringsOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700218 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800219 }
220
221 static MemberOffset DexCacheResolvedMethodsOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700222 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800223 }
224
225 static MemberOffset DexCacheResolvedTypesOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700226 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800227 }
228
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700229 ALWAYS_INLINE ArtMethod* GetDexCacheResolvedMethod(uint16_t method_idx)
Andreas Gampe58a5af82014-07-31 16:23:49 -0700230 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700231 ALWAYS_INLINE void SetDexCacheResolvedMethod(uint16_t method_idx, ArtMethod* new_method)
Andreas Gampe58a5af82014-07-31 16:23:49 -0700232 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700233 ALWAYS_INLINE void SetDexCacheResolvedMethods(ObjectArray<ArtMethod>* new_dex_cache_methods)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800234 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe58a5af82014-07-31 16:23:49 -0700235 bool HasDexCacheResolvedMethods() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
236 bool HasSameDexCacheResolvedMethods(ArtMethod* other) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
237 bool HasSameDexCacheResolvedMethods(ObjectArray<ArtMethod>* other_cache)
238 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800239
Andreas Gampe58a5af82014-07-31 16:23:49 -0700240 template <bool kWithCheck = true>
241 Class* GetDexCacheResolvedType(uint32_t type_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800242 void SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_types)
243 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe58a5af82014-07-31 16:23:49 -0700244 bool HasDexCacheResolvedTypes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
245 bool HasSameDexCacheResolvedTypes(ArtMethod* other) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
246 bool HasSameDexCacheResolvedTypes(ObjectArray<Class>* other_cache)
247 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800248
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800249 // Find the method that this method overrides
Ian Rogersef7d42f2014-01-06 12:55:46 -0800250 ArtMethod* FindOverriddenMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800251
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700252 void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, const char* shorty)
253 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800254
Mathieu Chartier4e305412014-02-19 10:54:44 -0800255 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700256 EntryPointFromInterpreter* GetEntryPointFromInterpreter()
257 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800258 return GetFieldPtr<EntryPointFromInterpreter*, kVerifyFlags>(
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700259 OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_));
Jeff Hao16743632013-05-08 10:59:04 -0700260 }
261
Mathieu Chartier4e305412014-02-19 10:54:44 -0800262 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700263 void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter)
264 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800265 SetFieldPtr<false, true, kVerifyFlags>(
266 OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_),
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700267 entry_point_from_interpreter);
Jeff Hao16743632013-05-08 10:59:04 -0700268 }
269
Ian Rogersef7d42f2014-01-06 12:55:46 -0800270 static MemberOffset EntryPointFromPortableCompiledCodeOffset() {
271 return MemberOffset(OFFSETOF_MEMBER(ArtMethod, entry_point_from_portable_compiled_code_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800272 }
273
Mathieu Chartier4e305412014-02-19 10:54:44 -0800274 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700275 const void* GetEntryPointFromPortableCompiledCode() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800276 return GetFieldPtr<const void*, kVerifyFlags>(
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700277 EntryPointFromPortableCompiledCodeOffset());
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800278 }
279
Mathieu Chartier4e305412014-02-19 10:54:44 -0800280 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700281 void SetEntryPointFromPortableCompiledCode(const void* entry_point_from_portable_compiled_code)
282 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800283 SetFieldPtr<false, true, kVerifyFlags>(
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700284 EntryPointFromPortableCompiledCodeOffset(), entry_point_from_portable_compiled_code);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800285 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800286
Ian Rogersef7d42f2014-01-06 12:55:46 -0800287 static MemberOffset EntryPointFromQuickCompiledCodeOffset() {
288 return MemberOffset(OFFSETOF_MEMBER(ArtMethod, entry_point_from_quick_compiled_code_));
289 }
290
Mathieu Chartier4e305412014-02-19 10:54:44 -0800291 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700292 const void* GetEntryPointFromQuickCompiledCode() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
293 return GetFieldPtr<const void*, kVerifyFlags>(EntryPointFromQuickCompiledCodeOffset());
Ian Rogersef7d42f2014-01-06 12:55:46 -0800294 }
295
Mathieu Chartier4e305412014-02-19 10:54:44 -0800296 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700297 void SetEntryPointFromQuickCompiledCode(const void* entry_point_from_quick_compiled_code)
298 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800299 SetFieldPtr<false, true, kVerifyFlags>(
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700300 EntryPointFromQuickCompiledCodeOffset(), entry_point_from_quick_compiled_code);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800301 }
302
Ian Rogersef7d42f2014-01-06 12:55:46 -0800303 uint32_t GetCodeSize() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
304
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700305 // Check whether the given PC is within the quick compiled code associated with this method's
306 // quick entrypoint. This code isn't robust for instrumentation, etc. and is only used for
307 // debug purposes.
308 bool PcIsWithinQuickCode(uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800309 uintptr_t code = reinterpret_cast<uintptr_t>(GetEntryPointFromQuickCompiledCode());
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800310 if (code == 0) {
311 return pc == 0;
312 }
313 /*
Vladimir Marko96c6ab92014-04-08 14:00:50 +0100314 * During a stack walk, a return PC may point past-the-end of the code
315 * in the case that the last instruction is a call that isn't expected to
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800316 * return. Thus, we check <= code + GetCodeSize().
Vladimir Marko96c6ab92014-04-08 14:00:50 +0100317 *
318 * NOTE: For Thumb both pc and code are offset by 1 indicating the Thumb state.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800319 */
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700320 return code <= pc && pc <= code + GetCodeSize();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800321 }
322
Ian Rogersef7d42f2014-01-06 12:55:46 -0800323 void AssertPcIsWithinQuickCode(uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800324
Hiroshi Yamauchi9bdec882014-08-15 17:11:12 -0700325 // Returns true if the entrypoint points to the interpreter, as
326 // opposed to the compiled code, that is, this method will be
327 // interpretered on invocation.
328 bool IsEntrypointInterpreter() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
329
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700330 uint32_t GetQuickOatCodeOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
331 uint32_t GetPortableOatCodeOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
332 void SetQuickOatCodeOffset(uint32_t code_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
333 void SetPortableOatCodeOffset(uint32_t code_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800334
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700335 ALWAYS_INLINE static const void* EntryPointToCodePointer(const void* entry_point) {
Vladimir Marko8a630572014-04-09 18:45:35 +0100336 uintptr_t code = reinterpret_cast<uintptr_t>(entry_point);
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700337 // TODO: Make this Thumb2 specific. It is benign on other architectures as code is always at
338 // least 2 byte aligned.
339 code &= ~0x1;
Vladimir Marko8a630572014-04-09 18:45:35 +0100340 return reinterpret_cast<const void*>(code);
341 }
342
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700343 // Actual entry point pointer to compiled oat code or nullptr if method has no compiled code.
Vladimir Marko4c1c5102014-05-14 16:51:16 +0100344 const void* GetQuickOatEntryPoint() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700345
Vladimir Marko8a630572014-04-09 18:45:35 +0100346 // Actual pointer to compiled oat code or nullptr.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700347 const void* GetQuickOatCodePointer() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
348 return EntryPointToCodePointer(GetQuickOatEntryPoint());
349 }
Vladimir Marko8a630572014-04-09 18:45:35 +0100350
Ian Rogers1809a722013-08-09 22:05:32 -0700351 // Callers should wrap the uint8_t* in a MappingTable instance for convenient access.
Vladimir Marko8a630572014-04-09 18:45:35 +0100352 const uint8_t* GetMappingTable() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Vladimir Marko4c1c5102014-05-14 16:51:16 +0100353 const uint8_t* GetMappingTable(const void* code_pointer)
354 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800355
Ian Rogers1809a722013-08-09 22:05:32 -0700356 // Callers should wrap the uint8_t* in a VmapTable instance for convenient access.
Vladimir Marko8a630572014-04-09 18:45:35 +0100357 const uint8_t* GetVmapTable() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Vladimir Marko4c1c5102014-05-14 16:51:16 +0100358 const uint8_t* GetVmapTable(const void* code_pointer)
359 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800360
Nicolas Geoffray39468442014-09-02 15:17:15 +0100361 StackMap GetStackMap(uint32_t native_pc_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Nicolas Geoffraye982f0b2014-08-13 02:11:24 +0100362 CodeInfo GetOptimizedCodeInfo() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Nicolas Geoffray39468442014-09-02 15:17:15 +0100363
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700364 const uint8_t* GetNativeGcMap() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
365 return GetFieldPtr<uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800366 }
Mathieu Chartier4e305412014-02-19 10:54:44 -0800367 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700368 void SetNativeGcMap(const uint8_t* data) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
369 SetFieldPtr<false, true, kVerifyFlags>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), data);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800370 }
371
372 // When building the oat need a convenient place to stuff the offset of the native GC map.
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700373 void SetOatNativeGcMapOffset(uint32_t gc_map_offset) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
374 uint32_t GetOatNativeGcMapOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800375
Andreas Gampe90546832014-03-12 18:07:19 -0700376 template <bool kCheckFrameSize = true>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700377 uint32_t GetFrameSizeInBytes() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Vladimir Marko7624d252014-05-02 14:40:15 +0100378 uint32_t result = GetQuickFrameInfo().FrameSizeInBytes();
Andreas Gampe90546832014-03-12 18:07:19 -0700379 if (kCheckFrameSize) {
380 DCHECK_LE(static_cast<size_t>(kStackAlignment), result);
381 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800382 return result;
383 }
384
Vladimir Marko7624d252014-05-02 14:40:15 +0100385 QuickMethodFrameInfo GetQuickFrameInfo() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Vladimir Marko4c1c5102014-05-14 16:51:16 +0100386 QuickMethodFrameInfo GetQuickFrameInfo(const void* code_pointer)
387 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800388
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700389 FrameOffset GetReturnPcOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
390 return GetReturnPcOffset(GetFrameSizeInBytes());
Vladimir Marko4c1c5102014-05-14 16:51:16 +0100391 }
392
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700393 FrameOffset GetReturnPcOffset(uint32_t frame_size_in_bytes)
Vladimir Marko4c1c5102014-05-14 16:51:16 +0100394 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
395 DCHECK_EQ(frame_size_in_bytes, GetFrameSizeInBytes());
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700396 return FrameOffset(frame_size_in_bytes - sizeof(void*));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800397 }
398
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700399 FrameOffset GetHandleScopeOffset() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
400 DCHECK_LT(sizeof(void*), GetFrameSizeInBytes());
401 return FrameOffset(sizeof(void*));
Ian Rogers62d6c772013-02-27 08:32:07 -0800402 }
403
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700404 void RegisterNative(const void* native_method, bool is_fast)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800405 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
406
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700407 void UnregisterNative() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800408
409 static MemberOffset NativeMethodOffset() {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800410 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_jni_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800411 }
412
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700413 const void* GetNativeMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
414 return GetFieldPtr<const void*>(NativeMethodOffset());
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800415 }
416
Mathieu Chartier4e305412014-02-19 10:54:44 -0800417 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersb0fa5dc2014-04-28 16:47:08 -0700418 void SetNativeMethod(const void*) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800419
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800420 static MemberOffset GetMethodIndexOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700421 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800422 }
423
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800424 // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal
425 // conventions for a method of managed code. Returns false for Proxy methods.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800426 bool IsRuntimeMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800427
428 // Is this a hand crafted method used for something like describing callee saves?
Ian Rogersef7d42f2014-01-06 12:55:46 -0800429 bool IsCalleeSaveMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800430
Ian Rogersef7d42f2014-01-06 12:55:46 -0800431 bool IsResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800432
Ian Rogersef7d42f2014-01-06 12:55:46 -0800433 bool IsImtConflictMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Jeff Hao88474b42013-10-23 16:24:40 -0700434
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700435 bool IsImtUnimplementedMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
436
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700437 uintptr_t NativeQuickPcOffset(const uintptr_t pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
438#ifdef NDEBUG
439 uintptr_t NativeQuickPcOffset(const uintptr_t pc, const void* quick_entry_point)
440 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
441 return pc - reinterpret_cast<uintptr_t>(quick_entry_point);
442 }
443#else
444 uintptr_t NativeQuickPcOffset(const uintptr_t pc, const void* quick_entry_point)
Vladimir Marko4c1c5102014-05-14 16:51:16 +0100445 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700446#endif
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800447
448 // Converts a native PC to a dex PC.
Dave Allisonb373e092014-02-20 16:06:36 -0800449 uint32_t ToDexPc(const uintptr_t pc, bool abort_on_failure = true)
450 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800451
452 // Converts a dex PC to a native PC.
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700453 uintptr_t ToNativeQuickPc(const uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800454
Ian Rogersc449aa82013-07-29 14:35:46 -0700455 // Find the catch block for the given exception type and dex_pc. When a catch block is found,
456 // indicates whether the found catch block is responsible for clearing the exception or whether
457 // a move-exception instruction is present.
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700458 static uint32_t FindCatchBlock(Handle<ArtMethod> h_this, Handle<Class> exception_type,
459 uint32_t dex_pc, bool* has_no_move_exception)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800460 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
461
Brian Carlstromea46f952013-07-30 01:26:50 -0700462 static void SetClass(Class* java_lang_reflect_ArtMethod);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800463
Hiroshi Yamauchi4f1ebc22014-06-25 14:30:41 -0700464 template<ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700465 static Class* GetJavaLangReflectArtMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800466
Brian Carlstromea46f952013-07-30 01:26:50 -0700467 static void ResetClass();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800468
Mathieu Chartier83c8ee02014-01-28 14:50:23 -0800469 static void VisitRoots(RootCallback* callback, void* arg)
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800470 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
471
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700472 const DexFile* GetDexFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700473
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700474 const char* GetDeclaringClassDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700475
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700476 const char* GetShorty() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
477 uint32_t unused_length;
478 return GetShorty(&unused_length);
479 }
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700480
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700481 const char* GetShorty(uint32_t* out_length) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700482
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700483 const Signature GetSignature() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700484
Ian Rogers1ff3c982014-08-12 02:30:58 -0700485 ALWAYS_INLINE const char* GetName() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700486
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700487 const DexFile::CodeItem* GetCodeItem() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700488
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700489 bool IsResolvedTypeIdx(uint16_t type_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700490
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700491 int32_t GetLineNumFromDexPC(uint32_t dex_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700492
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700493 const DexFile::ProtoId& GetPrototype() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700494
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700495 const DexFile::TypeList* GetParameterTypeList() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700496
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700497 const char* GetDeclaringClassSourceFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700498
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700499 uint16_t GetClassDefIndex() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700500
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700501 const DexFile::ClassDef& GetClassDef() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700502
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700503 const char* GetReturnTypeDescriptor() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700504
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700505 const char* GetTypeDescriptorFromTypeIdx(uint16_t type_idx)
506 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700507
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700508 mirror::ClassLoader* GetClassLoader() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700509
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700510 mirror::DexCache* GetDexCache() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700511
Ian Rogers1ff3c982014-08-12 02:30:58 -0700512 ALWAYS_INLINE ArtMethod* GetInterfaceMethodIfProxy() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700513
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800514 protected:
515 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
Ian Rogersef7d42f2014-01-06 12:55:46 -0800516 // The class we are a part of.
517 HeapReference<Class> declaring_class_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800518
Ian Rogersef7d42f2014-01-06 12:55:46 -0800519 // Short cuts to declaring_class_->dex_cache_ member for fast compiled code access.
Ian Rogers700a4022014-05-19 16:49:03 -0700520 HeapReference<ObjectArray<ArtMethod>> dex_cache_resolved_methods_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800521
Ian Rogersef7d42f2014-01-06 12:55:46 -0800522 // Short cuts to declaring_class_->dex_cache_ member for fast compiled code access.
Ian Rogers700a4022014-05-19 16:49:03 -0700523 HeapReference<ObjectArray<Class>> dex_cache_resolved_types_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800524
Ian Rogersef7d42f2014-01-06 12:55:46 -0800525 // Short cuts to declaring_class_->dex_cache_ member for fast compiled code access.
Ian Rogers700a4022014-05-19 16:49:03 -0700526 HeapReference<ObjectArray<String>> dex_cache_strings_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800527
Ian Rogersef7d42f2014-01-06 12:55:46 -0800528 // Method dispatch from the interpreter invokes this pointer which may cause a bridge into
529 // compiled code.
530 uint64_t entry_point_from_interpreter_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800531
Ian Rogersef7d42f2014-01-06 12:55:46 -0800532 // Pointer to JNI function registered to this method, or a function to resolve the JNI function.
533 uint64_t entry_point_from_jni_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800534
Ian Rogersef7d42f2014-01-06 12:55:46 -0800535 // Method dispatch from portable compiled code invokes this pointer which may cause bridging into
536 // quick compiled code or the interpreter.
537 uint64_t entry_point_from_portable_compiled_code_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800538
Ian Rogersef7d42f2014-01-06 12:55:46 -0800539 // Method dispatch from quick compiled code invokes this pointer which may cause bridging into
540 // portable compiled code or the interpreter.
541 uint64_t entry_point_from_quick_compiled_code_;
Jeff Haoaa4a7932013-05-13 11:28:27 -0700542
Ian Rogersef7d42f2014-01-06 12:55:46 -0800543 // Pointer to a data structure created by the compiler and used by the garbage collector to
544 // determine which registers hold live references to objects within the heap. Keyed by native PC
545 // offsets for the quick compiler and dex PCs for the portable.
546 uint64_t gc_map_;
Jeff Hao16743632013-05-08 10:59:04 -0700547
Ian Rogersef7d42f2014-01-06 12:55:46 -0800548 // Access flags; low 16 bits are defined by spec.
549 uint32_t access_flags_;
550
551 /* Dex file fields. The defining dex file is available via declaring_class_->dex_cache_ */
552
553 // Offset to the CodeItem.
554 uint32_t dex_code_item_offset_;
555
556 // Index into method_ids of the dex file associated with this method.
557 uint32_t dex_method_index_;
558
559 /* End of dex file fields. */
560
561 // Entry within a dispatch table for this method. For static/direct methods the index is into
562 // the declaringClass.directMethods, for virtual methods the vtable and for interface methods the
563 // ifTable.
564 uint32_t method_index_;
565
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -0700566 static GcRoot<Class> java_lang_reflect_ArtMethod_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800567
Mathieu Chartier02e25112013-08-14 16:14:24 -0700568 private:
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700569 ALWAYS_INLINE ObjectArray<ArtMethod>* GetDexCacheResolvedMethods()
570 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe58a5af82014-07-31 16:23:49 -0700571
Mathieu Chartier2d2621a2014-10-23 16:48:06 -0700572 ALWAYS_INLINE ObjectArray<Class>* GetDexCacheResolvedTypes()
573 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Andreas Gampe58a5af82014-07-31 16:23:49 -0700574
Brian Carlstromea46f952013-07-30 01:26:50 -0700575 friend struct art::ArtMethodOffsets; // for verifying offset information
576 DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethod);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800577};
578
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800579} // namespace mirror
580} // namespace art
581
Brian Carlstromea46f952013-07-30 01:26:50 -0700582#endif // ART_RUNTIME_MIRROR_ART_METHOD_H_