Skip to main content

logos_rt_str_append

Function logos_rt_str_append 

Source
pub unsafe extern "C" fn logos_rt_str_append(
    frame: *mut i64,
    handle_slot: i64,
    src: i64,
    src_len: i64,
)
Expand description

MUTABLE-Text append helper for the MicroOp::StrAppend regalloc lowering of a Set text to text + <s> build loop. frame[handle_slot] holds a *mut Value pointing AT THE VM REGISTER CELL holding the accumulator (planted at region entry). src/src_len carry the appended operand:

  • src_len < 0 — BYTE form: src is a single ASCII byte VALUE (0..=127); the appended text is that one character.
  • src_len >= 0 — CONST form: src is a *const u8 to src_len bytes (a baked ASCII literal).

The grow reproduces the VM’s Vm::add_assign semantics EXACTLY so the tiered run is BIT-IDENTICAL to the tree-walker for every alias case:

  • if the accumulator is a sole-owned Rc<String> (Rc::get_mut succeeds), it is extended IN PLACE (String::push_str);
  • otherwise (the Rc is aliased — a captured Set saved to text) it is grown COPY-ON-WRITE through the kernel’s arith::add (Rc::new(format!("{a}{b}")), the SAME path add_assign falls through to), and the FRESH Rc replaces the accumulator’s cell — the alias keeps its own (unchanged) Rc;
  • a non-Text accumulator (never planted — the entry pin declines a non-Text) still falls to the kernel add, matching the bytecode.

§Safety

frame[handle_slot] must be the live *mut Value planted by the region-entry pin loop; for the CONST form src must point to src_len readable ASCII bytes valid for the call. The single accumulator cell is exclusively reachable for the native run (no other code touches that register), so the &mut Value is non-aliasing.