[MLton] x86_64 port status
Matthew Fluet
fluet@cs.cornell.edu
Mon, 8 May 2006 10:15:38 -0400 (EDT)
> > I'm hoping that they are benign. What's going on is that we are allocating
> > space for a C struct in ML as a Word8.word array or a Word8.word vector.
> > These are passed through the FFI as pointers:
> >
> > typedef unsigned char* Pointer;
> > #define Array(t) Pointer
> > #define Ref(t) Pointer
> > #define Vector(t) const Pointer
>
> May break aliasing rules. Use unions. This also ensures
> correct alignment.
I was under the impression that 'unsigned char*' implies that it may alias
with anything, so that this specifically doesn't break aliasing rules.
Union with what? The point is that the callers of these functions are not
C/gcc; they are the MLton codegen (which, admittedly, might be C/gcc, but
equally well might not). We can't guarantee anything more than what the
codegen's guarantee: namely, that the start of ML objects will be 4-byte
aligned. (It is a compile time option to ensure 8-byte alignment, but we
need to be conservative at compile-compile time.)