wasmtime/runtime/vm/
interpreter_disabled.rs

1//! Stubs for when pulley is disabled at compile time.
2//!
3//! Note that this is structured so that these structures are all zero-sized and
4//! `Option<Thing>` is also zero-sized so there should be no runtime cost for
5//! having these structures plumbed around.
6
7use crate::runtime::Uninhabited;
8use crate::runtime::vm::{VMContext, VMOpaqueContext};
9use crate::{Engine, ValRaw};
10use core::marker;
11use core::mem;
12use core::ptr::NonNull;
13use wasmtime_unwinder::Unwind;
14
15pub struct Interpreter {
16    empty: Uninhabited,
17}
18
19const _: () = assert!(mem::size_of::<Interpreter>() == 0);
20const _: () = assert!(mem::size_of::<Option<Interpreter>>() == 0);
21
22impl Interpreter {
23    pub fn new(_engine: &Engine) -> Interpreter {
24        unreachable!()
25    }
26
27    pub fn as_interpreter_ref(&mut self) -> InterpreterRef<'_> {
28        match self.empty {}
29    }
30
31    pub fn unwinder(&self) -> &'static dyn Unwind {
32        match self.empty {}
33    }
34}
35
36pub struct InterpreterRef<'a> {
37    empty: Uninhabited,
38    _marker: marker::PhantomData<&'a mut Interpreter>,
39}
40
41const _: () = assert!(mem::size_of::<InterpreterRef<'_>>() == 0);
42const _: () = assert!(mem::size_of::<Option<InterpreterRef<'_>>>() == 0);
43
44impl InterpreterRef<'_> {
45    pub unsafe fn call(
46        self,
47        _bytecode: NonNull<u8>,
48        _callee: NonNull<VMOpaqueContext>,
49        _caller: NonNull<VMContext>,
50        _args_and_results: NonNull<[ValRaw]>,
51    ) -> bool {
52        match self.empty {}
53    }
54
55    pub(crate) unsafe fn resume_to_exception_handler(
56        &mut self,
57        _handler: &wasmtime_unwinder::Handler,
58        _payload1: usize,
59        _payload2: usize,
60    ) {
61        match self.empty {}
62    }
63}