Skip to main content

Module value_ffi

Module value_ffi 

Source
Expand description

JIT-side value-encoding helpers (NaN-box layout used by JIT-emitted code).

Per ADR-006 §2.7.5, the JIT FFI boundary carries raw u64 plus a parallel NativeKind companion stamped at JIT compile time from the call signature. The constants and helpers in this module are JIT-internal: they encode the sentinel u64 layout that JIT-emitted Cranelift code uses for inline scalars (TAG_NULL, TAG_BOOL_*, TAG_UNIT, TAG_DATA_ROW) and the JitAlloc / UnifiedValue pointer shape for heap values.

The deleted shape_value::tag_bits::*, shape_value::ValueWord*, shape_value::ValueBits, shape_value::unified_string, and shape_value::unified_wrapper references that this file previously relied on were retired by the strict-typing bulldozer (Phase 2). The tag constants below are defined locally with the exact u64 layout the JIT-emitted code already targets — they are not a “tag_bits restoration shim” (forbidden per W10 playbook §3) but the JIT-internal sentinel encoding that survives §2.7.5’s stable-FFI rule (raw u64 ABI, no runtime kind discrimination from the bits themselves; consumers that need a runtime-tier carrier wrap the bits as KindedSlot::new(ValueSlot::from_raw(bits), kind) per §2.7.5/Q7).

Heap-pointer values produced by box_string / box_ok / box_err / box_some / box_typed_object / box_column_ref use the jit_kinds::unified_box shape: a UnifiedValue<T> heap allocation with a kind: u16 prefix at offset 0, readable via jit_kinds::read_heap_kind (per §2.7.5: this is not tag-bit dispatch — it reads a field from a heap-resident struct). The HK_* constants mirror HeapKind ordinals (cast to u16) for use as the prefix.

Constants§

CANONICAL_NAN
IEEE-754 canonical quiet NaN (positive sign).
HEAP_PTR_MASK
HK_ARRAY
HK_BIG_INT
HK_BOOL_ARRAY
HK_CLOSURE
HK_COLUMN_REF
HK_DATATABLE
HK_DATA_DATETIME_REF
HK_DATA_REFERENCE
HK_DATETIME_EXPR
HK_DECIMAL
HK_DURATION
HK_ENUM
HK_ERR
HK_EXPR_PROXY
HK_F32_ARRAY
HK_FILTER_EXPR
HK_FLOAT_ARRAY
HK_FLOAT_ARRAY_SLICE
HK_FUNCTION_REF
HK_FUTURE
HK_HASHMAP
HK_HOST_CLOSURE
HK_I8_ARRAY
HK_I16_ARRAY
HK_I32_ARRAY
HK_INDEXED_TABLE
HK_INT_ARRAY
HK_MATRIX
HK_OK
HK_PRINT_RESULT
HK_RANGE
HK_ROW_VIEW
HK_SIMULATION_CALL
HK_SOME
HK_STRING
HK_TASK_GROUP
HK_TIME
HK_TIMEFRAME
HK_TIMESPAN
HK_TIME_REFERENCE
HK_TRAIT_OBJECT
HK_TYPED_OBJECT
HK_TYPED_TABLE
HK_TYPE_ANNOTATED_VALUE
HK_TYPE_ANNOTATION
HK_U8_ARRAY
HK_U16_ARRAY
HK_U32_ARRAY
HK_U64_ARRAY
I48_MAX
i48 payload range — JIT inline-int encoding fits in 48 bits.
I48_MIN
JIT_LEGACY_HK_BASE
NAN_BASE
NaN base: all 1s in exponent (bits 62-52). Used for number detection.
PAYLOAD_MASK
48-bit payload mask.
TAG_BASE
Tagged-value base: negative-NaN exponent + sign bit.
TAG_BOOL_FALSE
Boolean false. Uses shared TAG_BOOL (0b010) with payload 0.
TAG_BOOL_TRUE
Boolean true. Uses shared TAG_BOOL (0b010) with payload 1.
TAG_DATA_ROW
Data row tag: uses the shared TAG_INT (0b001) encoding in negative NaN space. Row indices are stored as i48 in the 48-bit payload.
TAG_MASK
16-bit tag mask – used for legacy positive-NaN tag discrimination in translator IR.
TAG_NONE
None sentinel — alias for TAG_NULL (Option::None JIT representation). Re-exported under TAG_NONE for legacy callers.
TAG_NULL
Null/None value. Uses shared TAG_NONE (0b011).
TAG_NUMBER
Number tag sentinel (not a real tag – numbers are plain f64).
TAG_SHIFT
Bit shift for the 3-bit inline-tag field at bits 50-48.
TAG_UNIT
Unit (void return). Uses shared TAG_UNIT (0b100).
UNIFIED_HEAP_FLAG
Bit-47 marker for unified-heap pointers; legacy bit retained for the JIT consumer migration window where some helpers still discriminate the pointer shape. Per Band 1 close (§2.7.5): the discriminator no longer gates kind decode — both shapes are raw Box::into_raw pointers and the kind flows through the parallel NativeKind companion.
UNIFIED_PTR_MASK

Functions§

box_bool
Box a boolean into a NaN-boxed u64 (shared scheme).
box_column_ref
box_column_result
Box a Vec<f64> as a new column reference.
box_data_row
Box a row index as a data row reference using shared TAG_INT encoding.
box_err
box_function
Box an inline function reference (shared TAG_FUNCTION, payload = function_id).
box_number
Box a number into a NaN-boxed u64.
box_ok
box_some
box_str
Box a &str as a unified heap string value.
box_string
Box a String as a unified heap string value.
box_typed_object
extract_column⚠
Extract a &[f64] slice from a NaN-boxed column reference.
heap_kind
Get the heap kind of a value, or None if not a heap value.
is_column_ref
is_data_row
Check if a value is a data row reference. Data rows use the shared TAG_INT encoding (tag bits 50-48 == 0b001).
is_err_tag
is_heap
Check if a value has TAG_HEAP (tag bits 50-48 == 0, in negative NaN space).
is_heap_kind
Check if a value is a heap value with a specific kind.
is_inline_function
Check if a value is an inline function reference.
is_none_tag
is_number
Check if a value is a plain f64 number (not NaN-boxed with any tag). All tags live in negative NaN space (sign bit = 1).
is_ok_tag
is_option_tag
is_result_tag
is_some_tag
is_typed_object
unbox_column_ref⚠
unbox_data_row
Extract the row index from a data row reference (TAG_INT payload).
unbox_function_id
Extract function_id from an inline function reference.
unbox_heap_pointer
Extract the raw pointer from a TAG_HEAP value (points to JitAlloc header).
unbox_number
Unbox a number (assumes value is a number – check with is_number() first).
unbox_result_inner⚠
unbox_result_pointer
unbox_some_inner⚠
unbox_string⚠
Read a string from a NaN-boxed heap value.
unbox_typed_object