Replace the global-exports mechanism with a caller-vmctx mechanism. (#789)
* Replace the global-exports mechanism with a caller-vmctx mechanism. This eliminates the global exports mechanism, and instead adds a caller-vmctx argument to wasm functions so that WASI can obtain the memory and other things from the caller rather than looking them up in a global registry. This replaces #390. * Fixup some merge conflicts * Rustfmt * Ensure VMContext is aligned to 16 bytes With the removal of `global_exports` it "just so happens" that this isn't happening naturally any more. * Fixup some bugs with double vmctx in wasmtime crate * Trampoline stub needed adjusting * Use pointer type instead of always using I64 for caller vmctx * Don't store `ir::Signature` in `Func` since we don't know the pointer size at creation time. * Skip the first 2 arguments in IR signatures since that's the two vmctx parameters. * Update cranelift to 0.56.0 * Handle more merge conflicts * Rustfmt Co-authored-by: Alex Crichton <alex@alexcrichton.com>
This commit is contained in:
@@ -193,6 +193,7 @@ pub fn add_wrappers_to_module(args: TokenStream) -> TokenStream {
|
||||
|
||||
unsafe extern "C" fn #name_ident(
|
||||
ctx: *mut wasmtime_runtime::VMContext,
|
||||
caller_ctx: *mut wasmtime_runtime::VMContext,
|
||||
#(#shim_arg_decls),*
|
||||
) -> #ret_ty {
|
||||
log::trace!(
|
||||
@@ -203,7 +204,7 @@ pub fn add_wrappers_to_module(args: TokenStream) -> TokenStream {
|
||||
Ok(e) => e,
|
||||
Err(e) => #handle_early_error,
|
||||
};
|
||||
let memory = match get_memory(&mut *ctx) {
|
||||
let memory = match get_memory(&mut *caller_ctx) {
|
||||
Ok(e) => e,
|
||||
Err(e) => #handle_early_error,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user