Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
Posted Mar 23, 2022 20:51 UTC (Wed) by excors (subscriber, #95769)In reply to: Beingessner: Rust's Unsafe Pointer Types Need An Overhaul by JoeBuck
Parent article: Beingessner: Rust's Unsafe Pointer Types Need An Overhaul
Does that mean the implementation of tagged pointers would have to be baked into the language/compiler, instead of being up to the application? That sounds excessively restrictive for a systems language, since applications may want to implement it very differently - e.g. some JavaScript engines store all values (doubles, integers, pointers, etc) as doubles, packing the tag bits and pointer values into the NaN range. (NaNs have a 51-bit payload, and x86-64 has 48-bit virtual address space (and I think only 47-bit if you exclude kernel addresses, and less if you require alignment), so there's enough space for whole pointers plus several tag bits.) (https://anniecherkaev.com/the-secret-life-of-nan)
There are also other use cases where you might want to do something funny with pointers, like XOR linked lists (a doubly linked list where you store 'prev XOR next' as a single word per node, which makes iteration trickier but saves memory).
I think Rust needs to provide the low-level primitives for applications to safely implement those things however they want.
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
