Update document and fix wasm_runtime_call_wasm_a issue (#1005)

Update document memory_tune.md: fix embed wamr link error,
fix description error of wasm operand stack size, update picture.

Fix wasm_runtime_call_wasm_a issue reported by #1003 and update
sample basic to call this API.
This commit is contained in:
Wenyong Huang
2022-02-14 17:36:38 +08:00
committed by GitHub
parent 59282f7ddb
commit bb87180b72
5 changed files with 13 additions and 13 deletions

View File

@ -22,7 +22,7 @@ cd ${CURR_DIR}
mkdir -p cmake_build
cd cmake_build
cmake ..
make
make -j ${nproc}
if [ $? != 0 ];then
echo "BUILD_FAIL basic exit as $?\n"
exit 2

View File

@ -123,28 +123,28 @@ main(int argc, char *argv_main[])
goto fail;
}
uint32 argv[4];
double arg_d = 0.000101;
argv[0] = 10;
// the second arg will occupy two array elements
memcpy(&argv[1], &arg_d, sizeof(arg_d));
*(float *)(argv + 3) = 300.002;
if (!(func = wasm_runtime_lookup_function(module_inst, "generate_float",
NULL))) {
printf("The generate_float wasm function is not found.\n");
goto fail;
}
wasm_val_t results[1] = { { .kind = WASM_F32, .of.f32 = 0 } };
wasm_val_t arguments[3] = {
{ .kind = WASM_I32, .of.i32 = 10 },
{ .kind = WASM_F64, .of.f64 = 0.000101 },
{ .kind = WASM_F32, .of.f32 = 300.002 },
};
// pass 4 elements for function arguments
if (!wasm_runtime_call_wasm(exec_env, func, 4, argv)) {
if (!wasm_runtime_call_wasm_a(exec_env, func, 1, results, 3, arguments)) {
printf("call wasm function generate_float failed. %s\n",
wasm_runtime_get_exception(module_inst));
goto fail;
}
float ret_val;
memcpy(&ret_val, argv, sizeof(float));
ret_val = results[0].of.f32;
printf("Native finished calling wasm function generate_float(), returned a "
"float value: %ff\n",
ret_val);