extended type system to use symbolic references
[cacao.git] / src / vm / method.h
1 /* src/vm/method.h - method functions header
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    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., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Reinhard Grafl
28
29    Changes: Christian Thalinger
30
31    $Id: method.h 2181 2005-04-01 16:53:33Z edwin $
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
45 #include "vm/global.h"
46 #include "vm/utf8.h"
47 #include "vm/references.h"
48 #include "vm/descriptor.h"
49 #include "vm/jit/jit.h"
50 #include "vm/jit/inline/parseXTA.h"
51
52
53 /* methodinfo *****************************************************************/
54
55 struct methodinfo {                 /* method structure                       */
56         java_objectheader header;       /* we need this in jit's monitorenter     */
57         s4          flags;              /* ACC flags                              */
58         utf        *name;               /* name of method                         */
59         utf        *descriptor;         /* JavaVM descriptor string of method     */
60         methoddesc *parseddesc;         /* parsed descriptor                      */
61
62         s4          returntype;         /* only temporary valid, return type      */
63         classinfo  *returnclass;        /* pointer to classinfo for the rtn type  */ /*XTA*/ 
64
65         s4          paramcount;         /* only temporary valid, parameter count  */
66         u1         *paramtypes;         /* only temporary valid, parameter types  */
67         classinfo **paramclass;         /* pointer to classinfo for a parameter   */ /*XTA*/
68
69         bool        isleafmethod;       /* does method call subroutines           */
70
71         classinfo  *class;              /* class, the method belongs to           */
72         s4          vftblindex;         /* index of method in virtual function    */
73                                         /* table (if it is a virtual method)      */
74         s4          maxstack;           /* maximum stack depth of method          */
75         s4          maxlocals;          /* maximum number of local variables      */
76         s4          jcodelength;        /* length of JavaVM code                  */
77         u1         *jcode;              /* pointer to JavaVM code                 */
78
79         s4          basicblockcount;    /* number of basic blocks                 */
80         basicblock *basicblocks;        /* points to basic block array            */
81         s4         *basicblockindex;    /* a table which contains for every byte  */
82                                         /* of JavaVM code a basic block index if  */
83                                         /* at this byte is the start of a basic   */
84                                         /* block                                  */
85
86         s4          instructioncount;   /* number of JavaVM instructions          */
87         instruction *instructions;      /* points to intermediate code instr.     */
88
89         s4          stackcount;         /* number of stack elements               */
90         stackelement *stack;            /* points to intermediate code instr.     */
91
92         s4          exceptiontablelength;/* exceptiontable length                 */
93         exceptiontable *exceptiontable; /* the exceptiontable                     */
94
95         u2          thrownexceptionscount;/* number of exceptions attribute       */
96         classinfo **thrownexceptions;   /* checked exceptions a method may throw  */
97
98         u2          linenumbercount;    /* number of linenumber attributes        */
99         lineinfo   *linenumbers;        /* array of lineinfo items                */
100
101         int       c_debug_nr;           /* a counter to number all BB with an     */
102                                         /* unique value                           */
103
104         u1         *stubroutine;        /* stub for compiling or calling natives  */
105         s4          mcodelength;        /* legth of generated machine code        */
106         functionptr mcode;              /* pointer to machine code                */
107         functionptr entrypoint;         /* entry point in machine code            */
108
109         /*rtainfo   rta;*/
110         xtainfo    *xta;
111
112         bool        methodXTAparsed;    /*  true if xta parsed */
113         s4          methodUsed;         /* marked (might be used later) /not used /used */
114         s4          monoPoly;           /* call is mono or poly or unknown        */ /*RT stats */
115         /* should # method def'd and used be kept after static parse (will it be used?) */
116         s4              subRedefs;
117         s4              subRedefsUsed;
118         s4              nativelyoverloaded; /* used in header.c and only valid there  */
119         /* helper for lsra */
120         s4          maxlifetimes;
121 };
122
123
124 /* exceptiontable *************************************************************/
125
126 struct exceptiontable {         /* exceptiontable entry in a method           */
127         s4              startpc;    /* start pc of guarded area (inclusive)       */
128         basicblock     *start;
129
130         s4              endpc;      /* end pc of guarded area (exklusive)         */
131         basicblock     *end;
132
133         s4              handlerpc;  /* pc of exception handler                    */
134         basicblock     *handler;
135
136         classinfo      *catchtype;  /* catchtype of exception (NULL == catchall)  */
137         exceptiontable *next;       /* used to build a list of exception when     */
138                                     /* loops are copied */
139         exceptiontable *down;       /* instead of the old array, a list is used   */
140 };
141
142
143 /* lineinfo *******************************************************************/
144
145 struct lineinfo {
146         u2 start_pc;
147         u2 line_number;
148 };
149
150
151 /* function prototypes ********************************************************/
152
153 void method_free(methodinfo *m);
154 bool method_canoverwrite(methodinfo *m, methodinfo *old);
155
156 void method_display(methodinfo *m);
157 void method_display_w_class(methodinfo *m);
158
159 #endif /* _METHOD_H */
160
161
162 /*
163  * These are local overrides for various environment variables in Emacs.
164  * Please do not remove this and leave it at the end of the file, where
165  * Emacs will automagically detect them.
166  * ---------------------------------------------------------------------
167  * Local variables:
168  * mode: c
169  * indent-tabs-mode: t
170  * c-basic-offset: 4
171  * tab-width: 4
172  * End:
173  */