This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[BC ABI] Fix generation of type verification assertions
- From: Andrew Haley <aph at redhat dot com>
- To: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 6 Sep 2004 14:59:15 +0100
- Subject: [BC ABI] Fix generation of type verification assertions
- References: <16693.51543.912185.241005@cuddles.cambridge.redhat.com><16693.58779.110358.885898@cuddles.cambridge.redhat.com><16696.33053.10930.410655@cuddles.cambridge.redhat.com>
Reduce even further the runtime assertions that are generated.
This does mean that sufficient type assertions for full runtime
security are not generated, but as we are not keeping full type
information in the curent verifier this can't be helped. To be fixed
with a new verifier, I hope.
Andrew.
2004-09-06 Andrew Haley <aph@redhat.com>
* verify.c (merge_types): Return Object for all merges of
interfaces.
* expr.c (add_type_assertion): Don't generate assertions when
source type is array of Object.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.185.2.11
diff -p -2 -c -r1.185.2.11 expr.c
*** expr.c 3 Sep 2004 14:36:49 -0000 1.185.2.11
--- expr.c 6 Sep 2004 13:55:07 -0000
*************** add_type_assertion (tree source_type, tr
*** 443,447 ****
if (TYPE_ARRAY_P (source_type))
! source_type = build_java_array_type (TYPE_ARRAY_ELEMENT (source_type), -1);
if (TYPE_ARRAY_P (target_type))
target_type = build_java_array_type (TYPE_ARRAY_ELEMENT (target_type), -1);
--- 443,453 ----
if (TYPE_ARRAY_P (source_type))
! {
! // FIXME: This is just a placeholder for merged types. We need to
! // do something more real than this.
! if (TYPE_ARRAY_ELEMENT (source_type) == object_type_node)
! return;
! source_type = build_java_array_type (TYPE_ARRAY_ELEMENT (source_type), -1);
! }
if (TYPE_ARRAY_P (target_type))
target_type = build_java_array_type (TYPE_ARRAY_ELEMENT (target_type), -1);
Index: verify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/verify.c,v
retrieving revision 1.59.10.4
diff -p -2 -c -r1.59.10.4 verify.c
*** verify.c 3 Sep 2004 14:36:49 -0000 1.59.10.4
--- verify.c 6 Sep 2004 13:55:07 -0000
*************** merge_types (tree type1, tree type2)
*** 244,272 ****
}
! if (CLASS_INTERFACE (TYPE_NAME (tt1)))
{
! /* FIXME: should see if two interfaces have a common
! superinterface. */
! if (CLASS_INTERFACE (TYPE_NAME (tt2)))
! {
! /* This is a kludge, but matches what Sun's verifier does.
! It can be tricked, but is safe as long as type errors
! (i.e. interface method calls) are caught at run-time. */
! return object_ptr_type_node;
! }
! else
! {
! if (can_widen_reference_to (tt2, tt1))
! return type1;
! else
! return object_ptr_type_node;
! }
! }
! else if (CLASS_INTERFACE (TYPE_NAME (tt2)))
! {
! if (can_widen_reference_to (tt1, tt2))
! return type2;
! else
! return object_ptr_type_node;
}
--- 244,251 ----
}
! if (CLASS_INTERFACE (TYPE_NAME (tt1))
! || (CLASS_INTERFACE (TYPE_NAME (tt2))))
{
! return object_ptr_type_node;
}