On Wednesday, 20 April 2016 at 13:41:27 UTC, Nordlöw wrote:
At

https://github.com/nordlow/phobos-next/blob/master/src/variant_pointer.d

I've implemented a pointer-only version of Variant called VariantPointer.

I plan to use it to construct light-weight polymorphism in trie containers for D I'm currently writing.

VariantPointer uses the top N-bits (N currently 8) to encode the type pointed to be the untyped-pointer encoded in the 64-N bits lower bits.

My question is:

It safe to assume that `typeBits` most significant bits of a pointer on a 64-bit system are always zero?

Note that I didn't want to use the lower bits because I'm currently unsure whether I need to represent stack-pointers aswell.

Linux seems to reject mmap requests at or above 0x80000000000, though the vsyscall page is at 0xffffffffff600000 near the end of the virtual memory space. So it might work on Linux.

As for the GC, you're probably out of luck. Adding a global mask option is unlikely to work well if multiple libraries use it.

Reply via email to