Remove sandboxing host function interface (#12852)

* Remove sandboxing interface

* Remove unused struct
This commit is contained in:
Alexander Theißen
2022-12-07 13:48:30 +01:00
committed by GitHub
parent 198faaa6f9
commit 32578cb010
31 changed files with 34 additions and 4478 deletions
@@ -303,9 +303,6 @@ pub trait FunctionContext {
fn allocate_memory(&mut self, size: WordSize) -> Result<Pointer<u8>>;
/// Deallocate a given memory instance.
fn deallocate_memory(&mut self, ptr: Pointer<u8>) -> Result<()>;
/// Provides access to the sandbox.
fn sandbox(&mut self) -> &mut dyn Sandbox;
/// Registers a panic error message within the executor.
///
/// This is meant to be used in situations where the runtime
@@ -330,60 +327,6 @@ pub trait FunctionContext {
fn register_panic_error_message(&mut self, message: &str);
}
/// Sandbox memory identifier.
pub type MemoryId = u32;
/// Something that provides access to the sandbox.
pub trait Sandbox {
/// Get sandbox memory from the `memory_id` instance at `offset` into the given buffer.
fn memory_get(
&mut self,
memory_id: MemoryId,
offset: WordSize,
buf_ptr: Pointer<u8>,
buf_len: WordSize,
) -> Result<u32>;
/// Set sandbox memory from the given value.
fn memory_set(
&mut self,
memory_id: MemoryId,
offset: WordSize,
val_ptr: Pointer<u8>,
val_len: WordSize,
) -> Result<u32>;
/// Delete a memory instance.
fn memory_teardown(&mut self, memory_id: MemoryId) -> Result<()>;
/// Create a new memory instance with the given `initial` size and the `maximum` size.
/// The size is given in wasm pages.
fn memory_new(&mut self, initial: u32, maximum: u32) -> Result<MemoryId>;
/// Invoke an exported function by a name.
fn invoke(
&mut self,
instance_id: u32,
export_name: &str,
args: &[u8],
return_val: Pointer<u8>,
return_val_len: WordSize,
state: u32,
) -> Result<u32>;
/// Delete a sandbox instance.
fn instance_teardown(&mut self, instance_id: u32) -> Result<()>;
/// Create a new sandbox instance.
fn instance_new(
&mut self,
dispatch_thunk_id: u32,
wasm: &[u8],
raw_env_def: &[u8],
state: u32,
) -> Result<u32>;
/// Get the value from a global with the given `name`. The sandbox is determined by the
/// given `instance_idx` instance.
///
/// Returns `Some(_)` when the requested global variable could be found.
fn get_global_val(&self, instance_idx: u32, name: &str) -> Result<Option<Value>>;
}
if_wasmtime_is_enabled! {
/// A trait used to statically register host callbacks with the WASM executor,
/// so that they call be called from within the runtime with minimal overhead.