Skip to main content

Crate subsoil_derive

Crate subsoil_derive 

Source
Expand description

Procedural macros for declaring subsoil guest endpoints.

The #[subsoil::endpoint(N)] attribute marks a function as endpoint N of a JAR chain Image. The macro emits three items into the guest crate:

  1. The function definition itself, unchanged.
  2. A per-endpoint trampoline __subsoil_ep_N_trampoline in .text that calls the user function, then halts the VM via a REPLY ecall (li t0, 0; ecall). The trampoline lives in regular code; the kernel enters it at endpoints[N].entry_pc.
  3. A subsoil::EndpointDescriptor static in the .subsoil.endpoints ELF section whose fn_ptr points at the trampoline (not the user fn). The transpiler reads the section at link time and resolves each fn_ptr to a PVM PC.
#[subsoil::endpoint(0)]
fn process(args_len: u64) -> u64 { ... }

On host targets the macro emits only the function definition; the trampoline and descriptor are gated behind cfg(all(target_env = "javm", target_os = "none")).

Attribute Macros§

endpoint
Mark a function as endpoint N of a JAR chain Image.