Re: alignment on sparc

Date view Thread view Subject view Author view

From: Godmar Back (gback@cs.utah.edu)
Date: Fri Feb 12 1999 - 15:09:45 EST


>
> Ah heck - what a pain. Kaffe tries to align structures like C - so it trys to
> make sure that the alignment of serialVersionUID is on it's natural boundary
> (for the sparc at least - the x86 doesn't insist on 8 byte boundaries).
> I guess the alignment code is wrong - I will take a look.
>
> Tim
>
> PS. a 'temporary' fix would be to swap the serialVersionUID with method ...
> I think.
>

I'm not so sure.

> > #define HandleTo(class) \
> > typedef struct H##class { \
> > Hjava_lang_Object base; \
> > struct Class##class data[1]; \
> > } H##class

The C compiler will introduce a 4 byte gap between base and data
if struct Class##class has an 8 byte field *anywhere*.
At least that's what Kaffe assumes it does, it aligns the beginning
of a structure according to the maximum alignment required.
Think about it: otherwise, it couldn't guarantee required alignments
for long long or double.

If a superclass like java.io.ObjectStreamClass does not have an
8 byte field, it will not introduce this gap.

If a subclass like kaffe.io.ObjectStreamClass then add an 8 byte
field, the gap is all the sudden there and it is impossible to
cast up.

What Alexandre suggested, I think, was something like:

> > #define HandleTo(class) \
> > typedef struct H##class { \
> > struct Class##class data[1]; \
> > } H##class

And then define struct Class##class differently.

        struct Class##class {
            Hjava_lang_Object base;
            ...
        }

The only other alternative I'd see is to make sure that "data" is
always aligned for the biggest alignment. Would waste 4 bytes on
Sparc, wouldn't make a diff for x86.

        - Godmar


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:58:07 EDT