* src/vm/jit/replace.c: Only recompile if necessary. Count
[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 6012 2006-11-16 19:45:15Z 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 raw_exception_entry raw_exception_entry;
42 typedef struct lineinfo            lineinfo; 
43 typedef struct method_assumption   method_assumption;
44 typedef struct method_worklist     method_worklist;
45
46 #include "config.h"
47 #include "vm/types.h"
48
49 #include "vm/descriptor.h"
50 #include "vm/global.h"
51 #include "vm/linker.h"
52 #include "vm/references.h"
53 #include "vm/utf8.h"
54 #include "vm/jit/code.h"
55 #include "vm/jit/jit.h"
56
57
58 /* methodinfo *****************************************************************/
59
60 struct methodinfo {                 /* method structure                       */
61         java_objectheader header;       /* we need this in jit's monitorenter     */
62         s4            flags;            /* ACC flags                              */
63         utf          *name;             /* name of method                         */
64         utf          *descriptor;       /* JavaVM descriptor string of method     */
65         utf          *signature;        /* Signature attribute string             */
66         methoddesc   *parseddesc;       /* parsed descriptor                      */
67                              
68         classinfo    *class;            /* class, the method belongs to           */
69         s4            vftblindex;       /* index of method in virtual function    */
70                                         /* table (if it is a virtual method)      */
71         s4            maxstack;         /* maximum stack depth of method          */
72         s4            maxlocals;        /* maximum number of local variables      */
73         s4            jcodelength;      /* length of JavaVM code                  */
74         u1           *jcode;            /* pointer to JavaVM code                 */
75
76         s4            rawexceptiontablelength;  /* exceptiontable length          */
77         raw_exception_entry *rawexceptiontable; /* the exceptiontable             */
78
79         u2            thrownexceptionscount; /* number of exceptions attribute    */
80         classref_or_classinfo *thrownexceptions; /* except. a method may throw    */
81
82         u2            linenumbercount;  /* number of linenumber attributes        */
83         lineinfo     *linenumbers;      /* array of lineinfo items                */
84
85         u1           *stubroutine;      /* stub for compiling or calling natives  */
86         codeinfo     *code;             /* current code of this method            */
87
88 #if defined(ENABLE_LSRA)
89         s4            maxlifetimes;     /* helper for lsra                        */
90 #endif
91
92         methodinfo   *overwrites;       /* method that is directly overwritten    */
93         method_assumption *assumptions; /* list of assumptions about this method  */
94 };
95
96
97 /* method_assumption ***********************************************************
98
99    This struct is used for registering assumptions about methods.
100
101 *******************************************************************************/
102
103 struct method_assumption {
104         method_assumption *next;
105         methodinfo        *context;
106 };
107
108
109 /* method_worklist *************************************************************
110
111    List node used for method worklists.
112
113 *******************************************************************************/
114
115 struct method_worklist {
116         method_worklist *next;
117         methodinfo      *m;
118 };
119
120
121 /* raw_exception_entry ********************************************************/
122
123 /* exception table entry read by the loader */
124
125 struct raw_exception_entry {    /* exceptiontable entry in a method           */
126         classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall)     */
127         u2              startpc;    /* start pc of guarded area (inclusive)       */
128         u2              endpc;      /* end pc of guarded area (exklusive)         */
129         u2              handlerpc;  /* pc of exception handler                    */
130 };
131
132
133 /* lineinfo *******************************************************************/
134
135 struct lineinfo {
136         u2 start_pc;
137         u2 line_number;
138 };
139
140
141 /* function prototypes ********************************************************/
142
143 void method_free(methodinfo *m);
144 bool method_canoverwrite(methodinfo *m, methodinfo *old);
145
146 methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m);
147
148 void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller);
149 void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
150
151 #if !defined(NDEBUG)
152 void method_printflags(methodinfo *m);
153 void method_print(methodinfo *m);
154 void method_println(methodinfo *m);
155 void method_methodref_print(constant_FMIref *mr);
156 void method_methodref_println(constant_FMIref *mr);
157 #endif
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  * vim:noexpandtab:sw=4:ts=4:
174  */