1 /* src/vm/resolve.hpp - resolving classes/interfaces/fields/methods
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 /* forward declarations *******************************************************/
31 typedef struct unresolved_class unresolved_class;
32 typedef struct unresolved_field unresolved_field;
33 typedef struct unresolved_method unresolved_method;
34 typedef struct unresolved_subtype_set unresolved_subtype_set;
40 #include "vm/class.hpp"
41 #include "vm/field.hpp"
42 #include "vm/global.h"
43 #include "vm/method.hpp"
44 #include "vm/references.h"
46 #include "vm/jit/jit.hpp"
47 #include "vm/jit/reg.h"
49 #include "vm/jit/ir/instruction.hpp"
50 #include "vm/jit/verify/typeinfo.hpp"
53 /* constants ******************************************************************/
55 #define RESOLVE_STATIC 0x0001 /* ref to static fields/methods */
56 #define RESOLVE_PUTFIELD 0x0002 /* field ref inside a PUT{FIELD,STATIC}... */
57 #define RESOLVE_SPECIAL 0x0004 /* method ref inside INVOKESPECIAL */
60 /* enums **********************************************************************/
69 resolveIllegalAccessError
73 resolveFailed = false, /* this must be a false value */
74 resolveDeferred = true, /* this must be a true value */
78 /* structs ********************************************************************/
80 struct unresolved_subtype_set {
81 classref_or_classinfo *subtyperefs; /* NULL terminated list */
84 struct unresolved_class {
85 constant_classref *classref;
86 methodinfo *referermethod;
87 unresolved_subtype_set subtypeconstraints;
90 /* XXX unify heads of unresolved_field and unresolved_method? */
92 struct unresolved_field {
93 constant_FMIref *fieldref;
94 methodinfo *referermethod;
97 unresolved_subtype_set instancetypes;
98 unresolved_subtype_set valueconstraints;
101 struct unresolved_method {
102 constant_FMIref *methodref;
103 methodinfo *referermethod;
106 unresolved_subtype_set instancetypes;
107 unresolved_subtype_set *paramconstraints;
110 #define SUBTYPESET_IS_EMPTY(stset) \
111 ((stset).subtyperefs == NULL)
113 #define UNRESOLVED_SUBTYPE_SET_EMTPY(stset) \
114 do { (stset).subtyperefs = NULL; } while(0)
117 /* function prototypes ********************************************************/
123 void resolve_handle_pending_exception(bool throwError);
125 bool resolve_class_from_name(classinfo* referer,methodinfo *refmethod,
132 bool resolve_classref(methodinfo *refmethod,
133 constant_classref *ref,
139 bool resolve_classref_or_classinfo(methodinfo *refmethod,
140 classref_or_classinfo cls,
146 classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess);
148 bool resolve_class_from_typedesc(typedesc *d,bool checkaccess,bool link,classinfo **result);
150 #ifdef ENABLE_VERIFIER
151 bool resolve_class(unresolved_class *ref,
156 classinfo * resolve_class_eager(unresolved_class *ref);
157 classinfo * resolve_class_eager_no_access_check(unresolved_class *ref);
158 #endif /* ENABLE_VERIFIER */
160 bool resolve_field(unresolved_field *ref,
164 bool resolve_method(unresolved_method *ref,
166 methodinfo **result);
168 classinfo * resolve_classref_eager(constant_classref *ref);
169 classinfo * resolve_classref_eager_nonabstract(constant_classref *ref);
170 fieldinfo * resolve_field_eager(unresolved_field *ref);
171 methodinfo * resolve_method_eager(unresolved_method *ref);
173 #ifdef ENABLE_VERIFIER
174 unresolved_class * create_unresolved_class(methodinfo *refmethod,
175 constant_classref *classref,
176 typeinfo_t *valuetype);
179 unresolved_field *resolve_create_unresolved_field(classinfo *referer,
180 methodinfo *refmethod,
183 unresolved_method * resolve_create_unresolved_method(classinfo *referer,
184 methodinfo *refmethod,
185 constant_FMIref *methodref,
189 void unresolved_class_free(unresolved_class *ref);
190 void unresolved_field_free(unresolved_field *ref);
191 void unresolved_method_free(unresolved_method *ref);
193 resolve_result_t resolve_method_lazy(methodinfo *refmethod,
194 constant_FMIref *methodref,
197 resolve_result_t resolve_field_lazy(methodinfo *refmethod,
198 constant_FMIref *fieldref);
200 #if defined(ENABLE_VERIFIER)
201 resolve_result_t resolve_field_verifier_checks(methodinfo *refmethod,
202 constant_FMIref *fieldref,
203 classinfo *container,
205 typeinfo_t *instanceti,
210 bool resolve_constrain_unresolved_field(unresolved_field *ref,
212 methodinfo *refmethod,
213 typeinfo_t *instanceti,
214 typeinfo_t *valueti);
216 resolve_result_t resolve_method_verifier_checks(methodinfo *refmethod,
217 constant_FMIref *methodref,
221 resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
223 typeinfo_t *instanceti,
226 resolve_result_t resolve_method_param_type_checks(jitdata *jd,
227 methodinfo *refmethod,
232 resolve_result_t resolve_method_param_type_checks_stackbased(
233 methodinfo *refmethod,
236 typedescriptor_t *stack);
238 bool resolve_method_loading_constraints(classinfo *referer,
241 bool resolve_constrain_unresolved_method_instance(unresolved_method *ref,
242 methodinfo *refmethod,
243 typeinfo_t *instanceti,
246 bool resolve_constrain_unresolved_method_params(jitdata *jd,
247 unresolved_method *ref,
248 methodinfo *refmethod,
251 bool resolve_constrain_unresolved_method_params_stackbased(
252 unresolved_method *ref,
253 methodinfo *refmethod,
254 typedescriptor_t *stack);
256 #endif /* defined(ENABLE_VERIFIER) */
259 void unresolved_class_debug_dump(unresolved_class *ref,FILE *file);
260 void unresolved_field_debug_dump(unresolved_field *ref,FILE *file);
261 void unresolved_method_debug_dump(unresolved_method *ref,FILE *file);
262 void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file);
269 #endif /* _RESOLVE_HPP */
272 * These are local overrides for various environment variables in Emacs.
273 * Please do not remove this and leave it at the end of the file, where
274 * Emacs will automagically detect them.
275 * ---------------------------------------------------------------------
278 * indent-tabs-mode: t
282 * vim:noexpandtab:sw=4:ts=4: