Expand description
ValueWord: 8-byte NaN-boxed value representation for the VM stack.
Uses IEEE 754 quiet NaN space to pack type tags and payloads into 8 bytes.
Simple types (f64, i48, bool, None, Unit, Function) are stored inline.
Complex types are heap-allocated as Arc<HeapValue> with the raw pointer in the payload.
§NaN-boxing scheme
All tagged values use sign bit = 1 with a quiet NaN exponent, giving us 51 bits for tag + payload. Normal f64 values (including NaN, which is canonicalized to a positive quiet NaN) are stored directly and never collide with our tagged range.
Tagged: 0xFFF[C-F]_XXXX_XXXX_XXXX
Bit 63 = 1 (sign, marks as tagged)
Bits 62-52 = 0x7FF (NaN exponent)
Bit 51 = 1 (quiet NaN bit)
Bits 50-48 = tag (3 bits)
Bits 47-0 = payload (48 bits)| Tag | Meaning |
|---|---|
| 0b000 | Heap pointer to Arc<HeapValue> (48-bit ptr) |
| 0b001 | i48 (48-bit signed integer, sign-extended) |
| 0b010 | Bool (payload bit 0) |
| 0b011 | None |
| 0b100 | Unit |
| 0b101 | Function(u16) (payload = function_id) |
| 0b110 | ModuleFunction(u32) (payload = index) |
| 0b111 | Ref (absolute stack slot index, 48 bits) |
Structs§
- Value
Word - An 8-byte value word for the VM stack (NaN-boxed encoding).
Enums§
- Array
View - Unified read-only view over all array variants (generic, int, float, bool, width-specific).
- Array
View Mut - Mutable view over all array variants. Uses Arc::make_mut for COW semantics.
- NanTag
- Tag discriminator for ValueWord values.
- RefTarget