Use unused high bits for additional pointer tags on x64
This idea has came up at last ICFP, again at ZuriHac and again recently in a discussion.
So I think it warrants writing it down so that future discussion can be directed here.
We currently use the low bits for encoding constructor tags/arity as all objects are aligned to words. Which is very beneficial.
We can use the same thing for the high bits, as we never need the whole 64 bits for actual memory access.
If we can for example ensure that all objects are allocated below the 2 TB mark we would gain 23 additional tag bits. Although we might not get (or need) as many.
The obvious thing to use this for is expanding the tag range, but we could also encode a host of other things which currently require us to read the info table like:
- Encode the closures type - Potentially avoiding the need to read the info table at all.
- Heap vs static object information - This check is fairly efficient already, but would get slightly faster still.
- Ojects we can simply copy and their size. - Allowing us to copy things like Int without touching the info table.
- Evacuatedness (currently requires reading the block descriptor)
- Or maybe other things.
As far as I know the JVM does similar things, so this ought to be possible.
However I do not plan to implement this any time soon.