|
|
|
|
|
by Animats
7 days ago
|
|
Trying to figure out Fil-C's "inviscaps".[1] When you allocate space with Fil-C's "malloc", some additional bounds checking data precedes the space the program gets to use. Pointers are "fat pointers", with a pointer to the beginning of the buffer and a pointer to someplace within the buffer, allowing ordinary C pointer manipulation. There's much new verbiage around this. But it's roughly the same idea as GCC "fat pointers".[2][3] So it's not a new idea. It's one that's been tried several times, but never caught on. There's a performance penalty. Especially if the compiler can't hoist the checks out of loops. [1] https://fil-c.org/invisicaps [2] https://williambader.com/bounds/example.html [3] https://www.doc.ic.ac.uk/~awl03/projects/miro/MIRO.pdf |
|
Fat pointers show up inline in memory, which has a bunch of problems:
- sizeof(void*) changes
- either you let the bounds get corrupted by bad casts, unions, and other issues, or you impose restrictions that prevent unions from working compatibly, or you end up supporting unions by having issues with races, or you need special hardware. Invisicaps sidestep all of those issues