On 21/01/17 17:30, Nick Treleaven wrote:
On Saturday, 14 January 2017 at 15:30:42 UTC, Rainer Schuetze wrote:
In addition, you need to lookup the pool anyway to figure out if the
pointer points to non-managed memory (stack, global data, malloc'd
memory).
Makes me wonder about a GC'd language where each pointer is actually a
member of a struct which also has a base allocation pointer. The base
pointer could either only be set for managed allocations, or the low bit
of the base address could be used to indicate such instead*. This would
make for faster GC scans, but would also cause slowdowns when copying
pointers. Pointer arithmetic would be just as efficient though.
(*) With this scheme, pointer arithmetic can be @safe in assert mode.
You are neglecting to account for cache locality performance cost. An
array of pointers would, under this plan, store half as many pointers in
a single cache line. This means handling this array would be, give or
take, half as fast. That's a huge price to pay.
Shachar