Skip to main content

JitVmGuard

Struct JitVmGuard 

Source
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).

Trait Implementations§

Source§

impl Drop for JitVmGuard

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.