compiler: Precisely name units of object size

Co-authored-by: Ralf Jung <post@ralfj.de>
This commit is contained in:
Jubilee 2024-09-21 07:54:54 -07:00 committed by GitHub
parent d93d2f146d
commit cf78f26d5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -337,15 +337,15 @@ impl TargetDataLayout {
Ok(dl) Ok(dl)
} }
/// Returns **exclusive** upper bound on object size. /// Returns **exclusive** upper bound on object size in bytes.
/// ///
/// The theoretical maximum object size is defined as the maximum positive `isize` value. /// The theoretical maximum object size is defined as the maximum positive `isize` value.
/// This ensures that the `offset` semantics remain well-defined by allowing it to correctly /// This ensures that the `offset` semantics remain well-defined by allowing it to correctly
/// index every address within an object along with one byte past the end, along with allowing /// index every address within an object along with one byte past the end, along with allowing
/// `isize` to store the difference between any two pointers into an object. /// `isize` to store the difference between any two pointers into an object.
/// ///
/// LLVM uses a 64-bit integer to represent object size in bits, but we care only for bytes, /// LLVM uses a 64-bit integer to represent object size in *bits*, but we care only for bytes,
/// so we adopt such a more-constrained address space due to its technical limitations. /// so we adopt such a more-constrained size bound due to its technical limitations.
#[inline] #[inline]
pub fn obj_size_bound(&self) -> u64 { pub fn obj_size_bound(&self) -> u64 {
match self.pointer_size.bits() { match self.pointer_size.bits() {