3 ms·
The `repr(C)` ABI is stable. There is a trade-off between "provide types a stable layout" (required for a stable ABI) and "optimize my program as much as possi
by fluffything 7y ago
The `repr(C)` ABI is stable.
There is a trade-off between "provide types a stable layout" (required for a stable ABI) and "optimize my program as much as possible" (e.g. change type-layout using profile-guided optimization to put hot fields inside the same cacheline).
In Rust, if you want to give a type a stable ABI, you just need to stamp `#[repr(C)]` on it. Otherwise, you get optimizations by default.
The amount of types and functions in a code-base is usually much larger than its surface API, and this decision balances optimizing properly, while still providing a stable API.