On 11-12-2012 02:49, Timon Gehr wrote:
On 12/11/2012 01:04 AM, Alex Rønne Petersen wrote:
http://xtzgzorex.wordpress.com/2012/12/11/array-slices-and-interior-pointers/
Destroy.
Why does the internal representation have to be the same for a managed
port and native D? Also, how does the second representation work
exactly? Not all slices extend to the end of the memory block.
They don't have to be. Ideally it shouldn't even have to matter because
D code shouldn't make assumptions about it.
And good point. That makes the second variation not useful for VMs that
don't natively support slicing arrays, so I'll scratch that as a useful
representation. A representation for a VM would then probably need to be
{length, base, offset} (which could also work for a native D).
I don't really feel strongly about the memory requirements for slices,
but 12 / 24 bytes is starting to feel a little bulky. I am not
intimately familiar with druntime, but OTOH and AFAICS, the additional
pointer should also allow faster retrieval of the slice's capacity.
(though the compiler should IMHO implement specific optimizations for ~=
in loops anyway.)
Some optimizations can probably be done when the base pointer is known.
--
Alex Rønne Petersen
a...@lycus.org
http://lycus.org