* Updated header: Added 2006. Changed address of FSF. Changed email
[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
29    Changes: Christian Thalinger
30
31    $Id: method.h 4357 2006-01-22 23:33:38Z twisti $
32 */
33
34
35 #ifndef _METHOD_H
36 #define _METHOD_H
37
38 /* forward typedefs ***********************************************************/
39
40 typedef struct methodinfo methodinfo; 
41 typedef struct exceptiontable exceptiontable;
42 typedef struct lineinfo lineinfo; 
43
44 #include "config.h"
45 #include "vm/types.h"
46
47 #include "vm/global.h"
48 #include "vm/utf8.h"
49 #include "vm/references.h"
50 #include "vm/descriptor.h"
51 #include "vm/jit/jit.h"
52 #include "vm/jit/inline/parseXTA.h"
53
54
55 /* methodinfo *****************************************************************/
56
57 struct methodinfo {                 /* method structure                       */
58         java_objectheader header;       /* we need this in jit's monitorenter     */
59         s4          flags;              /* ACC flags                              */
60         utf        *name;               /* name of method                         */
61         utf        *descriptor;         /* JavaVM descriptor string of method     */
62         methoddesc *parseddesc;         /* parsed descriptor                      */
63
64         s4          returntype;         /* only temporary valid, return type      */
65         classinfo  *returnclass;        /* pointer to classinfo for the rtn type  */ /*XTA*/ 
66
67         s4          paramcount;         /* only temporary valid, parameter count  */
68         u1         *paramtypes;         /* only temporary valid, parameter types  */
69         classinfo **paramclass;         /* pointer to classinfo for a parameter   */ /*XTA*/
70
71         bool        isleafmethod;       /* does method call subroutines           */
72
73         classinfo  *class;              /* class, the method belongs to           */
74         s4          vftblindex;         /* index of method in virtual function    */
75                                         /* table (if it is a virtual method)      */
76         s4          maxstack;           /* maximum stack depth of method          */
77         s4          maxlocals;          /* maximum number of local variables      */
78         s4          jcodelength;        /* length of JavaVM code                  */
79         u1         *jcode;              /* pointer to JavaVM code                 */
80
81         s4          basicblockcount;    /* number of basic blocks                 */
82         basicblock *basicblocks;        /* points to basic block array            */
83         s4         *basicblockindex;    /* a table which contains for every byte  */
84                                         /* of JavaVM code a basic block index if  */
85                                         /* at this byte is the start of a basic   */
86                                         /* block                                  */
87
88         s4          instructioncount;   /* number of JavaVM instructions          */
89         instruction *instructions;      /* points to intermediate code instr.     */
90
91         s4          stackcount;         /* number of stack elements               */
92         stackelement *stack;            /* points to intermediate code instr.     */
93
94         s4          exceptiontablelength;/* exceptiontable length                 */
95         exceptiontable *exceptiontable; /* the exceptiontable                     */
96
97         u2          thrownexceptionscount;/* number of exceptions attribute       */
98         classref_or_classinfo *thrownexceptions; /* except. a method may throw    */
99
100         u2          linenumbercount;    /* number of linenumber attributes        */
101         lineinfo   *linenumbers;        /* array of lineinfo items                */
102
103         int       c_debug_nr;           /* a counter to number all BB with an     */
104                                         /* unique value                           */
105
106         u1         *stubroutine;        /* stub for compiling or calling natives  */
107         s4          mcodelength;        /* legth of generated machine code        */
108         u1         *mcode;              /* pointer to machine code                */
109         u1         *entrypoint;         /* entry point in machine code            */
110
111         /*rtainfo   rta;*/
112         xtainfo    *xta;
113
114         bool        methodXTAparsed;    /*  true if xta parsed */
115         s4          methodUsed;         /* marked (might be used later) /not used /used */
116         s4          monoPoly;           /* call is mono or poly or unknown        */ /*RT stats */
117         /* should # method def'd and used be kept after static parse (will it be used?) */
118         s4              subRedefs;
119         s4              subRedefsUsed;
120         s4              nativelyoverloaded; /* used in header.c and only valid there  */
121
122 #if defined(ENABLE_LSRA)
123         s4          maxlifetimes;           /* helper for lsra                        */
124 #endif
125 };
126
127
128 /* exceptiontable *************************************************************/
129
130 struct exceptiontable {         /* exceptiontable entry in a method           */
131         s4              startpc;    /* start pc of guarded area (inclusive)       */
132         basicblock     *start;
133
134         s4              endpc;      /* end pc of guarded area (exklusive)         */
135         basicblock     *end;
136
137         s4              handlerpc;  /* pc of exception handler                    */
138         basicblock     *handler;
139
140         classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall)  */
141         exceptiontable *next;       /* used to build a list of exception when     */
142                                     /* loops are copied */
143         exceptiontable *down;       /* instead of the old array, a list is used   */
144 };
145
146
147 /* lineinfo *******************************************************************/
148
149 struct lineinfo {
150         u2 start_pc;
151         u2 line_number;
152 };
153
154
155 /* function prototypes ********************************************************/
156
157 void method_free(methodinfo *m);
158 bool method_canoverwrite(methodinfo *m, methodinfo *old);
159
160 #if !defined(NDEBUG)
161 void method_printflags(methodinfo *m);
162 void method_print(methodinfo *m);
163 void method_println(methodinfo *m);
164
165 void method_descriptor2types(methodinfo *m);
166 #endif
167
168 #endif /* _METHOD_H */
169
170
171 /*
172  * These are local overrides for various environment variables in Emacs.
173  * Please do not remove this and leave it at the end of the file, where
174  * Emacs will automagically detect them.
175  * ---------------------------------------------------------------------
176  * Local variables:
177  * mode: c
178  * indent-tabs-mode: t
179  * c-basic-offset: 4
180  * tab-width: 4
181  * End:
182  */