Class Instance allocations

bearophile bearophileHUGS at lycos.com
Thu Jan 14 05:06:07 PST 2010


Steven Schveighoffer:
> I'm not sure if SSE register requires alignment.  Typically  
> on systems that do not support loading from a byte-aligned memory segment  
> will throw a bus error if you try to do it.

I think SSE registers require 8 byte alignment, but some of their operations are faster with data aligned on 16 bytes. In future this 16 byte alignment requirement will probably be slowly dropped (already partially dropped in core i7). At that point the 16 byte alignment of the D GC can become overkill.


> I think the reason the allocator must return 8-byte aligned memory is  
> because the allocator doesn't know what you're going to put in there, so  
> it must handle the worst case scenario (doubles).

I think it may also be a matter of tag bits added to pointers by the mark phase of the GC. I think two bits may suffice, so I don't know why the alignment to 8. Anyway, the new() method in the class I've shown at the top of this thread is wrong then, because sometimes it returns aligned to 4. It needs some extra machinery to fix this.

Bye,
bearophile



More information about the Digitalmars-d mailing list