1 /* src/vm/resolve.h - resolving classes/interfaces/fields/methods
3 Copyright (C) 1996-2005, 2006, 2007 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
8 This file is part of CACAO.
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.
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.
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
31 /* forward declarations *******************************************************/
33 typedef struct unresolved_class unresolved_class;
34 typedef struct unresolved_field unresolved_field;
35 typedef struct unresolved_method unresolved_method;
36 typedef struct unresolved_subtype_set unresolved_subtype_set;
42 #include "vm/global.h"
44 #include "vm/jit/jit.h"
45 #include "vm/jit/reg.h"
46 #include "vm/jit/verify/typeinfo.h"
48 #include "vmcore/class.h"
49 #include "vmcore/field.h"
50 #include "vmcore/method.h"
51 #include "vmcore/references.h"
54 /* constants ******************************************************************/
56 #define RESOLVE_STATIC 0x0001 /* ref to static fields/methods */
57 #define RESOLVE_PUTFIELD 0x0002 /* field ref inside a PUT{FIELD,STATIC}... */
58 #define RESOLVE_SPECIAL 0x0004 /* method ref inside INVOKESPECIAL */
61 /* enums **********************************************************************/
70 resolveIllegalAccessError
74 resolveFailed = false, /* this must be a false value */
75 resolveDeferred = true, /* this must be a true value */
79 /* structs ********************************************************************/
81 struct unresolved_subtype_set {
82 classref_or_classinfo *subtyperefs; /* NULL terminated list */
85 struct unresolved_class {
86 constant_classref *classref;
87 methodinfo *referermethod;
88 unresolved_subtype_set subtypeconstraints;
91 /* XXX unify heads of unresolved_field and unresolved_method? */
93 struct unresolved_field {
94 constant_FMIref *fieldref;
95 methodinfo *referermethod;
98 unresolved_subtype_set instancetypes;
99 unresolved_subtype_set valueconstraints;
102 struct unresolved_method {
103 constant_FMIref *methodref;
104 methodinfo *referermethod;
107 unresolved_subtype_set instancetypes;
108 unresolved_subtype_set *paramconstraints;
111 #define SUBTYPESET_IS_EMPTY(stset) \
112 ((stset).subtyperefs == NULL)
114 #define UNRESOLVED_SUBTYPE_SET_EMTPY(stset) \
115 do { (stset).subtyperefs = NULL; } while(0)
117 /* function prototypes ********************************************************/
119 bool resolve_class_from_name(classinfo* referer,methodinfo *refmethod,
126 bool resolve_classref(methodinfo *refmethod,
127 constant_classref *ref,
133 bool resolve_classref_or_classinfo(methodinfo *refmethod,
134 classref_or_classinfo cls,
140 classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess);
142 bool resolve_class_from_typedesc(typedesc *d,bool checkaccess,bool link,classinfo **result);
144 #ifdef ENABLE_VERIFIER
145 bool resolve_class(unresolved_class *ref,
150 classinfo * resolve_class_eager(unresolved_class *ref);
151 classinfo * resolve_class_eager_no_access_check(unresolved_class *ref);
152 #endif /* ENABLE_VERIFIER */
154 bool resolve_field(unresolved_field *ref,
158 bool resolve_method(unresolved_method *ref,
160 methodinfo **result);
162 classinfo * resolve_classref_eager(constant_classref *ref);
163 classinfo * resolve_classref_eager_nonabstract(constant_classref *ref);
164 fieldinfo * resolve_field_eager(unresolved_field *ref);
165 methodinfo * resolve_method_eager(unresolved_method *ref);
167 #ifdef ENABLE_VERIFIER
168 unresolved_class * create_unresolved_class(methodinfo *refmethod,
169 constant_classref *classref,
170 typeinfo *valuetype);
173 unresolved_field *resolve_create_unresolved_field(classinfo *referer,
174 methodinfo *refmethod,
177 unresolved_method * resolve_create_unresolved_method(classinfo *referer,
178 methodinfo *refmethod,
179 constant_FMIref *methodref,
183 void unresolved_class_free(unresolved_class *ref);
184 void unresolved_field_free(unresolved_field *ref);
185 void unresolved_method_free(unresolved_method *ref);
187 resolve_result_t resolve_method_lazy(methodinfo *refmethod,
188 constant_FMIref *methodref,
191 resolve_result_t resolve_field_lazy(methodinfo *refmethod,
192 constant_FMIref *fieldref);
194 #if defined(ENABLE_VERIFIER)
195 resolve_result_t resolve_field_verifier_checks(methodinfo *refmethod,
196 constant_FMIref *fieldref,
197 classinfo *container,
199 typeinfo *instanceti,
204 bool resolve_constrain_unresolved_field(unresolved_field *ref,
206 methodinfo *refmethod,
207 typeinfo *instanceti,
210 resolve_result_t resolve_method_verifier_checks(methodinfo *refmethod,
211 constant_FMIref *methodref,
215 resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
217 typeinfo *instanceti,
220 resolve_result_t resolve_method_param_type_checks(jitdata *jd,
221 methodinfo *refmethod,
226 resolve_result_t resolve_method_param_type_checks_stackbased(
227 methodinfo *refmethod,
230 typedescriptor *stack);
232 bool resolve_method_loading_constraints(classinfo *referer,
235 bool resolve_constrain_unresolved_method_instance(unresolved_method *ref,
236 methodinfo *refmethod,
237 typeinfo *instanceti,
240 bool resolve_constrain_unresolved_method_params(jitdata *jd,
241 unresolved_method *ref,
242 methodinfo *refmethod,
245 bool resolve_constrain_unresolved_method_params_stackbased(
246 unresolved_method *ref,
247 methodinfo *refmethod,
248 typedescriptor *stack);
250 #endif /* defined(ENABLE_VERIFIER) */
253 void unresolved_class_debug_dump(unresolved_class *ref,FILE *file);
254 void unresolved_field_debug_dump(unresolved_field *ref,FILE *file);
255 void unresolved_method_debug_dump(unresolved_method *ref,FILE *file);
256 void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file);
259 #endif /* _RESOLVE_H */
262 * These are local overrides for various environment variables in Emacs.
263 * Please do not remove this and leave it at the end of the file, where
264 * Emacs will automagically detect them.
265 * ---------------------------------------------------------------------
268 * indent-tabs-mode: t
272 * vim:noexpandtab:sw=4:ts=4: