1012c6870a27461fa410d87d96188b5548dea6fa
[cacao.git] / src / vm / method.c
1 /* src/vm/method.c - method functions
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: Andreas Krall
30             Roman Obermaiser
31             Mark Probst
32             Edwin Steiner
33             Christian Thalinger
34
35    $Id: method.c 2100 2005-03-28 21:57:23Z twisti $
36
37 */
38
39
40 #include "mm/memory.h"
41 #include "vm/method.h"
42 #include "vm/jit/codegen.inc.h"
43
44
45 /* method_free *****************************************************************
46
47    Frees all memory that was allocated for this method.
48
49 *******************************************************************************/
50
51 void method_free(methodinfo *m)
52 {
53         if (m->jcode)
54                 MFREE(m->jcode, u1, m->jcodelength);
55
56         if (m->exceptiontable)
57                 MFREE(m->exceptiontable, exceptiontable, m->exceptiontablelength);
58
59         if (m->mcode)
60                 CFREE(m->mcode, m->mcodelength);
61
62         if (m->stubroutine) {
63                 if (m->flags & ACC_NATIVE) {
64                         removenativestub(m->stubroutine);
65
66                 } else {
67                         removecompilerstub(m->stubroutine);
68                 }
69         }
70 }
71
72
73 /* method_canoverwrite *********************************************************
74
75    Check if m and old are identical with respect to type and
76    name. This means that old can be overwritten with m.
77         
78 *******************************************************************************/
79
80 bool method_canoverwrite(methodinfo *m, methodinfo *old)
81 {
82         if (m->name != old->name)
83                 return false;
84
85         if (m->descriptor != old->descriptor)
86                 return false;
87
88         if (m->flags & ACC_STATIC)
89                 return false;
90
91         return true;
92 }
93
94
95 /************** Function: method_display  (debugging only) **************/
96
97 void method_display(methodinfo *m)
98 {
99         printf("   ");
100         printflags(m->flags);
101         printf(" ");
102         utf_display(m->name);
103         printf(" "); 
104         utf_display(m->descriptor);
105         printf("\n");
106 }
107
108 /************** Function: method_display_w_class  (debugging only) **************/
109
110 void method_display_w_class(methodinfo *m)
111 {
112         printflags(m->class->flags);
113         printf(" "); fflush(stdout);
114         utf_display(m->class->name);
115         printf(".");fflush(stdout);
116
117         printf("   ");
118         printflags(m->flags);
119         printf(" "); fflush(stdout);
120         utf_display(m->name);
121         printf(" "); fflush(stdout);
122         utf_display(m->descriptor);
123         printf("\n"); fflush(stdout);
124 }
125
126 /************** Function: method_display_flags_last  (debugging only) **************/
127
128 void method_display_flags_last(methodinfo *m)
129 {
130         printf(" ");
131         utf_display(m->name);
132         printf(" ");
133         utf_display(m->descriptor);
134         printf("   ");
135         printflags(m->flags);
136         printf("\n");
137 }
138
139
140 /*
141  * These are local overrides for various environment variables in Emacs.
142  * Please do not remove this and leave it at the end of the file, where
143  * Emacs will automagically detect them.
144  * ---------------------------------------------------------------------
145  * Local variables:
146  * mode: c
147  * indent-tabs-mode: t
148  * c-basic-offset: 4
149  * tab-width: 4
150  * End:
151  */