Skip to main content

Module array

Module array 

Source
Expand description

Array FFI Functions for JIT

Functions for creating and manipulating arrays in JIT-compiled code. All arrays are stored as JitAlloc<JitArray> via jit_box(HK_ARRAY, ...).

Structs§

ArrayInfo
Extract array data pointer and length from a NaN-boxed array value.

Functions§

create_array_from_elements
Helper: Create a new array from elements
get_array_elements
Helper: Extract elements from a NaN-boxed array (returns a clone as Vec)
jit_array_filled
Create a pre-allocated array filled with a given value. Array.filled(size, value) — equivalent to vec![value; size].
jit_array_first
Get first element of array
jit_array_get
Get element from array by index (supports negative indexing)
jit_array_info
jit_array_last
Get last element of array
jit_array_max
Get maximum element of numeric array
jit_array_min
Get minimum element of numeric array
jit_array_pop
Pop last element from array (returns new array without last element)
jit_array_push
Push multiple values onto array (returns new array)
jit_array_push_elem
Push single element onto array (returns new array with element appended) Used by ArrayPush opcode in list comprehensions
jit_array_push_element
Push a single element onto an array (method call style). Returns new array with element appended. Used by JIT inline path for .push(element).
jit_array_push_local
Push a value into an array in-place, mutating the existing JitArray. Returns the same array bits (the JitAlloc pointer doesn’t move; JitArray handles realloc internally). This is O(1) amortized vs O(n) for jit_array_push_elem which copies all elements. Used by ArrayPushLocal opcode for x = x.push(val) optimization.
jit_array_reserve_local
Ensure array capacity is at least min_capacity elements. Returns original array bits.
jit_array_reverse
Reverse an array, returning a new reversed array. Used by JIT inline path for .reverse().
jit_array_zip
Zip two arrays into array of pairs
jit_hof_array_alloc
Allocate a new empty array with pre-allocated capacity. Returns a NaN-boxed HK_ARRAY. Used by HOF inlining to pre-allocate result arrays.
jit_hof_array_push
Push a single element into an in-place array (used by HOF inlining loops). Mutates the JitArray, returns the same boxed array bits. Identical to jit_array_push_local but with a different name for clarity.
jit_make_range
Create a Range object from start and end values This creates a proper Range object (not an array), used by MakeRange opcode
jit_new_array
Create a new array from values on stack
jit_range
Create a range array [start, start+1, …, end-1]
jit_slice
Slice an array or string