* 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>
27 lines
1017 B
Rust
27 lines
1017 B
Rust
use more_asserts::assert_gt;
|
|
use std::path::PathBuf;
|
|
use wasmtime_environ::settings;
|
|
use wasmtime_environ::settings::Configurable;
|
|
use wasmtime_jit::{instantiate, native, CompilationStrategy, Compiler, NullResolver};
|
|
|
|
const PATH_MODULE_RS2WASM_ADD_FUNC: &str = r"tests/wat/rs2wasm-add-func.wat";
|
|
|
|
/// Simple test reading a wasm-file and translating to binary representation.
|
|
#[test]
|
|
fn test_environ_translate() {
|
|
let path = PathBuf::from(PATH_MODULE_RS2WASM_ADD_FUNC);
|
|
let data = wat::parse_file(path).expect("expecting valid wat-file");
|
|
assert_gt!(data.len(), 0);
|
|
|
|
let mut flag_builder = settings::builder();
|
|
flag_builder.enable("enable_verifier").unwrap();
|
|
|
|
let isa_builder = native::builder();
|
|
let isa = isa_builder.finish(settings::Flags::new(flag_builder));
|
|
|
|
let mut resolver = NullResolver {};
|
|
let mut compiler = Compiler::new(isa, CompilationStrategy::Auto);
|
|
let instance = instantiate(&mut compiler, &data, None, &mut resolver, false);
|
|
assert!(instance.is_ok());
|
|
}
|