[M3devel] fewer wrappers/more C? (or a wash?)
Mika Nystrom
mika at async.caltech.edu
Mon Apr 20 17:31:32 CEST 2009
I just wanted to point out that the discussion about X pointers
is introducing a large red herring into the discussion about tagged REFANYs.
The tagged REFANY idea just depends on Modula-3's own heap allocator's
returning aligned addresses. If they're not aligned, you can't tag
the REFANY. If they are, you can, because the only thing ever held by
a REFANY is a Modula-3-heap-allocated address, NIL, or a tagged value.
X pointers should clearly be passed as ADDRESS, not as REFANY. Completely
different issue.
Mika
Jay writes:
>
>> 1. Some heap objects have to be aligned because they contain a field or
>> element
>> that must be aligned. Examples are an open array of INTEGER and a
>> linked-list node that contains a pointer. And,
>
>
>And on every system there exist fields/elements that really require alignment?
>
>
>The following works fine for me..x86 tends to be very lax on requiring any alignment.
>
>
>#include
>
>
>int main()
>{
>unsigned char a[20];
>unsigned i;
>
>
>for (i = 0 ; i < 20 ; ++i)
> a[i] = (unsigned char)i;
>
>
>for (i = 0 ; i < 8 ; ++i)
> printf("%x\n", *(unsigned*)&a[i]);
>
>for (i = 0 ; i < 8 ; ++i)
> printf("%f\n", *(double*)&a[i]);
>
>return 0;
>}
>
>
>I think we only care about Modula-3 heap allocated pointers, so what
>folks do in their C code doesn't matter.
>We can even introduce and depend upon higher alignment than the hardware requires
>or the underlying allocator provides.
>
>
>I realize that SPARC, MIPS, maybe Alpha, ARM?, IA64, and probably others,
>do have hardware-enforced alignment requirements.
>(Having debugged some of them.)
>
>
>I'm mostly just causing trouble.
>The proposals are all somewhat dangerous, but in reality they are ok,
>and can buy significant efficiencies in certain applications.
>Alignment is normal, even on x86.
>
>
>Btw, presumably on a 64 bit system, you can get a 32bit float in one of these things.
>
>
>
> - Jay
More information about the M3devel
mailing list