-/* vm/resolve.h - resolving classes/interfaces/fields/methods
+/* src/vm/resolve.h - resolving classes/interfaces/fields/methods
- Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
- R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
- C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
- Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
This file is part of CACAO.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
-
- Contact: cacao@complang.tuwien.ac.at
-
- Authors: Edwin Steiner
-
- Changes:
-
- $Id: resolve.h 2086 2005-03-25 17:12:35Z edwin $
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
*/
+
#ifndef _RESOLVE_H
#define _RESOLVE_H
-#include "vm/global.h"
-#include "vm/jit/jit.h"
-
/* forward declarations *******************************************************/
+typedef struct unresolved_class unresolved_class;
typedef struct unresolved_field unresolved_field;
typedef struct unresolved_method unresolved_method;
typedef struct unresolved_subtype_set unresolved_subtype_set;
+
+#include "config.h"
+#include "vm/types.h"
+
+#include "vm/global.h"
+
+#include "vm/jit/jit.h"
+#include "vm/jit/reg.h"
+#include "vm/jit/verify/typeinfo.h"
+
+#include "vmcore/class.h"
+#include "vmcore/field.h"
+#include "vmcore/method.h"
+#include "vmcore/references.h"
+
+
/* constants ******************************************************************/
-#define RESOLVE_STATIC 0x0001
-#define RESOLVE_PUTFIELD 0x0002
+#define RESOLVE_STATIC 0x0001 /* ref to static fields/methods */
+#define RESOLVE_PUTFIELD 0x0002 /* field ref inside a PUT{FIELD,STATIC}... */
+#define RESOLVE_SPECIAL 0x0004 /* method ref inside INVOKESPECIAL */
+
/* enums **********************************************************************/
resolveIllegalAccessError
} resolve_err_t;
+typedef enum {
+ resolveFailed = false, /* this must be a false value */
+ resolveDeferred = true, /* this must be a true value */
+ resolveSucceeded
+} resolve_result_t;
+
/* structs ********************************************************************/
struct unresolved_subtype_set {
classref_or_classinfo *subtyperefs; /* NULL terminated list */
};
+struct unresolved_class {
+ constant_classref *classref;
+ methodinfo *referermethod;
+ unresolved_subtype_set subtypeconstraints;
+};
+
/* XXX unify heads of unresolved_field and unresolved_method? */
struct unresolved_field {
/* function prototypes ********************************************************/
-/* resolve_class ***************************************************************
-
- Resolve a symbolic class reference
-
- IN:
- referer..........the class containing the reference
- refmethod........the method from which resolution was triggered
- (may be NULL if not applicable)
- classname........class name to resolve
- mode.............mode of resolution:
- resolveLazy...only resolve if it does not
- require loading classes
- resolveEager..load classes if necessary
-
- OUT:
- *result..........set to result of resolution, or to NULL if
- the reference has not been resolved
- In the case of an exception, *result is
- guaranteed to be set to NULL.
-
- RETURN VALUE:
- true.............everything ok
- (*result may still be NULL for resolveLazy)
- false............an exception has been thrown
-
- NOTE:
- The returned class is *not* guaranteed to be linked!
- (It is guaranteed to be loaded, though.)
-
-*******************************************************************************/
-
-bool
-resolve_class(classinfo *referer,methodinfo *refmethod,
- utf *classname,
- resolve_mode_t mode,
- classinfo **result);
-
-/* resolve_classref_or_classinfo ***********************************************
-
- Resolve a symbolic class reference if necessary
-
- IN:
- refmethod........the method from which resolution was triggered
- (may be NULL if not applicable)
- cls..............class reference or classinfo
- mode.............mode of resolution:
- resolveLazy...only resolve if it does not
- require loading classes
- resolveEager..load classes if necessary
- link.............if true, guarantee that the returned class, if any,
- has been linked
-
- OUT:
- *result..........set to result of resolution, or to NULL if
- the reference has not been resolved
- In the case of an exception, *result is
- guaranteed to be set to NULL.
-
- RETURN VALUE:
- true.............everything ok
- (*result may still be NULL for resolveLazy)
- false............an exception has been thrown
-
-*******************************************************************************/
-
-bool
-resolve_classref_or_classinfo(methodinfo *refmethod,
+bool resolve_class_from_name(classinfo* referer,methodinfo *refmethod,
+ utf *classname,
+ resolve_mode_t mode,
+ bool checkaccess,
+ bool link,
+ classinfo **result);
+
+bool resolve_classref(methodinfo *refmethod,
+ constant_classref *ref,
+ resolve_mode_t mode,
+ bool checkaccess,
+ bool link,
+ classinfo **result);
+
+bool resolve_classref_or_classinfo(methodinfo *refmethod,
classref_or_classinfo cls,
resolve_mode_t mode,
+ bool checkaccess,
bool link,
classinfo **result);
-/* resolve_field ***************************************************************
-
- Resolve an unresolved field reference
-
- IN:
- ref..............struct containing the reference
- mode.............mode of resolution:
- resolveLazy...only resolve if it does not
- require loading classes
- resolveEager..load classes if necessary
-
- OUT:
- *result..........set to the result of resolution, or to NULL if
- the reference has not been resolved
- In the case of an exception, *result is
- guaranteed to be set to NULL.
-
- RETURN VALUE:
- true.............everything ok
- (*result may still be NULL for resolveLazy) XXX implement
- false............an exception has been thrown
-
-*******************************************************************************/
-
-bool
-resolve_field(unresolved_field *ref,
+classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess);
+
+bool resolve_class_from_typedesc(typedesc *d,bool checkaccess,bool link,classinfo **result);
+
+#ifdef ENABLE_VERIFIER
+bool resolve_class(unresolved_class *ref,
+ resolve_mode_t mode,
+ bool checkaccess,
+ classinfo **result);
+
+classinfo * resolve_class_eager(unresolved_class *ref);
+classinfo * resolve_class_eager_no_access_check(unresolved_class *ref);
+#endif /* ENABLE_VERIFIER */
+
+bool resolve_field(unresolved_field *ref,
resolve_mode_t mode,
fieldinfo **result);
-/* resolve_method **************************************************************
-
- Resolve an unresolved method reference
-
- IN:
- ref..............struct containing the reference
- mode.............mode of resolution:
- resolveLazy...only resolve if it does not
- require loading classes
- resolveEager..load classes if necessary
-
- OUT:
- *result..........set to the result of resolution, or to NULL if
- the reference has not been resolved
- In the case of an exception, *result is
- guaranteed to be set to NULL.
-
- RETURN VALUE:
- true.............everything ok
- (*result may still be NULL for resolveLazy) XXX implement
- false............an exception has been thrown
-
-*******************************************************************************/
-
-bool
-resolve_method(unresolved_method *ref,
+bool resolve_method(unresolved_method *ref,
resolve_mode_t mode,
methodinfo **result);
-/* resolve_and_check_subtype_set ***********************************************
-
- Resolve the references in the given set and test subtype relationships
-
- IN:
- referer..........the class containing the references
- refmethod........the method triggering the resolution
- ref..............a set of class/interface references
- (may be empty)
- type.............the type to test against the set
- reversed.........if true, test if type is a subtype of
- the set members, instead of the other
- way round
- mode.............mode of resolution:
- resolveLazy...only resolve if it does not
- require loading classes
- resolveEager..load classes if necessary
- error............which type of exception to throw if
- the test fails. May be:
- resolveLinkageError, or
- resolveIllegalAccessError
-
- OUT:
- *checked.........set to true if all checks were performed,
- otherwise set to false
- (This is guaranteed to be true if mode was
- resolveEager and no exception occured.)
- If checked == NULL, this parameter is not used.
-
- RETURN VALUE:
- true.............the check succeeded
- false............the check failed. An exception has been
- thrown.
-
- NOTE:
- The references in the set are resolved first, so any
- exception which may occurr during resolution may
- be thrown by this function.
-
-*******************************************************************************/
-
-bool
-resolve_and_check_subtype_set(classinfo *referer,methodinfo *refmethod,
- unresolved_subtype_set *ref,
- classref_or_classinfo type,
- bool reversed,
- resolve_mode_t mode,
- resolve_err_t error,
- bool *checked);
-
-/* create_unresolved_field *****************************************************
-
- Create an unresolved_field struct for the given field access instruction
-
- IN:
- referer..........the class containing the reference
- refmethod........the method triggering the resolution (if any)
- iptr.............the {GET,PUT}{FIELD,STATIC}{,CONST} instruction
- stack............the input stack of the instruction
-
- RETURN VALUE:
- a pointer to a new unresolved_field struct
-
-*******************************************************************************/
-
-unresolved_field *
-create_unresolved_field(classinfo *referer,methodinfo *refmethod,
- instruction *iptr,
- stackelement *stack);
-
-/* create_unresolved_method ****************************************************
-
- Create an unresolved_method struct for the given method invocation
-
- IN:
- referer..........the class containing the reference
- refmethod........the method triggering the resolution (if any)
- iptr.............the INVOKE* instruction
- stack............the input stack of the instruction
-
- RETURN VALUE:
- a pointer to a new unresolved_method struct
-
-*******************************************************************************/
-
-unresolved_method *
-create_unresolved_method(classinfo *referer,methodinfo *refmethod,
- instruction *iptr,
- stackelement *stack);
-
-/* unresolved_field_free *******************************************************
-
- Free the memory used by an unresolved_field
-
- IN:
- ref..............the unresolved_field
-
-*******************************************************************************/
+classinfo * resolve_classref_eager(constant_classref *ref);
+classinfo * resolve_classref_eager_nonabstract(constant_classref *ref);
+fieldinfo * resolve_field_eager(unresolved_field *ref);
+methodinfo * resolve_method_eager(unresolved_method *ref);
-void unresolved_field_free(unresolved_field *ref);
+#ifdef ENABLE_VERIFIER
+unresolved_class * create_unresolved_class(methodinfo *refmethod,
+ constant_classref *classref,
+ typeinfo *valuetype);
+#endif
-/* unresolved_method_free ******************************************************
-
- Free the memory used by an unresolved_method
-
- IN:
- ref..............the unresolved_method
+unresolved_field *resolve_create_unresolved_field(classinfo *referer,
+ methodinfo *refmethod,
+ instruction *iptr);
-*******************************************************************************/
+unresolved_method * resolve_create_unresolved_method(classinfo *referer,
+ methodinfo *refmethod,
+ constant_FMIref *methodref,
+ bool invokestatic,
+ bool invokespecial);
+void unresolved_class_free(unresolved_class *ref);
+void unresolved_field_free(unresolved_field *ref);
void unresolved_method_free(unresolved_method *ref);
-/* unresolved_field_debug_dump *************************************************
-
- Print debug info for unresolved_field to stream
-
- IN:
- ref..............the unresolved_field
- file.............the stream
-
-*******************************************************************************/
-
+resolve_result_t resolve_method_lazy(methodinfo *refmethod,
+ constant_FMIref *methodref,
+ bool invokespecial);
+
+resolve_result_t resolve_field_lazy(methodinfo *refmethod,
+ constant_FMIref *fieldref);
+
+#if defined(ENABLE_VERIFIER)
+resolve_result_t resolve_field_verifier_checks(methodinfo *refmethod,
+ constant_FMIref *fieldref,
+ classinfo *container,
+ fieldinfo *fi,
+ typeinfo *instanceti,
+ typeinfo *valueti,
+ bool isstatic,
+ bool isput);
+
+bool resolve_constrain_unresolved_field(unresolved_field *ref,
+ classinfo *referer,
+ methodinfo *refmethod,
+ typeinfo *instanceti,
+ typeinfo *valueti);
+
+resolve_result_t resolve_method_verifier_checks(methodinfo *refmethod,
+ constant_FMIref *methodref,
+ methodinfo *mi,
+ bool invokestatic);
+
+resolve_result_t resolve_method_instance_type_checks(methodinfo *refmethod,
+ methodinfo *mi,
+ typeinfo *instanceti,
+ bool invokespecial);
+
+resolve_result_t resolve_method_param_type_checks(jitdata *jd,
+ methodinfo *refmethod,
+ instruction *iptr,
+ methodinfo *mi,
+ bool invokestatic);
+
+resolve_result_t resolve_method_param_type_checks_stackbased(
+ methodinfo *refmethod,
+ methodinfo *mi,
+ bool invokestatic,
+ typedescriptor *stack);
+
+bool resolve_method_loading_constraints(classinfo *referer,
+ methodinfo *mi);
+
+bool resolve_constrain_unresolved_method_instance(unresolved_method *ref,
+ methodinfo *refmethod,
+ typeinfo *instanceti,
+ bool invokespecial);
+
+bool resolve_constrain_unresolved_method_params(jitdata *jd,
+ unresolved_method *ref,
+ methodinfo *refmethod,
+ instruction *iptr);
+
+bool resolve_constrain_unresolved_method_params_stackbased(
+ unresolved_method *ref,
+ methodinfo *refmethod,
+ typedescriptor *stack);
+
+#endif /* defined(ENABLE_VERIFIER) */
+
+#ifndef NDEBUG
+void unresolved_class_debug_dump(unresolved_class *ref,FILE *file);
void unresolved_field_debug_dump(unresolved_field *ref,FILE *file);
-
-/* unresolved_method_debug_dump ************************************************
-
- Print debug info for unresolved_method to stream
-
- IN:
- ref..............the unresolved_method
- file.............the stream
-
-*******************************************************************************/
-
void unresolved_method_debug_dump(unresolved_method *ref,FILE *file);
-
-/* unresolved_subtype_set_debug_dump *******************************************
-
- Print debug info for unresolved_subtype_set to stream
-
- IN:
- stset............the unresolved_subtype_set
- file.............the stream
-
-*******************************************************************************/
-
void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file);
+#endif
#endif /* _RESOLVE_H */