This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[BC] Patch: RFA: itable fix


Tom Tromey writes:
 > I found the interface dispatch bug.  In build_invokeinterface, we
 > compute both `interface' and `idx' using the same index.  Patch
 > appended.
 > 
 > I'm asking for approval rather than just committing it since the code
 > here is weird and it would be nice to have someone else take a quick
 > look.
 > 
 > The oddity is that the data type declarations in the compiler don't
 > match what I see in Class.h.
 > 
 > In the compiler:
 > 
 >   itable_type = build_array_type (ptr_type_node, 
 > 				  one_elt_array_domain_type);
 >   TYPE_NONALIASED_COMPONENT (itable_type) = 1;
 >   itable_ptr_type = build_pointer_type (itable_type);
 > 
 >   PUSH_FIELD (class_type_node, field, "itable", itable_ptr_type);
 > 
 > So it looks like an itable is a `void *[]'.
 > 
 > In Class.h:
 > 
 >     struct _Jv_AddressTable
 >     {
 >       jint state;
 >       void *addresses[];
 >     };
 > 
 >     _Jv_AddressTable *itable;
 > 
 > Are we relying on padding to ensure that these are compatible?
 > Why not just declare things the same in both places?  That is both
 > more understandable and safer.

Yes, much.

 > Anyway, on that theory I think my patch is ok.  The first interface
 > method is given index 1 by the compiler (so "slots" 1 and 2), which is
 > really index 0 to the runtime (same slots).

This is a known (at least, known to me) bug that dates from some of
the earliest BC code and has been perpetuated because of inertia.  It
should be fixed before we release any of this code.

 > Index: ChangeLog
 > from  Tom Tromey  <tromey@redhat.com>
 > 
 > 	* expr.c (build_invokeinterface): Compute correct offset for
 > 	index into interface methods.

Thanks.  FWIW, this did work before but broke as a consequence of the
merge.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]