Add trampoline compilation support for lowered imports (#4206)
* Add trampoline compilation support for lowered imports This commit adds support to the component model implementation for compiling trampolines suitable for calling host imports. Currently this is purely just the compilation side of things, modifying the wasmtime-cranelift crate and additionally filling out a new `VMComponentOffsets` type (similar to `VMOffsets`). The actual creation of a `VMComponentContext` is still not performed and will be a subsequent PR. Internally though some tests are actually possible with this where we at least assert that compilation of a component and creation of everything in-memory doesn't panic or trip any assertions, so some tests are added here for that as well. * Fix some test errors
This commit is contained in:
@@ -16,7 +16,7 @@ use std::convert::TryFrom;
|
||||
use std::mem;
|
||||
use wasmparser::Operator;
|
||||
use wasmtime_environ::{
|
||||
BuiltinFunctionIndex, MemoryPlan, MemoryStyle, Module, ModuleTranslation, ModuleTypes,
|
||||
BuiltinFunctionIndex, MemoryPlan, MemoryStyle, Module, ModuleTranslation, ModuleTypes, PtrSize,
|
||||
TableStyle, Tunables, VMOffsets, WASM_PAGE_SIZE,
|
||||
};
|
||||
use wasmtime_environ::{FUNCREF_INIT_BIT, FUNCREF_MASK};
|
||||
@@ -1536,7 +1536,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
||||
pointer_type,
|
||||
mem_flags,
|
||||
anyfunc_ptr,
|
||||
i32::from(self.offsets.vmcaller_checked_anyfunc_func_ptr()),
|
||||
i32::from(self.offsets.ptr.vmcaller_checked_anyfunc_func_ptr()),
|
||||
);
|
||||
|
||||
// If necessary, check the signature.
|
||||
@@ -1572,7 +1572,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
||||
sig_id_type,
|
||||
mem_flags,
|
||||
anyfunc_ptr,
|
||||
i32::from(self.offsets.vmcaller_checked_anyfunc_type_index()),
|
||||
i32::from(self.offsets.ptr.vmcaller_checked_anyfunc_type_index()),
|
||||
);
|
||||
|
||||
// Check that they match.
|
||||
@@ -1594,7 +1594,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
|
||||
pointer_type,
|
||||
mem_flags,
|
||||
anyfunc_ptr,
|
||||
i32::from(self.offsets.vmcaller_checked_anyfunc_vmctx()),
|
||||
i32::from(self.offsets.ptr.vmcaller_checked_anyfunc_vmctx()),
|
||||
);
|
||||
real_call_args.push(vmctx);
|
||||
real_call_args.push(caller_vmctx);
|
||||
|
||||
Reference in New Issue
Block a user