3 ms·
If your program targets a 68000, and uses tags in the upper bits of pointer, and that program also hashes pointers, then of course you're going to reconcile the
by kazinator 10y ago
If your program targets a 68000, and uses tags in the upper bits of pointer, and that program also hashes pointers, then of course you're going to reconcile these two facts: your hashing function will have to strip out the pointer tags.
Or perhaps not; it depends on whether the tags are immutable attributes. For instance if they indicate type, and type is immutable, then they can perhaps just be mixed into the hash. Under this design, the only way two pointers to the same thing can have a different hash is if you have a use-after-free bug: you're hashing a pointer to something that was de-allocated and re-allocated as a new kind of object. Two objects which occupy the same address at different times don't have to have the same hash, even if it is a pointer hash.
Looked at in another way, those tag bits, if they are immutable, effectively extend the address space. An object with tag 0101 and another one with 0110, all other bits equal, can be considered to be in different spaces (with the constraint that since they collide to the same physical address, they cannot exist simultaneously).
- vidarh 10y agoI'm not quite sure what you're replying to. I was not talking about hashing pointers at all. Bare, raw, pointers on the M68000 are 32 bits, but the CPU only has 24 address lines, and the top 8 bits are disregarded. But starting with the 68020, the CPU has 32 address lines and the top 8 bits are not disregarded. The point is/was that relying on bits that are unused today is risky because it has historically tended to ensure your software breaks when the next CPU generation needs more of the possible address space. Note specially that a lot of the apps that used the top 8 bits did not use it for type tags that might imply safe usage, but often used it to store unrelated data. E.g. lets say you had a data structure with a number of pointers and a number of flags. You might very well decide to pack the structure so that the flags overlapped the top 8 bits of the pointers.