code review

This commit is contained in:
Pat Hickey
2021-10-22 10:43:46 -07:00
parent 52542b6c01
commit b00d811e83
2 changed files with 9 additions and 15 deletions

View File

@@ -195,13 +195,11 @@ pub unsafe extern "C" fn wasmtime_memory32_grow(
match std::panic::catch_unwind(|| {
let instance = (*vmctx).instance_mut();
let memory_index = MemoryIndex::from_u32(memory_index);
match instance.memory_grow(memory_index, delta) {
Ok(Some(size_in_bytes)) => size_in_bytes / (wasmtime_environ::WASM_PAGE_SIZE as usize),
Ok(None) => usize::max_value(),
Err(err) => crate::traphandlers::raise_user_trap(err),
}
instance.memory_grow(memory_index, delta)
}) {
Ok(r) => r,
Ok(Ok(Some(size_in_bytes))) => size_in_bytes / (wasmtime_environ::WASM_PAGE_SIZE as usize),
Ok(Ok(None)) => usize::max_value(),
Ok(Err(err)) => crate::traphandlers::raise_user_trap(err),
Err(p) => resume_panic(p),
}
}
@@ -231,13 +229,11 @@ pub unsafe extern "C" fn wasmtime_table_grow(
init_value.into()
}
};
match instance.table_grow(table_index, delta, element) {
Ok(Some(r)) => r,
Ok(None) => -1_i32 as u32,
Err(err) => crate::traphandlers::raise_user_trap(err),
}
instance.table_grow(table_index, delta, element)
}) {
Ok(r) => r,
Ok(Ok(Some(r))) => r,
Ok(Ok(None)) => -1_i32 as u32,
Ok(Err(err)) => crate::traphandlers::raise_user_trap(err),
Err(p) => resume_panic(p),
}
}

View File

@@ -1880,9 +1880,7 @@ macro_rules! impl_into_func {
// can't assume it returned a value that is
// compatible with this store.
if !ret.compatible_with_store(caller.store.0) {
CallResult::Trap(anyhow::anyhow!(
"host function attempted to return cross-`Store` value to Wasm"
))
CallResult::Trap(anyhow::anyhow!("host function attempted to return cross-`Store` value to Wasm"))
} else {
match ret.into_abi_for_ret(caller.store.0, retptr) {
Ok(val) => CallResult::Ok(val),