asm

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package asm provides architecture-specific helpers for hot paths.

Layout contract: The SPSCIndirect offsets used by assembly must match the Go struct layout. The expected offsets are verified by tests on supported architectures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SPSCDequeue

func SPSCDequeue(q uintptr) (elem uintptr, err int)

SPSCDequeue performs an optimized SPSC dequeue operation. Combines cached index check, buffer load, and head update.

Returns:

  • elem: the dequeued value (valid only if err == 0)
  • err: 0 on success, 1 if queue is empty (ErrWouldBlock)

func SPSCEnqueue

func SPSCEnqueue(q uintptr, elem uintptr) int

SPSCEnqueue performs an optimized SPSC enqueue operation. It combines the cached index check, buffer store, and tail update in a tight instruction sequence without Go runtime preemption points.

Parameters (passed via registers per Go ABI):

  • q: pointer to SPSCIndirect struct
  • elem: the uintptr value to enqueue

Returns:

  • 0 on success
  • 1 if queue is full (ErrWouldBlock)

The struct layout is (verified via reflection):

  • offset 0: pad (64 bytes cache line isolation)
  • offset 64: head (atomix.Uint64 - 8 bytes)
  • offset 72: pad (64 bytes)
  • offset 136: cachedTail (8 bytes, non-atomic)
  • offset 144: pad (64 bytes)
  • offset 208: tail (atomix.Uint64 - 8 bytes)
  • offset 216: pad (64 bytes)
  • offset 280: cachedHead (8 bytes, non-atomic)
  • offset 288: pad (64 bytes)
  • offset 352: buffer (slice header: ptr, len, cap = 24 bytes)
  • offset 376: mask (8 bytes)
  • Total size: 384 bytes

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL