Skip to documentation
SLOP

alloc_observe.Identity

Reference alloc_observe Identity

Internal implementation documentation

Defined in alloc_observe.

Identifies an allocation source by recording a producer identifier, a producer kind, an owner-supplied generation number, and an owner-supplied cookie value.

API (5)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callsalloc_observeIdentity
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/alloc/observe/src/protocol.zig:91

zig
/// Identifies an allocation source by recording a producer identifier, a/// producer kind, an owner-supplied generation number, and an owner-supplied/// cookie value. When observation is enabled, starting a span requires a/// nonzero producer identifier, and specifying a nonzero generation number/// requires a nonzero cookie. The observation layer stores and forwards these/// values as provided by the caller without automatically tracking lifetime/// state or advancing generation numbers.pub const Identity = struct {    producer_id: u64,    producer: Producer,    generation: u64,    owner_cookie: usize,    /// Derives an identity whose cookie is computed from a nonzero producer    /// identifier rather than a memory address. The constructor requires a    /// nonzero producer identifier, folds the identifier into a `usize` by    /// XORing the high word on narrower targets and truncating, and substitutes    /// one whenever the folded result is zero. Deriving the cookie from an    /// identifier allows owner structs to move in memory without altering their    /// identity. This derivation does not guarantee collision-free cookie    /// values and does not update existing allocator handles that continue to    /// borrow old owner addresses.    pub fn movable(        producer_id: u64,        producer: Producer,        generation: u64,    ) Identity {        std.debug.assert(producer_id != 0);        const folded = if (comptime @bitSizeOf(usize) < @bitSizeOf(u64))            producer_id ^ (producer_id >> @bitSizeOf(usize))        else            producer_id;        const cookie: usize = @truncate(folded);        return .{            .producer_id = producer_id,            .producer = producer,            .generation = generation,            .owner_cookie = if (cookie == 0) 1 else cookie,        };    }};

Source: lib/alloc/observe/src/root.zig:360

zig
/// Identifies an allocation source by recording a producer identifier, a/// producer kind, an owner-supplied generation number, and an owner-supplied/// cookie value. When observation is enabled, starting a span requires a/// nonzero producer identifier, and specifying a nonzero generation number/// requires a nonzero cookie. The observation layer stores and forwards these/// values as provided by the caller without automatically tracking lifetime/// state or advancing generation numbers.pub const Identity = protocol.Identity;

Audit

Definitions2
Public names2
Members4
Version26.7.0
Revisiondaab053ee433