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
36 constant_FMIref *fieldref;
39 #if !defined(TYPECHECK_TYPEINFERER)
40 resolve_result_t result;
43 TYPECHECK_COUNT(stat_ins_field);
45 instanceti = (instance) ? &(instance->typeinfo) : NULL;
46 valueti = (value && value->type == TYPE_ADR) ? &(value->typeinfo) : NULL;
48 /* get the field reference from the instruction */
50 if (INSTRUCTION_IS_UNRESOLVED(state->iptr)) {
51 uf = state->iptr->sx.s23.s3.uf;
52 fieldref = uf->fieldref;
56 fieldref = state->iptr->sx.s23.s3.fmiref;
59 #if !defined(TYPECHECK_TYPEINFERER)
60 /* check the basic value type for PUT instructions */
62 if (value && value->type != fieldref->parseddesc.fd->type)
63 VERIFY_ERROR("Field type mismatch");
65 /* try to resolve the field reference lazily */
67 result = resolve_field_lazy(state->m, fieldref);
69 if (result == resolveSucceeded) {
72 /* perform verification checks now */
74 fi = fieldref->p.field;
76 result = resolve_field_verifier_checks(
77 state->m, fieldref, fi->class, fi,
83 if (result == resolveFailed)
86 /* if not resolved, yet, create an unresolved field */
88 if (result != resolveSucceeded) {
90 uf = resolve_create_unresolved_field(state->m->class,
91 state->m, state->iptr);
95 state->iptr->sx.s23.s3.uf = uf;
96 state->iptr->flags.bits |= INS_FLAG_UNRESOLVED;
99 /* record the subtype constraints for this field access */
101 if (!resolve_constrain_unresolved_field(
102 uf, state->m->class, state->m,
103 instanceti, valueti))
104 EXCEPTION; /* XXX maybe wrap exception? */
106 TYPECHECK_COUNTIF(INSTRUCTION_IS_UNRESOLVED(state->iptr),stat_ins_field_unresolved);
107 TYPECHECK_COUNTIF(INSTRUCTION_IS_RESOLVED(state->iptr) &&
108 !state->iptr->sx.s23.s3.fmiref->p.field->class->initialized,
109 stat_ins_field_uninitialized);
111 #endif /* !defined(TYPECHECK_TYPEINFERER) */
113 /* write the result type */
116 #if defined(TYPECHECK_STACKBASED)
119 if (IS_2_WORD_TYPE(fieldref->parseddesc.fd->type)) {
120 CHECK_STACK_SPACE(2);
123 stack[0].type = TYPE_VOID;
126 CHECK_STACK_SPACE(1);
132 #define DST VAROP(state->iptr->dst)
134 DST->type = fieldref->parseddesc.fd->type;
135 if (DST->type == TYPE_ADR) {
136 if (!typeinfo_init_from_typedesc(fieldref->parseddesc.fd,NULL,&(DST->typeinfo)))
144 * These are local overrides for various environment variables in Emacs.
145 * Please do not remove this and leave it at the end of the file, where
146 * Emacs will automagically detect them.
147 * ---------------------------------------------------------------------
150 * indent-tabs-mode: t
154 * vim:noexpandtab:sw=4:ts=4:filetype=c: