Returns a resized copy of this data.
Returns a resized copy of this data.
the number of bytes to copy.
the copied data.
Returns the internal byte order.
Loads a single byte.
Loads a single byte.
the address to load.
the loaded Byte
value.
Returns the size in bytes of the address space.
Stores a single byte.
Stores a single byte.
the storage address.
the Byte
value to store.
Returns the internal word size.
Zeros a range of addresses.
Zeros a range of addresses.
the lower bound of the address range.
the excluded upper bound of the address range.
Copies a sequence of loaded struct values to an array slice.
Copies a sequence of loaded struct values to an array slice.
the instance type to load.
the aligned address to load.
the array to copy to.
the offset to copy to in the array.
the number of values to copy.
the implicit struct type to load.
Loads an instance from a struct value.
Loads an instance from a struct value.
the instance type to load.
the aligned address to load.
the implicit struct type to load.
the loaded instance.
Loads and unpacks a struct as two values.
Loads and unpacks a struct as two values.
Loads and unpacks a struct as three values.
Loads and unpacks a struct as three values.
Loads and unpacks a struct as four values.
Loads and unpacks a struct as four values.
Loads a sequence of struct values into a new array.
Loads a sequence of struct values into a new array.
the instance type to load.
the aligned address to load.
the number of values to load.
the implicit struct type to load.
the loaded array of instance values.
Loads an 8-byte endian
ordered word as a native-endian Double
value.
Loads an 8-byte endian
ordered word as a native-endian Double
value.
Truncates address
to 8-byte alignment.
the 8-byte aligned address to load.
the loaded Double
value.
Loads a 4-byte endian
ordered word as a native-endian Float
value.
Loads a 4-byte endian
ordered word as a native-endian Float
value.
Truncates address
to 4-byte alignment.
the 4-byte aligned address to load.
the loaded Float
value.
Loads a 4-byte endian
ordered word as a native-endian Int
value.
Loads a 4-byte endian
ordered word as a native-endian Int
value.
Truncates address
to 4-byte alignment.
the 4-byte aligned address to load.
the loaded Int
value.
Loads an 8-byte endian
ordered word as a native-endian Long
value.
Loads an 8-byte endian
ordered word as a native-endian Long
value.
Truncates address
to 8-byte alignment.
the 8-byte aligned address to load.
the loaded Long
value.
Loads a 2-byte endian
ordered word as a native-endian Short
value.
Loads a 2-byte endian
ordered word as a native-endian Short
value.
Truncates address
to 2-byte alignment.
the 2-byte aligned address to load.
the loaded Short
value.
Loads an 8-byte endian
ordered word as a native-endian Double
value.
Loads an 8-byte endian
ordered word as a native-endian Double
value.
the unaligned address to load.
the loaded Double
value.
Loads a 4-byte endian
ordered word as a native-endian Float
value.
Loads a 4-byte endian
ordered word as a native-endian Float
value.
the unaligned address to load.
the loaded Float
value.
Loads a 4-byte endian
ordered word as a native-endian Int
value.
Loads a 4-byte endian
ordered word as a native-endian Int
value.
the unaligned address to load.
the loaded Int
value.
Loads an 8-byte endian
ordered word as a native-endian Long
value.
Loads an 8-byte endian
ordered word as a native-endian Long
value.
the unaligned address to load.
the loaded Long
value.
Loads a 2-byte endian
ordered word as a native-endian Short
value.
Loads a 2-byte endian
ordered word as a native-endian Short
value.
the unaligned address to load.
the loaded Short
value.
Moves a byte range to a new, potentially overlapping address.
Moves a byte range to a new, potentially overlapping address.
the address to copy from.
the address to copy to.
the number of bytes to copy.
Stores an instance as a struct value.
Stores an instance as a struct value.
the instance type to store.
the aligned storage address.
the instance to store.
the implicit struct type to store.
Packs and stores two values as a struct.
Packs and stores two values as a struct.
Packs and stores three values as a struct.
Packs and stores three values as a struct.
Packs and stores four values as a struct.
Packs and stores four values as a struct.
Stores an array slice as a sequence of struct values.
Stores an array slice as a sequence of struct values.
the instance type to store.
the aligned storage address.
the array to store from.
the offset to store from in the array.
the number of values to store.
the implicit struct type to store.
Stores a native-endian Double
value as an 8-byte endian
ordered word.
Stores a native-endian Double
value as an 8-byte endian
ordered word.
Truncates address
to 8-byte alignment.
the 8-byte aligned storage address.
the Double
value to store.
Stores a native-endian Float
value as a 4-byte endian
ordered word.
Stores a native-endian Float
value as a 4-byte endian
ordered word.
Truncates address
to 4-byte alignment.
the 4-byte aligned storage address.
the Float
value to store.
Stores a native-endian Int
value as a 4-byte endian
ordered word.
Stores a native-endian Int
value as a 4-byte endian
ordered word.
Truncates address
to 4-byte alignment.
the 4-byte aligned storage address.
the Int
value to store.
Store a native-endian Long
value as an 8-byte endian
ordered word.
Store a native-endian Long
value as an 8-byte endian
ordered word.
Truncates address
to 8-byte alignment.
the 8-byte aligned storage address.
the Long
value to store.
Stores a native-endian Short
value as a 2-byte endian
ordered word.
Stores a native-endian Short
value as a 2-byte endian
ordered word.
Truncates address
to 2-byte alignment.
the 2-byte aligned storage address.
the Short
value to store.
Stores a native-endian Double
value as an 8-byte endian
ordered word.
Stores a native-endian Double
value as an 8-byte endian
ordered word.
the unaligned storage address.
the Double
value to store.
Stores a native-endian Float
value as a 4-byte endian
ordered word.
Stores a native-endian Float
value as a 4-byte endian
ordered word.
the unaligned storage address.
the Float
value to store.
Stores a native-endian Int
value as a 4-byte endian
ordered word.
Stores a native-endian Int
value as a 4-byte endian
ordered word.
the unaligned storage address.
the Int
value to store.
Stores a native-endian Long
value as an 8-byte endian
ordered word.
Stores a native-endian Long
value as an 8-byte endian
ordered word.
the unaligned storage address.
the Long
value to store.
Stores a native-endian Short
value as a 2-byte endian
ordered word.
Stores a native-endian Short
value as a 2-byte endian
ordered word.
the unaligned storage address.
the Short
value to store.
A byte-addressed memory region.
Address Space
Data
objects have a 64-bit address space ranging from0
untilsize
. Each address in the space identifies a unique storage location for a singleByte
value. Multi-byte values occupy multiple storage locations and thus have multiple addresses–one address per byte. The lowest address of a multi-byte sequence canonically refers to the whole byte sequence.N-byte divisible addresses are said to be N-byte aligned. Using aligned addresses reduces some multi-byte memory accesses to single array operations, which can improve performance. Alignment sensitive allocators, such as the default Data allocator, try to allocate memory backed by a primitive array whose element size matches the alignment of the struct values it will store. This allocation strategy, combined with proper address alignment, enables an optimal code path when serializaing many values.
Aligned memory accesses truncate unaligned addresses to their required alignment.
Value Types
Data
objects store structured value types. Structs model value types as transformations between instance types and fixed-length byte sequences, with a restriction on address alignment.Primitive types have dedicated
load
andstore
methods, with multi-byte primitives declaring aligned and unaligned variants. AData
object'sendian
property specifies the byte order used to interpret multi-byte values.