mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-26 15:11:37 +00:00
transition to protected_caller
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::resolver::FuncResolverBuilder;
|
||||
use crate::{call::Caller, resolver::FuncResolverBuilder};
|
||||
use cranelift_codegen::{ir, isa};
|
||||
use cranelift_entity::EntityRef;
|
||||
use cranelift_wasm;
|
||||
@ -8,20 +8,21 @@ use std::{
|
||||
ptr::NonNull,
|
||||
};
|
||||
use wasmer_runtime::{
|
||||
backend::FuncResolver,
|
||||
backend::SigRegistry,
|
||||
error::CompileResult,
|
||||
backend::{FuncResolver, ProtectedCaller, Token},
|
||||
error::{CompileResult, RuntimeResult},
|
||||
module::ModuleInner,
|
||||
structures::{Map, TypedIndex},
|
||||
types::{
|
||||
FuncIndex, FuncSig, GlobalIndex, LocalFuncIndex, MemoryIndex, SigIndex, TableIndex, Type,
|
||||
Value,
|
||||
},
|
||||
vm,
|
||||
vm::{self, ImportBacking},
|
||||
};
|
||||
|
||||
struct PlaceholderFuncResolver;
|
||||
struct Placeholder;
|
||||
|
||||
impl FuncResolver for PlaceholderFuncResolver {
|
||||
impl FuncResolver for Placeholder {
|
||||
fn get(
|
||||
&self,
|
||||
_module: &ModuleInner,
|
||||
@ -31,6 +32,21 @@ impl FuncResolver for PlaceholderFuncResolver {
|
||||
}
|
||||
}
|
||||
|
||||
impl ProtectedCaller for Placeholder {
|
||||
fn call(
|
||||
&self,
|
||||
_module: &ModuleInner,
|
||||
_func_index: FuncIndex,
|
||||
_params: &[Value],
|
||||
_returns: &mut [Value],
|
||||
_import_backing: &ImportBacking,
|
||||
_vmctx: *mut vm::Ctx,
|
||||
_: Token,
|
||||
) -> RuntimeResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// This contains all of the items in a `ModuleInner` except the `func_resolver`.
|
||||
pub struct Module {
|
||||
pub module: ModuleInner,
|
||||
@ -41,7 +57,9 @@ impl Module {
|
||||
Self {
|
||||
module: ModuleInner {
|
||||
// this is a placeholder
|
||||
func_resolver: Box::new(PlaceholderFuncResolver),
|
||||
func_resolver: Box::new(Placeholder),
|
||||
protected_caller: Box::new(Placeholder),
|
||||
|
||||
memories: Map::new(),
|
||||
globals: Map::new(),
|
||||
tables: Map::new(),
|
||||
@ -78,6 +96,9 @@ impl Module {
|
||||
|
||||
let func_resolver_builder = FuncResolverBuilder::new(isa, functions)?;
|
||||
self.module.func_resolver = Box::new(func_resolver_builder.finalize()?);
|
||||
|
||||
self.module.protected_caller = Box::new(Caller::new(&self.module));
|
||||
|
||||
Ok(self.module)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user