Implement more wasm-c-apis and enable Envoy integration (#622)

Implement more wasm-c-api APIs to support Envoy integration:
- sync up with latest c-api definition
- change CMakeLists to export necessary headers and install the static library of iwasm
- enable to export tables and memories
- support memorytype and tabletype APIs
- update wasm-c-api sampels
- enable to export importtype APIs

And refine bazel scripts for sample XNNPACK workload, add license headers for sample simple.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
Wenyong Huang
2021-04-27 17:05:40 +08:00
committed by GitHub
parent a332a49a0d
commit eb29385963
36 changed files with 3190 additions and 1939 deletions

View File

@ -3417,21 +3417,18 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst,
if (function->is_import_func) {
#if WASM_ENABLE_MULTI_MODULE != 0
if (function->import_module_inst) {
LOG_DEBUG("it is a function of a sub module");
wasm_interp_call_func_import(module_inst, exec_env,
function, frame);
}
else
#endif
{
LOG_DEBUG("it is an native function");
/* it is a native function */
wasm_interp_call_func_native(module_inst, exec_env,
function, frame);
}
}
else {
LOG_DEBUG("it is a function of the module itself");
wasm_interp_call_func_bytecode(module_inst, exec_env, function, frame);
}
@ -3440,13 +3437,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst,
for (i = 0; i < function->ret_cell_num; i++) {
argv[i] = *(frame->sp + i - function->ret_cell_num);
}
if (function->ret_cell_num) {
LOG_DEBUG("first return value argv[0]=%d", argv[0]);
}
else {
LOG_DEBUG("no return value");
}
}
else {
#if WASM_ENABLE_DUMP_CALL_STACK != 0

View File

@ -377,7 +377,6 @@ const_str_list_insert(const uint8 *str, uint32 len, WASMModule *module,
}
if (node) {
LOG_DEBUG("reuse %s", node->str);
return node->str;
}
@ -703,7 +702,8 @@ wasm_loader_resolve_function(const char *module_name,
module_reg = wasm_runtime_find_module_registered(module_name);
if (!module_reg
|| module_reg->module_type != Wasm_Module_Bytecode) {
LOG_DEBUG("can not find a module named %s for function", module_name);
LOG_DEBUG("can not find a module named %s for function %s",
module_name, function_name);
set_error_buf(error_buf, error_buf_size, "unknown import");
return NULL;
}
@ -1722,8 +1722,6 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
/* 0x00/0x01/0x02/0x03 */
kind = read_uint8(p);
LOG_DEBUG("import #%d: (%s, %s), kind: %d",
i, sub_module_name, field_name, kind);
switch (kind) {
case IMPORT_KIND_FUNC: /* import function */
bh_assert(import_functions);
@ -2947,7 +2945,6 @@ load_from_sections(WASMModule *module, WASMSection *sections,
while (section) {
buf = section->section_body;
buf_end = buf + section->section_body_size;
LOG_DEBUG("load section, type: %d", section->section_type);
switch (section->section_type) {
case SECTION_TYPE_USER:
/* unsupported user section, ignore it. */