Store WasmFuncType in FuncType (#2365)

This commit updates `wasmtime::FuncType` to exactly store an internal
`WasmFuncType` from the cranelift crates. This allows us to remove a
translation layer when we are given a `FuncType` and want to get an
internal cranelift type out as a result.

The other major change from this commit was changing the constructor and
accessors of `FuncType` to be iterator-based instead of exposing
implementation details.
This commit is contained in:
Alex Crichton
2020-11-05 08:49:03 -06:00
committed by GitHub
parent ea3306e74c
commit a277cf5ee4
13 changed files with 118 additions and 150 deletions

View File

@@ -13,7 +13,7 @@ fn test_trap_return() -> Result<()> {
"#;
let module = Module::new(store.engine(), wat)?;
let hello_type = FuncType::new(Box::new([]), Box::new([]));
let hello_type = FuncType::new(None, None);
let hello_func = Func::new(&store, hello_type, |_, _, _| Err(Trap::new("test 123")));
let instance = Instance::new(&store, &module, &[hello_func.into()])?;
@@ -86,7 +86,7 @@ fn test_trap_trace_cb() -> Result<()> {
)
"#;
let fn_type = FuncType::new(Box::new([]), Box::new([]));
let fn_type = FuncType::new(None, None);
let fn_func = Func::new(&store, fn_type, |_, _, _| Err(Trap::new("cb throw")));
let module = Module::new(store.engine(), wat)?;
@@ -237,7 +237,7 @@ fn trap_start_function_import() -> Result<()> {
)?;
let module = Module::new(store.engine(), &binary)?;
let sig = FuncType::new(Box::new([]), Box::new([]));
let sig = FuncType::new(None, None);
let func = Func::new(&store, sig, |_, _, _| Err(Trap::new("user trap")));
let err = Instance::new(&store, &module, &[func.into()])
.err()
@@ -267,7 +267,7 @@ fn rust_panic_import() -> Result<()> {
)?;
let module = Module::new(store.engine(), &binary)?;
let sig = FuncType::new(Box::new([]), Box::new([]));
let sig = FuncType::new(None, None);
let func = Func::new(&store, sig, |_, _, _| panic!("this is a panic"));
let instance = Instance::new(
&store,
@@ -311,7 +311,7 @@ fn rust_panic_start_function() -> Result<()> {
)?;
let module = Module::new(store.engine(), &binary)?;
let sig = FuncType::new(Box::new([]), Box::new([]));
let sig = FuncType::new(None, None);
let func = Func::new(&store, sig, |_, _, _| panic!("this is a panic"));
let err = panic::catch_unwind(AssertUnwindSafe(|| {
drop(Instance::new(&store, &module, &[func.into()]));