Expand description
v2 String FFI functions for JIT-compiled code.
These functions operate on the v2 StringObj layout — a compact, C-compatible
representation that the JIT can manipulate with native pointer types instead
of NaN-boxed u64 values.
§StringObj memory layout (24 bytes)
Offset Size Field
------ ---- -----
0 4 refcount (u32)
4 2 kind (u16, = HK_STRING = 0)
6 2 (padding)
8 8 data (*const u8, UTF-8 bytes)
16 4 len (u32, byte length)
20 4 (padding)The 8-byte header at offset 0 packs refcount + kind + padding so that
the data pointer is naturally 8-byte aligned.
Functions§
- jit_
v2_ string_ alloc - Allocate a new
StringObjfrom raw UTF-8 bytes. Returns a raw pointer to theStringObj(which the JIT treats as*mut u8/ I64). - jit_
v2_ string_ concat - Concatenate two v2 strings. Returns a freshly allocated
StringObjwith refcount 1. Neither input is consumed (their refcounts are unchanged). - jit_
v2_ string_ data - Return a pointer to the raw UTF-8 data bytes.
- jit_
v2_ string_ eq - Compare two v2 strings for byte-equality. Returns 1 if equal, 0 otherwise.
- jit_
v2_ string_ len - Return the byte length of the string.
- jit_
v2_ string_ print - Print a v2 string to stdout (with trailing newline), used by the
printbuiltin in JIT-compiled code. - jit_
v2_ string_ release - Decrement the reference count (release). Deallocates the object when the count reaches zero. No-op on null.
- jit_
v2_ string_ retain - Increment the reference count (retain). No-op on null.