* src/vmcore/descriptor.c (vm/jit/abi.h): Added.
[cacao.git] / src / vmcore / method.h
1 /* src/vmcore/method.h - method functions header
2
3    Copyright (C) 1996-2005, 2006, 2007 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    $Id: method.h 7268 2007-02-01 12:02:56Z twisti $
26 */
27
28
29 #ifndef _METHOD_H
30 #define _METHOD_H
31
32 /* forward typedefs ***********************************************************/
33
34 typedef struct methodinfo          methodinfo; 
35 typedef struct raw_exception_entry raw_exception_entry;
36 typedef struct lineinfo            lineinfo; 
37 typedef struct method_assumption   method_assumption;
38 typedef struct method_worklist     method_worklist;
39
40 #include "config.h"
41 #include "vm/types.h"
42
43 #include "vm/global.h"
44
45 #include "vm/jit/code.h"
46 #include "vm/jit/codegen-common.h"
47
48 #include "vmcore/descriptor.h"
49 #include "vmcore/references.h"
50 #include "vmcore/linker.h"
51
52 #if defined(ENABLE_JAVASE)
53 # include "vmcore/stackmap.h"
54 #endif
55
56 #include "vmcore/utf8.h"
57
58
59 /* methodinfo *****************************************************************/
60
61 struct methodinfo {                 /* method structure                       */
62         s4            flags;            /* ACC flags                              */
63         utf          *name;             /* name of method                         */
64         utf          *descriptor;       /* JavaVM descriptor string of method     */
65 #if defined(ENABLE_JAVASE)
66         utf          *signature;        /* Signature attribute                    */
67         stack_map_t  *stack_map;        /* StackMapTable attribute                */
68 #endif
69
70         methoddesc   *parseddesc;       /* parsed descriptor                      */
71                              
72         classinfo    *class;            /* class, the method belongs to           */
73         s4            vftblindex;       /* index of method in virtual function    */
74                                         /* table (if it is a virtual method)      */
75         s4            maxstack;         /* maximum stack depth of method          */
76         s4            maxlocals;        /* maximum number of local variables      */
77         s4            jcodelength;      /* length of JavaVM code                  */
78         u1           *jcode;            /* pointer to JavaVM code                 */
79
80         s4            rawexceptiontablelength;  /* exceptiontable length          */
81         raw_exception_entry *rawexceptiontable; /* the exceptiontable             */
82
83         u2            thrownexceptionscount; /* number of exceptions attribute    */
84         classref_or_classinfo *thrownexceptions; /* except. a method may throw    */
85
86         u2            linenumbercount;  /* number of linenumber attributes        */
87         lineinfo     *linenumbers;      /* array of lineinfo items                */
88
89         u1           *stubroutine;      /* stub for compiling or calling natives  */
90         codeinfo     *code;             /* current code of this method            */
91
92 #if defined(ENABLE_LSRA)
93         s4            maxlifetimes;     /* helper for lsra                        */
94 #endif
95
96         methodinfo   *overwrites;       /* method that is directly overwritten    */
97         method_assumption *assumptions; /* list of assumptions about this method  */
98 };
99
100
101 /* method_assumption ***********************************************************
102
103    This struct is used for registering assumptions about methods.
104
105 *******************************************************************************/
106
107 struct method_assumption {
108         method_assumption *next;
109         methodinfo        *context;
110 };
111
112
113 /* method_worklist *************************************************************
114
115    List node used for method worklists.
116
117 *******************************************************************************/
118
119 struct method_worklist {
120         method_worklist *next;
121         methodinfo      *m;
122 };
123
124
125 /* raw_exception_entry ********************************************************/
126
127 /* exception table entry read by the loader */
128
129 struct raw_exception_entry {    /* exceptiontable entry in a method           */
130         classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall)     */
131         u2              startpc;    /* start pc of guarded area (inclusive)       */
132         u2              endpc;      /* end pc of guarded area (exklusive)         */
133         u2              handlerpc;  /* pc of exception handler                    */
134 };
135
136
137 /* lineinfo *******************************************************************/
138
139 struct lineinfo {
140         u2 start_pc;
141         u2 line_number;
142 };
143
144
145 /* function prototypes ********************************************************/
146
147 void method_free(methodinfo *m);
148 bool method_canoverwrite(methodinfo *m, methodinfo *old);
149
150 methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m);
151
152 void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller);
153 void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
154
155 s4   method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found);
156
157 #if !defined(NDEBUG)
158 void method_printflags(methodinfo *m);
159 void method_print(methodinfo *m);
160 void method_println(methodinfo *m);
161 void method_methodref_print(constant_FMIref *mr);
162 void method_methodref_println(constant_FMIref *mr);
163 #endif
164
165 #endif /* _METHOD_H */
166
167
168 /*
169  * These are local overrides for various environment variables in Emacs.
170  * Please do not remove this and leave it at the end of the file, where
171  * Emacs will automagically detect them.
172  * ---------------------------------------------------------------------
173  * Local variables:
174  * mode: c
175  * indent-tabs-mode: t
176  * c-basic-offset: 4
177  * tab-width: 4
178  * End:
179  * vim:noexpandtab:sw=4:ts=4:
180  */