aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/verify-impl.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2005-02-19 01:14:17 +0000
committerTom Tromey <tromey@gcc.gnu.org>2005-02-19 01:14:17 +0000
commit1870a43b3e9ab55bc5b29284c64be32d08989bf3 (patch)
tree70744c5a070902162b614e77d6868d603b6be97f /gcc/java/verify-impl.c
parent4c334b377cb494b44fabd5f5263d53863f051748 (diff)
downloadgcc-1870a43b3e9ab55bc5b29284c64be32d08989bf3.zip
gcc-1870a43b3e9ab55bc5b29284c64be32d08989bf3.tar.gz
gcc-1870a43b3e9ab55bc5b29284c64be32d08989bf3.tar.bz2
re PR java/20056 ('verification failed: incompatible type on stack' with --indirect-dispatch)
PR java/20056: * verify-glue.c (vfy_class_has_field): New function. * verify.h (vfy_class_has_field): Declare. * verify-impl.c (check_field_constant): Added 'putfield' argument. (verify_instructions_0): Updated. (types_equal): New function. From-SVN: r95258
Diffstat (limited to 'gcc/java/verify-impl.c')
-rw-r--r--gcc/java/verify-impl.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/gcc/java/verify-impl.c b/gcc/java/verify-impl.c
index ee8f426..376f749 100644
--- a/gcc/java/verify-impl.c
+++ b/gcc/java/verify-impl.c
@@ -738,6 +738,20 @@ types_compatible (type *t, type *k)
return ref_compatible (t->klass, k->klass);
}
+/* Return true if two types are equal. Only valid for reference
+ types. */
+static bool
+types_equal (type *t1, type *t2)
+{
+ if (t1->key != reference_type || t1->key != uninitialized_reference_type
+ || t2->key != reference_type || t2->key != uninitialized_reference_type)
+ return false;
+ /* Only single-ref types are allowed. */
+ if (t1->klass->ref_next || t2->klass->ref_next)
+ return false;
+ return refs_equal (t1->klass, t2->klass);
+}
+
static bool
type_isvoid (type *t)
{
@@ -2117,9 +2131,10 @@ handle_field_or_method (int index, int expected,
return check_class_constant (class_index);
}
-/* Return field's type, compute class' type if requested. */
+/* Return field's type, compute class' type if requested. If
+ PUTFIELD is true, use the special 'putfield' semantics. */
static type
-check_field_constant (int index, type *class_type)
+check_field_constant (int index, type *class_type, bool putfield)
{
vfy_string name, field_type;
const char *typec;
@@ -2137,6 +2152,17 @@ check_field_constant (int index, type *class_type)
init_type_from_string (&t, field_type);
else
init_type_from_tag (&t, get_type_val_for_signature (typec[0]));
+
+ /* We have an obscure special case here: we can use `putfield' on a
+ field declared in this class, even if `this' has not yet been
+ initialized. */
+ if (putfield
+ && ! type_initialized (&vfr->current_state->this_type)
+ && vfr->current_state->this_type.pc == SELF
+ && types_equal (&vfr->current_state->this_type, &ct)
+ && vfy_class_has_field (vfr->current_class, name, field_type))
+ type_set_uninitialized (class_type, SELF);
+
return t;
}
@@ -2971,15 +2997,15 @@ verify_instructions_0 (void)
invalidate_pc ();
break;
case op_getstatic:
- push_type_t (check_field_constant (get_ushort (), NULL));
+ push_type_t (check_field_constant (get_ushort (), NULL, false));
break;
case op_putstatic:
- pop_type_t (check_field_constant (get_ushort (), NULL));
+ pop_type_t (check_field_constant (get_ushort (), NULL, false));
break;
case op_getfield:
{
type klass;
- type field = check_field_constant (get_ushort (), &klass);
+ type field = check_field_constant (get_ushort (), &klass, false);
pop_type_t (klass);
push_type_t (field);
}
@@ -2987,15 +3013,8 @@ verify_instructions_0 (void)
case op_putfield:
{
type klass;
- type field = check_field_constant (get_ushort (), &klass);
+ type field = check_field_constant (get_ushort (), &klass, true);
pop_type_t (field);
-
- /* We have an obscure special case here: we can use
- `putfield' on a field declared in this class, even if
- `this' has not yet been initialized. */
- if (! type_initialized (&vfr->current_state->this_type)
- && vfr->current_state->this_type.pc == SELF)
- type_set_uninitialized (&klass, SELF);
pop_type_t (klass);
}
break;