From: Godmar Back (gback@cs.utah.edu)
Date: Fri Feb 12 1999 - 16:08:37 EST
>
> Your correct - an additional minor fix is also required - the alignment
> should be done *only* if it's the first object (oldoffset == 0) - that
> might be better.
>
Still doesn't work.
You don't address the underlying problem: you don't know what the
required alignment for a subclass is when you compute the offsets for
the baseclass.
We don't change the first alignment for a baseclass if we compute the
subclass, we just assume we can append and add to the offsets. It is
this assumption that's wrong.
With the latest suggestions, for instance, you get:
GCLayout for java/io/ObjectStreamClass:
offset= 4 nbits= 1 01 fsize= 4 (name)
offset= 8 nbits= 2 011 fsize= 4 (clazz)
That would be fine for pure ObjectStreamClass objects.
But when we compute the subclass, we just append, like so:
GCLayout for kaffe/io/ObjectStreamClassImpl:
offset= 12 nbits= 3 0110 fsize= 4 (method)
offset= 16 nbits= 4 01100 fsize= 8 (serialVersionUID)
offset= 24 nbits= 6 0110001 fsize= 4 (superstream)
offset= 28 nbits= 7 01100011 fsize= 4 (iclazz)
offset= 32 nbits= 8 011000111 fsize= 4 (fields)
That's wrong. For the subclass, the right offsets are:
offset= 8 (name)
offset= 12 (clazz)
offset= 16 (method)
offset= 24 (serialVersionUID)
offset= 28 (superstream)
offset= 32 (iclazz)
offset= 36 (fields)
gdb confirms my computations:
(gdb) p *cls
$1 = {base = {dtable = 0x11fdd0}, data = {{name = 0x15c6b8, clazz = 0x2,
method = 0, serialVersionUID = 0x0000000000000000, superstream = 0x0,
iclazz = 0x0, fields = 0x184d80}}}
(gdb) p (void*)&cls.data.name - (void*)cls
$2 = 8
(gdb) p (void*)&cls.data.clazz - (void*)cls
$3 = 12
(gdb) p (void*)&cls.data.method - (void*)cls
$4 = 16
(gdb) p (void*)&cls.data.serialVersionUID - (void*)cls
$5 = 24
(gdb) p (void*)&cls.data.superstream - (void*)cls
$6 = 32
Note how the offsets of "name" and "clazz" change due to subclassing.
- Godmar
This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:58:07 EDT