[squeak-dev] Re: FFI related questions

Kragen Javier Sitaker kragen at canonical.org
Tue Jan 5 20:24:37 UTC 2010


On Tue, Jan 05, 2010 at 09:13:28PM +0100, Andreas Raab wrote:

> You're right it [DoubleArray]'s nontrivial, at least for the current
> object model.  Many platforms have 8 byte alignment requirements for
> doubles and our oops are only 4 byte aligned. This is the main reason
> why there isn't a double array - since garbage collector will move
> objects around there is absolutely no guarantee that the double array
> will be 8 byte aligned.  And having a double array that the code in
> the VM needs to shift to align properly would completely defeat the
> purpose of having it in the first place. This may change with the move
> to 64 bit or perhaps with some of Eliot's ideas about changing the
> object format, but it's nothing that is going to happen in the short
> term.

DoubleArrays can't contain any pointers, so the GC doesn't have to know
about them directly; you can allocate their contents in a separate heap and
maintain reference counts using finalizers, leaving only a small
DoubleArray object in the regular heap containing something analogous to
an object table index.

This runs into the usual problems with finalizers (you may get
suboptimal performance if the relative sizes of your heaps are too
different, although that's not usually a huge problem in practice) but
it's something that you could do relatively easily, without changing the
object format.

Perhaps, since we have almost 40 years of experience in implementing
Smalltalk, this has been tried already. Does it work well in practice?

Kragen



More information about the Squeak-dev mailing list