pub struct WasmTier { /* private fields */ }Expand description
The runtime WASM-JIT tier: per-function call counters plus a cache of compiled +
instantiated modules. When a function crosses the hot threshold it is lowered to WASM and
instantiated; subsequent calls dispatch to the compiled module. Functions the codegen
declines are remembered as Ineligible and stay on the bytecode tier. The VM’s
Op::Call consults this only under #[cfg(feature = "wasm-jit")], so the default build
never carries it.
The host differs by target — and this is the whole point of the WASM backend:
- native: the pure-Rust [
wasmi] interpreter. This is also the codegen oracle the differential tests cross-check the emitter against. - wasm32: the platform’s real
WebAssembly(V8 in the browser / node) viajs_sys::WebAssembly. This is the production tier — a hot function tiers up to a freshly-compiled native WebAssembly module the host JITs, exactly as the spec requires.
on_call and the tier-up bookkeeping are target-independent; only [instantiate] and
[ReadyModule::call] (the host seam) are #[cfg]-split.
Implementations§
Source§impl WasmTier
impl WasmTier
Sourcepub fn new(threshold: u32) -> Self
pub fn new(threshold: u32) -> Self
A tier that compiles a function after threshold calls (clamped to ≥1).
Sourcepub fn hits(&self) -> u64
pub fn hits(&self) -> u64
How many calls have dispatched to a compiled WASM module — a diagnostic/test hook proving the tier actually fired.
Sourcepub fn on_call(
&mut self,
program: &CompiledProgram,
func: u16,
args: &[i64],
) -> Option<i64>
pub fn on_call( &mut self, program: &CompiledProgram, func: u16, args: &[i64], ) -> Option<i64>
Run program.functions[func](args) on the WASM-JIT tier, or None to fall back to
the bytecode tier (not yet hot, or ineligible). A Some result is the emitted
module’s output — cross-checked against the VM by the differential tests.
Auto Trait Implementations§
impl Freeze for WasmTier
impl !RefUnwindSafe for WasmTier
impl Send for WasmTier
impl Sync for WasmTier
impl Unpin for WasmTier
impl UnsafeUnpin for WasmTier
impl !UnwindSafe for WasmTier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.