Patch: RFC: alignment fix in resolve.cc
Tom Tromey
tromey@redhat.com
Sun Apr 13 19:26:00 GMT 2003
Last night I had a dream that told me about a potential bug in libgcj.
This morning I looked, and sure enough the recent alignment changes
weren't propagated to the runtime code that lays out interpreted
classes.
I believe there is no way to observe a bug here with 3.3. I tried to
think of a case but couldn't. (Maybe I'll have another dream to tell
me :-)
However, I think this problem could be visible on the trunk if using
-fno-assume-compiled. And of course this will be an issue if/when
-findirect-dispatch is fully implemented.
Andrew, what do you think?
I haven't tested (or even compiled) this yet.
I wasn't sure how to get the alignment of the superclass, so the
patch just uses Object in all cases. It seemed to me that that must
be ok; hopefully someone will tell me if I'm mistaken.
Tom
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
* resolve.cc (_Jv_PrepareClass): Properly align first data member
of class.
Index: libjava/resolve.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/resolve.cc,v
retrieving revision 1.34.2.2
diff -u -r1.34.2.2 resolve.cc
--- libjava/resolve.cc 3 Feb 2003 21:04:50 -0000 1.34.2.2
+++ libjava/resolve.cc 13 Apr 2003 19:13:45 -0000
@@ -469,6 +469,7 @@
instance_size = java::lang::Object::class$.size();
static_size = 0;
+ bool is_first_data_member = true;
for (int i = 0; i < clz->field_count; i++)
{
int field_size;
@@ -506,6 +507,13 @@
}
else
{
+ if (is_first_data_member
+ && field_align < __alignof__ (java::lang::Object))
+ {
+ is_first_data_member = false;
+ field_align = __alignof__ (java::lang::Object);
+ }
+
instance_size = ROUND (instance_size, field_align);
field->u.boffset = instance_size;
instance_size += field_size;
More information about the Java-patches
mailing list