Skip to main content

Module tagged_stack

Module tagged_stack 

Source
Expand description

Tagged Stack Implementation

A contiguous array of 8-byte tagged values for high-performance stack operations.

§Tagged Value Encoding (8 bytes)

- Odd (bit 0 = 1): Int — 63-bit signed integer
    tagged = (value << 1) | 1
    value  = tagged >> 1  (arithmetic shift)

- 0x0: Bool false
- 0x2: Bool true

- Even, > 2: Heap pointer to Box<Value>
    All heap pointers are 8-byte aligned (low 3 bits = 0)
    and always > 2, so no ambiguity with false/true.

§Stack Layout

Stack: contiguous array of 8-byte u64 slots
┌──────┬──────┬──────┬──────┬─────┐
│  v0  │  v1  │  v2  │  v3  │ ... │
│(8 B) │(8 B) │(8 B) │(8 B) │     │
└──────┴──────┴──────┴──────┴─────┘
                               ↑ SP

Structs§

TaggedStack
Stack state for the tagged value stack

Constants§

DEFAULT_STACK_CAPACITY
Default stack capacity (number of stack values)
STACK_VALUE_SIZE
Size of StackValue in bytes (8 bytes = 1 x u64)
TAG_FALSE
Tagged value for Bool false
TAG_TRUE
Tagged value for Bool true

Functions§

is_tagged_heap
Check if a tagged value is a heap pointer (not Int, not Bool)
is_tagged_int
Check if a tagged value is an inline integer
seq_stack_base
Safety
seq_stack_capacity
Safety
seq_stack_clone
Safety
seq_stack_free
Safety
seq_stack_grow
Safety
seq_stack_new
seq_stack_new_default
seq_stack_set_sp
Safety
seq_stack_sp
Safety
tag_int
Encode an i64 as a tagged integer.
untag_int
Decode a tagged integer back to i64 (arithmetic shift)

Type Aliases§

StackValue
An 8-byte tagged stack value.