pub struct JitVmGuard { /* private fields */ }Expand description
RAII guard pinning the active Vm (and optional closure)
pointer for JIT-emitted Rust helper calls.
§Real RAII rebind
enter_jit captures the prior (JIT_VM, JIT_CL) values into the
guard, and Drop restores them. A drop that skipped the restore
would save 2 TLS writes per dispatch, but under feature = "send"
a Vm can park on thread A, move to thread B, and dispatch there:
the per-thread JIT_VM slot on thread B is null/stale at entry,
and a no-op drop would leave stale Vm pointers behind for any
nested JIT entry (Lua-from-Rust-from-JIT call chains, e.g.
metamethod dispatch under a JIT’d op). With nested entries,
restoring the outer Vm pointer is load-bearing. In the
single-thread-no-nesting case the values restored on exit are the
same null/stale ones the next enter_jit would overwrite anyway.
NullJitBackend::enter keeps the no-op shape via
noop_jit_guard — its guard has restore = None.
Debug-mode assertions still catch misuse via current_jit_vm’s
is_null check IF a helper runs outside enter_jit (would happen
only if some bug calls a helper symbol from interp code, which
never happens by design).