As far I know, x86-64 processors do only have 48 bit virtual memory addresses, but pointers are usually 64 bit long. Can I use the upper two bytes for pointer related meta data? Do modern processors comply with shadow memory?
Asked
Active
Viewed 53 times
0
-
Doing awfully obscure and complex things just for the sake of it is an excellent way to get obscure and complex bugs. What's the actual problem you are trying to solve here? – Lundin Oct 29 '20 at 15:10
-
@Lundin I have multiple allocators with different life times, and it would be great to keep track of the origin of these pointers – Cosinus Oct 29 '20 at 15:17
-
And using `struct` for that is too simple and readable, or...? – Lundin Oct 29 '20 at 15:19
-
Also... what OS if any? Did you consider ASLR? I don't know the dirty details of ASLR on the various mainstream OS, but someone else here will. – Lundin Oct 29 '20 at 15:21
-
A struct does not fit into a single register – Cosinus Oct 29 '20 at 15:21
-
2Who cares, you are apparently going to use this for heap allocation, which is a massive performance bottleneck compared to some single CPU instruction more or less. – Lundin Oct 29 '20 at 15:22
-
1https://stackoverflow.com/questions/16198700/using-the-extra-16-bits-in-64-bit-pointers – Mat Oct 29 '20 at 15:24
-
@Mat: thanks. This did not appear when I've googled it – Cosinus Oct 29 '20 at 15:31
-
Doing extra work every time you use a pointer is unlikely to be worth it just to make deallocation faster. Unless you have a lot of alloc/free churn and don't actually use the resulting pointers often. x86-64 doesn't ignore high bits for you, they have to be in canonical form to dereference. – Peter Cordes Oct 29 '20 at 19:46