Skip to content

Commit cfd4758

Browse files
committed
Add some documentation
1 parent b949de2 commit cfd4758

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/runtime-core/src/backend.rs

+7
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ pub trait ProtectedCaller: Send + Sync {
8686
///
8787
/// The existance of the Token parameter ensures that this can only be called from
8888
/// within the runtime crate.
89+
///
90+
/// TODO(lachlan): Now that `get_wasm_trampoline` exists, `ProtectedCaller::call`
91+
/// can be removed. That should speed up calls a little bit, since sanity checks
92+
/// would only occur once.
8993
fn call(
9094
&self,
9195
module: &ModuleInner,
@@ -96,6 +100,9 @@ pub trait ProtectedCaller: Send + Sync {
96100
_: Token,
97101
) -> RuntimeResult<Vec<Value>>;
98102

103+
/// A wasm trampoline contains the necesarry data to dynamically call an exported wasm function.
104+
/// Given a particular signature index, we are returned a trampoline that is matched with that
105+
/// signature and an invoke function that can call the trampoline.
99106
fn get_wasm_trampoline(&self, module: &ModuleInner, sig_index: SigIndex) -> Option<Wasm>;
100107

101108
fn get_early_trapper(&self) -> Box<dyn UserTrapper>;

lib/runtime-core/src/typed_func.rs

+9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ impl fmt::Display for WasmTrapInfo {
5050
}
5151
}
5252

53+
/// This is just an empty trait to constrict that types that
54+
/// can be put into the third/fourth (depending if you include lifetimes)
55+
/// of the `Func` struct.
5356
pub trait Kind {}
5457

5558
pub type Trampoline = unsafe extern "C" fn(*mut Ctx, NonNull<vm::Func>, *const u64, *mut u64);
@@ -63,6 +66,10 @@ pub type Invoke = unsafe extern "C" fn(
6366
Option<NonNull<c_void>>,
6467
) -> bool;
6568

69+
70+
/// TODO(lachlan): Naming TBD.
71+
/// This contains the trampoline and invoke functions for a specific signature,
72+
/// as well as the environment that the invoke function may or may not require.
6673
#[derive(Copy, Clone)]
6774
pub struct Wasm {
6875
trampoline: Trampoline,
@@ -84,6 +91,8 @@ impl Wasm {
8491
}
8592
}
8693

94+
/// This type, as part of the `Func` type signature, represents a function that is created
95+
/// by the host.
8796
pub struct Host(());
8897
impl Kind for Wasm {}
8998
impl Kind for Host {}

0 commit comments

Comments
 (0)