I did not think of memory moves issues during GC and others. I will
have to look at it.
Actually I already thought about your 3rd solution (not at assembly
level though). I give some details below.
Your 2nd solution seems nice. It seems it would only need very precise
and confined changes, and avoid memory moves issues.
For now aligning everything to 8 bytes is easy and seems to work fine.
My shell crashes too fast to reach other doubles bad alignment errors.
I am not yet very familiar with architecture independent code and have
other issues to fix on my shell, so I think I will leave this aside
until I get a better understanding, and then make something efficient.
Here are some details on the solution I thought about:
It seems that this double value is only accessed through the WRITE or
READ_DOUBLE_FIELD macros (objects-inl.h line 700), and that HeapNumber
is the only one using this.
Assuming HeapNumber is the only one using this (else we can make 2
macros just for it) and that only these macros are used to access the
double field, ce can increase the HeapNumber size by 4 and make both
macros both access 8-bytes aligned double address.
The issue with this approach is that the HeapNumber kOffsetValue will
stay the same for all, but in half of the cases the double value will
indeed be stored at address+kValueOffset , and for the other half it
will be at address+kValueOffset+4 (depending on if the HeapNumber
address is 8 or 4 bytes aligned). I don't like much the idea of a
value being actually stored at a different offset for a same kind of
Object (while at first sight the offset seems to be the same as
kOffsetValue does not change), but this might be more efficient than
aligning everything to 8 bytes.
Thanks
On Sep 25, 1:08 am, Erik Corry <
erik.co...@gmail.com> wrote:
> 2009/9/25 Erik Corry <
erik.co...@gmail.com>
>
>
>
> > Personally I think 8-byte aligning by rounding all object sizes up to a
> > multiple of 8 is the easiest. It's a 2 byte penalty per object on average.
> > An alternative is to generate code that loads fp values into consecutive
> > integer registers and uses dmtc1 to move to floating point registers. You
> > somehow need to persuade the C++ compiler to do the same when accessing heap
> > numbers, perhaps with gcc inline assembly.
>
> > A third possibility is to make heap numbers 16 byte and leave all other
> > objects alone. The store sequence is then (the tagged address of the heap
> > number object is in r0):
>
> > ori r1, r0, #4
> > addi r1, r1, 3 // 4 bytes minus heap object tag.
> > store fp to address in r1
>
> > (Sadly in MIPS IV the ldc1 instruction doesn't allow you to combine the
> > addi into it by providing an offset that is not divisible by 8.)
>
> > That makes the store always be aligned somewhere in the last 3 quarters of
> > the heap number. The load would be similar. The two places where the
> > garbage collector moves objects it would need to move the map and the fp
> > number separately instead of using memcpy to ensure that the fp number is
> > correctly aligned in the new location. I can't remember whether the
>
> I can't remember what I couldn't remember there!
>
>
>
>
>
> > 2009/9/25 Søren Gjesse <
sgje...@chromium.org>
>
> > Aligning all objects to 8-byte boundaries will loose a lot of space in the
> >> heap, also it is not only an issue when allocating in new-space, but when
> >> allocating in ole space as well (I don't think we allocate tenured
> >> HeapNumbers though). Also during both scavenge and compacting garbage
> >> collection this property needs to be preserved. One option would be to have
> >> the alignment in new-space only, and then make a separate space for
> >> HeapNumbers, where each HeapNumber would occupy 4 words, this would waste
> >> one word per heap number though. There are already separate spaces for some
> >> fixed sized objects.
> >> If you want to start out with aligning all HeapNumbers make sure to place
> >> heap filler objects when skipping a work for allocation purposes as the GC
> >> needs this for consistency.
>
> >> Regards,
> >> Søren
>
> c/o Philip & Partners, 7 Vognmagergade, ...
>
> read more »