1 /* src/vm/jit/verify/typecheck-fields.inc - type checking for field ICMDs
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
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
25 Contact: cacao@cacaojvm.org
27 Authors: Edwin Steiner
38 constant_FMIref *fieldref;
41 #if !defined(TYPECHECK_TYPEINFERER)
42 resolve_result_t result;
45 TYPECHECK_COUNT(stat_ins_field);
47 instanceti = (instance) ? &(instance->typeinfo) : NULL;
48 valueti = (value && value->type == TYPE_ADR) ? &(value->typeinfo) : NULL;
50 /* get the field reference from the instruction */
52 if (INSTRUCTION_IS_UNRESOLVED(state->iptr)) {
53 uf = state->iptr->sx.s23.s3.uf;
54 fieldref = uf->fieldref;
58 fieldref = state->iptr->sx.s23.s3.fmiref;
61 #if !defined(TYPECHECK_TYPEINFERER)
62 /* check the basic value type for PUT instructions */
64 if (value && value->type != fieldref->parseddesc.fd->type)
65 VERIFY_ERROR("Field type mismatch");
67 /* try to resolve the field reference lazily */
69 result = resolve_field_lazy(state->m, fieldref);
71 if (result == resolveSucceeded) {
74 /* perform verification checks now */
76 fi = fieldref->p.field;
78 result = resolve_field_verifier_checks(
79 state->m, fieldref, fi->class, fi,
85 if (result == resolveFailed)
88 /* if not resolved, yet, create an unresolved field */
90 if (result != resolveSucceeded) {
92 uf = resolve_create_unresolved_field(state->m->class,
93 state->m, state->iptr);
97 state->iptr->sx.s23.s3.uf = uf;
98 state->iptr->flags.bits |= INS_FLAG_UNRESOLVED;
101 /* record the subtype constraints for this field access */
103 if (!resolve_constrain_unresolved_field(
104 uf, state->m->class, state->m,
105 instanceti, valueti))
106 EXCEPTION; /* XXX maybe wrap exception? */
108 TYPECHECK_COUNTIF(INSTRUCTION_IS_UNRESOLVED(state->iptr),stat_ins_field_unresolved);
109 TYPECHECK_COUNTIF(INSTRUCTION_IS_RESOLVED(state->iptr) &&
110 !state->iptr->sx.s23.s3.fmiref->p.field->class->initialized,
111 stat_ins_field_uninitialized);
113 #endif /* !defined(TYPECHECK_TYPEINFERER) */
115 /* write the result type */
118 #if defined(TYPECHECK_STACKBASED)
121 if (IS_2_WORD_TYPE(fieldref->parseddesc.fd->type)) {
122 CHECK_STACK_SPACE(2);
125 stack[0].type = TYPE_VOID;
128 CHECK_STACK_SPACE(1);
134 #define DST VAROP(state->iptr->dst)
136 DST->type = fieldref->parseddesc.fd->type;
137 if (DST->type == TYPE_ADR) {
138 if (!typeinfo_init_from_typedesc(fieldref->parseddesc.fd,NULL,&(DST->typeinfo)))
146 * These are local overrides for various environment variables in Emacs.
147 * Please do not remove this and leave it at the end of the file, where
148 * Emacs will automagically detect them.
149 * ---------------------------------------------------------------------
152 * indent-tabs-mode: t
156 * vim:noexpandtab:sw=4:ts=4:filetype=c: