| Status | 🟡 Partial — same-region pointer-array compression implemented |
| Stage | Whole-program data layout |
| IR | 🟡 Ir/Passes/DataLayoutTransforms.cs — when an explicit target pointer width is greater than 16 bits, a private pointer array whose non-null values are all typed GEPs into one proven region is stored as u16 encoded indices (0 = null, index + 1 = pointer) and reconstructed on load |
| Related | O0323, O0057, docs/FORMATS.md |
When every object a pointer can address lies inside a bounded region, the pointer can be stored as a narrower offset or index into that region and widened only when dereferenced.
On x86-16 this is unusually concrete: a far pointer is 4 bytes (segment + offset), but if the target is always inside one known segment — the string heap, the array heap, a single data segment — the segment half is redundant and a 2-byte near offset does the same job. Halving every stored pointer in a large structure is a real memory saving on a 640 KiB machine.
TYPE Node
next AS LONG POINTER ' 4 bytes, but always into the same segment
value AS INTEGER
END TYPE- A proof that every value stored into the field points into the known region — which is a points-to question (O0263).
- Widening on dereference, and correct handling of the null representation.
VARPTR32/STRPTR32and any pointer that escapes to an external unit must keep the full form.
The IR array encoding reserves zero for null and stores a non-null element index
as index + 1. This is slightly more arithmetic than reserving 65535, but it
preserves the language/runtime invariant that zero-initialized pointer storage is
null. The largest compressible region index is therefore 65534.
The current IR implementation covers pointer arrays because their element provenance is explicit in typed GEPs. Compressing a pointer field inside an opaque packed UDT byte buffer needs equivalent pointer-field provenance from lowering before it can be done without guessing the source type.