5 ms·
Right, any language could do this -- `malloc` and friends return pointers aligned to 16 bytes, giving you 4 bits at the bottom that are totally free. It can go
by krichman 14y ago
Right, any language could do this -- `malloc` and friends return pointers aligned to 16 bytes, giving you 4 bits at the bottom that are totally free.
It can go even further than that; most systems only use 48 bits for addresses -- this leaves more than enough space to "NaN-box" objects by putting the address inside the extraneous bits of a 64 bit floating NaN.
- stonemetal 14y agoRight, any language could do this -- `malloc` and friends return pointers aligned to 16 bytes How does the having the bottom 4 bits free in a pointer help if you can't use them to tell the difference between a pointer and an integer 1 or 2? He is asking for a reserved set of bits on every data type so that he can store minimal type information like pointer, not pointer.
- krickle 14y agoTo use this, you would have a tag for ints and a tag for pointers; when using the ints you shift right 4 bits, pointers would be masked before use.