blob: 963b4d554b61e97c02fbbe061025cd411122ab5d [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
20#include "class.h"
Jeff Hao790ad902013-05-22 15:02:08 -070021#include "dex_file.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080022#include "invoke_type.h"
23#include "locks.h"
24#include "modifiers.h"
25#include "object.h"
Mathieu Chartierc528dba2013-11-26 12:00:11 -080026#include "root_visitor.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080027
28namespace art {
29
Brian Carlstromea46f952013-07-30 01:26:50 -070030struct ArtMethodOffsets;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031struct ConstructorMethodOffsets;
32union JValue;
33struct MethodClassOffsets;
Jeff Hao790ad902013-05-22 15:02:08 -070034class MethodHelper;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080035class StringPiece;
Jeff Hao16743632013-05-08 10:59:04 -070036class ShadowFrame;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080037
38namespace mirror {
39
40class StaticStorageBase;
41
Jeff Hao790ad902013-05-22 15:02:08 -070042typedef void (EntryPointFromInterpreter)(Thread* self, MethodHelper& mh,
43 const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, JValue* result);
Jeff Hao16743632013-05-08 10:59:04 -070044
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080045// C++ mirror of java.lang.reflect.Method and java.lang.reflect.Constructor
Brian Carlstromea46f952013-07-30 01:26:50 -070046class MANAGED ArtMethod : public Object {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080047 public:
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080048 Class* GetDeclaringClass() const;
49
50 void SetDeclaringClass(Class *new_declaring_class) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
51
52 static MemberOffset DeclaringClassOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -070053 return MemberOffset(OFFSETOF_MEMBER(ArtMethod, declaring_class_));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080054 }
55
Jeff Haoaa4a7932013-05-13 11:28:27 -070056 static MemberOffset EntryPointFromCompiledCodeOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -070057 return MemberOffset(OFFSETOF_MEMBER(ArtMethod, entry_point_from_compiled_code_));
Jeff Hao5d917302013-02-27 17:57:33 -080058 }
59
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080060 uint32_t GetAccessFlags() const;
61
62 void SetAccessFlags(uint32_t new_access_flags) {
Brian Carlstromea46f952013-07-30 01:26:50 -070063 SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, access_flags_), new_access_flags, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080064 }
65
66 // Approximate what kind of method call would be used for this method.
67 InvokeType GetInvokeType() const;
68
69 // Returns true if the method is declared public.
70 bool IsPublic() const {
71 return (GetAccessFlags() & kAccPublic) != 0;
72 }
73
74 // Returns true if the method is declared private.
75 bool IsPrivate() const {
76 return (GetAccessFlags() & kAccPrivate) != 0;
77 }
78
79 // Returns true if the method is declared static.
80 bool IsStatic() const {
81 return (GetAccessFlags() & kAccStatic) != 0;
82 }
83
84 // Returns true if the method is a constructor.
85 bool IsConstructor() const {
86 return (GetAccessFlags() & kAccConstructor) != 0;
87 }
88
89 // Returns true if the method is static, private, or a constructor.
90 bool IsDirect() const {
91 return IsDirect(GetAccessFlags());
92 }
93
94 static bool IsDirect(uint32_t access_flags) {
95 return (access_flags & (kAccStatic | kAccPrivate | kAccConstructor)) != 0;
96 }
97
98 // Returns true if the method is declared synchronized.
99 bool IsSynchronized() const {
100 uint32_t synchonized = kAccSynchronized | kAccDeclaredSynchronized;
101 return (GetAccessFlags() & synchonized) != 0;
102 }
103
104 bool IsFinal() const {
105 return (GetAccessFlags() & kAccFinal) != 0;
106 }
107
108 bool IsMiranda() const {
109 return (GetAccessFlags() & kAccMiranda) != 0;
110 }
111
112 bool IsNative() const {
113 return (GetAccessFlags() & kAccNative) != 0;
114 }
115
Ian Rogers1eb512d2013-10-18 15:42:20 -0700116 bool IsFastNative() const {
117 return (GetAccessFlags() & kAccFastNative) != 0;
118 }
119
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800120 bool IsAbstract() const {
121 return (GetAccessFlags() & kAccAbstract) != 0;
122 }
123
124 bool IsSynthetic() const {
125 return (GetAccessFlags() & kAccSynthetic) != 0;
126 }
127
128 bool IsProxyMethod() const;
129
Sebastien Hertz233ea8e2013-06-06 11:57:09 +0200130 bool IsPreverified() const {
131 return (GetAccessFlags() & kAccPreverified) != 0;
132 }
133
134 void SetPreverified() {
135 SetAccessFlags(GetAccessFlags() | kAccPreverified);
136 }
137
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800138 bool CheckIncompatibleClassChange(InvokeType type) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
139
140 uint16_t GetMethodIndex() const;
141
142 size_t GetVtableIndex() const {
143 return GetMethodIndex();
144 }
145
146 void SetMethodIndex(uint16_t new_method_index) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700147 SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_), new_method_index, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800148 }
149
150 static MemberOffset MethodIndexOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700151 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800152 }
153
154 uint32_t GetCodeItemOffset() const {
Brian Carlstromea46f952013-07-30 01:26:50 -0700155 return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, code_item_offset_), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800156 }
157
158 void SetCodeItemOffset(uint32_t new_code_off) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700159 SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, code_item_offset_), new_code_off, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800160 }
161
162 // Number of 32bit registers that would be required to hold all the arguments
163 static size_t NumArgRegisters(const StringPiece& shorty);
164
165 uint32_t GetDexMethodIndex() const;
166
167 void SetDexMethodIndex(uint32_t new_idx) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700168 SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_dex_index_), new_idx, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800169 }
170
171 ObjectArray<String>* GetDexCacheStrings() const;
172 void SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings)
173 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
174
175 static MemberOffset DexCacheStringsOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700176 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800177 }
178
179 static MemberOffset DexCacheResolvedMethodsOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700180 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800181 }
182
183 static MemberOffset DexCacheResolvedTypesOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700184 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800185 }
186
Brian Carlstromea46f952013-07-30 01:26:50 -0700187 ObjectArray<ArtMethod>* GetDexCacheResolvedMethods() const;
188 void SetDexCacheResolvedMethods(ObjectArray<ArtMethod>* new_dex_cache_methods)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800189 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
190
191 ObjectArray<Class>* GetDexCacheResolvedTypes() const;
192 void SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_types)
193 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
194
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800195 // Find the method that this method overrides
Brian Carlstromea46f952013-07-30 01:26:50 -0700196 ArtMethod* FindOverriddenMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800197
Jeff Hao6474d192013-03-26 14:08:09 -0700198 void Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result, char result_type)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800199 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
200
Jeff Hao16743632013-05-08 10:59:04 -0700201 EntryPointFromInterpreter* GetEntryPointFromInterpreter() const {
Brian Carlstromea46f952013-07-30 01:26:50 -0700202 return GetFieldPtr<EntryPointFromInterpreter*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), false);
Jeff Hao16743632013-05-08 10:59:04 -0700203 }
204
205 void SetEntryPointFromInterpreter(EntryPointFromInterpreter* entry_point_from_interpreter) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700206 SetFieldPtr<EntryPointFromInterpreter*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_interpreter_), entry_point_from_interpreter, false);
Jeff Hao16743632013-05-08 10:59:04 -0700207 }
208
Jeff Haoaa4a7932013-05-13 11:28:27 -0700209 const void* GetEntryPointFromCompiledCode() const {
Brian Carlstromea46f952013-07-30 01:26:50 -0700210 return GetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800211 }
212
Jeff Haoaa4a7932013-05-13 11:28:27 -0700213 void SetEntryPointFromCompiledCode(const void* entry_point_from_compiled_code) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700214 SetFieldPtr<const void*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_), entry_point_from_compiled_code, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800215 }
216
217 uint32_t GetCodeSize() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
218
219 bool IsWithinCode(uintptr_t pc) const
220 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Jeff Haoaa4a7932013-05-13 11:28:27 -0700221 uintptr_t code = reinterpret_cast<uintptr_t>(GetEntryPointFromCompiledCode());
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800222 if (code == 0) {
223 return pc == 0;
224 }
225 /*
226 * During a stack walk, a return PC may point to the end of the code + 1
227 * (in the case that the last instruction is a call that isn't expected to
228 * return. Thus, we check <= code + GetCodeSize().
229 */
230 return (code <= pc && pc <= code + GetCodeSize());
231 }
232
233 void AssertPcIsWithinCode(uintptr_t pc) const
234 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
235
236 uint32_t GetOatCodeOffset() const;
237
238 void SetOatCodeOffset(uint32_t code_offset);
239
Jeff Haoaa4a7932013-05-13 11:28:27 -0700240 static MemberOffset GetEntryPointFromCompiledCodeOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700241 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_compiled_code_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800242 }
243
Ian Rogers1809a722013-08-09 22:05:32 -0700244 // Callers should wrap the uint8_t* in a MappingTable instance for convenient access.
245 const uint8_t* GetMappingTable() const {
Brian Carlstromea46f952013-07-30 01:26:50 -0700246 return GetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, mapping_table_), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800247 }
248
Ian Rogers1809a722013-08-09 22:05:32 -0700249 void SetMappingTable(const uint8_t* mapping_table) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700250 SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, mapping_table_),
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800251 mapping_table, false);
252 }
253
254 uint32_t GetOatMappingTableOffset() const;
255
256 void SetOatMappingTableOffset(uint32_t mapping_table_offset);
257
Ian Rogers1809a722013-08-09 22:05:32 -0700258 // Callers should wrap the uint8_t* in a VmapTable instance for convenient access.
259 const uint8_t* GetVmapTable() const {
Brian Carlstromea46f952013-07-30 01:26:50 -0700260 return GetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, vmap_table_), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800261 }
262
Ian Rogers1809a722013-08-09 22:05:32 -0700263 void SetVmapTable(const uint8_t* vmap_table) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700264 SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, vmap_table_), vmap_table, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800265 }
266
267 uint32_t GetOatVmapTableOffset() const;
268
269 void SetOatVmapTableOffset(uint32_t vmap_table_offset);
270
271 const uint8_t* GetNativeGcMap() const {
Brian Carlstromea46f952013-07-30 01:26:50 -0700272 return GetFieldPtr<uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800273 }
274 void SetNativeGcMap(const uint8_t* data) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700275 SetFieldPtr<const uint8_t*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_), data, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800276 }
277
278 // When building the oat need a convenient place to stuff the offset of the native GC map.
279 void SetOatNativeGcMapOffset(uint32_t gc_map_offset);
280 uint32_t GetOatNativeGcMapOffset() const;
281
282 size_t GetFrameSizeInBytes() const {
283 DCHECK_EQ(sizeof(size_t), sizeof(uint32_t));
Brian Carlstromea46f952013-07-30 01:26:50 -0700284 size_t result = GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, frame_size_in_bytes_), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800285 DCHECK_LE(static_cast<size_t>(kStackAlignment), result);
286 return result;
287 }
288
289 void SetFrameSizeInBytes(size_t new_frame_size_in_bytes) {
290 DCHECK_EQ(sizeof(size_t), sizeof(uint32_t));
Brian Carlstromea46f952013-07-30 01:26:50 -0700291 SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, frame_size_in_bytes_),
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800292 new_frame_size_in_bytes, false);
293 }
294
295 size_t GetReturnPcOffsetInBytes() const {
296 return GetFrameSizeInBytes() - kPointerSize;
297 }
298
Ian Rogers62d6c772013-02-27 08:32:07 -0800299 size_t GetSirtOffsetInBytes() const {
300 CHECK(IsNative());
301 return kPointerSize;
302 }
303
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800304 bool IsRegistered() const;
305
Ian Rogers1eb512d2013-10-18 15:42:20 -0700306 void RegisterNative(Thread* self, const void* native_method, bool is_fast)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800307 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
308
309 void UnregisterNative(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
310
311 static MemberOffset NativeMethodOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700312 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, native_method_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800313 }
314
315 const void* GetNativeMethod() const {
316 return reinterpret_cast<const void*>(GetField32(NativeMethodOffset(), false));
317 }
318
319 void SetNativeMethod(const void*);
320
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800321 static MemberOffset GetMethodIndexOffset() {
Brian Carlstromea46f952013-07-30 01:26:50 -0700322 return OFFSET_OF_OBJECT_MEMBER(ArtMethod, method_index_);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800323 }
324
325 uint32_t GetCoreSpillMask() const {
Brian Carlstromea46f952013-07-30 01:26:50 -0700326 return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, core_spill_mask_), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800327 }
328
329 void SetCoreSpillMask(uint32_t core_spill_mask) {
330 // Computed during compilation
Brian Carlstromea46f952013-07-30 01:26:50 -0700331 SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, core_spill_mask_), core_spill_mask, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800332 }
333
334 uint32_t GetFpSpillMask() const {
Brian Carlstromea46f952013-07-30 01:26:50 -0700335 return GetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, fp_spill_mask_), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800336 }
337
338 void SetFpSpillMask(uint32_t fp_spill_mask) {
339 // Computed during compilation
Brian Carlstromea46f952013-07-30 01:26:50 -0700340 SetField32(OFFSET_OF_OBJECT_MEMBER(ArtMethod, fp_spill_mask_), fp_spill_mask, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800341 }
342
343 // Is this a CalleSaveMethod or ResolutionMethod and therefore doesn't adhere to normal
344 // conventions for a method of managed code. Returns false for Proxy methods.
345 bool IsRuntimeMethod() const;
346
347 // Is this a hand crafted method used for something like describing callee saves?
348 bool IsCalleeSaveMethod() const;
349
350 bool IsResolutionMethod() const;
351
Jeff Hao88474b42013-10-23 16:24:40 -0700352 bool IsImtConflictMethod() const;
353
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800354 uintptr_t NativePcOffset(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
355
356 // Converts a native PC to a dex PC.
357 uint32_t ToDexPc(const uintptr_t pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
358
359 // Converts a dex PC to a native PC.
360 uintptr_t ToNativePc(const uint32_t dex_pc) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
361
Ian Rogersc449aa82013-07-29 14:35:46 -0700362 // Find the catch block for the given exception type and dex_pc. When a catch block is found,
363 // indicates whether the found catch block is responsible for clearing the exception or whether
364 // a move-exception instruction is present.
365 uint32_t FindCatchBlock(Class* exception_type, uint32_t dex_pc, bool* has_no_move_exception) const
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800366 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
367
Brian Carlstromea46f952013-07-30 01:26:50 -0700368 static void SetClass(Class* java_lang_reflect_ArtMethod);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800369
Brian Carlstromea46f952013-07-30 01:26:50 -0700370 static Class* GetJavaLangReflectArtMethod() {
371 return java_lang_reflect_ArtMethod_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800372 }
373
Brian Carlstromea46f952013-07-30 01:26:50 -0700374 static void ResetClass();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800375
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800376 static void VisitRoots(RootVisitor* visitor, void* arg)
377 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
378
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800379 protected:
380 // Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
381 // The class we are a part of
382 Class* declaring_class_;
383
384 // short cuts to declaring_class_->dex_cache_ member for fast compiled code access
Brian Carlstromea46f952013-07-30 01:26:50 -0700385 ObjectArray<ArtMethod>* dex_cache_resolved_methods_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800386
387 // short cuts to declaring_class_->dex_cache_ member for fast compiled code access
388 ObjectArray<Class>* dex_cache_resolved_types_;
389
390 // short cuts to declaring_class_->dex_cache_ member for fast compiled code access
391 ObjectArray<String>* dex_cache_strings_;
392
393 // Access flags; low 16 bits are defined by spec.
394 uint32_t access_flags_;
395
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800396 // Offset to the CodeItem.
397 uint32_t code_item_offset_;
398
399 // Architecture-dependent register spill mask
400 uint32_t core_spill_mask_;
401
Jeff Haoaa4a7932013-05-13 11:28:27 -0700402 // Compiled code associated with this method for callers from managed code.
403 // May be compiled managed code or a bridge for invoking a native method.
404 // TODO: Break apart this into portable and quick.
405 const void* entry_point_from_compiled_code_;
406
Jeff Hao16743632013-05-08 10:59:04 -0700407 // Called by the interpreter to execute this method.
408 EntryPointFromInterpreter* entry_point_from_interpreter_;
409
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800410 // Architecture-dependent register spill mask
411 uint32_t fp_spill_mask_;
412
413 // Total size in bytes of the frame
414 size_t frame_size_in_bytes_;
415
Jeff Hao16743632013-05-08 10:59:04 -0700416 // Garbage collection map of native PC offsets (quick) or dex PCs (portable) to reference bitmaps.
417 const uint8_t* gc_map_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800418
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800419 // Mapping from native pc to dex pc
420 const uint32_t* mapping_table_;
421
422 // Index into method_ids of the dex file associated with this method
423 uint32_t method_dex_index_;
424
425 // For concrete virtual methods, this is the offset of the method in Class::vtable_.
426 //
427 // For abstract methods in an interface class, this is the offset of the method in
428 // "iftable_->Get(n)->GetMethodArray()".
429 //
430 // For static and direct methods this is the index in the direct methods table.
431 uint32_t method_index_;
432
433 // The target native method registered with this method
434 const void* native_method_;
435
436 // When a register is promoted into a register, the spill mask holds which registers hold dex
437 // registers. The first promoted register's corresponding dex register is vmap_table_[1], the Nth
438 // is vmap_table_[N]. vmap_table_[0] holds the length of the table.
439 const uint16_t* vmap_table_;
440
Brian Carlstromea46f952013-07-30 01:26:50 -0700441 static Class* java_lang_reflect_ArtMethod_;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800442
Mathieu Chartier02e25112013-08-14 16:14:24 -0700443 private:
Brian Carlstromea46f952013-07-30 01:26:50 -0700444 friend struct art::ArtMethodOffsets; // for verifying offset information
445 DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethod);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800446};
447
Brian Carlstromea46f952013-07-30 01:26:50 -0700448class MANAGED ArtMethodClass : public Class {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800449 private:
Brian Carlstromea46f952013-07-30 01:26:50 -0700450 DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethodClass);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800451};
452
453} // namespace mirror
454} // namespace art
455
Brian Carlstromea46f952013-07-30 01:26:50 -0700456#endif // ART_RUNTIME_MIRROR_ART_METHOD_H_