CACAO
method.hpp
Go to the documentation of this file.
1 /* src/vm/method.hpp - method functions header
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 
26 #ifndef METHOD_HPP_
27 #define METHOD_HPP_ 1
28 
29 #include "config.h" // for ENABLE_JAVASE, etc
30 
31 #include <stdint.h> // for uint16_t, int32_t
32 
33 #include "vm/global.hpp" // for java_handle_bytearray_t, etc
34 #include "vm/references.hpp" // for classref_or_classinfo
35 #include "vm/types.hpp" // for s4, u2, u1
36 #include "vm/utf8.hpp" // for Utf8String
37 
38 class BreakpointTable;
39 class Mutex;
40 struct builtintable_entry;
41 struct classbuffer;
42 struct classinfo;
43 struct codeinfo;
44 struct lineinfo;
45 struct localvarinfo;
46 struct method_assumption;
47 struct method_worklist;
48 struct methoddesc;
49 struct methodinfo;
50 struct raw_exception_entry;
51 struct stack_map_t;
52 struct vftbl_t;
53 
54 namespace cacao {
55  struct ClassBuffer;
56  struct DescriptorPool;
57 }
58 
59 
60 #if defined(ENABLE_REPLACEMENT)
61 // Initial value for the hit countdown field of each method.
62 #define METHOD_INITIAL_HIT_COUNTDOWN 1000
63 #endif
64 
65 
66 /* methodinfo *****************************************************************/
67 
68 struct methodinfo { /* method structure */
69  Mutex *mutex; /* we need this in jit's locking */
70  s4 flags; /* ACC flags */
71  Utf8String name; /* name of method */
72  Utf8String descriptor; /* JavaVM descriptor string of method */
73 #if defined(ENABLE_JAVASE)
74  Utf8String signature; /* Signature attribute */
75  stack_map_t *stack_map; /* StackMapTable attribute */
76 #endif
77 
78  methoddesc *parseddesc; /* parsed descriptor */
79 
80  classinfo *clazz; /* class, the method belongs to */
81  s4 vftblindex; /* index of method in virtual function */
82  /* table (if it is a virtual method) */
83  s4 maxstack; /* maximum stack depth of method */
84  s4 maxlocals; /* maximum number of local variables */
85  s4 jcodelength; /* length of JavaVM code */
86  u1 *jcode; /* pointer to JavaVM code */
87 
88  s4 rawexceptiontablelength; /* exceptiontable length */
89  raw_exception_entry *rawexceptiontable; /* the exceptiontable */
90 
91  u2 thrownexceptionscount; /* number of exceptions attribute */
92  classref_or_classinfo *thrownexceptions; /* except. a method may throw */
93 
94  u2 linenumbercount; /* number of linenumber attributes */
95  lineinfo *linenumbers; /* array of lineinfo items */
96 
97 #if defined(ENABLE_JAVASE) && defined(ENABLE_JVMTI)
98  uint16_t localvarcount; /* number of local variable attributes */
99  localvarinfo* localvars; /* array of localvarinfo items */
100 #endif
101 
102  u1 *stubroutine; /* stub for compiling or calling natives */
103  codeinfo *code; /* current code of this method */
104 
105 #if defined(ENABLE_LSRA)
106  s4 maxlifetimes; /* helper for lsra */
107 #endif
108 
109  methodinfo *overwrites; /* method that is directly overwritten */
110  method_assumption *assumptions; /* list of assumptions about this method */
111 
112  BreakpointTable* breakpoints; /* breakpoints in this method */
113 
114 #if defined(ENABLE_REPLACEMENT)
115  s4 hitcountdown; /* decreased for each hit */
116 #endif
117 
118 #if defined(ENABLE_DEBUG_FILTER)
119  u1 filtermatches; /* flags indicating which filters the method matches */
120 #endif
121 
122 #if defined(ENABLE_ESCAPE)
123  u1 *paramescape;
124 #endif
125 };
126 
127 /* method_assumption ***********************************************************
128 
129  This struct is used for registering assumptions about methods.
130 
131 *******************************************************************************/
132 
136 };
137 
138 
139 /* method_worklist *************************************************************
140 
141  List node used for method worklists.
142 
143 *******************************************************************************/
144 
148 };
149 
150 
151 /* raw_exception_entry ********************************************************/
152 
153 /* exception table entry read by the loader */
154 
155 struct raw_exception_entry { /* exceptiontable entry in a method */
156  classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall) */
157  u2 startpc; /* start pc of guarded area (inclusive) */
158  u2 endpc; /* end pc of guarded area (exklusive) */
159  u2 handlerpc; /* pc of exception handler */
160 };
161 
162 
163 /* lineinfo *******************************************************************/
164 
165 struct lineinfo {
168 };
169 
170 
171 /* localvarinfo ***************************************************************/
172 
173 struct localvarinfo {
174  uint16_t start_pc;
175  uint16_t length;
178  uint16_t index;
179 };
180 
181 
182 /* global variables ***********************************************************/
183 
185 
186 
187 /* inline functions ***********************************************************/
188 
189 inline static bool method_is_builtin(methodinfo* m)
190 {
191  return m->flags & ACC_METHOD_BUILTIN;
192 }
193 
194 
195 /* function prototypes ********************************************************/
196 
197 void method_init(void);
198 
200 void method_free(methodinfo *m);
202 
204 
206 
211 
214 
216 
220 
221 #if !defined(NDEBUG)
223 void method_print(methodinfo *m);
224 void method_println(methodinfo *m);
227 
228 #endif
229 bool method_matches(methodinfo *m, const char* name);
230 
231 
232 namespace cacao {
233 
234 // forward declaration
235 class OStream;
236 
238 
239 } // end namespace cacao
240 
241 #endif // METHOD_HPP_
242 
243 
244 /*
245  * These are local overrides for various environment variables in Emacs.
246  * Please do not remove this and leave it at the end of the file, where
247  * Emacs will automagically detect them.
248  * ---------------------------------------------------------------------
249  * Local variables:
250  * mode: c++
251  * indent-tabs-mode: t
252  * c-basic-offset: 4
253  * tab-width: 4
254  * End:
255  * vim:noexpandtab:sw=4:ts=4:
256  */
Utf8String name
Definition: method.hpp:71
uint16_t start_pc
Definition: method.hpp:174
void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl)
Definition: method.cpp:1118
void method_free(methodinfo *m)
Definition: method.cpp:608
bool method_load(ClassBuffer &cb, methodinfo *m, DescriptorPool &descpool)
Definition: method.cpp:162
void method_print(methodinfo *m)
Definition: method.cpp:1189
s4 jcodelength
Definition: method.hpp:85
static bool method_is_builtin(methodinfo *m)
Definition: method.hpp:189
void method_init(void)
Definition: method.cpp:99
s4 rawexceptiontablelength
Definition: method.hpp:88
Utf8String descriptor
Definition: method.hpp:177
method_assumption * assumptions
Definition: method.hpp:110
java_handle_bytearray_t * method_get_annotations(methodinfo *m)
Definition: method.cpp:932
methodinfo * method_vftbl_lookup(vftbl_t *vftbl, methodinfo *m)
Definition: method.cpp:697
uint16_t length
Definition: method.hpp:175
Dummy implementation of a mutex.
Definition: mutex-none.hpp:33
method_assumption * next
Definition: method.hpp:134
u2 startpc
Definition: method.hpp:157
uint8_t u1
Definition: types.hpp:40
method_worklist * next
Definition: method.hpp:146
methodinfo * method_new_builtin(builtintable_entry *bte)
Definition: method.cpp:664
uint16_t index
Definition: method.hpp:178
JNIEnv jclass jobject const char * name
Definition: jvmti.h:312
java_handle_objectarray_t * method_get_parametertypearray(methodinfo *m)
Definition: method.cpp:774
int32_t method_get_parametercount(methodinfo *m)
Definition: method.cpp:742
Utf8String signature
Definition: method.hpp:74
classref_or_classinfo catchtype
Definition: method.hpp:156
u2 endpc
Definition: method.hpp:158
methodinfo * context
Definition: method.hpp:135
raw_exception_entry * rawexceptiontable
Definition: method.hpp:89
s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found)
Definition: method.cpp:891
Utf8String name
Definition: method.hpp:176
Utf8String descriptor
Definition: method.hpp:72
u1 * stubroutine
Definition: method.hpp:102
s4 vftblindex
Definition: method.hpp:81
uint16_t u2
Definition: types.hpp:43
void method_printflags(methodinfo *m)
Definition: method.cpp:1155
u2 handlerpc
Definition: method.hpp:159
void method_println(methodinfo *m)
Definition: method.cpp:1218
classinfo * clazz
Definition: method.hpp:80
Definition: method.hpp:155
Simple stream class for formatted output.
Definition: OStream.hpp:141
bool method_matches(methodinfo *m, const char *name)
Definition: method.cpp:1271
methodinfo * overwrites
Definition: method.hpp:109
u2 linenumbercount
Definition: method.hpp:94
u1 * jcode
Definition: method.hpp:86
s4 maxstack
Definition: method.hpp:83
Fieldref, Methodref and InterfaceMethodref.
Definition: references.hpp:86
int32_t s4
Definition: types.hpp:45
This class is used to record breakpoints in the methodinfo structure.
Definition: breakpoint.hpp:56
s4 maxlocals
Definition: method.hpp:84
classinfo * method_returntype_get(methodinfo *m)
Definition: method.cpp:857
OStream & OS
Mutex * mutex
Definition: method.hpp:69
codeinfo * code
Definition: method.hpp:103
OStream & operator<<(OStream &OS, const std::string &t)
Definition: OStream.hpp:459
stack_map_t * stack_map
Definition: method.hpp:75
u2 line_number
Definition: method.hpp:167
u2 thrownexceptionscount
Definition: method.hpp:91
methoddesc * parseddesc
Definition: method.hpp:78
Definition: builtin.hpp:60
u2 start_pc
Definition: method.hpp:166
void method_methodref_print(constant_FMIref *mr)
Definition: method.cpp:1235
u1 filtermatches
Definition: method.hpp:119
classref_or_classinfo * thrownexceptions
Definition: method.hpp:92
java_handle_bytearray_t * method_get_annotationdefault(methodinfo *m)
Definition: method.cpp:1021
lineinfo * linenumbers
Definition: method.hpp:95
BreakpointTable * breakpoints
Definition: method.hpp:112
void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller)
Definition: method.cpp:1085
void method_methodref_println(constant_FMIref *mr)
Definition: method.cpp:1264
s4 flags
Definition: method.hpp:70
methodinfo * method_java_lang_reflect_Method_invoke
java_handle_objectarray_t * method_get_exceptionarray(methodinfo *m)
Definition: method.cpp:824
java_handle_bytearray_t * method_get_parameterannotations(methodinfo *m)
Definition: method.cpp:976
bool method_canoverwrite(methodinfo *m, methodinfo *old)
Definition: method.cpp:642
methodinfo * m
Definition: method.hpp:147