mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 13:11:32 +00:00
Add some better docs
This commit is contained in:
@ -9,7 +9,16 @@ use std::{ffi::c_void, mem, ptr};
|
||||
|
||||
/// The context of the currently running WebAssembly instance.
|
||||
///
|
||||
/// This is implicitly passed to every webassembly function.
|
||||
/// Since this is per-module, each field has a statically
|
||||
/// (as in after compiling the wasm) known size, so no
|
||||
/// runtime checks are necessary.
|
||||
///
|
||||
/// While the runtime currently just passes this around
|
||||
/// as the first, implicit parameter of every function,
|
||||
/// it may someday be pinned to a register (especially
|
||||
/// on arm, which has a ton of registers) to reduce
|
||||
/// register shuffling.
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
pub struct Ctx {
|
||||
@ -42,11 +51,25 @@ pub struct Ctx {
|
||||
|
||||
pub(crate) local_functions: *const *const Func,
|
||||
|
||||
/// These are pointers to things that are known to be owned
|
||||
/// by the owning `Instance`.
|
||||
local_backing: *mut LocalBacking,
|
||||
import_backing: *mut ImportBacking,
|
||||
module: *const ModuleInner,
|
||||
|
||||
//// This is intended to be user-supplied, per-instance
|
||||
/// contextual data. There are currently some issue with it,
|
||||
/// notably that it cannot be set before running the `start`
|
||||
/// function in a webassembly module.
|
||||
///
|
||||
/// [#219](https://github.com/wasmerio/wasmer/pull/219) fixes that
|
||||
/// issue, as well as allowing the user to have *per-function*
|
||||
/// context, instead of just per-instance.
|
||||
pub data: *mut c_void,
|
||||
|
||||
/// If there's a function set in this field, it gets called
|
||||
/// when the context is destructed, e.g. when an `Instance`
|
||||
/// is dropped.
|
||||
pub data_finalizer: Option<extern "C" fn(data: *mut c_void)>,
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user