* src/vm/properties.c (properties_init) [ENABLE_JAVASE]: Allocate the
[cacao.git] / src / vm / method.h
1 /* src/vm/method.h - method functions header
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28             Christian Thalinger
29             Edwin Steiner
30
31    $Id: method.h 5974 2006-11-12 15:14:19Z edwin $
32 */
33
34
35 #ifndef _METHOD_H
36 #define _METHOD_H
37
38 /* forward typedefs ***********************************************************/
39
40 typedef struct raw_exception_entry raw_exception_entry;
41 typedef struct lineinfo lineinfo; 
42 typedef struct method_assumption method_assumption;
43 typedef struct method_worklist method_worklist;
44
45 #include "config.h"
46 #include "vm/types.h"
47
48 #include "vm/descriptor.h"
49 #include "vm/global.h"
50 #include "vm/linker.h"
51 #include "vm/references.h"
52 #include "vm/utf8.h"
53 #include "vm/jit/code.h"
54 #include "vm/jit/jit.h"
55
56
57 /* methodinfo *****************************************************************/
58
59 struct methodinfo {                 /* method structure                       */
60         java_objectheader header;       /* we need this in jit's monitorenter     */
61         s4            flags;            /* ACC flags                              */
62         utf          *name;             /* name of method                         */
63         utf          *descriptor;       /* JavaVM descriptor string of method     */
64         utf          *signature;        /* Signature attribute string             */
65         methoddesc   *parseddesc;       /* parsed descriptor                      */
66                              
67         classinfo    *class;            /* class, the method belongs to           */
68         s4            vftblindex;       /* index of method in virtual function    */
69                                         /* table (if it is a virtual method)      */
70         s4            maxstack;         /* maximum stack depth of method          */
71         s4            maxlocals;        /* maximum number of local variables      */
72         s4            jcodelength;      /* length of JavaVM code                  */
73         u1           *jcode;            /* pointer to JavaVM code                 */
74
75         s4            rawexceptiontablelength;  /* exceptiontable length          */
76         raw_exception_entry *rawexceptiontable; /* the exceptiontable             */
77
78         u2            thrownexceptionscount; /* number of exceptions attribute    */
79         classref_or_classinfo *thrownexceptions; /* except. a method may throw    */
80
81         u2            linenumbercount;  /* number of linenumber attributes        */
82         lineinfo     *linenumbers;      /* array of lineinfo items                */
83
84         u1           *stubroutine;      /* stub for compiling or calling natives  */
85         codeinfo     *code;             /* current code of this method            */
86
87 #if defined(ENABLE_LSRA)
88         s4            maxlifetimes;     /* helper for lsra                        */
89 #endif
90
91         methodinfo   *overwrites;       /* method that is directly overwritten    */
92         method_assumption *assumptions; /* list of assumptions about this method  */
93 };
94
95
96 /* method_assumption ***********************************************************
97
98    This struct is used for registering assumptions about methods.
99
100 *******************************************************************************/
101
102 struct method_assumption {
103         method_assumption *next;
104         methodinfo        *context;
105 };
106
107
108 /* method_worklist *************************************************************
109
110    List node used for method worklists.
111
112 *******************************************************************************/
113
114 struct method_worklist {
115         method_worklist *next;
116         methodinfo      *m;
117 };
118
119
120 /* raw_exception_entry ********************************************************/
121
122 /* exception table entry read by the loader */
123
124 struct raw_exception_entry {    /* exceptiontable entry in a method           */
125         classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall)     */
126         u2              startpc;    /* start pc of guarded area (inclusive)       */
127         u2              endpc;      /* end pc of guarded area (exklusive)         */
128         u2              handlerpc;  /* pc of exception handler                    */
129 };
130
131
132 /* lineinfo *******************************************************************/
133
134 struct lineinfo {
135         u2 start_pc;
136         u2 line_number;
137 };
138
139
140 /* function prototypes ********************************************************/
141
142 void method_free(methodinfo *m);
143 bool method_canoverwrite(methodinfo *m, methodinfo *old);
144
145 methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m);
146
147 void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller);
148 void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
149
150 #if !defined(NDEBUG)
151 void method_printflags(methodinfo *m);
152 void method_print(methodinfo *m);
153 void method_println(methodinfo *m);
154 void method_methodref_print(constant_FMIref *mr);
155 void method_methodref_println(constant_FMIref *mr);
156 #endif
157
158 #endif /* _METHOD_H */
159
160
161 /*
162  * These are local overrides for various environment variables in Emacs.
163  * Please do not remove this and leave it at the end of the file, where
164  * Emacs will automagically detect them.
165  * ---------------------------------------------------------------------
166  * Local variables:
167  * mode: c
168  * indent-tabs-mode: t
169  * c-basic-offset: 4
170  * tab-width: 4
171  * End:
172  * vim:noexpandtab:sw=4:ts=4:
173  */