Move around some panics in wasmtime (#804)
In preparation for eventual support for wasm interface types this commit moves around a few panics internally inside of conversions between the `wasmtime` crate and the underlying jit support crates. This should have any immediately-visible user changes, but the goal is that this'll help support interface types which means `wasmtime` will have types that are not supported by wasmtime itself and we'll be able to more gracefully support that with error messages instead of accidental panics.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
use super::create_handle::create_handle;
|
||||
use super::trap::{record_api_trap, TrapSink, API_TRAP_CODE};
|
||||
use crate::{Callable, FuncType, Store, Val};
|
||||
use anyhow::Result;
|
||||
use anyhow::{bail, Result};
|
||||
use std::cmp;
|
||||
use std::convert::TryFrom;
|
||||
use std::rc::Rc;
|
||||
@@ -234,7 +234,10 @@ pub fn create_handle_with_function(
|
||||
func: &Rc<dyn Callable + 'static>,
|
||||
store: &Store,
|
||||
) -> Result<InstanceHandle> {
|
||||
let sig = ft.get_wasmtime_signature().clone();
|
||||
let sig = match ft.get_wasmtime_signature() {
|
||||
Some(sig) => sig.clone(),
|
||||
None => bail!("not a supported core wasm signature {:?}", ft),
|
||||
};
|
||||
|
||||
let isa = {
|
||||
let isa_builder = native::builder();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::create_handle::create_handle;
|
||||
use crate::{GlobalType, Mutability, Val};
|
||||
use anyhow::Result;
|
||||
use anyhow::{bail, Result};
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::{wasm, Module};
|
||||
use wasmtime_runtime::{InstanceHandle, VMGlobalDefinition};
|
||||
@@ -24,7 +24,10 @@ pub fn create_global(gt: &GlobalType, val: Val) -> Result<(wasmtime_runtime::Exp
|
||||
}
|
||||
|
||||
let global = wasm::Global {
|
||||
ty: gt.content().get_wasmtime_type(),
|
||||
ty: match gt.content().get_wasmtime_type() {
|
||||
Some(t) => t,
|
||||
None => bail!("cannot support {:?} as a wasm global type", gt.content()),
|
||||
},
|
||||
mutability: match gt.mutability() {
|
||||
Mutability::Const => false,
|
||||
Mutability::Var => true,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::create_handle::create_handle;
|
||||
use crate::{TableType, ValType};
|
||||
use anyhow::Result;
|
||||
use anyhow::{bail, Result};
|
||||
use wasmtime_environ::entity::PrimaryMap;
|
||||
use wasmtime_environ::{wasm, Module};
|
||||
use wasmtime_runtime::InstanceHandle;
|
||||
@@ -13,7 +13,10 @@ pub fn create_handle_with_table(table: &TableType) -> Result<InstanceHandle> {
|
||||
maximum: table.limits().max(),
|
||||
ty: match table.element() {
|
||||
ValType::FuncRef => wasm::TableElementType::Func,
|
||||
_ => wasm::TableElementType::Val(table.element().get_wasmtime_type()),
|
||||
_ => match table.element().get_wasmtime_type() {
|
||||
Some(t) => wasm::TableElementType::Val(t),
|
||||
None => bail!("cannot support {:?} as a table element", table.element()),
|
||||
},
|
||||
},
|
||||
};
|
||||
let tunable = Default::default();
|
||||
|
||||
Reference in New Issue
Block a user