Subject: bug#14599: An option to make vector allocation aligned

From: [email-masked] (Ludovic Courtès)
Date: Thu, 13 Jun 2013 15:31:01 +0200

Hi,

Thanks for sharing your thoughts on this!

Jan Schukat <[email-masked]> skribis:

> Extending the programming api to support this is a bit more tricky. I
> guess most straightforward and backward compatible would be to just at
> a set of make-aligned-*vector and aligned-*vector and
> *->aligned-*vector functions and their scm_* versions with an
> additional alignment parameter. Optional alignment parameters on the
> old functions could be nice too, but I guess that is just asking for
> compatibility trouble.

What about something like ‘make-aligned-bytevector’?  This should be
enough, since bytevectors can be accessed through the SRFI-4 API (info
"(guile) Bytevectors as Uniform Arrays").  (And it can already be
implemented in Scheme, as I showed previously.)

> The other question is the read syntax (one of the primary reasons I'm
> doing all this). If alignment is something that should be preserved in
> the permanent representation, you also need to store it in the flags,
> since the content pointer can be aligned by coincidence. I haven't
> looked at the compiling of bytevectors yet, to see if alignment can be
> handled easily there.

I agree that we’d need some sort of annotation to specify the alignment
of literals, but adding read syntax for that scares me somewhat.  What
do people think?

On the compilation side, I think alignment will be more easily handled
in 2.2 (current ‘master’), which uses ELF (think of GCC’s ‘alignment’
attribute.)

None of this really seems doable in the 2.0 stable series.  So for now
you’d have to resort to one of the options discussed.

WDYT?

Thanks,
Ludo’.