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) │ │
└──────┴──────┴──────┴──────┴─────┘
↑ SPStructs§
- Tagged
Stack - 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§
- Stack
Value - An 8-byte tagged stack value.