MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / call_impl_check_args

Method call_impl_check_args

crates/wasmtime/src/runtime/func.rs:1137–1168  ·  view source on GitHub ↗

Perform dynamic checks that the arguments given to us match the signature of this function and are appropriate to pass to this function. This involves checking to make sure we have the right number and types of arguments as well as making sure everything is from the same `Store`. This must be called just before `call_impl_do_call`.

(
        &self,
        store: &mut StoreContextMut<'_, T>,
        params: &[Val],
        results: &mut [Val],
    )

Source from the content-addressed store, hash-verified

1135 ///
1136 /// This must be called just before `call_impl_do_call`.
1137 fn call_impl_check_args<T>(
1138 &self,
1139 store: &mut StoreContextMut<'_, T>,
1140 params: &[Val],
1141 results: &mut [Val],
1142 ) -> Result<()> {
1143 let ty = self.load_ty(store.0);
1144 if ty.params().len() != params.len() {
1145 bail!(
1146 "expected {} arguments, got {}",
1147 ty.params().len(),
1148 params.len()
1149 );
1150 }
1151 if ty.results().len() != results.len() {
1152 bail!(
1153 "expected {} results, got {}",
1154 ty.results().len(),
1155 results.len()
1156 );
1157 }
1158
1159 for (ty, arg) in ty.params().zip(params) {
1160 arg.ensure_matches_ty(store.0, &ty)
1161 .context("argument type mismatch")?;
1162 if !arg.comes_from_same_store(store.0) {
1163 bail!("cross-`Store` values are not currently supported");
1164 }
1165 }
1166
1167 Ok(())
1168 }
1169
1170 /// Do the actual call into Wasm.
1171 ///

Callers 2

callMethod · 0.80
call_asyncMethod · 0.80

Calls 8

OkFunction · 0.85
load_tyMethod · 0.45
lenMethod · 0.45
paramsMethod · 0.45
resultsMethod · 0.45
contextMethod · 0.45
ensure_matches_tyMethod · 0.45
comes_from_same_storeMethod · 0.45

Tested by

no test coverage detected