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

Method call

crates/c-api/include/wasmtime/func.hh:241–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239
240template <typename I>
241inline TrapResult<std::vector<Val>>
242Func::call(Store::Context cx, const I &begin, const I &end) const {
243 std::vector<wasmtime_val_t> raw_params;
244 raw_params.reserve(end - begin);
245 for (auto i = begin; i != end; i++) {
246 raw_params.push_back(i->val);
247 }
248 size_t nresults = this->type(cx)->results().size();
249 std::vector<wasmtime_val_t> raw_results(nresults);
250
251 wasm_trap_t *trap = nullptr;
252 auto *error =
253 wasmtime_func_call(cx.ptr, &func, raw_params.data(), raw_params.size(),
254 raw_results.data(), raw_results.capacity(), &trap);
255 if (error != nullptr) {
256 return TrapError(Error(error));
257 }
258 if (trap != nullptr) {
259 return TrapError(Trap(trap));
260 }
261
262 std::vector<Val> results;
263 results.reserve(nresults);
264 for (size_t i = 0; i < nresults; i++) {
265 results.push_back(raw_results[i]);
266 }
267 return results;
268}
269
270inline TrapResult<std::vector<Val>>
271Func::call(Store::Context cx, const std::initializer_list<Val> &params) const {

Callers 15

call_indirect_hostMethod · 0.45
trapMethod · 0.45
fuel_checkMethod · 0.45
hook_malloc_exitMethod · 0.45
hook_free_exitMethod · 0.45
epoch_check_fullMethod · 0.45
table_get_funcrefMethod · 0.45
check_malloc_startMethod · 0.45
check_free_startMethod · 0.45
get_instance_and_tagMethod · 0.45
direct_call_instMethod · 0.45
translate_table_growMethod · 0.45

Calls 12

typeMethod · 0.95
wasmtime_func_callFunction · 0.85
TrapErrorClass · 0.85
ErrorClass · 0.70
TrapClass · 0.70
reserveMethod · 0.45
sizeMethod · 0.45
resultsMethod · 0.45
dataMethod · 0.45
capacityMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 15

call_simple_list1Method · 0.36
call_simple_list2Method · 0.36
call_simple_list3Method · 0.36
call_simple_list4Method · 0.36
call_take_charMethod · 0.36
call_return_charMethod · 0.36
call_handle_requestMethod · 0.36
call_many_argsMethod · 0.36
call_big_argumentMethod · 0.36
call_option_testMethod · 0.36
call_mraMethod · 0.36
call_mrbMethod · 0.36