diff --git a/cmake/libraries.cmake b/cmake/libraries.cmake index f17e9267dda..f92abcf452c 100644 --- a/cmake/libraries.cmake +++ b/cmake/libraries.cmake @@ -24,4 +24,4 @@ set(FLB_PATH_LIB_CARES "lib/c-ares-1.33.1") set(FLB_PATH_LIB_SNAPPY "lib/snappy-fef67ac") set(FLB_PATH_LIB_RDKAFKA "lib/librdkafka-2.4.0") set(FLB_PATH_LIB_RING_BUFFER "lib/lwrb") -set(FLB_PATH_LIB_WASM_MICRO_RUNTIME "lib/wasm-micro-runtime-WAMR-1.3.0") +set(FLB_PATH_LIB_WASM_MICRO_RUNTIME "lib/wasm-micro-runtime-WAMR-1.3.3") diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/esp-idf/wamr/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/esp-idf/wamr/CMakeLists.txt deleted file mode 100644 index 5ac04ddc92e..00000000000 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/esp-idf/wamr/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (C) 2021 Intel Corporation and others. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Set WAMR's build options -if("${IDF_TARGET}" STREQUAL "esp32c3") - set(WAMR_BUILD_TARGET "RISCV32") -else() - set(WAMR_BUILD_TARGET "XTENSA") -endif() - -set(WAMR_BUILD_PLATFORM "esp-idf") - -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif () - -if (NOT DEFINED WAMR_BUILD_INTERP) - set (WAMR_BUILD_INTERP 1) -endif () - -if (NOT DEFINED WAMR_BUILD_FAST_INTERP) - set (WAMR_BUILD_FAST_INTERP 1) -endif () - -if (NOT DEFINED WAMR_BUILD_AOT) - set (WAMR_BUILD_AOT 1) -endif () - -if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN) - set (WAMR_BUILD_LIBC_BUILTIN 1) -endif () - -if (NOT DEFINED WAMR_BUILD_APP_FRAMEWORK) - set (WAMR_BUILD_APP_FRAMEWORK 0) -endif () - -if (NOT CMAKE_BUILD_EARLY_EXPANSION) - if (WAMR_BUILD_TARGET STREQUAL "XTENSA") - idf_build_set_property(COMPILE_DEFINITIONS "-DBUILD_TARGET_XTENSA=1" APPEND) - endif () - if (WAMR_BUILD_INTERP) - idf_build_set_property(COMPILE_DEFINITIONS "-DWASM_ENABLE_INTERP=1" APPEND) - endif () - if (WAMR_BUILD_AOT) - idf_build_set_property(COMPILE_DEFINITIONS "-DWASM_ENABLE_AOT=1" APPEND) - endif () - - set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) - include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) -endif() - -idf_component_register(SRCS ${WAMR_RUNTIME_LIB_SOURCE} ${PLATFORM_SHARED_SOURCE} - INCLUDE_DIRS ${IWASM_DIR}/include ${UTILS_SHARED_DIR} ${PLATFORM_SHARED_DIR} ${PLATFORM_SHARED_DIR}/../include - REQUIRES pthread lwip esp_timer -) - - diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_native.c b/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_native.c deleted file mode 100644 index c42bf7b318a..00000000000 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_native.c +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -#include "wasm_native.h" -#include "wasm_runtime_common.h" -#include "bh_log.h" -#if WASM_ENABLE_INTERP != 0 -#include "../interpreter/wasm_runtime.h" -#endif -#if WASM_ENABLE_AOT != 0 -#include "../aot/aot_runtime.h" -#endif -#if WASM_ENABLE_THREAD_MGR != 0 -#include "../libraries/thread-mgr/thread_manager.h" -#endif - -#if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS) \ - && !defined(BH_PLATFORM_OPENRTOS) && !defined(BH_PLATFORM_ESP_IDF) -#define ENABLE_QUICKSORT 1 -#else -#define ENABLE_QUICKSORT 0 -#endif - -#define ENABLE_SORT_DEBUG 0 - -#if ENABLE_SORT_DEBUG != 0 -#include -#endif - -static NativeSymbolsList g_native_symbols_list = NULL; - -#if WASM_ENABLE_LIBC_WASI != 0 -static void *g_wasi_context_key; -#endif /* WASM_ENABLE_LIBC_WASI */ - -uint32 -get_libc_builtin_export_apis(NativeSymbol **p_libc_builtin_apis); - -#if WASM_ENABLE_SPEC_TEST != 0 -uint32 -get_spectest_export_apis(NativeSymbol **p_libc_builtin_apis); -#endif - -uint32 -get_libc_wasi_export_apis(NativeSymbol **p_libc_wasi_apis); - -uint32_t -get_wasi_nn_export_apis(NativeSymbol **p_libc_wasi_apis); - -uint32 -get_base_lib_export_apis(NativeSymbol **p_base_lib_apis); - -uint32 -get_ext_lib_export_apis(NativeSymbol **p_ext_lib_apis); - -#if WASM_ENABLE_LIB_PTHREAD != 0 -bool -lib_pthread_init(); - -void -lib_pthread_destroy(); - -uint32 -get_lib_pthread_export_apis(NativeSymbol **p_lib_pthread_apis); -#endif - -#if WASM_ENABLE_LIB_WASI_THREADS != 0 -bool -lib_wasi_threads_init(void); - -void -lib_wasi_threads_destroy(void); - -uint32 -get_lib_wasi_threads_export_apis(NativeSymbol **p_lib_wasi_threads_apis); -#endif - -uint32 -get_libc_emcc_export_apis(NativeSymbol **p_libc_emcc_apis); - -uint32 -get_lib_rats_export_apis(NativeSymbol **p_lib_rats_apis); - -static bool -compare_type_with_signautre(uint8 type, const char signature) -{ - const char num_sig_map[] = { 'F', 'f', 'I', 'i' }; - - if (VALUE_TYPE_F64 <= type && type <= VALUE_TYPE_I32 - && signature == num_sig_map[type - VALUE_TYPE_F64]) { - return true; - } - -#if WASM_ENABLE_REF_TYPES != 0 - if ('r' == signature && type == VALUE_TYPE_EXTERNREF) - return true; -#endif - - /* TODO: a v128 parameter */ - return false; -} - -static bool -check_symbol_signature(const WASMType *type, const char *signature) -{ - const char *p = signature, *p_end; - char sig; - uint32 i = 0; - - if (!p || strlen(p) < 2) - return false; - - p_end = p + strlen(signature); - - if (*p++ != '(') - return false; - - if ((uint32)(p_end - p) < (uint32)(type->param_count + 1)) - /* signatures of parameters, and ')' */ - return false; - - for (i = 0; i < type->param_count; i++) { - sig = *p++; - - /* a f64/f32/i64/i32/externref parameter */ - if (compare_type_with_signautre(type->types[i], sig)) - continue; - - /* a pointer/string paramter */ - if (type->types[i] != VALUE_TYPE_I32) - /* pointer and string must be i32 type */ - return false; - - if (sig == '*') { - /* it is a pointer */ - if (i + 1 < type->param_count - && type->types[i + 1] == VALUE_TYPE_I32 && *p == '~') { - /* pointer length followed */ - i++; - p++; - } - } - else if (sig == '$') { - /* it is a string */ - } - else { - /* invalid signature */ - return false; - } - } - - if (*p++ != ')') - return false; - - if (type->result_count) { - if (p >= p_end) - return false; - - /* result types includes: f64,f32,i64,i32,externref */ - if (!compare_type_with_signautre(type->types[i], *p)) - return false; - - p++; - } - - if (*p != '\0') - return false; - - return true; -} - -#if ENABLE_QUICKSORT == 0 -static void -sort_symbol_ptr(NativeSymbol *native_symbols, uint32 n_native_symbols) -{ - uint32 i, j; - NativeSymbol temp; - - for (i = 0; i < n_native_symbols - 1; i++) { - for (j = i + 1; j < n_native_symbols; j++) { - if (strcmp(native_symbols[i].symbol, native_symbols[j].symbol) - > 0) { - temp = native_symbols[i]; - native_symbols[i] = native_symbols[j]; - native_symbols[j] = temp; - } - } - } -} -#else -static void -swap_symbol(NativeSymbol *left, NativeSymbol *right) -{ - NativeSymbol temp = *left; - *left = *right; - *right = temp; -} - -static void -quick_sort_symbols(NativeSymbol *native_symbols, int left, int right) -{ - NativeSymbol base_symbol; - int pin_left = left; - int pin_right = right; - - if (left >= right) { - return; - } - - base_symbol = native_symbols[left]; - while (left < right) { - while (left < right - && strcmp(native_symbols[right].symbol, base_symbol.symbol) - > 0) { - right--; - } - - if (left < right) { - swap_symbol(&native_symbols[left], &native_symbols[right]); - left++; - } - - while (left < right - && strcmp(native_symbols[left].symbol, base_symbol.symbol) < 0) { - left++; - } - - if (left < right) { - swap_symbol(&native_symbols[left], &native_symbols[right]); - right--; - } - } - native_symbols[left] = base_symbol; - - quick_sort_symbols(native_symbols, pin_left, left - 1); - quick_sort_symbols(native_symbols, left + 1, pin_right); -} -#endif /* end of ENABLE_QUICKSORT */ - -static void * -lookup_symbol(NativeSymbol *native_symbols, uint32 n_native_symbols, - const char *symbol, const char **p_signature, void **p_attachment) -{ - int low = 0, mid, ret; - int high = (int32)n_native_symbols - 1; - - while (low <= high) { - mid = (low + high) / 2; - ret = strcmp(symbol, native_symbols[mid].symbol); - if (ret == 0) { - *p_signature = native_symbols[mid].signature; - *p_attachment = native_symbols[mid].attachment; - return native_symbols[mid].func_ptr; - } - else if (ret < 0) - high = mid - 1; - else - low = mid + 1; - } - - return NULL; -} - -/** - * allow func_type and all outputs, like p_signature, p_attachment and - * p_call_conv_raw to be NULL - */ -void * -wasm_native_resolve_symbol(const char *module_name, const char *field_name, - const WASMType *func_type, const char **p_signature, - void **p_attachment, bool *p_call_conv_raw) -{ - NativeSymbolsNode *node, *node_next; - const char *signature = NULL; - void *func_ptr = NULL, *attachment; - - node = g_native_symbols_list; - while (node) { - node_next = node->next; - if (!strcmp(node->module_name, module_name)) { - if ((func_ptr = - lookup_symbol(node->native_symbols, node->n_native_symbols, - field_name, &signature, &attachment)) - || (field_name[0] == '_' - && (func_ptr = lookup_symbol( - node->native_symbols, node->n_native_symbols, - field_name + 1, &signature, &attachment)))) - break; - } - node = node_next; - } - - if (!p_signature || !p_attachment || !p_call_conv_raw) - return func_ptr; - - if (func_ptr) { - if (signature && signature[0] != '\0') { - /* signature is not empty, check its format */ - if (!func_type || !check_symbol_signature(func_type, signature)) { -#if WASM_ENABLE_WAMR_COMPILER == 0 - /* Output warning except running aot compiler */ - LOG_WARNING("failed to check signature '%s' and resolve " - "pointer params for import function (%s %s)\n", - signature, module_name, field_name); -#endif - return NULL; - } - else - /* Save signature for runtime to do pointer check and - address conversion */ - *p_signature = signature; - } - else - /* signature is empty */ - *p_signature = NULL; - - *p_attachment = attachment; - *p_call_conv_raw = node->call_conv_raw; - } - - return func_ptr; -} - -static bool -register_natives(const char *module_name, NativeSymbol *native_symbols, - uint32 n_native_symbols, bool call_conv_raw) -{ - NativeSymbolsNode *node; -#if ENABLE_SORT_DEBUG != 0 - struct timeval start; - struct timeval end; - unsigned long timer; -#endif - - if (!(node = wasm_runtime_malloc(sizeof(NativeSymbolsNode)))) - return false; -#if WASM_ENABLE_MEMORY_TRACING != 0 - os_printf("Register native, size: %u\n", sizeof(NativeSymbolsNode)); -#endif - - node->module_name = module_name; - node->native_symbols = native_symbols; - node->n_native_symbols = n_native_symbols; - node->call_conv_raw = call_conv_raw; - - /* Add to list head */ - node->next = g_native_symbols_list; - g_native_symbols_list = node; - -#if ENABLE_SORT_DEBUG != 0 - gettimeofday(&start, NULL); -#endif - -#if ENABLE_QUICKSORT == 0 - sort_symbol_ptr(native_symbols, n_native_symbols); -#else - quick_sort_symbols(native_symbols, 0, (int)(n_native_symbols - 1)); -#endif - -#if ENABLE_SORT_DEBUG != 0 - gettimeofday(&end, NULL); - timer = - 1000000 * (end.tv_sec - start.tv_sec) + (end.tv_usec - start.tv_usec); - LOG_ERROR("module_name: %s, nums: %d, sorted used: %ld us", module_name, - n_native_symbols, timer); -#endif - return true; -} - -bool -wasm_native_register_natives(const char *module_name, - NativeSymbol *native_symbols, - uint32 n_native_symbols) -{ - return register_natives(module_name, native_symbols, n_native_symbols, - false); -} - -bool -wasm_native_register_natives_raw(const char *module_name, - NativeSymbol *native_symbols, - uint32 n_native_symbols) -{ - return register_natives(module_name, native_symbols, n_native_symbols, - true); -} - -bool -wasm_native_unregister_natives(const char *module_name, - NativeSymbol *native_symbols) -{ - NativeSymbolsNode **prevp; - NativeSymbolsNode *node; - - prevp = &g_native_symbols_list; - while ((node = *prevp) != NULL) { - if (node->native_symbols == native_symbols - && !strcmp(node->module_name, module_name)) { - *prevp = node->next; - wasm_runtime_free(node); - return true; - } - prevp = &node->next; - } - return false; -} - -#if WASM_ENABLE_MODULE_INST_CONTEXT != 0 -static uint32 -context_key_to_idx(void *key) -{ - bh_assert(key != NULL); - uint32 idx = (uint32)(uintptr_t)key; - bh_assert(idx > 0); - bh_assert(idx <= WASM_MAX_INSTANCE_CONTEXTS); - return idx - 1; -} - -static void * -context_idx_to_key(uint32 idx) -{ - bh_assert(idx < WASM_MAX_INSTANCE_CONTEXTS); - return (void *)(uintptr_t)(idx + 1); -} - -typedef void (*dtor_t)(WASMModuleInstanceCommon *, void *); -static dtor_t g_context_dtors[WASM_MAX_INSTANCE_CONTEXTS]; - -static void -dtor_noop(WASMModuleInstanceCommon *inst, void *ctx) -{} - -void * -wasm_native_create_context_key(void (*dtor)(WASMModuleInstanceCommon *inst, - void *ctx)) -{ - uint32 i; - for (i = 0; i < WASM_MAX_INSTANCE_CONTEXTS; i++) { - if (g_context_dtors[i] == NULL) { - if (dtor == NULL) { - dtor = dtor_noop; - } - g_context_dtors[i] = dtor; - return context_idx_to_key(i); - } - } - LOG_ERROR("failed to allocate instance context key"); - return NULL; -} - -void -wasm_native_destroy_context_key(void *key) -{ - uint32 idx = context_key_to_idx(key); - bh_assert(g_context_dtors[idx] != NULL); - g_context_dtors[idx] = NULL; -} - -static WASMModuleInstanceExtraCommon * -wasm_module_inst_extra_common(WASMModuleInstanceCommon *inst) -{ -#if WASM_ENABLE_INTERP != 0 - if (inst->module_type == Wasm_Module_Bytecode) { - return &((WASMModuleInstance *)inst)->e->common; - } -#endif -#if WASM_ENABLE_AOT != 0 - if (inst->module_type == Wasm_Module_AoT) { - return &((AOTModuleInstanceExtra *)((AOTModuleInstance *)inst)->e) - ->common; - } -#endif - bh_assert(false); - return NULL; -} - -void -wasm_native_set_context(WASMModuleInstanceCommon *inst, void *key, void *ctx) -{ - uint32 idx = context_key_to_idx(key); - WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst); - common->contexts[idx] = ctx; -} - -void -wasm_native_set_context_spread(WASMModuleInstanceCommon *inst, void *key, - void *ctx) -{ -#if WASM_ENABLE_THREAD_MGR != 0 - wasm_cluster_set_context(inst, key, ctx); -#else - wasm_native_set_context(inst, key, ctx); -#endif -} - -void * -wasm_native_get_context(WASMModuleInstanceCommon *inst, void *key) -{ - uint32 idx = context_key_to_idx(key); - WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst); - return common->contexts[idx]; -} - -void -wasm_native_call_context_dtors(WASMModuleInstanceCommon *inst) -{ - WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst); - uint32 i; - for (i = 0; i < WASM_MAX_INSTANCE_CONTEXTS; i++) { - dtor_t dtor = g_context_dtors[i]; - if (dtor != NULL) { - dtor(inst, common->contexts[i]); - } - } -} - -void -wasm_native_inherit_contexts(WASMModuleInstanceCommon *child, - WASMModuleInstanceCommon *parent) -{ - WASMModuleInstanceExtraCommon *parent_common = - wasm_module_inst_extra_common(parent); - WASMModuleInstanceExtraCommon *child_common = - wasm_module_inst_extra_common(child); - bh_memcpy_s(child_common->contexts, - sizeof(*child_common->contexts) * WASM_MAX_INSTANCE_CONTEXTS, - parent_common->contexts, - sizeof(*parent_common->contexts) * WASM_MAX_INSTANCE_CONTEXTS); -} -#endif /* WASM_ENABLE_MODULE_INST_CONTEXT != 0 */ - -#if WASM_ENABLE_LIBC_WASI != 0 -WASIContext * -wasm_runtime_get_wasi_ctx(WASMModuleInstanceCommon *module_inst_comm) -{ - return wasm_native_get_context(module_inst_comm, g_wasi_context_key); -} - -void -wasm_runtime_set_wasi_ctx(WASMModuleInstanceCommon *module_inst_comm, - WASIContext *wasi_ctx) -{ - wasm_native_set_context(module_inst_comm, g_wasi_context_key, wasi_ctx); -} - -static void -wasi_context_dtor(WASMModuleInstanceCommon *inst, void *ctx) -{ - if (ctx == NULL) { - return; - } - wasm_runtime_destroy_wasi(inst); -} -#endif /* end of WASM_ENABLE_LIBC_WASI */ - -bool -wasm_native_init() -{ -#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \ - || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \ - || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \ - || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \ - || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0 - NativeSymbol *native_symbols; - uint32 n_native_symbols; -#endif - -#if WASM_ENABLE_LIBC_BUILTIN != 0 - n_native_symbols = get_libc_builtin_export_apis(&native_symbols); - if (!wasm_native_register_natives("env", native_symbols, n_native_symbols)) - goto fail; -#endif /* WASM_ENABLE_LIBC_BUILTIN */ - -#if WASM_ENABLE_SPEC_TEST - n_native_symbols = get_spectest_export_apis(&native_symbols); - if (!wasm_native_register_natives("spectest", native_symbols, - n_native_symbols)) - goto fail; -#endif /* WASM_ENABLE_SPEC_TEST */ - -#if WASM_ENABLE_LIBC_WASI != 0 - g_wasi_context_key = wasm_native_create_context_key(wasi_context_dtor); - if (g_wasi_context_key == NULL) { - goto fail; - } - n_native_symbols = get_libc_wasi_export_apis(&native_symbols); - if (!wasm_native_register_natives("wasi_unstable", native_symbols, - n_native_symbols)) - goto fail; - if (!wasm_native_register_natives("wasi_snapshot_preview1", native_symbols, - n_native_symbols)) - goto fail; -#endif - -#if WASM_ENABLE_BASE_LIB != 0 - n_native_symbols = get_base_lib_export_apis(&native_symbols); - if (n_native_symbols > 0 - && !wasm_native_register_natives("env", native_symbols, - n_native_symbols)) - goto fail; -#endif - -#if WASM_ENABLE_APP_FRAMEWORK != 0 - n_native_symbols = get_ext_lib_export_apis(&native_symbols); - if (n_native_symbols > 0 - && !wasm_native_register_natives("env", native_symbols, - n_native_symbols)) - goto fail; -#endif - -#if WASM_ENABLE_LIB_PTHREAD != 0 - if (!lib_pthread_init()) - goto fail; - - n_native_symbols = get_lib_pthread_export_apis(&native_symbols); - if (n_native_symbols > 0 - && !wasm_native_register_natives("env", native_symbols, - n_native_symbols)) - goto fail; -#endif - -#if WASM_ENABLE_LIB_WASI_THREADS != 0 - if (!lib_wasi_threads_init()) - goto fail; - - n_native_symbols = get_lib_wasi_threads_export_apis(&native_symbols); - if (n_native_symbols > 0 - && !wasm_native_register_natives("wasi", native_symbols, - n_native_symbols)) - goto fail; -#endif - -#if WASM_ENABLE_LIBC_EMCC != 0 - n_native_symbols = get_libc_emcc_export_apis(&native_symbols); - if (n_native_symbols > 0 - && !wasm_native_register_natives("env", native_symbols, - n_native_symbols)) - goto fail; -#endif /* WASM_ENABLE_LIBC_EMCC */ - -#if WASM_ENABLE_LIB_RATS != 0 - n_native_symbols = get_lib_rats_export_apis(&native_symbols); - if (n_native_symbols > 0 - && !wasm_native_register_natives("env", native_symbols, - n_native_symbols)) - goto fail; -#endif /* WASM_ENABLE_LIB_RATS */ - -#if WASM_ENABLE_WASI_NN != 0 - n_native_symbols = get_wasi_nn_export_apis(&native_symbols); - if (!wasm_native_register_natives("wasi_nn", native_symbols, - n_native_symbols)) - goto fail; -#endif - - return true; -#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \ - || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \ - || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \ - || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \ - || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0 -fail: - wasm_native_destroy(); - return false; -#endif -} - -void -wasm_native_destroy() -{ - NativeSymbolsNode *node, *node_next; - -#if WASM_ENABLE_LIBC_WASI != 0 - if (g_wasi_context_key != NULL) { - wasm_native_destroy_context_key(g_wasi_context_key); - g_wasi_context_key = NULL; - } -#endif -#if WASM_ENABLE_LIB_PTHREAD != 0 - lib_pthread_destroy(); -#endif - -#if WASM_ENABLE_LIB_WASI_THREADS != 0 - lib_wasi_threads_destroy(); -#endif - - node = g_native_symbols_list; - while (node) { - node_next = node->next; - wasm_runtime_free(node); - node = node_next; - } - - g_native_symbols_list = NULL; -} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_socket.c b/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_socket.c deleted file mode 100644 index a75d82975d0..00000000000 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_socket.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) 2021 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -#include "platform_api_vmcore.h" -#include "platform_api_extension.h" -#include "libc_errno.h" - -#include - -static void -textual_addr_to_sockaddr(const char *textual, int port, struct sockaddr_in *out) -{ - assert(textual); - - out->sin_family = AF_INET; - out->sin_port = htons(port); - out->sin_addr.s_addr = inet_addr(textual); -} - -static int -sockaddr_to_bh_sockaddr(const struct sockaddr *sockaddr, socklen_t socklen, - bh_sockaddr_t *bh_sockaddr) -{ - switch (sockaddr->sa_family) { - case AF_INET: - { - struct sockaddr_in *addr = (struct sockaddr_in *)sockaddr; - - assert(socklen >= sizeof(struct sockaddr_in)); - - bh_sockaddr->port = ntohs(addr->sin_port); - bh_sockaddr->addr_buffer.ipv4 = ntohl(addr->sin_addr.s_addr); - bh_sockaddr->is_ipv4 = true; - return BHT_OK; - } - default: - errno = EAFNOSUPPORT; - return BHT_ERROR; - } -} - -int -os_socket_create(bh_socket_t *sock, bool is_ipv4, bool is_tcp) -{ - if (!sock) { - return BHT_ERROR; - } - - if (is_tcp) { - *sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - } - else { - *sock = socket(AF_INET, SOCK_DGRAM, 0); - } - - return (*sock == -1) ? BHT_ERROR : BHT_OK; -} - -int -os_socket_bind(bh_socket_t socket, const char *host, int *port) -{ - struct sockaddr_in addr; - socklen_t socklen; - int ret; - - assert(host); - assert(port); - - addr.sin_addr.s_addr = inet_addr(host); - addr.sin_port = htons(*port); - addr.sin_family = AF_INET; - - ret = bind(socket, (struct sockaddr *)&addr, sizeof(addr)); - if (ret < 0) { - goto fail; - } - - socklen = sizeof(addr); - if (getsockname(socket, (struct sockaddr *)&addr, &socklen) == -1) { - goto fail; - } - - *port = ntohs(addr.sin_port); - - return BHT_OK; - -fail: - return BHT_ERROR; -} - -int -os_socket_settimeout(bh_socket_t socket, uint64 timeout_us) -{ - struct timeval tv; - tv.tv_sec = timeout_us / 1000000UL; - tv.tv_usec = timeout_us % 1000000UL; - - if (setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, - sizeof(tv)) - != 0) { - return BHT_ERROR; - } - - return BHT_OK; -} - -int -os_socket_listen(bh_socket_t socket, int max_client) -{ - if (listen(socket, max_client) != 0) { - return BHT_ERROR; - } - - return BHT_OK; -} - -int -os_socket_accept(bh_socket_t server_sock, bh_socket_t *sock, void *addr, - unsigned int *addrlen) -{ - struct sockaddr addr_tmp; - socklen_t len = sizeof(struct sockaddr); - - *sock = accept(server_sock, (struct sockaddr *)&addr_tmp, &len); - - if (*sock < 0) { - return BHT_ERROR; - } - - return BHT_OK; -} - -int -os_socket_connect(bh_socket_t socket, const char *addr, int port) -{ - struct sockaddr_in addr_in = { 0 }; - socklen_t addr_len = sizeof(struct sockaddr_in); - int ret = 0; - - textual_addr_to_sockaddr(addr, port, &addr_in); - - ret = connect(socket, (struct sockaddr *)&addr_in, addr_len); - if (ret == -1) { - return BHT_ERROR; - } - - return BHT_OK; -} - -int -os_socket_recv(bh_socket_t socket, void *buf, unsigned int len) -{ - return recv(socket, buf, len, 0); -} - -int -os_socket_send(bh_socket_t socket, const void *buf, unsigned int len) -{ - return send(socket, buf, len, 0); -} - -int -os_socket_close(bh_socket_t socket) -{ - close(socket); - return BHT_OK; -} - -__wasi_errno_t -os_socket_shutdown(bh_socket_t socket) -{ - if (shutdown(socket, O_RDWR) != 0) { - return convert_errno(errno); - } - return __WASI_ESUCCESS; -} - -int -os_socket_inet_network(bool is_ipv4, const char *cp, bh_ip_addr_buffer_t *out) -{ - if (!cp) - return BHT_ERROR; - - if (is_ipv4) { - if (inet_pton(AF_INET, cp, &out->ipv4) != 1) { - return BHT_ERROR; - } - /* Note: ntohl(INADDR_NONE) == INADDR_NONE */ - out->ipv4 = ntohl(out->ipv4); - } - else { - if (inet_pton(AF_INET6, cp, out->ipv6) != 1) { - return BHT_ERROR; - } - for (int i = 0; i < 8; i++) { - out->ipv6[i] = ntohs(out->ipv6[i]); - } - } - - return BHT_OK; -} - -int -os_socket_addr_remote(bh_socket_t socket, bh_sockaddr_t *sockaddr) -{ - struct sockaddr_in addr; - socklen_t addr_len = sizeof(addr); - - if (getpeername(socket, (struct sockaddr *)&addr, &addr_len) == -1) { - return BHT_ERROR; - } - - return sockaddr_to_bh_sockaddr((struct sockaddr *)&addr, addr_len, - sockaddr); -} - -int -os_socket_addr_local(bh_socket_t socket, bh_sockaddr_t *sockaddr) -{ - struct sockaddr_in addr; - socklen_t addr_len = sizeof(addr); - - if (getsockname(socket, (struct sockaddr *)&addr, &addr_len) == -1) { - return BHT_ERROR; - } - - return sockaddr_to_bh_sockaddr((struct sockaddr *)&addr, addr_len, - sockaddr); -} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/Config_building_target.png b/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/Config_building_target.png deleted file mode 100644 index a1270007fda..00000000000 Binary files a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/Config_building_target.png and /dev/null differ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/compilation_config.png b/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/compilation_config.png deleted file mode 100644 index 43c60a21f9a..00000000000 Binary files a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/compilation_config.png and /dev/null differ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/compilation_config_2.png b/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/compilation_config_2.png deleted file mode 100644 index c16bb09ec34..00000000000 Binary files a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/compilation_config_2.png and /dev/null differ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/runTest.ts b/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/runTest.ts deleted file mode 100644 index ae81a539b92..00000000000 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/runTest.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -import * as path from 'path'; -import * as os from 'os'; - -import { runTests } from '@vscode/test-electron'; - -async function main() { - try { - // The folder containing the Extension Manifest package.json - // Passed to `--extensionDevelopmentPath` - const extensionDevelopmentPath = path.resolve(__dirname, '../../'); - - // The path to the extension test script - // Passed to --extensionTestsPath - const extensionTestsPath = path.resolve(__dirname, './suite/index'); - - // Download VS Code, unzip it and run the integration test - await runTests({ - extensionDevelopmentPath, - extensionTestsPath, - launchArgs: ['--user-data-dir', `${os.tmpdir()}`] - }); - } catch (err) { - console.error('Failed to run tests'); - process.exit(1); - } -} - -main(); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts b/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts deleted file mode 100644 index 5bd717b28b2..00000000000 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -import {DebugProtocol} from '@vscode/debugprotocol'; -import {after, before, test, suite} from 'mocha'; -import {assert} from 'chai'; -import * as vscode from 'vscode'; -import * as cp from 'child_process'; -import * as path from "path"; -import * as os from 'os'; -import {WasmDebugConfig, WasmDebugConfigurationProvider} from "../../debugConfigurationProvider"; -import {EXTENSION_PATH, clearAllBp, setBpAtMarker, compileRustToWasm} from "./utils"; -import {downloadLldb, isLLDBInstalled} from '../../utilities/lldbUtilities'; - -suite('Unit Tests', function () { - test('DebugConfigurationProvider init commands', function () { - const testExtensionPath = "/test/path/"; - const provider = new WasmDebugConfigurationProvider(testExtensionPath); - - assert.includeMembers( - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - provider.getDebugConfig().initCommands!, - [`command script import ${testExtensionPath}/formatters/rust.py`], - "Debugger init commands did not contain " - ); - }); - - test('DebugConfigurationProvider resolve configuration', function () { - const testExtensionPath = "/test/path/"; - const provider = new WasmDebugConfigurationProvider(testExtensionPath); - - const actual = provider.resolveDebugConfiguration(undefined, { - type: "wamr-debug", - name: "Attach", - request: "attach", - initCommands: [], - attachCommands: [ - 'process connect -p wasm connect://123.456.789.1:1237', - ] - }); - - assert.deepEqual( - actual, - { - type: "wamr-debug", - name: "Attach", - request: "attach", - stopOnEntry: true, - initCommands: [], - attachCommands: [ - 'process connect -p wasm connect://123.456.789.1:1237', - ] - }, - "Configuration did not match the expected configuration after calling resolveDebugConfiguration()" - ); - }); -}); - -suite('Inegration Tests', function () { - let debuggerProcess: cp.ChildProcessWithoutNullStreams; - const port = 1239; - const downloadTimeout = 60 * 1000; - - before(async function () { - // timeout of 20 seconds - this.timeout(20 * 1000); - // Download LLDB if necessary. Should be available in the CI. Only for local execution. - if (!isLLDBInstalled(EXTENSION_PATH)) { - this.timeout(downloadTimeout); - console.log("Downloading LLDB. This might take a moment..."); - await downloadLldb(EXTENSION_PATH); - assert.isTrue(isLLDBInstalled(EXTENSION_PATH), "LLDB was not installed correctly"); - } - - compileRustToWasm(); - - const platform = os.platform(); - assert.isTrue(platform === "darwin" || platform === "linux", `Tests do not support your platform: ${platform}`); - const iWasmPath = path.resolve(`${EXTENSION_PATH}/../../../product-mini/platforms/${platform}/build/iwasm`); - const testWasmFilePath = `${EXTENSION_PATH}/resource/test/test.wasm`; - - debuggerProcess = cp.spawn( - iWasmPath, - [`-g=127.0.0.1:${port}`, testWasmFilePath], - {} - ); - - debuggerProcess.stderr.on('data', (data) => { - console.log(`Error from debugger process: ${data}`); - }); - }); - - after(async function () { - await vscode.debug.stopDebugging(); - debuggerProcess.kill(); - }); - - test('Rust formatters', async function () { - // timeout of 1 minutes - this.timeout(60 * 1000); - clearAllBp(); - setBpAtMarker(`${EXTENSION_PATH}/resource/test/test.rs`, "BP_MARKER_1"); - - const getVariables = new Promise((resolve, reject) => { - vscode.debug.registerDebugAdapterTrackerFactory("wamr-debug", { - createDebugAdapterTracker: function () { - return { - // The debug adapter has sent a Debug Adapter Protocol message to the editor. - onDidSendMessage: (message: DebugProtocol.ProtocolMessage) => { - if (message.type === "response") { - const m = message as DebugProtocol.Response; - if (m.command === "variables") { - const res = m as DebugProtocol.VariablesResponse; - resolve(res.body.variables); - } - } - }, - onError: (error: Error) => { - reject("An error occurred before vscode reached the breakpoint: " + error); - }, - onExit: (code: number | undefined) => { - reject(`Debugger exited before vscode reached the breakpoint with code: ${code}`); - }, - }; - } - }); - }); - - const config: WasmDebugConfig = { - type: "wamr-debug", - request: "attach", - name: "Attach Debugger", - stopOnEntry: false, - initCommands: [ - `command script import ${EXTENSION_PATH}/formatters/rust.py` - ], - attachCommands: [ - `process connect -p wasm connect://127.0.0.1:${port}` - ] - }; - - if (os.platform() === 'win32' || os.platform() === 'darwin') { - config.initCommands?.push('platform select remote-linux'); - } - - try { - await vscode.debug.startDebugging(undefined, config); - } catch (e) { - assert.fail("Could not connect to debug adapter"); - } - - // wait until vs code has reached breakpoint and has requested the variables. - const variables = await getVariables; - const namesToVariables = variables.reduce((acc: { [name: string]: DebugProtocol.Variable }, c) => { - if (c.evaluateName) { - acc[c.evaluateName] = c; - } - return acc; - }, {}); - - assert.includeMembers(Object.keys(namesToVariables), ["vector", "map", "string", "slice", "deque", "ref_cell"], "The Debugger did not return all expected debugger variables."); - - // Vector - assert.equal(namesToVariables["vector"].value, " (5) vec![1, 2, 3, 4, 12]", "The Vector summary string looks different than expected"); - - // Map - assert.equal(namesToVariables["map"].value, " size=5, capacity=8", "The Map summary string looks different than expected"); - - // String - assert.equal(namesToVariables["string"].value, " \"this is a string\"", "The String summary string looks different than expected"); - - // Slice - assert.equal(namesToVariables["slice"].value, " \"ello\"", "The Slice summary string looks different than expected"); - - // Deque - assert.equal(namesToVariables["deque"].value, " (5) VecDeque[1, 2, 3, 4, 5]", "The Deque summary string looks different than expected"); - - // RefCell - assert.equal(namesToVariables["ref_cell"].value, " 5", "The RefCell summary string looks different than expected"); - }); -}); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/index.ts b/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/index.ts deleted file mode 100644 index 9b56c6ffe67..00000000000 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2019 Intel Corporation. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ - -import * as path from 'path'; -import * as Mocha from 'mocha'; -import * as glob from 'glob'; - -export function run(): Promise { - // Create the mocha test - const mocha = new Mocha({ - ui: 'tdd' - }); - - const testsRoot = path.resolve(__dirname, '..'); - - return new Promise((c, e) => { - glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { - if (err) { - return e(err); - } - - // Add files to the test suite - files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); - - try { - // Run the mocha test - mocha.run(failures => { - if (failures > 0) { - e(new Error(`${failures} tests failed.`)); - } else { - c(); - } - }); - } catch (err) { - console.error(err); - e(err); - } - }); - }); -} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.clang-tidy b/lib/wasm-micro-runtime-WAMR-1.3.3/.clang-tidy similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.clang-tidy rename to lib/wasm-micro-runtime-WAMR-1.3.3/.clang-tidy diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.devcontainer/Dockerfile b/lib/wasm-micro-runtime-WAMR-1.3.3/.devcontainer/Dockerfile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.devcontainer/Dockerfile rename to lib/wasm-micro-runtime-WAMR-1.3.3/.devcontainer/Dockerfile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.devcontainer/devcontainer.json b/lib/wasm-micro-runtime-WAMR-1.3.3/.devcontainer/devcontainer.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.devcontainer/devcontainer.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/.devcontainer/devcontainer.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/scripts/extract_from_release_notes.py b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/scripts/extract_from_release_notes.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/scripts/extract_from_release_notes.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/scripts/extract_from_release_notes.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/scripts/fetch_and_compare_version.py b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/scripts/fetch_and_compare_version.py similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/scripts/fetch_and_compare_version.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/scripts/fetch_and_compare_version.py index ac206cadec3..ad9e53a0a5c 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/scripts/fetch_and_compare_version.py +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/scripts/fetch_and_compare_version.py @@ -42,9 +42,12 @@ def fetch_version_from_code(): def fetch_latest_git_tag(): - list_tag_cmd = ( - 'git tag --list WAMR-*.*.* --sort=committerdate --format="%(refname:short)"' - ) + """ + Get the most recent tag from the HEAD, + if it's main branch, it should be the latest release tag. + if it's release/x.x.x branch, it should be the latest release tag of the branch. + """ + list_tag_cmd = "git describe --tags --abbrev=0 HEAD" p = subprocess.run(shlex.split(list_tag_cmd), capture_output=True, check=True) all_tags = p.stdout.decode().strip() diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/scripts/reuse_latest_release_binaries.py b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/scripts/reuse_latest_release_binaries.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/scripts/reuse_latest_release_binaries.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/scripts/reuse_latest_release_binaries.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_docker_images.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_docker_images.yml similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_docker_images.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_docker_images.yml index 819bf94c311..d5bf682c4ea 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_docker_images.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_docker_images.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build and save Docker image(wasm-debug-server:${{ inputs.ver_num }}) to tar file run: | diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_iwasm_release.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_iwasm_release.yml similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_iwasm_release.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_iwasm_release.yml index 64aa9a92c17..86e50ede99a 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_iwasm_release.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_iwasm_release.yml @@ -35,11 +35,11 @@ jobs: build: runs-on: ${{ inputs.runner }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: get cached LLVM libraries id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_llvm_libraries.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_llvm_libraries.yml similarity index 78% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_llvm_libraries.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_llvm_libraries.yml index 7ef1dd63f86..67eaf614d1b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_llvm_libraries.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_llvm_libraries.yml @@ -11,6 +11,9 @@ on: arch: required: true type: string + container_image: + required: false + type: string outputs: cache_key: description: "A cached key of LLVM libraries" @@ -19,17 +22,27 @@ on: jobs: build_llvm_libraries: runs-on: ${{ inputs.os }} + # Using given container image if it is specified. + # Otherwise, it will be ignored by the runner. + container: + image: ${{ inputs.container_image }} outputs: key: ${{ steps.create_lib_cache_key.outputs.key}} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: install dependencies + - name: install dependencies for non macos-14 + if: inputs.os != 'macos-14' run: /usr/bin/env python3 -m pip install -r requirements.txt working-directory: build-scripts + - name: install dependencies for macos-14 + if: inputs.os == 'macos-14' + run: /usr/bin/env python3 -m pip install -r requirements.txt --break-system-packages + working-directory: build-scripts + - name: retrive the last commit ID id: get_last_commit run: echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py --llvm-ver)" >> $GITHUB_OUTPUT @@ -45,7 +58,7 @@ jobs: - name: Cache LLVM libraries id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -55,7 +68,7 @@ jobs: ./core/deps/llvm/build/share key: ${{ steps.create_lib_cache_key.outputs.key}} - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.ccache key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }} @@ -63,7 +76,7 @@ jobs: 0-ccache-${{ inputs.os }} if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-20.04' - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/.cache/ccache key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }} @@ -71,10 +84,11 @@ jobs: 0-ccache-${{ inputs.os }} if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'ubuntu-22.04' + # Don't install dependencies if the cache is hit or running in docker container - run: sudo apt install -y ccache ninja-build - if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'ubuntu') + if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'ubuntu') && inputs.container_image == '' - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ~/Library/Caches/ccache key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_lldb.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_lldb.yml similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_lldb.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_lldb.yml index 1a73750a642..03474c53e14 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_lldb.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_lldb.yml @@ -47,7 +47,7 @@ jobs: PYTHON_UBUNTU_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-unknown-linux-gnu-install_only.tar.gz PYTHON_MACOS_STANDALONE_BUILD: https://github.com/indygreg/python-build-standalone/releases/download/20230507/cpython-3.10.11+20230507-x86_64-apple-darwin-install_only.tar.gz steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: download and install wasi-sdk run: | @@ -60,7 +60,7 @@ jobs: - name: Cache build id: lldb_build_cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm-project/build/bin @@ -82,9 +82,7 @@ jobs: - name: install utils macos if: steps.lldb_build_cache.outputs.cache-hit != 'true' && contains(inputs.runner, 'macos') run: | - brew remove swig - brew install swig@4.1 cmake ninja libedit - brew link --overwrite swig@4.1 + brew install swig cmake ninja libedit sudo rm -rf /Library/Developer/CommandLineTools - name: install utils ubuntu diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_sdk.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_sdk.yml similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_sdk.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_sdk.yml index fff6d85df74..f4ca9afd481 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_sdk.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_sdk.yml @@ -35,7 +35,7 @@ jobs: build: runs-on: ${{ inputs.runner }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: download and install wasi-sdk run: | diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_vscode_ext.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_vscode_ext.yml similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_vscode_ext.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_vscode_ext.yml index 3dfb290cf77..b91f054cf60 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamr_vscode_ext.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamr_vscode_ext.yml @@ -18,7 +18,7 @@ jobs: build: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js 16.x uses: actions/setup-node@v3 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamrc.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamrc.yml similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamrc.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamrc.yml index 11c5de9bafe..7c4dab039f2 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/build_wamrc.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/build_wamrc.yml @@ -35,11 +35,11 @@ jobs: build: runs-on: ${{ inputs.runner }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: get cached LLVM libraries id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/coding_guidelines.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/coding_guidelines.yml similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/coding_guidelines.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/coding_guidelines.yml index 17d60ac43d7..b0aa0a2b865 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/coding_guidelines.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/coding_guidelines.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_android_ubuntu.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_android_ubuntu.yml similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_android_ubuntu.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_android_ubuntu.yml index 98d346f9ebb..55383014fe6 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_android_ubuntu.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_android_ubuntu.yml @@ -85,13 +85,13 @@ jobs: llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # since jobs.id can't contain the dot character # it is hard to use `format` to assemble the cache key - name: Get LLVM libraries id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -145,6 +145,7 @@ jobs: "-DWAMR_BUILD_SIMD=1", "-DWAMR_BUILD_TAIL_CALL=1", "-DWAMR_DISABLE_HW_BOUND_CHECK=1", + "-DWAMR_ENABLE_SHARED_MEMORY_MMAP=1", ] os: [ubuntu-22.04] platform: [android, linux] @@ -213,13 +214,13 @@ jobs: llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # only download llvm cache when needed - name: Get LLVM libraries id: retrieve_llvm_libs if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -284,12 +285,12 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get LLVM libraries id: retrieve_llvm_libs if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -322,7 +323,7 @@ jobs: run: | VERBOSE=1 cmake -S . -B build ${{ matrix.make_options }} - cmake --build build --config Release --parallel 4 + cmake --build build --config Debug --parallel 4 ctest --test-dir build --output-on-failure working-directory: samples/wasm-c-api @@ -350,7 +351,7 @@ jobs: llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2204.outputs.cache_key }} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: download and install wasi-sdk run: | @@ -367,7 +368,7 @@ jobs: sudo mv wabt-1.0.31 wabt - name: Get LLVM libraries id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -393,7 +394,7 @@ jobs: cd samples/file mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./src/iwasm -f wasm-app/file.wasm -d . - name: Build Sample [multi-thread] @@ -401,7 +402,7 @@ jobs: cd samples/multi-thread mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./iwasm wasm-apps/test.wasm - name: Build Sample [multi-module] @@ -409,7 +410,7 @@ jobs: cd samples/multi-module mkdir build && cd build cmake .. -DWAMR_BUILD_AOT=1 - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./multi_module mC.wasm ./multi_module mC.aot @@ -418,7 +419,7 @@ jobs: cd samples/spawn-thread mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./spawn_thread - name: Build Sample [ref-types] @@ -426,7 +427,7 @@ jobs: cd samples/ref-types mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./hello - name: Build Sample [simple] @@ -441,7 +442,7 @@ jobs: cd samples/wasi-threads mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./iwasm wasm-apps/no_pthread.wasm - name: Build Sample [shared-module] @@ -450,6 +451,12 @@ jobs: ./build.sh ./run.sh + - name: Build Sample [terminate] + run: | + cd samples/terminate + ./build.sh + ./run.sh + test: needs: [ @@ -513,7 +520,7 @@ jobs: test_option: $SIMD_TEST_OPTIONS steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: download and install wasi-sdk if: matrix.test_option == '$WASI_TEST_OPTIONS' @@ -548,7 +555,7 @@ jobs: - name: Get LLVM libraries if: env.USE_LLVM == 'true' id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -610,7 +617,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: install dependencies run: | @@ -619,6 +626,12 @@ jobs: npm install working-directory: test-tools/wamr-ide/VSCode-Extension + - name: code style check + run: | + npm install --save-dev prettier + npm run prettier-format-check + working-directory: test-tools/wamr-ide/VSCode-Extension + - name: build iwasm with source debugging feature run: | mkdir build @@ -629,7 +642,7 @@ jobs: - name: Cache LLDB id: cache-lldb - uses: actions/cache@v3 + uses: actions/cache@v4 env: cache-name: cache-lldb-vscode with: diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_macos.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_macos.yml similarity index 93% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_macos.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_macos.yml index 12f1d73cb91..f3ec53057c3 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_macos.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_macos.yml @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -name: compilation on macos-latest +name: compilation on macos on: # will be triggered on PR events @@ -58,7 +58,7 @@ jobs: build_llvm_libraries: uses: ./.github/workflows/build_llvm_libraries.yml with: - os: "macos-latest" + os: "macos-13" arch: "X86" build_wamrc: @@ -67,15 +67,15 @@ jobs: strategy: matrix: include: - - os: macos-latest + - os: macos-13 llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get LLVM libraries id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -128,7 +128,7 @@ jobs: "-DWAMR_BUILD_TAIL_CALL=1", "-DWAMR_DISABLE_HW_BOUND_CHECK=1", ] - os: [macos-latest] + os: [macos-13] platform: [darwin] exclude: # uncompatiable feature and platform @@ -170,17 +170,17 @@ jobs: - make_options_run_mode: $LLVM_EAGER_JIT_BUILD_OPTIONS make_options_feature: "-DWAMR_BUILD_MINI_LOADER=1" include: - - os: macos-latest + - os: macos-13 llvm_cache_key: ${{ needs.build_llvm_libraries.outputs.cache_key }} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # only download llvm cache when needed - name: Get LLVM libraries id: retrieve_llvm_libs if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -215,7 +215,7 @@ jobs: #$LLVM_EAGER_JIT_BUILD_OPTIONS, #$AOT_BUILD_OPTIONS, ] - os: [macos-latest] + os: [macos-13] wasi_sdk_release: [ "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz", @@ -226,7 +226,7 @@ jobs: ] steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: download and install wabt run: | @@ -247,7 +247,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest] + os: [macos-13] wasi_sdk_release: [ "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz", @@ -258,7 +258,7 @@ jobs: ] steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: download and install wasi-sdk run: | @@ -285,7 +285,7 @@ jobs: cd samples/file mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./src/iwasm -f wasm-app/file.wasm -d . - name: Build Sample [multi-thread] @@ -293,7 +293,7 @@ jobs: cd samples/multi-thread mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./iwasm wasm-apps/test.wasm - name: Build Sample [multi-module] @@ -301,7 +301,7 @@ jobs: cd samples/multi-module mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./multi_module mC.wasm - name: Build Sample [spawn-thread] @@ -309,7 +309,7 @@ jobs: cd samples/spawn-thread mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./spawn_thread - name: Build Sample [ref-types] @@ -317,7 +317,7 @@ jobs: cd samples/ref-types mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./hello - name: Build Sample [wasi-threads] @@ -325,7 +325,7 @@ jobs: cd samples/wasi-threads mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 ./iwasm wasm-apps/no_pthread.wasm - name: Build Sample [shared-module] @@ -333,3 +333,9 @@ jobs: cd samples/shared-module ./build.sh ./run.sh + + - name: Build Sample [terminate] + run: | + cd samples/terminate + ./build.sh + ./run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_nuttx.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_nuttx.yml similarity index 73% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_nuttx.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_nuttx.yml index 77b3da75a10..2eff73c2c33 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_nuttx.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_nuttx.yml @@ -50,7 +50,10 @@ env: jobs: build_iwasm_on_nuttx: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest + container: + image: ghcr.io/apache/nuttx/apache-nuttx-ci-linux@sha256:d9261eacf6c6ebe656c571757751c803e8f04c3ae9b820320a5ea5dd57b7205a + strategy: matrix: nuttx_board_config: [ @@ -60,12 +63,14 @@ jobs: "boards/arm/rp2040/raspberrypi-pico/configs/nsh", # cortex-m7 "boards/arm/stm32h7/nucleo-h743zi/configs/nsh", - # riscv32imac + # riscv32imc + "boards/risc-v/espressif/esp32c3-generic/configs/nsh", + # riscv32gc "boards/risc-v/qemu-rv/rv-virt/configs/nsh", - # riscv64imac - "boards/risc-v/qemu-rv/rv-virt/configs/nsh64", # riscv64gc - "boards/risc-v/k210/maix-bit/configs/nsh", + "boards/risc-v/qemu-rv/rv-virt/configs/nsh64", + # arm64 + "boards/arm64/qemu/qemu-armv8a/configs/nsh", ] wamr_config_option: [ "CONFIG_INTERPRETERS_WAMR=y\\nCONFIG_INTERPRETERS_WAMR_AOT=y\\nCONFIG_INTERPRETERS_WAMR_FAST=y\\n", @@ -81,52 +86,29 @@ jobs: ] steps: - - name: Install Utilities - run: | - sudo apt install -y kconfig-frontends-nox genromfs - pip3 install pyelftools - pip3 install cxxfilt - - - name: Install ARM Compilers - if: contains(matrix.nuttx_board_config, 'arm') - run: sudo apt install -y gcc-arm-none-eabi - - - name: Install RISC-V Compilers - if: contains(matrix.nuttx_board_config, 'risc-v') - run: | - curl -L https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v12.3.0-1/xpack-riscv-none-elf-gcc-12.3.0-1-linux-x64.tar.gz > riscv.tar.gz - tar xvf riscv.tar.gz - echo "$PWD/xpack-riscv-none-elf-gcc-12.3.0-1/bin" >> $GITHUB_PATH - - - name: Install WASI-SDK - run: | - curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz > wasi-sdk.tar.gz - tar xvf wasi-sdk.tar.gz - sudo mv wasi-sdk-* /opt/wasi-sdk - - name: Checkout NuttX - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: apache/incubator-nuttx - ref: releases/12.3 + ref: releases/12.4 path: nuttx - name: Checkout NuttX Apps - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: apache/incubator-nuttx-apps - ref: releases/12.3 + ref: releases/12.4 path: apps - name: Checkout WAMR - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ${{ github.repository }} path: apps/interpreters/wamr/wamr - name: Enable WAMR for NuttX run: | - find nuttx/boards -name defconfig | xargs sed -i '$a\CONFIG_EOL_IS_LF=y\nCONFIG_PSEUDOFS_SOFTLINKS=y\n${{ matrix.wamr_config_option }}' + find nuttx/boards -name defconfig | xargs sed -i '$a\CONFIG_EOL_IS_LF=y\n${{ matrix.wamr_config_option }}' find nuttx/boards/sim -name defconfig | xargs sed -i '$a\CONFIG_LIBM=y\n' - name: Build diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_sgx.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_sgx.yml similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_sgx.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_sgx.yml index 0d19d83ad94..8dadb518df5 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_sgx.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_sgx.yml @@ -119,7 +119,7 @@ jobs: source /opt/intel/sgxsdk/environment - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build iwasm run: | @@ -165,7 +165,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: download and install wasi-sdk run: | @@ -221,7 +221,7 @@ jobs: - name: Get LLVM libraries if: matrix.iwasm_make_options_run_mode == '$AOT_BUILD_OPTIONS' id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -246,7 +246,7 @@ jobs: cd samples/file mkdir build && cd build cmake .. - cmake --build . --config Release --parallel 4 + cmake --build . --config Debug --parallel 4 cp wasm-app/file.wasm `pwd`/../../../product-mini/platforms/${{ matrix.platform }}/enclave-sample - name: Test Sample [file] in non-aot mode @@ -290,12 +290,12 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get LLVM libraries if: matrix.running_mode == 'aot' id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_windows.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_windows.yml similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_windows.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_windows.yml index 97a4aaae20e..a623ab1a774 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/compilation_on_windows.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/compilation_on_windows.yml @@ -74,7 +74,7 @@ jobs: "-DWAMR_BUILD_LIBC_UVWASI=0 -DWAMR_BUILD_LIBC_WASI=1" ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: clone uvwasi library if: ${{ !contains(matrix.build_options, '-DWAMR_BUILD_LIBC_UVWASI=0') }} @@ -108,7 +108,7 @@ jobs: ] steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: download and install wasi-sdk if: matrix.test_option == '$WASI_TEST_OPTIONS' diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/create_tag.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/create_tag.yml similarity index 78% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/create_tag.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/create_tag.yml index 3a145bf041e..5480592a933 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/create_tag.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/create_tag.yml @@ -24,7 +24,7 @@ jobs: new_tag: ${{ steps.preparation.outputs.new_tag }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Full git history is needed to get a proper list of commits and tags with: fetch-depth: 0 @@ -32,8 +32,22 @@ jobs: - name: prepare id: preparation run: | - # show latest 3 versions - git tag --list WAMR-*.*.* --sort=committerdate --format="%(refname:short)" | tail -n 3 + # show latest 3 versions on the branch that create release + # Set the initial commit to the head of the branch + commit="HEAD" + # + # Loop to get the three most recent tags + for i in {1..3} + do + # Get the most recent tag reachable from the current commit + tag=$(git describe --tags --abbrev=0 $commit) + + # Print the tag + echo "$tag" + + # Move to the commit before the found tag to find the next tag in the next iteration + commit=$(git rev-list -n 1 $tag^) + done # compare latest git tag and semantic version definition result=$(python3 ./.github/scripts/fetch_and_compare_version.py) echo "script result is ${result}" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/hadolint_dockerfiles.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/hadolint_dockerfiles.yml similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/hadolint_dockerfiles.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/hadolint_dockerfiles.yml index bdabeb6e5d4..c540649c895 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/hadolint_dockerfiles.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/hadolint_dockerfiles.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # on default, hadolint will fail on warnings and errors - name: Run hadolint on dockerfiles diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/nightly_run.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/nightly_run.yml similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/nightly_run.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/nightly_run.yml index 8153cea99f4..21b1be901c9 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/nightly_run.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/nightly_run.yml @@ -68,13 +68,13 @@ jobs: llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # since jobs.id can't contain the dot character # it is hard to use `format` to assemble the cache key - name: Get LLVM libraries id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -199,13 +199,13 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # only download llvm cache when needed - name: Get LLVM libraries id: retrieve_llvm_libs if: endsWith(matrix.make_options_run_mode, '_JIT_BUILD_OPTIONS') - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -347,12 +347,12 @@ jobs: sanitizer: asan steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get LLVM libraries id: retrieve_llvm_libs if: (!endsWith(matrix.make_options, '_INTERP_BUILD_OPTIONS')) - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -383,7 +383,9 @@ jobs: - name: Build Sample [wasm-c-api] run: | VERBOSE=1 - cmake -S . -B build ${{ matrix.make_options }} -D WAMR_BUILD_SANITIZER="${{matrix.sanitizer}}" + cmake -S . -B build ${{ matrix.make_options }} \ + -D WAMR_BUILD_SANITIZER="${{matrix.sanitizer}}" \ + -D WAMR_BUILD_QUICK_AOT_ENTRY=0 cmake --build build --config Release --parallel 4 ctest --test-dir build --output-on-failure working-directory: samples/wasm-c-api @@ -412,7 +414,7 @@ jobs: llvm_cache_key: ${{ needs.build_llvm_libraries_on_ubuntu_2004.outputs.cache_key }} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: download and install wasi-sdk run: | @@ -429,7 +431,7 @@ jobs: - name: Get LLVM libraries id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -507,6 +509,12 @@ jobs: cd samples/shared-module ./build.sh ./run.sh + + - name: Build Sample [terminate] + run: | + cd samples/terminate + ./build.sh + ./run.sh test: needs: [ @@ -593,7 +601,7 @@ jobs: test_option: $SIMD_TEST_OPTIONS steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: download and install wasi-sdk if: matrix.test_option == '$WASI_TEST_OPTIONS' @@ -624,14 +632,16 @@ jobs: run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV - name: set additional tsan options - run: echo "TSAN_OPTIONS=suppressions=$PWD/tsan_suppressions.txt" >> $GITHUB_ENV + run: | + echo "TSAN_OPTIONS=suppressions=$PWD/tsan_suppressions.txt" >> $GITHUB_ENV + sudo sysctl vm.mmap_rnd_bits=28 working-directory: tests/wamr-test-suites #only download llvm libraries in jit and aot mode - name: Get LLVM libraries if: env.USE_LLVM == 'true' id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -666,7 +676,7 @@ jobs: - name: run tests timeout-minutes: 40 - run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} -T %{{matrix.sanitizer}} + run: ./test_wamr.sh ${{ matrix.test_option }} -t ${{ matrix.running_mode }} -T "${{ matrix.sanitizer }}" working-directory: ./tests/wamr-test-suites #only install x32 support libraries when to run x86_32 cases diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/release_process.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/release_process.yml similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/release_process.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/release_process.yml index ef722acdb1f..cab3f1677f0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/release_process.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/release_process.yml @@ -28,7 +28,7 @@ jobs: outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: prepare the release note run: | @@ -69,7 +69,7 @@ jobs: needs: [create_tag, create_release] uses: ./.github/workflows/build_llvm_libraries.yml with: - os: "macos-latest" + os: "macos-13" arch: "AArch64 ARM Mips RISCV X86" # @@ -100,7 +100,7 @@ jobs: with: llvm_cache_key: ${{ needs.build_llvm_libraries_on_macos.outputs.cache_key }} release: true - runner: macos-latest + runner: macos-13 upload_url: ${{ needs.create_release.outputs.upload_url }} ver_num: ${{ needs.create_tag.outputs.new_ver }} @@ -132,7 +132,7 @@ jobs: with: cwd: product-mini/platforms/darwin llvm_cache_key: ${{ needs.build_llvm_libraries_on_macos.outputs.cache_key }} - runner: macos-latest + runner: macos-13 upload_url: ${{ needs.create_release.outputs.upload_url }} ver_num: ${{ needs.create_tag.outputs.new_ver}} @@ -163,7 +163,7 @@ jobs: uses: ./.github/workflows/build_wamr_sdk.yml with: config_file: wamr_config_macos_release.cmake - runner: macos-latest + runner: macos-13 upload_url: ${{ needs.create_release.outputs.upload_url }} ver_num: ${{ needs.create_tag.outputs.new_ver}} wasi_sdk_url: https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-macos.tar.gz @@ -209,7 +209,7 @@ jobs: needs: [create_tag, create_release] uses: ./.github/workflows/build_wamr_lldb.yml with: - runner: macos-latest + runner: macos-13 arch: universal upload_url: ${{ needs.create_release.outputs.upload_url }} ver_num: ${{ needs.create_tag.outputs.new_ver}} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/reuse_latest_release_binaries.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/reuse_latest_release_binaries.yml similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/reuse_latest_release_binaries.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/reuse_latest_release_binaries.yml index 7f82672a69a..c9832cec958 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/reuse_latest_release_binaries.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/reuse_latest_release_binaries.yml @@ -28,7 +28,7 @@ jobs: outputs: result: ${{ steps.try_reuse.outputs.result }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Full git history is needed to get a proper list of commits and tags with: fetch-depth: 0 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/spec_test_on_nuttx.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/spec_test_on_nuttx.yml similarity index 69% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/spec_test_on_nuttx.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/spec_test_on_nuttx.yml index 48fff2d23c0..5bdad8f232a 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/.github/workflows/spec_test_on_nuttx.yml +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/.github/workflows/spec_test_on_nuttx.yml @@ -6,9 +6,10 @@ name: spec test on nuttx on: pull_request: types: - - closed - branches: - - main + - opened + - synchronize + paths: + - ".github/workflows/spec_test_on_nuttx.yml" schedule: - cron: '0 0 * * *' @@ -27,10 +28,13 @@ jobs: with: os: "ubuntu-22.04" arch: "ARM RISCV AArch64" + container_image: ghcr.io/apache/nuttx/apache-nuttx-ci-linux@sha256:d9261eacf6c6ebe656c571757751c803e8f04c3ae9b820320a5ea5dd57b7205a spec_test_on_qemu: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest needs: [build_llvm_libraries] + container: + image: ghcr.io/apache/nuttx/apache-nuttx-ci-linux@sha256:d9261eacf6c6ebe656c571757751c803e8f04c3ae9b820320a5ea5dd57b7205a strategy: matrix: target_config: [ @@ -91,48 +95,22 @@ jobs: wamr_test_option: { mode: "-t aot -X" } steps: - - name: Install Utilities - run: | - sudo apt install -y kconfig-frontends-nox genromfs - - - name: Install ARM Compilers - if: startsWith(matrix.target_config.config, 'boards/arm') - run: | - sudo apt install -y gcc-arm-none-eabi - wget --quiet https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz - xz -d gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz - tar xf gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar - echo "$PWD/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin" >> $GITHUB_PATH - - - name: Install RISC-V Compilers - if: startsWith(matrix.target_config.config, 'boards/risc-v') - run: | - curl -L https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v12.3.0-1/xpack-riscv-none-elf-gcc-12.3.0-1-linux-x64.tar.gz > riscv.tar.gz - tar xvf riscv.tar.gz - echo "$PWD/xpack-riscv-none-elf-gcc-12.3.0-1/bin" >> $GITHUB_PATH - - - name: Install WASI-SDK - run: | - curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz > wasi-sdk.tar.gz - tar xvf wasi-sdk.tar.gz - sudo mv wasi-sdk-* /opt/wasi-sdk - - name: Checkout NuttX - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: apache/incubator-nuttx - ref: releases/12.3 + ref: releases/12.4 path: nuttx - name: Checkout NuttX Apps - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: apache/incubator-nuttx-apps - ref: releases/12.3 + ref: releases/12.4 path: apps - name: Checkout WAMR - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ${{ github.repository }} path: apps/interpreters/wamr/wamr @@ -140,7 +118,7 @@ jobs: - name: Get LLVM libraries if: contains(matrix.wamr_test_option.mode, 'aot') id: retrieve_llvm_libs - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ./core/deps/llvm/build/bin @@ -190,20 +168,6 @@ jobs: tools/configure.sh ${{ matrix.target_config.config }} make -j$(nproc) echo "firmware=$PWD/nuttx" >> $GITHUB_OUTPUT - - - name: Install QEMU for ARM - if: startsWith(matrix.target_config.config, 'boards/arm') - run: | - curl -L https://github.com/xpack-dev-tools/qemu-arm-xpack/releases/download/v7.1.0-1/xpack-qemu-arm-7.1.0-1-linux-x64.tar.gz > xpack-qemu-arm.tar.gz - tar xvf xpack-qemu-arm.tar.gz - echo $PWD/xpack-qemu-arm-7.1.0-1/bin >> $GITHUB_PATH - - - name: Install QEMU for RISC-V - if: startsWith(matrix.target_config.config, 'boards/risc-v') - run: | - curl -L https://github.com/xpack-dev-tools/qemu-riscv-xpack/releases/download/v7.1.0-1/xpack-qemu-riscv-7.1.0-1-linux-x64.tar.gz > xpack-qemu-riscv.tar.gz - tar xvf xpack-qemu-riscv.tar.gz - echo PATH=$PATH:$PWD/xpack-qemu-riscv-7.1.0-1/bin >> $GITHUB_PATH - name: Test run: | diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/ATTRIBUTIONS.md b/lib/wasm-micro-runtime-WAMR-1.3.3/ATTRIBUTIONS.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/ATTRIBUTIONS.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/ATTRIBUTIONS.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/CMakeLists.txt similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/CMakeLists.txt index 1c87994945a..0ffba05a41a 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/CMakeLists.txt @@ -3,6 +3,11 @@ cmake_minimum_required (VERSION 3.0) +if(ESP_PLATFORM) + include (${COMPONENT_DIR}/build-scripts/esp-idf/wamr/CMakeLists.txt) + return() +endif() + project (iwasm) set (CMAKE_VERBOSE_MAKEFILE OFF) @@ -151,7 +156,7 @@ if (WAMR_BUILD_WASM_CACHE EQUAL 1) endif () if (MINGW) - target_link_libraries (iwasm_shared -lWs2_32) + target_link_libraries (iwasm_shared INTERFACE -lWs2_32 -lwsock32) endif () install (TARGETS iwasm_shared LIBRARY DESTINATION lib) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/CODE_OF_CONDUCT.md b/lib/wasm-micro-runtime-WAMR-1.3.3/CODE_OF_CONDUCT.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/CODE_OF_CONDUCT.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/CODE_OF_CONDUCT.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/CONTRIBUTING.md b/lib/wasm-micro-runtime-WAMR-1.3.3/CONTRIBUTING.md similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/CONTRIBUTING.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/CONTRIBUTING.md index 9210b3deb1c..0e04101d293 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/CONTRIBUTING.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/CONTRIBUTING.md @@ -27,7 +27,7 @@ We Use Github Flow, So All Code Changes Happen Through Pull Requests. Pull reque Coding Style =============================== Please use [K&R](https://en.wikipedia.org/wiki/Indentation_style#K.26R) coding style, such as 4 spaces for indentation rather than tabs etc. -We suggest use Eclipse like IDE or stable coding format tools to make your code compliant to K&R format. +We suggest using VS Code like IDE or stable coding format tools, like clang-format, to make your code compliant to the customized format(in .clang-format). Report bugs =================== diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/ORG_CODE_OF_CONDUCT.md b/lib/wasm-micro-runtime-WAMR-1.3.3/ORG_CODE_OF_CONDUCT.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/ORG_CODE_OF_CONDUCT.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/ORG_CODE_OF_CONDUCT.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/README.md similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/README.md index dfdae2da894..31156b9cc39 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/README.md @@ -75,9 +75,9 @@ The following platforms are supported, click each link below for how to build iw - [Blog: The WAMR memory model](https://bytecodealliance.github.io/wamr.dev/blog/the-wamr-memory-model/) - [Blog: Understand WAMR heaps](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-heaps/) and [stacks](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-stacks/) - [Blog: Introduction to WAMR running modes](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/) -- [Memory usage tunning](./doc/memory_tune.md): the memory model and how to tune the memory usage +- [Memory usage tuning](./doc/memory_tune.md): the memory model and how to tune the memory usage - [Memory usage profiling](./doc/build_wamr.md#enable-memory-profiling-experiment): how to profile the memory usage -- [Performance tunning](./doc/perf_tune.md): how to tune the performance +- [Performance tuning](./doc/perf_tune.md): how to tune the performance - [Benchmarks](./tests/benchmarks): checkout these links for how to run the benchmarks: [PolyBench](./tests/benchmarks/polybench), [CoreMark](./tests/benchmarks/coremark), [Sightglass](./tests/benchmarks/sightglass), [JetStream2](./tests/benchmarks/jetstream) - [Performance and footprint data](https://github.com/bytecodealliance/wasm-micro-runtime/wiki/Performance): the performance and footprint data diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/RELEASE_NOTES.md b/lib/wasm-micro-runtime-WAMR-1.3.3/RELEASE_NOTES.md similarity index 75% rename from lib/wasm-micro-runtime-WAMR-1.3.0/RELEASE_NOTES.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/RELEASE_NOTES.md index fbb97f5d756..6cc01936862 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/RELEASE_NOTES.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/RELEASE_NOTES.md @@ -1,3 +1,218 @@ +## WAMR-1.3.3 + +### Breaking Changes + +### New Features + +### Bug Fixes +- Cumulative fixes for release/1.3.x (#3155) + Apply patches in branch main for branch `release/1.3.x`: + - Fix loader check_wasi_abi_compatibility (#3126) + - Zero the memory mapped from os_mmap in NuttX (#3132) + - Fix possible integer overflow in loader target block check (#3133) + - Fix locel.set in polymorphic stack (#3135) + - Fix threads opcodes' boundary check in classic-interp and fast-interp (#3136) + - aot_compile_op_call: Stop setting calling convention explicitly (#3140) + - aot compiler: Place precheck wrapper before the corresponding wrapped function (#3141) + - fast-interp: Fix copy_stack_top_i64 overlap issue (#3146) + - fast-interp: Fix frame_offset overflow issue (#3149) + - Fix null pointer access in fast-interp when configurable soft bound check is enabled (#3150) +- Cumulative fixes for release/1.3.x (#3268) + Apply patches which were fixed branch main to branch `release/1.3.x`: + - zephyr: Use zephyr sys_cache instead of CMSIS (#3162) + - Fix llvm jit push funcref/externref result type issue (#3169) + - Fix inconsistent coding convention (#3171) + - VSCode IDE enhancement and readme update (#3172) + - zephyr: include math only with minimal libc (#3177) + - Fix wasm loader handling opcode br_table (#3176) + - Specify language in the wasi socket ext project (#3183) + - lldb_function_to_function_dbi: Fix a null dereference (#3189) + - Fix LLVM assertion failure and update CONTRIBUTING.md (#3197) + - lldb_function_to_function_dbi: A hack to avoid crashing on C++ methods (#3190) + - Fix compilation errors on MinGW (#3217) + - Fix compilation errors on esp-idf platform (#3224) + - Fix aot relocation symbols not found on windows 32-bit (#3231) + - Fix nightly run tsan ASLR issue (#3233) + - Go binding: Change C.long to C.int64_t when call wasm_runtime_set_wasi_args_ex (#3235) + - posix_file.c: Correct the dirfd argument that passes to fstatat (#3244) + - Fix compilation errors on zephyr platform (#3255) + - Fix dynamic offset not updated in op_br for block with ret type (#3269) + - Fix CI error when install packages for macos-14 (#3270) +- Fix ESP-IDF platform mmap data size error (#3288) +- Fix ESP32-S3 compiling error (#3360) +- release/1.3.x: Cumulative fixes for release/1.3.x (#3342) + Apply patches which were fixed in branch main to branch `release/1.3.x`: + - aot debug: Fix a few NULL dereferences on errors (#3273) + - aot debug: Fix a NULL dereference (#3274) + - aot debug: Process lldb_function_to_function_dbi only for C (#3278) + - Revert "lldb_function_to_function_dbi: A hack to avoid crashing on C++ methods (#3190)" (#3281) + - Fix warnings/issues reported in Windows and by CodeQL/Coverity (#3275) + - thread mgr: Free aux stack only when it was allocated (#3282) + - interp: Restore context from prev_frame after tail calling a native function (#3283) + - Sync simd opcode definitions spec (#3290) + - Add more checks in wasm loader (#3300) + - Fix posix_fadvise error handling (#3323) + - Fix readdir for posix (#3339) + - wasm loader: Fix checks for opcode ref.func and opcode else (#3340) + - Enhance wasm loader checks for opcode br_table (#3352) + - CI: Use macos-13 instead of macos-latest (#3366) + +### Enhancements +- Add wamr to esp-idf components registry (#3264) +- Update esp-idf platform support in release/v1.3.x (#3296) +- Add WASI support for esp-idf platform in release/1.3.x (#3334) + +### Others +- Update release CI (#3294) + +--- + +## WAMR-1.3.2 + +### Breaking Changes + +### New Features +- Implement Exception Handling for classic interpreter (#3096) + - Use `cmake -DWAMR_BUILD_EXCE_HANDLING=1/0` option to enable/disable + the feature, and by default it is disabled + - It is still in highly experimental stage + +### Bug Fixes +- Fix build errors when initializing wasm_val_t values with macros (#3007) +- fix(wasm-c-api): Do not clone stack frames if there's no trap (#3008) +- classic-interp: Handle SIMD opcode when JIT is enabled (#3046) +- fast-interp: Fix dynamic offset error issue in else branch (#3058) +- wasm_cluster_destroy_spawned_exec_env: Avoid "invalid exec env" trap (#3068) +- thread-mgr: Fix locking problems around aux stack allocation (#3073) +- cosmopolitan: Update compiler and update platform_internal.h (#3079) +- wasi: Apply wasm_runtime_begin_blocking_op to poll as well (#3080) +- Fix memory/table segment checks in memory.init/table.init (#3081) +- perf profiling: Adjust the calculation of execution time (#3089) +- aot: Fix LLVMSetTailCallKind check (#3099) +- fast-interp: Fix stack recovery for else branch (#3100) +- fast-interp: Fix frame_offset pop order (#3101) +- Fix AOT compilation on MacOS (#3102) +- fast-interp: Fix block with parameter in polymorphic stack issue (#3112) +- Fix read and validation of misc/simd/atomic sub opcodes (#3115) + +### Enhancements +- Clear compilation warning and dead code (#3002) +- aot debug: Try to use a bit more appropriate file names (#3000) +- Increase default app thread stack size (#3010) +- Rename rwlock_init to avoid conflict (#3016) +- nuttx: Use larger alignment for os_mmap and comment why (#3017) +- Allow using mmap for shared memory if hw bound check is disabled (#3029) +- Don't redefine D_INO if already defined (#3036) +- Enhancements on wasm function execution time statistic (#2985) +- wamr-compiler: Fix non-x86{_64} host builds (#3037) +- Disable quick aot entry for interp and fast-jit (#3039) +- nuttx: Add option to enable quick aot entry (#3040) +- Set CONFIG_HAS_CAP_ENTER to support posix file api for freertos (#3041) +- Revert "Enable MAP_32BIT for macOS (#2992)" (#3032) +- Enable quick aot entry when hw bound check is disabled (#3044) +- Do not inherit WASM_SUSPEND_FLAG_BLOCKING from the parent thread (#3051) +- wasm_runtime_begin_blocking_op: A comment about usage expectation (#3056) +- Check arguments before calling bh_hash_map_find (#3055) +- Fix aot large model (--size-level=0) with LLVM 18 (#3057) +- Add flag to control Winsocket initialization (#3060) +- nuttx: If STACK_GUARD_SIZE is not set, leave it to config.h (#2927) +- Enhance setting write gs base with cmake variable (#3066) +- aot_reloc_x86_64.c: Suggest to try --size-level=0 as well (#3067) +- Fix some issues reported by CodeQL (#3064) +- Remove a lot of "unused parameter" warnings (#3075) +- Forward log and log level to custom bh_log callback (#3070) +- Fix inconsistent code style in aot_loader.c (#3082) +- freertos: Thread exit more common (#3094) +- Fix windows build error and compilation warnings (#3095) + +### Others +- Fix nightly-run CI failure (#3014) +- Build samples in debug mode (#3019) +- Remove deprecated tests in language-bindings python (#3018) +- Avoid unused thread_id warning and recompile multi-module sample (#3033) +- samples/terminate: Add a sample to demonstrate wasm_runtime_terminate (#3043) +- Bump NuttX version to 12.4.x in CI (#3047) +- perf_tune.md: Add refine the calling processes between host and wasm (#3065) +- build_wamr.md: Update the document (#3074) +- Fix download link for wasi-sdk (#3077) +- README.md: Fix typo tunning to tuning (#3078) +- Update outdated reference link in multi_module.md (#3092) +- Add comments to suppress warning from clang-tidy (#3088) +- CI: Update version of checkout to suppress warnings (#3093) +- test_wamr.sh: Allow using test script on different platforms (#3098) + +--- + +## WAMR-1.3.1 + +### Breaking Changes +- In multi-threading, when an exception was thrown in wasm_func_call(), + the trap returned contains the stack frames of the thread where the + exception occurs, but not the stack frames of the main thread. +- Disable emitting custom name section to AOT file with + `wamrc --enable-dump-call-stack` option, instead, use + `wamrc --emit-custom-sections=name` to emit it and make it clear. + +### New Features +- Enable AOT linux perf support (#2930) + +### Bug Fixes +- Corrects Zephyr include files for current versions of Zephyr (#2881) +- Fix possible dead lock in wasm_cluster_spawn_exec_env (#2882) +- Handle ambiguous fstflags on fd_filestat_set_times (#2892) +- Fix memory size not updating after growing in interpreter (#2898) +- fixed(freertos): Fix crash when wasm app call pthread_exit(NULL) (#2970) +- fast-jit: Fix const shift and const i64 compare issues (#2969) +- Fix ref.is_null processing in fast-interp loader (#2971) +- simd-128: The input lanes of integer-to-integer narrowing ops should be interpreted as signed (#2850) +- Fix ref.func function declared check in wasm loader (#2972) +- Fix fast-interp polymorphic stack processing (#2974) +- Fix potential recursive lock in pthread_create_wrapper (#2980) +- Fix build failure on esp-idf platform (#2991) +- Return stack frames of crashed thread when using wasm-c-api (#2908) +- Fix compilation error on iOS due to macOS-specific API (#2995) +- Fix a bug when emit the custom name section to aot file (#2987) +- Fix linux-sgx build error when libc-wasi is disabled (#2997) + +### Enhancements +- fix command-reactor: Look for _initialize only if _start not found (#2891) +- Refactor reloc symbols for riscv (#2894) +- Avoid memory import failure when wasi-threads is enabled (#2893) +- interpreter: Simplify memory.grow a bit (#2899) +- Avoid reporting timestamp if custom logger is used (#2905) +- Expose API to set log level in embedder (#2907) +- Add a script to translate jitted function names in flamegraph (#2906) +- Refine wasm-c-api wasm_func_call (#2922) +- Add VectorCombine pass for JIT and AOT (#2923) +- Enable wasm_runtime_terminate for single-threading (#2924) +- nuttx: Add CONFIG_INTERPRETERS_WAMR_DEBUG_AOT (#2929) +- Allow to control built-in libraries for wamrc from command line options (#2928) +- Fix a bug that appends '_precheck' to aot_func (#2936) +- freertos: Add os_cond_broadcast for pthread wrapper (#2937) +- Append .aot to .wasm as a custom section named "aot" (#2933) +- fix(sgx-ra): Fix building when enclave is built without librats ahead (#2968) +- Refine LLVM JIT function call process (#2925) +- Refine AOT function call process (#2940) +- Allow to set segue flags for wasm-c-api JIT (#2926) +- freertos: Minor changes for freertos libc_wasi build adaption (#2973) +- freertos: Change ssp_config.h due to clock_nanosleep() not supported in freertos (#2979) +- aot compiler: Some updates for LLVM 18 (#2981) +- Enable MAP_32BIT for macOS (#2992) +- Register quick call entries to speedup the aot/jit func call process (#2978) +- Refine AOT/JIT code call wasm-c-api import process (#2982) + +### Others +- compilation_on_nuttx.yml: Use docker image to simplify env setup (#2878) +- samples/spawn-thread: Disable libc and pthread (#2883) +- Add arm64 to nuttx compilation test (#2886) +- samples/spawn-thread: Tweak to expose a bug (#2888) +- Fix typo in CI config and suppress STORE_U8 in TSAN (#2802) +- Using docker image for nuttx spectest (#2887) +- doc: Separate source_debugging.md into two files (#2932) +- doc/build_wasm_app.md: Add a note about aot abi compatibility (#2993) + +--- + ## WAMR-1.3.0 ### Breaking Changes diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/SECURITY.md b/lib/wasm-micro-runtime-WAMR-1.3.3/SECURITY.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/SECURITY.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/SECURITY.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/TSC_Charter.md b/lib/wasm-micro-runtime-WAMR-1.3.3/TSC_Charter.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/TSC_Charter.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/TSC_Charter.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/package-lock.json b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/package-lock.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/package-lock.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/package-lock.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/package.json b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/package.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/package.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/package.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/event_publisher.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/event_publisher.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/event_publisher.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/event_publisher.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/event_subscriber.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/event_subscriber.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/event_subscriber.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/event_subscriber.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/request_handler.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/request_handler.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/request_handler.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/request_handler.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/request_sender.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/request_sender.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/request_sender.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/request_sender.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/timer.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/timer.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/timer.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/timer.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/tsconfig.json b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/tsconfig.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/samples/tsconfig.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/samples/tsconfig.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/wamr_app_lib/console.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/wamr_app_lib/console.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/wamr_app_lib/console.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/wamr_app_lib/console.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/wamr_app_lib/request.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/wamr_app_lib/request.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/wamr_app_lib/request.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/wamr_app_lib/request.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/wamr_app_lib/timer.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/wamr_app_lib/timer.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/wamr_app_lib/timer.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/wamr_app_lib/timer.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/wamr_app_lib/tsconfig.json b/lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/wamr_app_lib/tsconfig.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/assembly-script/wamr_app_lib/tsconfig.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/assembly-script/wamr_app_lib/tsconfig.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/SConscript_config b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/SConscript_config similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/SConscript_config rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/SConscript_config diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/build_llvm.py b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/build_llvm.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/build_llvm.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/build_llvm.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/config_common.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/config_common.cmake similarity index 84% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/config_common.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/config_common.cmake index e73ebc85f1f..22783a50921 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/config_common.cmake +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/config_common.cmake @@ -147,13 +147,20 @@ elseif (WAMR_BUILD_SANITIZER STREQUAL "asan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=address -fno-sanitize-recover=all" ) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") endif() -elseif (WAMR_BUILD_SANITIZER STREQUAL "tsan") +elseif (WAMR_BUILD_SANITIZER STREQUAL "tsan") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" ) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread") elseif (NOT (WAMR_BUILD_SANITIZER STREQUAL "") ) message(SEND_ERROR "Unsupported sanitizer: ${WAMR_BUILD_SANITIZER}") endif() +if (WAMR_BUILD_LINUX_PERF EQUAL 1) + if (NOT WAMR_BUILD_JIT AND NOT WAMR_BUILD_AOT) + message(WARNING "only support perf in aot and llvm-jit") + set(WAMR_BUILD_LINUX_PERF 0) + endif () +endif () + ######################################## message ("-- Build Configurations:") @@ -241,6 +248,12 @@ if (WAMR_BUILD_SHARED_MEMORY EQUAL 1) else () add_definitions (-DWASM_ENABLE_SHARED_MEMORY=0) endif () +if (WAMR_ENABLE_SHARED_MEMORY_MMAP EQUAL 1) + add_definitions (-DWASM_ENABLE_SHARED_MEMORY_MMAP=1) + message (" Shared memory allocated using mmap enabled") +else () + add_definitions (-DWASM_ENABLE_SHARED_MEMORY_MMAP=0) +endif () if (WAMR_BUILD_THREAD_MGR EQUAL 1) message (" Thread manager enabled") endif () @@ -322,9 +335,17 @@ if (WAMR_BUILD_REF_TYPES EQUAL 1) else () message (" Reference types disabled") endif () +if (WAMR_BUILD_EXCE_HANDLING EQUAL 1) + add_definitions (-DWASM_ENABLE_EXCE_HANDLING=1) + add_definitions (-DWASM_ENABLE_TAGS=1) + message (" Exception Handling enabled") +endif () if (DEFINED WAMR_BH_VPRINTF) add_definitions (-DBH_VPRINTF=${WAMR_BH_VPRINTF}) endif () +if (DEFINED WAMR_BH_LOG) + add_definitions (-DBH_LOG=${WAMR_BH_LOG}) +endif () if (WAMR_DISABLE_APP_ENTRY EQUAL 1) message (" WAMR application entry functions excluded") endif () @@ -408,35 +429,72 @@ if (WAMR_BUILD_STATIC_PGO EQUAL 1) add_definitions (-DWASM_ENABLE_STATIC_PGO=1) message (" AOT static PGO enabled") endif () -if (WAMR_DISABLE_WRITE_GS_BASE EQUAL 1) - add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1) - message (" Write linear memory base addr to x86 GS register disabled") -elseif (WAMR_BUILD_TARGET STREQUAL "X86_64" - AND WAMR_BUILD_PLATFORM STREQUAL "linux") - set (TEST_WRGSBASE_SOURCE "${CMAKE_BINARY_DIR}/test_wrgsbase.c") - file (WRITE "${TEST_WRGSBASE_SOURCE}" " - #include - #include - int main() { - uint64_t value; - asm volatile (\"wrgsbase %0\" : : \"r\"(value)); - printf(\"WRGSBASE instruction is available.\\n\"); - return 0; - }") - # Try to compile and run the test program - try_run (TEST_WRGSBASE_RESULT - TEST_WRGSBASE_COMPILED - ${CMAKE_BINARY_DIR}/test_wrgsbase - SOURCES ${TEST_WRGSBASE_SOURCE} - CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - ) - #message("${TEST_WRGSBASE_COMPILED}, ${TEST_WRGSBASE_RESULT}") - if (NOT TEST_WRGSBASE_RESULT EQUAL 0) +if (WAMR_BUILD_TARGET STREQUAL "X86_64" + AND WAMR_BUILD_PLATFORM STREQUAL "linux") + if (WAMR_DISABLE_WRITE_GS_BASE EQUAL 1) + # disabled by user + set (DISABLE_WRITE_GS_BASE 1) + elseif (WAMR_DISABLE_WRITE_GS_BASE EQUAL 0) + # enabled by user + set (DISABLE_WRITE_GS_BASE 0) + elseif (CMAKE_CROSSCOMPILING) + # disabled in cross compilation environment + set (DISABLE_WRITE_GS_BASE 1) + else () + # auto-detected by the compiler + set (TEST_WRGSBASE_SOURCE "${CMAKE_BINARY_DIR}/test_wrgsbase.c") + file (WRITE "${TEST_WRGSBASE_SOURCE}" " + #include + #include + int main() { + uint64_t value; + asm volatile (\"wrgsbase %0\" : : \"r\"(value)); + printf(\"WRGSBASE instruction is available.\\n\"); + return 0; + }") + # Try to compile and run the test program + try_run (TEST_WRGSBASE_RESULT + TEST_WRGSBASE_COMPILED + ${CMAKE_BINARY_DIR}/test_wrgsbase + SOURCES ${TEST_WRGSBASE_SOURCE} + CMAKE_FLAGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + ) + #message("${TEST_WRGSBASE_COMPILED}, ${TEST_WRGSBASE_RESULT}") + if (TEST_WRGSBASE_RESULT EQUAL 0) + set (DISABLE_WRITE_GS_BASE 0) + else () + set (DISABLE_WRITE_GS_BASE 1) + endif () + endif () + if (DISABLE_WRITE_GS_BASE EQUAL 1) add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=1) message (" Write linear memory base addr to x86 GS register disabled") + else () + add_definitions (-DWASM_DISABLE_WRITE_GS_BASE=0) + message (" Write linear memory base addr to x86 GS register enabled") endif () endif () if (WAMR_CONFIGUABLE_BOUNDS_CHECKS EQUAL 1) add_definitions (-DWASM_CONFIGURABLE_BOUNDS_CHECKS=1) message (" Configurable bounds checks enabled") endif () +if (WAMR_BUILD_LINUX_PERF EQUAL 1) + add_definitions (-DWASM_ENABLE_LINUX_PERF=1) + message (" Linux perf support enabled") +endif () +if (WAMR_BUILD_AOT EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1) + if (NOT DEFINED WAMR_BUILD_QUICK_AOT_ENTRY) + # Enable quick aot/jit entries by default + set (WAMR_BUILD_QUICK_AOT_ENTRY 1) + endif () + if (WAMR_BUILD_QUICK_AOT_ENTRY EQUAL 1) + add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=1) + message (" Quick AOT/JIT entries enabled") + else () + add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0) + message (" Quick AOT/JIT entries disabled") + endif () +else () + # Disable quick aot/jit entries for interp and fast-jit + add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0) +endif () diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/esp-idf/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/esp-idf/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/esp-idf/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/esp-idf/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/esp-idf/wamr/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/esp-idf/wamr/CMakeLists.txt new file mode 100644 index 00000000000..f467f4cadd9 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/esp-idf/wamr/CMakeLists.txt @@ -0,0 +1,117 @@ +# Copyright (C) 2021 Intel Corporation and others. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Set WAMR's build options +if (NOT CMAKE_BUILD_EARLY_EXPANSION) + + if (CONFIG_IDF_TARGET_ARCH_RISCV) + set (WAMR_BUILD_TARGET "RISCV32") + elseif (CONFIG_IDF_TARGET_ARCH_XTENSA) + set (WAMR_BUILD_TARGET "XTENSA") + else () + message (FATAL_ERROR "Arch ${CONFIG_IDF_TARGET_ARCH} is not supported") + endif () + + set (WAMR_BUILD_PLATFORM "esp-idf") + + if (CONFIG_WAMR_BUILD_DEBUG) + set (CMAKE_BUILD_TYPE Debug) + else () + set (CMAKE_BUILD_TYPE Release) + endif () + + if (CONFIG_WAMR_ENABLE_INTERP) + set (WAMR_BUILD_INTERP 1) + endif () + + if (CONFIG_WAMR_INTERP_FAST) + set (WAMR_BUILD_FAST_INTERP 1) + endif () + + if (CONFIG_WAMR_ENABLE_AOT) + set (WAMR_BUILD_AOT 1) + endif () + + if (CONFIG_WAMR_ENABLE_LIBC_BUILTIN) + set (WAMR_BUILD_LIBC_BUILTIN 1) + endif () + + if (CONFIG_WAMR_ENABLE_APP_FRAMEWORK) + set (WAMR_BUILD_APP_FRAMEWORK 1) + set (WAMR_BUILD_APP_LIST WAMR_APP_BUILD_BASE) + set (WAMR_APP_THREAD_STACK_SIZE_MAX ${CONFIG_WAMR_APP_THREAD_STACK_SIZE_MAX}) + endif () + + if (CONFIG_WAMR_INTERP_LOADER_MINI) + set (WAMR_BUILD_MINI_LOADER 1) + endif () + + if (CONFIG_WAMR_ENABLE_MULTI_MODULE) + set (WAMR_BUILD_MULTI_MODULE 1) + endif () + + if (CONFIG_WAMR_ENABLE_SHARED_MEMORY) + set (WAMR_BUILD_SHARED_MEMORY 1) + endif () + + if (CONFIG_WAMR_ENABLE_MEMORY_PROFILING) + set (WAMR_BUILD_MEMORY_PROFILING 1) + endif () + + if (CONFIG_WAMR_ENABLE_PERF_PROFILING) + set (WAMR_BUILD_PERF_PROFILING 1) + endif () + + if (CONFIG_WAMR_ENABLE_REF_TYPES) + set (WAMR_BUILD_REF_TYPES 1) + endif () + + if (CONFIG_WAMR_ENABLE_LIBC_WASI) + set (WAMR_BUILD_LIBC_WASI 1) + endif () + + if (CONFIG_WAMR_ENABLE_LIB_PTHREAD) + set (WAMR_BUILD_LIB_PTHREAD 1) + endif () + + set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..) + include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) + + list (APPEND srcs "${WAMR_RUNTIME_LIB_SOURCE}" + "${PLATFORM_SHARED_SOURCE}") + + set (include_dirs "${IWASM_DIR}/include" + "${UTILS_SHARED_DIR}" + "${PLATFORM_SHARED_DIR}" + "${PLATFORM_SHARED_DIR}/../include" + "${IWASM_COMMON_DIR}") + + if (CONFIG_WAMR_ENABLE_APP_FRAMEWORK) + list (APPEND include_dirs "${APP_MGR_SHARED_DIR}" + "${__APP_MGR_DIR}" + "${NATIVE_INTERFACE_DIR}" + "${WASM_APP_LIBS_DIR}" + "${APP_FRAMEWORK_ROOT_DIR}/base/app") + endif () +endif () + +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS ${include_dirs} + REQUIRES pthread lwip esp_timer + KCONFIG ${CMAKE_CURRENT_LIST_DIR}/Kconfig) + +target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") + +if (CONFIG_IDF_TARGET_ARCH_RISCV) + target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_RISCV32_ILP32=1) +elseif (CONFIG_IDF_TARGET_ARCH_XTENSA) + target_compile_definitions(${COMPONENT_LIB} PUBLIC -DBUILD_TARGET_XTENSA=1) +endif () + +if (CONFIG_WAMR_ENABLE_AOT) + target_compile_definitions(${COMPONENT_LIB} PUBLIC -DWASM_ENABLE_AOT=1) +endif () + +if (CONFIG_WAMR_ENABLE_INTERP) + target_compile_definitions(${COMPONENT_LIB} PUBLIC -DWASM_ENABLE_INTERP=1) +endif () diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/esp-idf/wamr/Kconfig b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/esp-idf/wamr/Kconfig new file mode 100644 index 00000000000..ba7c679df1c --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/esp-idf/wamr/Kconfig @@ -0,0 +1,88 @@ +menu "WASM Micro Runtime" + choice WAMR_BUILD_TYPE + prompt "Build type" + default WAMR_BUILD_RELEASE + + config WAMR_BUILD_RELEASE + bool "Release" + + config WAMR_BUILD_DEBUG + bool "Debug" + endchoice + + config WAMR_ENABLE_AOT + bool "AOT" + default y + + menuconfig WAMR_ENABLE_INTERP + bool "Interpreter" + default y + + if WAMR_ENABLE_INTERP + + choice WAMR_INTERP_MODE + prompt "Interpreter mode" + default WAMR_INTERP_FAST + + config WAMR_INTERP_CLASSIC + bool "Classic" + + config WAMR_INTERP_FAST + bool "Fast" + endchoice + + choice WAMR_INTERP_LOADER_MODE + prompt "Loader mode" + default WAMR_INTERP_LOADER_NORMAL + + config WAMR_INTERP_LOADER_NORMAL + bool "Normal" + + config WAMR_INTERP_LOADER_MINI + bool "Mini" + endchoice + endif + + config WAMR_ENABLE_LIB_PTHREAD + bool "Lib pthread" + default y + + config WAMR_ENABLE_LIBC_BUILTIN + bool "Libc builtin" + default y + + config WAMR_ENABLE_LIBC_WASI + bool "Libc WASI" + default y + + config WAMR_ENABLE_MEMORY_PROFILING + bool "Memory profiling" + default n + + config WAMR_ENABLE_MULTI_MODULE + bool "Multi module" + default n + + config WAMR_ENABLE_PERF_PROFILING + bool "Performance profiling" + default n + + config WAMR_ENABLE_REF_TYPES + bool "Reference types" + default n + + config WAMR_ENABLE_SHARED_MEMORY + bool "Shared memory" + default n + + menuconfig WAMR_ENABLE_APP_FRAMEWORK + bool "App framework" + default y + + if WAMR_ENABLE_APP_FRAMEWORK + + config WAMR_APP_THREAD_STACK_SIZE_MAX + int "Application thread max stack size" + default 131072 + endif +endmenu diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/involve_boringssl.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/involve_boringssl.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/involve_boringssl.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/involve_boringssl.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/lldb_wasm.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/lldb_wasm.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/lldb_wasm.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/lldb_wasm.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/requirements.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/requirements.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/requirements.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/requirements.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/runtime_lib.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/runtime_lib.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/build-scripts/runtime_lib.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/build-scripts/runtime_lib.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/ci/build_wamr.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/ci/build_wamr.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/ci/build_wamr.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/ci/build_wamr.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/ci/coding_guidelines_check.py b/lib/wasm-micro-runtime-WAMR-1.3.3/ci/coding_guidelines_check.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/ci/coding_guidelines_check.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/ci/coding_guidelines_check.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/ci/pre_commit_hook_sample b/lib/wasm-micro-runtime-WAMR-1.3.3/ci/pre_commit_hook_sample similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/ci/pre_commit_hook_sample rename to lib/wasm-micro-runtime-WAMR-1.3.3/ci/pre_commit_hook_sample diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/ci/setup.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/ci/setup.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/ci/setup.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/ci/setup.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/ci/validate_lldb.py b/lib/wasm-micro-runtime-WAMR-1.3.3/ci/validate_lldb.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/ci/validate_lldb.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/ci/validate_lldb.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/attr_container.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/attr_container.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/attr_container.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/attr_container.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/bi-inc/attr_container.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/bi-inc/attr_container.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/bi-inc/attr_container.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/bi-inc/attr_container.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/bi-inc/shared_utils.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/bi-inc/shared_utils.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/bi-inc/shared_utils.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/bi-inc/shared_utils.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/bi-inc/wgl_shared_utils.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/bi-inc/wgl_shared_utils.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/bi-inc/wgl_shared_utils.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/bi-inc/wgl_shared_utils.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/native_interface.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/native_interface.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/native_interface.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/native_interface.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/native_interface.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/native_interface.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/native_interface.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/native_interface.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/restful_utils.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/restful_utils.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app-native-shared/restful_utils.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app-native-shared/restful_utils.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app_ext_lib_export.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app_ext_lib_export.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app_ext_lib_export.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app_ext_lib_export.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app_framework.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app_framework.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/app_framework.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/app_framework.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/bh_platform.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/bh_platform.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/bh_platform.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/bh_platform.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/bh_platform.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/bh_platform.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/bh_platform.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/bh_platform.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/req_resp_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/req_resp_api.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/req_resp_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/req_resp_api.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/request.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/request.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/request.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/request.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/timer.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/timer.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/timer.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/timer.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/timer_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/timer_api.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/timer_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/timer_api.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/wa-inc/request.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/wa-inc/request.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/wa-inc/request.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/wa-inc/request.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/wa-inc/timer_wasm_app.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/wa-inc/timer_wasm_app.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/wa-inc/timer_wasm_app.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/wa-inc/timer_wasm_app.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/wasm_app.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/wasm_app.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/wasm_app.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/wasm_app.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/wasm_app.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/wasm_app.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/app/wasm_app.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/app/wasm_app.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/base_lib.inl b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/base_lib.inl similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/base_lib.inl rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/base_lib.inl diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/base_lib_export.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/base_lib_export.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/base_lib_export.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/base_lib_export.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/req_resp_native_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/req_resp_native_api.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/req_resp_native_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/req_resp_native_api.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/request_response.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/request_response.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/request_response.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/request_response.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/runtime_lib.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/runtime_lib.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/runtime_lib.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/runtime_lib.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/timer_native_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/timer_native_api.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/timer_native_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/timer_native_api.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/timer_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/timer_wrapper.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/timer_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/timer_wrapper.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/wasm_lib.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/wasm_lib.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/base/native/wasm_lib.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/base/native/wasm_lib.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/app/connection.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/app/connection.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/app/connection.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/app/connection.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/app/connection_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/app/connection_api.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/app/connection_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/app/connection_api.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/app/wa-inc/connection.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/app/wa-inc/connection.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/app/wa-inc/connection.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/app/wa-inc/connection.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/app/wasm_app.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/app/wasm_app.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/app/wasm_app.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/app/wasm_app.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/connection.inl b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/connection.inl similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/connection.inl rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/connection.inl diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/connection_lib.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/connection_lib.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/connection_lib.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/connection_lib.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/connection_native_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/connection_native_api.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/connection_native_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/connection_native_api.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/connection_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/connection_wrapper.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/connection_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/connection_wrapper.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_tcp.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_tcp.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_tcp.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_tcp.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_tcp.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_tcp.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_tcp.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_tcp.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_uart.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_uart.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_uart.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_uart.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_uart.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_uart.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_uart.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_uart.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_udp.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_udp.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_udp.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_udp.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_udp.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_udp.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/conn_udp.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/conn_udp.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/connection_mgr.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/connection_mgr.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/connection_mgr.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/connection_mgr.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/connection_mgr.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/connection_mgr.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/linux/connection_mgr.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/linux/connection_mgr.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/wasm_lib.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/wasm_lib.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/wasm_lib.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/wasm_lib.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/zephyr/connection_lib_impl.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/zephyr/connection_lib_impl.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/zephyr/connection_lib_impl.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/zephyr/connection_lib_impl.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/zephyr/connection_mgr.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/zephyr/connection_mgr.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/connection/native/zephyr/connection_mgr.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/connection/native/zephyr/connection_mgr.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/app/sensor.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/app/sensor.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/app/sensor.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/app/sensor.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/app/sensor_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/app/sensor_api.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/app/sensor_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/app/sensor_api.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/app/wa-inc/sensor.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/app/wa-inc/sensor.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/app/wa-inc/sensor.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/app/wa-inc/sensor.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/app/wasm_app.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/app/wasm_app.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/app/wasm_app.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/app/wasm_app.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/runtime_sensor.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/runtime_sensor.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/runtime_sensor.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/runtime_sensor.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/runtime_sensor.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/runtime_sensor.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/runtime_sensor.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/runtime_sensor.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/runtime_sensor.inl b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/runtime_sensor.inl similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/runtime_sensor.inl rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/runtime_sensor.inl diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/sensor_mgr_ref.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/sensor_mgr_ref.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/sensor_mgr_ref.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/sensor_mgr_ref.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/sensor_native_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/sensor_native_api.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/sensor_native_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/sensor_native_api.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/wasm_lib.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/wasm_lib.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/sensor/native/wasm_lib.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/sensor/native/wasm_lib.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/template/app/wa-inc/app_xxx.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/template/app/wa-inc/app_xxx.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/template/app/wa-inc/app_xxx.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/template/app/wa-inc/app_xxx.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/template/app/wasm_app.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/template/app/wasm_app.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/template/app/wasm_app.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/template/app/wasm_app.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/template/native/app_xxx.inl b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/template/native/app_xxx.inl similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/template/native/app_xxx.inl rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/template/native/app_xxx.inl diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/template/native/wasm_lib.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/template/native/wasm_lib.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-framework/template/native/wasm_lib.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-framework/template/native/wasm_lib.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_manager.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_manager.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_manager.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_manager.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_manager.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_manager.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_manager.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_manager.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_manager_host.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_manager_host.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_manager_host.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_manager_host.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_manager_host.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_manager_host.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_manager_host.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_manager_host.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_mgr.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_mgr.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/app_mgr.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/app_mgr.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/ble_msg.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/ble_msg.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/ble_msg.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/ble_msg.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/coding_rule.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/coding_rule.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/coding_rule.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/coding_rule.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/event.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/event.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/event.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/event.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/event.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/event.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/event.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/event.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/message.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/message.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/message.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/message.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_config.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_config.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_config.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_config.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_jeff.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_jeff.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_jeff.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_jeff.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_jeff.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_jeff.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_jeff.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_jeff.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_utils.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_utils.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_utils.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_utils.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_wasm_app.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_wasm_app.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_wasm_app.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_wasm_app.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_wasm_app.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_wasm_app.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_wasm_app.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_wasm_app.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_wasm_lib.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_wasm_lib.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_wasm_lib.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_wasm_lib.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_wasm_lib.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_wasm_lib.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/module_wasm_lib.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/module_wasm_lib.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/platform/darwin/app_mgr_darwin.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/platform/darwin/app_mgr_darwin.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/platform/darwin/app_mgr_darwin.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/platform/darwin/app_mgr_darwin.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/platform/linux/app_mgr_linux.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/platform/linux/app_mgr_linux.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/platform/linux/app_mgr_linux.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/platform/linux/app_mgr_linux.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/platform/zephyr/app_mgr_zephyr.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/platform/zephyr/app_mgr_zephyr.c similarity index 93% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/platform/zephyr/app_mgr_zephyr.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/platform/zephyr/app_mgr_zephyr.c index 650e536f11c..68147c0622b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/platform/zephyr/app_mgr_zephyr.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/platform/zephyr/app_mgr_zephyr.c @@ -6,8 +6,14 @@ #include "app_manager.h" #include "bh_platform.h" #include + +#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */ #include #include +#else +#include +#endif + #if 0 #include #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/resource_reg.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/resource_reg.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/resource_reg.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/resource_reg.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/watchdog.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/watchdog.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/watchdog.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/watchdog.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/watchdog.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/watchdog.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-manager/watchdog.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-manager/watchdog.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-mgr-shared/app_manager_export.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-mgr-shared/app_manager_export.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-mgr-shared/app_manager_export.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-mgr-shared/app_manager_export.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-mgr-shared/app_mgr_shared.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-mgr-shared/app_mgr_shared.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-mgr-shared/app_mgr_shared.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-mgr-shared/app_mgr_shared.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-mgr-shared/host_link.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-mgr-shared/host_link.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/app-mgr-shared/host_link.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/app-mgr-shared/host_link.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/module.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/module.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/app-mgr/module.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/app-mgr/module.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/config.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/config.h similarity index 91% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/config.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/config.h index acf70ff081b..0ed8723d336 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/config.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/config.h @@ -231,6 +231,17 @@ #define WASM_ENABLE_LOG 1 #endif +/* When this flag is set, WAMR will not automatically + * initialize sockets on Windows platforms. The host + * application is responsible for calling WSAStartup() + * before executing WAMR code that uses sockets, and + * calling WSACleanup() after. + * This flag passes control of socket initialization from + * WAMR to the host application. */ +#ifndef WASM_ENABLE_HOST_SOCKET_INIT +#define WASM_ENABLE_HOST_SOCKET_INIT 0 +#endif + #ifndef WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS #if defined(BUILD_TARGET_X86_32) || defined(BUILD_TARGET_X86_64) \ || defined(BUILD_TARGET_AARCH64) @@ -379,7 +390,7 @@ #else #define DEFAULT_WASM_STACK_SIZE (12 * 1024) #endif -/* Min auxilliary stack size of each wasm thread */ +/* Min auxiliary stack size of each wasm thread */ #define WASM_THREAD_AUX_STACK_SIZE_MIN (256) /* Default/min native stack size of each app thread */ @@ -397,7 +408,7 @@ #define APP_THREAD_STACK_SIZE_DEFAULT (64 * 1024) #define APP_THREAD_STACK_SIZE_MIN (48 * 1024) #else -#define APP_THREAD_STACK_SIZE_DEFAULT (64 * 1024) +#define APP_THREAD_STACK_SIZE_DEFAULT (128 * 1024) #define APP_THREAD_STACK_SIZE_MIN (24 * 1024) #endif #endif /* end of !(defined(APP_THREAD_STACK_SIZE_DEFAULT) \ @@ -446,6 +457,14 @@ #define WASM_ENABLE_REF_TYPES 0 #endif +#ifndef WASM_ENABLE_EXCE_HANDLING +#define WASM_ENABLE_EXCE_HANDLING 0 +#endif + +#ifndef WASM_ENABLE_TAGS +#define WASM_ENABLE_TAGS 0 +#endif + #ifndef WASM_ENABLE_SGX_IPFS #define WASM_ENABLE_SGX_IPFS 0 #endif @@ -490,4 +509,21 @@ #define WASM_MAX_INSTANCE_CONTEXTS 8 #endif +/* linux perf support */ +#ifndef WASM_ENABLE_LINUX_PERF +#define WASM_ENABLE_LINUX_PERF 0 +#endif + +/* Support registering quick AOT/JIT function entries of some func types + to speed up the calling process of invoking the AOT/JIT functions of + these types from the host embedder */ +#ifndef WASM_ENABLE_QUICK_AOT_ENTRY +#define WASM_ENABLE_QUICK_AOT_ENTRY 1 +#endif + +/* Disable mmap based shared memory by default */ +#ifndef WASM_ENABLE_SHARED_MEMORY_MMAP +#define WASM_ENABLE_SHARED_MEMORY_MMAP 0 +#endif + #endif /* end of _CONFIG_H_ */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_intrinsic.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_intrinsic.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_intrinsic.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_intrinsic.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_intrinsic.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_intrinsic.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_intrinsic.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_intrinsic.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_loader.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_loader.c similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_loader.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_loader.c index abffd6438a7..6983601c427 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_loader.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_loader.c @@ -66,15 +66,15 @@ exchange_uint32(uint8 *p_data) } static void -exchange_uint64(uint8 *pData) +exchange_uint64(uint8 *p_data) { uint32 value; - value = *(uint32 *)pData; - *(uint32 *)pData = *(uint32 *)(pData + 4); - *(uint32 *)(pData + 4) = value; - exchange_uint32(pData); - exchange_uint32(pData + 4); + value = *(uint32 *)p_data; + *(uint32 *)p_data = *(uint32 *)(p_data + 4); + *(uint32 *)(p_data + 4) = value; + exchange_uint32(p_data); + exchange_uint32(p_data + 4); } static union { @@ -214,6 +214,8 @@ GET_U16_FROM_ADDR(const uint8 *p) p += sizeof(type); \ } while (0) +/* NOLINTBEGIN, disable lint for this region with clang-tidy */ + #define read_byte_array(p, p_end, addr, len) \ do { \ CHECK_BUF(p, p_end, len); \ @@ -236,6 +238,8 @@ GET_U16_FROM_ADDR(const uint8 *p) #define read_uint32(p, p_end, res) TEMPLATE_READ(p, p_end, res, uint32) #define read_uint64(p, p_end, res) TEMPLATE_READ(p, p_end, res, uint64) +/* NOLINTEND */ + /* Legal values for bin_type */ #define BIN_TYPE_ELF32L 0 /* 32-bit little endian */ #define BIN_TYPE_ELF32B 1 /* 32-bit big endian */ @@ -822,7 +826,9 @@ load_custom_section(const uint8 *buf, const uint8 *buf_end, AOTModule *module, case AOT_CUSTOM_SECTION_NAME: if (!load_name_section(buf, buf_end, module, is_load_from_file_buf, error_buf, error_buf_size)) - goto fail; + LOG_VERBOSE("Load name section failed."); + else + LOG_VERBOSE("Load name section success."); break; #if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 case AOT_CUSTOM_SECTION_RAW: @@ -1202,6 +1208,11 @@ load_func_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, func_types[i]->param_cell_num = (uint16)param_cell_num; func_types[i]->ret_cell_num = (uint16)ret_cell_num; + +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 + func_types[i]->quick_aot_entry = + wasm_native_lookup_quick_aot_entry(func_types[i]); +#endif } *p_buf = buf; @@ -1968,6 +1979,12 @@ str2uint64(const char *buf, uint64 *p_res) #define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative offset to GOT */ +static bool +is_text_section(const char *section_name) +{ + return !strcmp(section_name, ".text") || !strcmp(section_name, ".ltext"); +} + static bool do_text_relocation(AOTModule *module, AOTRelocationGroup *group, char *error_buf, uint32 error_buf_size) @@ -2055,8 +2072,19 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group, } symbol_addr = module->func_ptrs[func_index]; } + else if (!strncmp(symbol, "_" AOT_FUNC_INTERNAL_PREFIX, + strlen("_" AOT_FUNC_INTERNAL_PREFIX))) { + p = symbol + strlen("_" AOT_FUNC_INTERNAL_PREFIX); + if (*p == '\0' + || (func_index = (uint32)atoi(p)) > module->func_count) { + set_error_buf_v(error_buf, error_buf_size, "invalid symbol %s", + symbol); + goto check_symbol_fail; + } + symbol_addr = module->func_ptrs[func_index]; + } #endif - else if (!strcmp(symbol, ".text")) { + else if (is_text_section(symbol)) { symbol_addr = module->code; } else if (!strcmp(symbol, ".data") || !strcmp(symbol, ".sdata") @@ -2228,7 +2256,7 @@ do_data_relocation(AOTModule *module, AOTRelocationGroup *group, for (i = 0; i < group->relocation_count; i++, relocation++) { symbol = relocation->symbol_name; - if (!strcmp(symbol, ".text")) { + if (is_text_section(symbol)) { symbol_addr = module->code; } #if WASM_ENABLE_STATIC_PGO != 0 @@ -2689,6 +2717,8 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end, if (!strcmp(group->section_name, ".rel.text") || !strcmp(group->section_name, ".rela.text") + || !strcmp(group->section_name, ".rel.ltext") + || !strcmp(group->section_name, ".rela.ltext") || !strcmp(group->section_name, ".rela.literal") #ifdef BH_PLATFORM_WINDOWS || !strcmp(group->section_name, ".text") @@ -2764,6 +2794,104 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end, return ret; } +#if WASM_ENABLE_LINUX_PERF != 0 +struct func_info { + uint32 idx; + void *ptr; +}; + +static uint32 +get_func_size(const AOTModule *module, struct func_info *sorted_func_ptrs, + uint32 idx) +{ + uint32 func_sz; + + if (idx == module->func_count - 1) + func_sz = (uintptr_t)module->code + module->code_size + - (uintptr_t)(sorted_func_ptrs[idx].ptr); + else + func_sz = (uintptr_t)(sorted_func_ptrs[idx + 1].ptr) + - (uintptr_t)(sorted_func_ptrs[idx].ptr); + + return func_sz; +} + +static int +compare_func_ptrs(const void *f1, const void *f2) +{ + return (intptr_t)((struct func_info *)f1)->ptr + - (intptr_t)((struct func_info *)f2)->ptr; +} + +static struct func_info * +sort_func_ptrs(const AOTModule *module, char *error_buf, uint32 error_buf_size) +{ + uint64 content_len; + struct func_info *sorted_func_ptrs; + unsigned i; + + content_len = (uint64)sizeof(struct func_info) * module->func_count; + sorted_func_ptrs = loader_malloc(content_len, error_buf, error_buf_size); + if (!sorted_func_ptrs) + return NULL; + + for (i = 0; i < module->func_count; i++) { + sorted_func_ptrs[i].idx = i; + sorted_func_ptrs[i].ptr = module->func_ptrs[i]; + } + + qsort(sorted_func_ptrs, module->func_count, sizeof(struct func_info), + compare_func_ptrs); + + return sorted_func_ptrs; +} + +static bool +create_perf_map(const AOTModule *module, char *error_buf, uint32 error_buf_size) +{ + struct func_info *sorted_func_ptrs = NULL; + char perf_map_info[128] = { 0 }; + FILE *perf_map = NULL; + uint32 i; + pid_t pid = getpid(); + bool ret = false; + + sorted_func_ptrs = sort_func_ptrs(module, error_buf, error_buf_size); + if (!sorted_func_ptrs) + goto quit; + + snprintf(perf_map_info, 128, "/tmp/perf-%d.map", pid); + perf_map = fopen(perf_map_info, "w"); + if (!perf_map) { + LOG_WARNING("warning: can't create /tmp/perf-%d.map, because %s", pid, + strerror(errno)); + goto quit; + } + + for (i = 0; i < module->func_count; i++) { + memset(perf_map_info, 0, 128); + snprintf(perf_map_info, 128, "%lx %x aot_func#%u\n", + (uintptr_t)sorted_func_ptrs[i].ptr, + get_func_size(module, sorted_func_ptrs, i), + sorted_func_ptrs[i].idx); + + fwrite(perf_map_info, 1, strlen(perf_map_info), perf_map); + } + + LOG_VERBOSE("generate /tmp/perf-%d.map", pid); + ret = true; + +quit: + if (sorted_func_ptrs) + free(sorted_func_ptrs); + + if (perf_map) + fclose(perf_map); + + return ret; +} +#endif /* WASM_ENABLE_LINUX_PERF != 0*/ + static bool load_from_sections(AOTModule *module, AOTSection *sections, bool is_load_from_file_buf, char *error_buf, @@ -3021,8 +3149,7 @@ resolve_execute_mode(const uint8 *buf, uint32 size, bool *p_mode, p += 8; while (p < p_end) { read_uint32(p, p_end, section_type); - if (section_type <= AOT_SECTION_TYPE_SIGANATURE - || section_type == AOT_SECTION_TYPE_TARGET_INFO) { + if (section_type <= AOT_SECTION_TYPE_SIGANATURE) { read_uint32(p, p_end, section_size); CHECK_BUF(p, p_end, section_size); if (section_type == AOT_SECTION_TYPE_TARGET_INFO) { @@ -3037,7 +3164,7 @@ resolve_execute_mode(const uint8 *buf, uint32 size, bool *p_mode, break; } } - else if (section_type > AOT_SECTION_TYPE_SIGANATURE) { + else { /* section_type > AOT_SECTION_TYPE_SIGANATURE */ set_error_buf(error_buf, error_buf_size, "resolve execute mode failed"); break; @@ -3224,6 +3351,12 @@ load(const uint8 *buf, uint32 size, AOTModule *module, char *error_buf, } #endif +#if WASM_ENABLE_LINUX_PERF != 0 + if (wasm_runtime_get_linux_perf()) + if (!create_perf_map(module, error_buf, error_buf_size)) + goto fail; +#endif + return ret; fail: return false; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_reloc.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_reloc.h similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_reloc.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_reloc.h index 98df09cb4f2..797eacc1143 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_reloc.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_reloc.h @@ -136,6 +136,7 @@ typedef struct { REG_SYM(aot_enlarge_memory), \ REG_SYM(aot_set_exception), \ REG_SYM(aot_check_app_addr_and_convert),\ + REG_SYM(wasm_runtime_quick_invoke_c_api_native),\ { "memset", (void*)aot_memset }, \ { "memmove", (void*)aot_memmove }, \ { "memcpy", (void*)aot_memmove }, \ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_runtime.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_runtime.c similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_runtime.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_runtime.c index 076574cb737..731cacbeaae 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_runtime.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_runtime.c @@ -47,6 +47,13 @@ bh_static_assert(sizeof(AOTMemoryInstance) == 104); bh_static_assert(offsetof(AOTTableInstance, elems) == 8); bh_static_assert(offsetof(AOTModuleInstanceExtra, stack_sizes) == 0); +bh_static_assert(offsetof(AOTModuleInstanceExtra, common.c_api_func_imports) + == sizeof(uint64)); + +bh_static_assert(sizeof(CApiFuncImport) == sizeof(uintptr_t) * 3); + +bh_static_assert(sizeof(wasm_val_t) == 16); +bh_static_assert(offsetof(wasm_val_t, of) == 8); static void set_error_buf(char *error_buf, uint32 error_buf_size, const char *string) @@ -333,6 +340,9 @@ tables_instantiate(AOTModuleInstance *module_inst, AOTModule *module, static void memories_deinstantiate(AOTModuleInstance *module_inst) { +#ifdef WASM_LINEAR_MEMORY_MMAP + uint64 map_size; +#endif uint32 i; AOTMemoryInstance *memory_inst; @@ -355,14 +365,21 @@ memories_deinstantiate(AOTModuleInstance *module_inst) if (memory_inst->memory_data) { #ifndef OS_ENABLE_HW_BOUND_CHECK - wasm_runtime_free(memory_inst->memory_data); -#else -#ifdef BH_PLATFORM_WINDOWS - os_mem_decommit(memory_inst->memory_data, - memory_inst->num_bytes_per_page - * memory_inst->cur_page_count); +#ifdef WASM_LINEAR_MEMORY_MMAP + if (shared_memory_is_shared(memory_inst)) { + map_size = (uint64)memory_inst->num_bytes_per_page + * memory_inst->max_page_count; + wasm_munmap_linear_memory(memory_inst->memory_data, + map_size, map_size); + } + else #endif - os_munmap(memory_inst->memory_data, 8 * (uint64)BH_GB); + wasm_runtime_free(memory_inst->memory_data); +#else + map_size = (uint64)memory_inst->num_bytes_per_page + * memory_inst->cur_page_count; + wasm_munmap_linear_memory(memory_inst->memory_data, map_size, + 8 * (uint64)BH_GB); #endif } } @@ -385,10 +402,9 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent, uint32 heap_offset = num_bytes_per_page * init_page_count; uint64 memory_data_size, max_memory_data_size; uint8 *p = NULL, *global_addr; -#ifdef OS_ENABLE_HW_BOUND_CHECK - uint8 *mapped_mem; - uint64 map_size = 8 * (uint64)BH_GB; - uint64 page_size = os_getpagesize(); +#ifdef WASM_LINEAR_MEMORY_MMAP + uint8 *mapped_mem = NULL; + uint64 map_size; #endif #if WASM_ENABLE_SHARED_MEMORY != 0 @@ -512,15 +528,25 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent, #ifndef OS_ENABLE_HW_BOUND_CHECK #if WASM_ENABLE_SHARED_MEMORY != 0 if (is_shared_memory) { +#if WASM_ENABLE_SHARED_MEMORY_MMAP != 0 + map_size = max_memory_data_size; + if (max_memory_data_size > 0 + && !(p = mapped_mem = + wasm_mmap_linear_memory(map_size, &max_memory_data_size, + error_buf, error_buf_size))) { + return NULL; + } +#else /* Allocate maximum memory size when memory is shared */ if (max_memory_data_size > 0 && !(p = runtime_malloc(max_memory_data_size, error_buf, error_buf_size))) { return NULL; } +#endif } else -#endif +#endif /* end of WASM_ENABLE_SHARED_MEMORY != 0 */ { /* Allocate initial memory size when memory is not shared */ if (memory_data_size > 0 @@ -529,43 +555,18 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent, return NULL; } } -#else /* else of OS_ENABLE_HW_BOUND_CHECK */ - memory_data_size = (memory_data_size + page_size - 1) & ~(page_size - 1); - +#else /* else of OS_ENABLE_HW_BOUND_CHECK */ /* Totally 8G is mapped, the opcode load/store address range is 0 to 8G: * ea = i + memarg.offset * both i and memarg.offset are u32 in range 0 to 4G * so the range of ea is 0 to 8G */ - if (!(p = mapped_mem = os_mmap(NULL, map_size, MMAP_PROT_NONE, - MMAP_MAP_NONE, os_get_invalid_handle()))) { + map_size = 8 * (uint64)BH_GB; + if (!(p = mapped_mem = wasm_mmap_linear_memory( + map_size, &memory_data_size, error_buf, error_buf_size))) { set_error_buf(error_buf, error_buf_size, "mmap memory failed"); return NULL; } - -#ifdef BH_PLATFORM_WINDOWS - if (!os_mem_commit(p, memory_data_size, MMAP_PROT_READ | MMAP_PROT_WRITE)) { - set_error_buf(error_buf, error_buf_size, "commit memory failed"); - os_munmap(mapped_mem, map_size); - return NULL; - } -#endif - - if (os_mprotect(p, memory_data_size, MMAP_PROT_READ | MMAP_PROT_WRITE) - != 0) { - set_error_buf(error_buf, error_buf_size, "mprotect memory failed"); -#ifdef BH_PLATFORM_WINDOWS - os_mem_decommit(p, memory_data_size); -#endif - os_munmap(mapped_mem, map_size); - return NULL; - } - - /* Newly allocated pages are filled with zero by the OS, we don't fill it - * again here */ - - if (memory_data_size > UINT32_MAX) - memory_data_size = UINT32_MAX; #endif /* end of OS_ENABLE_HW_BOUND_CHECK */ memory_inst->module_type = Wasm_Module_AoT; @@ -616,16 +617,15 @@ memory_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent, if (heap_size > 0) wasm_runtime_free(memory_inst->heap_handle); fail1: -#ifndef OS_ENABLE_HW_BOUND_CHECK - if (memory_inst->memory_data) - wasm_runtime_free(memory_inst->memory_data); -#else -#ifdef BH_PLATFORM_WINDOWS - if (memory_inst->memory_data) - os_mem_decommit(p, memory_data_size); -#endif - os_munmap(mapped_mem, map_size); +#ifdef WASM_LINEAR_MEMORY_MMAP + if (mapped_mem) + wasm_munmap_linear_memory(mapped_mem, memory_data_size, map_size); + else #endif + { + if (memory_inst->memory_data) + wasm_runtime_free(memory_inst->memory_data); + } memory_inst->memory_data = NULL; return NULL; } @@ -1179,6 +1179,10 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent, "failed to allocate bitmaps"); goto fail; } + for (i = 0; i < module->mem_init_data_count; i++) { + if (!module->mem_init_data_list[i]->is_passive) + bh_bitmap_set_bit(common->data_dropped, i); + } } #endif #if WASM_ENABLE_REF_TYPES != 0 @@ -1190,6 +1194,10 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent, "failed to allocate bitmaps"); goto fail; } + for (i = 0; i < module->table_init_data_count; i++) { + if (wasm_elem_is_active(module->table_init_data_list[i]->mode)) + bh_bitmap_set_bit(common->elem_dropped, i); + } } #endif @@ -1374,7 +1382,6 @@ aot_lookup_function(const AOTModuleInstance *module_inst, const char *name, } #ifdef OS_ENABLE_HW_BOUND_CHECK - static bool invoke_native_with_hw_bound_check(WASMExecEnv *exec_env, void *func_ptr, const WASMType *func_type, @@ -1386,9 +1393,6 @@ invoke_native_with_hw_bound_check(WASMExecEnv *exec_env, void *func_ptr, WASMJmpBuf jmpbuf_node = { 0 }, *jmpbuf_node_pop; uint32 page_size = os_getpagesize(); uint32 guard_page_count = STACK_OVERFLOW_CHECK_GUARD_PAGE_COUNT; - uint16 param_count = func_type->param_count; - uint16 result_count = func_type->result_count; - const uint8 *types = func_type->types; #ifdef BH_PLATFORM_WINDOWS int result; bool has_exception; @@ -1406,42 +1410,39 @@ invoke_native_with_hw_bound_check(WASMExecEnv *exec_env, void *func_ptr, return false; } - if (exec_env_tls && (exec_env_tls != exec_env)) { - aot_set_exception(module_inst, "invalid exec env"); - return false; - } + if (!exec_env_tls) { + if (!os_thread_signal_inited()) { + aot_set_exception(module_inst, "thread signal env not inited"); + return false; + } - if (!os_thread_signal_inited()) { - aot_set_exception(module_inst, "thread signal env not inited"); - return false; + /* Set thread handle and stack boundary if they haven't been set */ + wasm_exec_env_set_thread_info(exec_env); + + wasm_runtime_set_exec_env_tls(exec_env); + } + else { + if (exec_env_tls != exec_env) { + aot_set_exception(module_inst, "invalid exec env"); + return false; + } } wasm_exec_env_push_jmpbuf(exec_env, &jmpbuf_node); - wasm_runtime_set_exec_env_tls(exec_env); if (os_setjmp(jmpbuf_node.jmpbuf) == 0) { - /* Quick call with func_ptr if the function signature is simple */ - if (!signature && param_count == 1 && types[0] == VALUE_TYPE_I32) { - if (result_count == 0) { - void (*NativeFunc)(WASMExecEnv *, uint32) = - (void (*)(WASMExecEnv *, uint32))func_ptr; - NativeFunc(exec_env, argv[0]); - ret = aot_copy_exception(module_inst, NULL) ? false : true; - } - else if (result_count == 1 - && types[param_count] == VALUE_TYPE_I32) { - uint32 (*NativeFunc)(WASMExecEnv *, uint32) = - (uint32(*)(WASMExecEnv *, uint32))func_ptr; - argv_ret[0] = NativeFunc(exec_env, argv[0]); - ret = aot_copy_exception(module_inst, NULL) ? false : true; - } - else { - ret = wasm_runtime_invoke_native(exec_env, func_ptr, func_type, - signature, attachment, argv, - argc, argv_ret); - } +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 + /* Quick call if the quick aot entry is registered */ + if (!signature && func_type->quick_aot_entry) { + void (*invoke_native)(void *func_ptr, void *exec_env, uint32 *argv, + uint32 *argv_ret) = + func_type->quick_aot_entry; + invoke_native(func_ptr, exec_env, argv, argv_ret); + ret = !aot_copy_exception(module_inst, NULL); } - else { + else +#endif + { ret = wasm_runtime_invoke_native(exec_env, func_ptr, func_type, signature, attachment, argv, argc, argv_ret); @@ -1473,10 +1474,28 @@ invoke_native_with_hw_bound_check(WASMExecEnv *exec_env, void *func_ptr, (void)jmpbuf_node_pop; return ret; } - -#define invoke_native_internal invoke_native_with_hw_bound_check +#define invoke_native_internal invoke_native_with_hw_bound_check /* NOLINT */ #else /* else of OS_ENABLE_HW_BOUND_CHECK */ -#define invoke_native_internal wasm_runtime_invoke_native +static inline bool +invoke_native_internal(WASMExecEnv *exec_env, void *func_ptr, + const WASMType *func_type, const char *signature, + void *attachment, uint32 *argv, uint32 argc, + uint32 *argv_ret) +{ +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 + /* Quick call if the quick aot entry is registered */ + if (!signature && func_type->quick_aot_entry) { + AOTModuleInstance *module_inst = + (AOTModuleInstance *)exec_env->module_inst; + void (*invoke_native)(void *func_ptr, void *exec_env, uint32 *argv, + uint32 *argv_ret) = func_type->quick_aot_entry; + invoke_native(func_ptr, exec_env, argv, argv_ret); + return !aot_copy_exception(module_inst, NULL); + } +#endif + return wasm_runtime_invoke_native(exec_env, func_ptr, func_type, signature, + attachment, argv, argc, argv_ret); +} #endif /* end of OS_ENABLE_HW_BOUND_CHECK */ bool @@ -1543,10 +1562,16 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function, /* func pointer was looked up previously */ bh_assert(func_ptr != NULL); - /* set thread handle and stack boundary */ + +#ifndef OS_ENABLE_HW_BOUND_CHECK + /* Set thread handle and stack boundary */ wasm_exec_env_set_thread_info(exec_env); +#else + /* Set thread info in invoke_native_with_hw_bound_check when + hw bound check is enabled */ +#endif - /* set exec env so it can be later retrieved from instance */ + /* Set exec env so it can be later retrieved from instance */ ((AOTModuleInstanceExtra *)module_inst->e)->common.cur_exec_env = exec_env; if (ext_ret_count > 0) { @@ -2604,6 +2629,7 @@ aot_table_init(AOTModuleInstance *module_inst, uint32 tbl_idx, { AOTTableInstance *tbl_inst; AOTTableInitData *tbl_seg; + uint32 *tbl_seg_elems = NULL, tbl_seg_len = 0; const AOTModule *module = (AOTModule *)module_inst->module; tbl_inst = module_inst->tables[tbl_idx]; @@ -2612,32 +2638,28 @@ aot_table_init(AOTModuleInstance *module_inst, uint32 tbl_idx, tbl_seg = module->table_init_data_list[tbl_seg_idx]; bh_assert(tbl_seg); - if (offset_len_out_of_bounds(src_offset, length, tbl_seg->func_index_count) - || offset_len_out_of_bounds(dst_offset, length, tbl_inst->cur_size)) { - aot_set_exception_with_id(module_inst, EXCE_OUT_OF_BOUNDS_TABLE_ACCESS); - return; - } - - if (!length) { - return; - } - - if (bh_bitmap_get_bit( + if (!bh_bitmap_get_bit( ((AOTModuleInstanceExtra *)module_inst->e)->common.elem_dropped, tbl_seg_idx)) { + /* table segment isn't dropped */ + tbl_seg_elems = tbl_seg->func_indexes; + tbl_seg_len = tbl_seg->func_index_count; + } + + if (offset_len_out_of_bounds(src_offset, length, tbl_seg_len) + || offset_len_out_of_bounds(dst_offset, length, tbl_inst->cur_size)) { aot_set_exception_with_id(module_inst, EXCE_OUT_OF_BOUNDS_TABLE_ACCESS); return; } - if (!wasm_elem_is_passive(tbl_seg->mode)) { - aot_set_exception_with_id(module_inst, EXCE_OUT_OF_BOUNDS_TABLE_ACCESS); + if (!length) { return; } bh_memcpy_s((uint8 *)tbl_inst + offsetof(AOTTableInstance, elems) + dst_offset * sizeof(uint32), (tbl_inst->cur_size - dst_offset) * sizeof(uint32), - tbl_seg->func_indexes + src_offset, length * sizeof(uint32)); + tbl_seg_elems + src_offset, length * sizeof(uint32)); } void @@ -2805,7 +2827,7 @@ aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) } #if WASM_ENABLE_PERF_PROFILING != 0 - frame->time_started = os_time_get_boot_microsecond(); + frame->time_started = os_time_thread_cputime_us(); frame->func_perf_prof_info = func_perf_prof; #endif @@ -2823,9 +2845,13 @@ aot_free_frame(WASMExecEnv *exec_env) AOTFrame *prev_frame = cur_frame->prev_frame; #if WASM_ENABLE_PERF_PROFILING != 0 - cur_frame->func_perf_prof_info->total_exec_time += - os_time_get_boot_microsecond() - cur_frame->time_started; + uint64 elapsed = os_time_thread_cputime_us() - cur_frame->time_started; + cur_frame->func_perf_prof_info->total_exec_time += elapsed; cur_frame->func_perf_prof_info->total_exec_cnt++; + + /* parent function */ + if (prev_frame) + prev_frame->func_perf_prof_info->children_exec_time += elapsed; #endif wasm_exec_env_free_wasm_frame(exec_env, cur_frame); @@ -2962,21 +2988,64 @@ aot_dump_perf_profiling(const AOTModuleInstance *module_inst) os_printf("Performance profiler data:\n"); for (i = 0; i < total_func_count; i++, perf_prof++) { + if (perf_prof->total_exec_cnt == 0) + continue; + func_name = get_func_name_from_index(module_inst, i); if (func_name) os_printf( " func %s, execution time: %.3f ms, execution count: %" PRIu32 - " times\n", + " times, children execution time: %.3f ms\n", func_name, perf_prof->total_exec_time / 1000.0f, - perf_prof->total_exec_cnt); + perf_prof->total_exec_cnt, + perf_prof->children_exec_time / 1000.0f); else os_printf(" func %" PRIu32 ", execution time: %.3f ms, execution count: %" PRIu32 - " times\n", + " times, children execution time: %.3f ms\n", i, perf_prof->total_exec_time / 1000.0f, - perf_prof->total_exec_cnt); + perf_prof->total_exec_cnt, + perf_prof->children_exec_time / 1000.0f); + } +} + +double +aot_summarize_wasm_execute_time(const AOTModuleInstance *inst) +{ + double ret = 0; + + AOTModule *module = (AOTModule *)inst->module; + uint32 total_func_count = module->import_func_count + module->func_count, i; + + for (i = 0; i < total_func_count; i++) { + AOTFuncPerfProfInfo *perf_prof = + (AOTFuncPerfProfInfo *)inst->func_perf_profilings + i; + ret += (perf_prof->total_exec_time - perf_prof->children_exec_time) + / 1000.0f; + } + + return ret; +} + +double +aot_get_wasm_func_exec_time(const AOTModuleInstance *inst, + const char *func_name) +{ + AOTModule *module = (AOTModule *)inst->module; + uint32 total_func_count = module->import_func_count + module->func_count, i; + + for (i = 0; i < total_func_count; i++) { + const char *name_in_wasm = get_func_name_from_index(inst, i); + if (name_in_wasm && strcmp(func_name, name_in_wasm) == 0) { + AOTFuncPerfProfInfo *perf_prof = + (AOTFuncPerfProfInfo *)inst->func_perf_profilings + i; + return (perf_prof->total_exec_time - perf_prof->children_exec_time) + / 1000.0f; + } } + + return -1.0; } #endif /* end of WASM_ENABLE_PERF_PROFILING */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_runtime.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_runtime.h similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_runtime.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_runtime.h index 35c78bfa082..47d8a2021a2 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/aot_runtime.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/aot_runtime.h @@ -286,6 +286,8 @@ typedef struct AOTFuncPerfProfInfo { uint64 total_exec_time; /* total execution count */ uint32 total_exec_cnt; + /* children execution time */ + uint64 children_exec_time; } AOTFuncPerfProfInfo; /* AOT auxiliary call stack */ @@ -613,6 +615,13 @@ aot_dump_call_stack(WASMExecEnv *exec_env, bool print, char *buf, uint32 len); void aot_dump_perf_profiling(const AOTModuleInstance *module_inst); +double +aot_summarize_wasm_execute_time(const AOTModuleInstance *inst); + +double +aot_get_wasm_func_exec_time(const AOTModuleInstance *inst, + const char *func_name); + const uint8 * aot_get_custom_section(const AOTModule *module, const char *name, uint32 *len); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_aarch64.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_aarch64.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_aarch64.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_aarch64.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_arc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_arc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_arc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_arc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_arm.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_arm.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_arm.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_arm.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_mips.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_mips.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_mips.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_mips.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_riscv.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_riscv.c similarity index 91% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_riscv.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_riscv.c index 045cab6412c..31830f780f5 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_riscv.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_riscv.c @@ -18,15 +18,45 @@ #define RV_OPCODE_SW 0x23 +#undef NEED_SOFT_FP +#undef NEED_SOFT_DP +#undef NEED_SOFT_I32_MUL +#undef NEED_SOFT_I32_DIV +#undef NEED_SOFT_I64_MUL +#undef NEED_SOFT_I64_DIV + +#ifdef __riscv_flen +#if __riscv_flen == 32 +#define NEED_SOFT_DP +#endif +#else +#define NEED_SOFT_FP +#define NEED_SOFT_DP +#endif + +#ifndef __riscv_mul +#define NEED_SOFT_I32_MUL +#define NEED_SOFT_I64_MUL +#elif __riscv_xlen == 32 +#define NEED_SOFT_I64_MUL +#endif + +#ifndef __riscv_div +#define NEED_SOFT_I32_DIV +#define NEED_SOFT_I64_DIV +#elif __riscv_xlen == 32 +#define NEED_SOFT_I64_DIV +#endif + /* clang-format off */ void __adddf3(); void __addsf3(); -void __divdi3(); -void __divsi3(); void __divdf3(); +void __divdi3(); void __divsf3(); -void __eqsf2(); +void __divsi3(); void __eqdf2(); +void __eqsf2(); void __extendsfdf2(); void __fixdfdi(); void __fixdfsi(); @@ -38,12 +68,12 @@ void __fixunssfdi(); void __fixunssfsi(); void __floatdidf(); void __floatdisf(); -void __floatsisf(); void __floatsidf(); +void __floatsisf(); void __floatundidf(); void __floatundisf(); -void __floatunsisf(); void __floatunsidf(); +void __floatunsisf(); void __gedf2(); void __gesf2(); void __gtdf2(); @@ -59,6 +89,8 @@ void __muldi3(); void __mulsf3(); void __mulsi3(); void __nedf2(); +void __negdf2(); +void __negsf2(); void __nesf2(); void __subdf3(); void __subsf3(); @@ -74,60 +106,74 @@ void __unordsf2(); static SymbolMap target_sym_map[] = { /* clang-format off */ REG_COMMON_SYMBOLS -#ifndef __riscv_flen - REG_SYM(__adddf3), +#ifdef NEED_SOFT_FP REG_SYM(__addsf3), - REG_SYM(__divdf3), REG_SYM(__divsf3), - REG_SYM(__eqdf2), REG_SYM(__eqsf2), + REG_SYM(__fixsfdi), + REG_SYM(__fixunssfdi), + REG_SYM(__fixunssfsi), + REG_SYM(__floatsidf), + REG_SYM(__gesf2), + REG_SYM(__gtsf2), + REG_SYM(__lesf2), + REG_SYM(__mulsf3), + REG_SYM(__negsf2), + REG_SYM(__nesf2), + REG_SYM(__subsf3), + REG_SYM(__unordsf2), +#elif __riscv_xlen == 32 + /* rv32f, support FP instruction but need soft routines + * to convert float and long long + */ + REG_SYM(__floatundisf), +#endif +#ifdef NEED_SOFT_DP + REG_SYM(__adddf3), + REG_SYM(__divdf3), + REG_SYM(__eqdf2), REG_SYM(__extendsfdf2), + REG_SYM(__fixdfdi), REG_SYM(__fixunsdfdi), REG_SYM(__fixunsdfsi), - REG_SYM(__fixunssfdi), - REG_SYM(__fixunssfsi), + REG_SYM(__floatdidf), + REG_SYM(__floatsidf), + REG_SYM(__floatundidf), + REG_SYM(__floatunsidf), REG_SYM(__gedf2), - REG_SYM(__gesf2), REG_SYM(__gtdf2), - REG_SYM(__gtsf2), REG_SYM(__ledf2), - REG_SYM(__lesf2), - REG_SYM(__ltdf2), - REG_SYM(__ltsf2), REG_SYM(__muldf3), REG_SYM(__nedf2), - REG_SYM(__nesf2), + REG_SYM(__negdf2), REG_SYM(__subdf3), - REG_SYM(__subsf3), REG_SYM(__truncdfsf2), REG_SYM(__unorddf2), - REG_SYM(__unordsf2), - REG_SYM(__mulsf3), - REG_SYM(__floatundidf), +#elif __riscv_xlen == 32 + /* rv32d, support DP instruction but need soft routines + * to convert double and long long + */ REG_SYM(__fixdfdi), - REG_SYM(__floatsidf), - REG_SYM(__floatunsidf), -#if __riscv_xlen == 32 - REG_SYM(__fixdfsi), - REG_SYM(__fixsfdi), - REG_SYM(__fixsfsi), - REG_SYM(__floatdidf), - REG_SYM(__floatdisf), - REG_SYM(__floatsisf), - REG_SYM(__floatundisf), - REG_SYM(__floatunsisf), - REG_SYM(__mulsi3), + REG_SYM(__floatundidf), #endif +#ifdef NEED_SOFT_I32_MUL + REG_SYM(__mulsi3), #endif - REG_SYM(__divdi3), +#ifdef NEED_SOFT_I32_DIV REG_SYM(__divsi3), - REG_SYM(__moddi3), REG_SYM(__modsi3), + REG_SYM(__udivsi3), + REG_SYM(__umodsi3), +#endif +#ifdef NEED_SOFT_I64_MUL REG_SYM(__muldi3), +#endif +#ifdef NEED_SOFT_I64_DIV + REG_SYM(__divdi3), + REG_SYM(__moddi3), REG_SYM(__udivdi3), - REG_SYM(__udivsi3), REG_SYM(__umoddi3), - REG_SYM(__umodsi3), +#endif /* clang-format on */ }; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_thumb.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_thumb.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_thumb.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_thumb.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_x86_32.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_x86_32.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_x86_32.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_x86_32.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_x86_64.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_x86_64.c similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_x86_64.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_x86_64.c index b5be2459322..d1f5cb5acc0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_x86_64.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_x86_64.c @@ -163,7 +163,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr, error_buf, error_buf_size, "AOT module load failed: " "relocation truncated to fit R_X86_64_PC32 failed. " - "Try using wamrc with --size-level=1 option."); + "Try using wamrc with --size-level=1 or 0 option."); return false; } @@ -196,7 +196,7 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr, snprintf(buf, sizeof(buf), "AOT module load failed: " "relocation truncated to fit %s failed. " - "Try using wamrc with --size-level=1 option.", + "Try using wamrc with --size-level=1 or 0 option.", reloc_type == R_X86_64_32 ? "R_X86_64_32" : "R_X86_64_32S"); set_error_buf(error_buf, error_buf_size, buf); @@ -236,15 +236,16 @@ apply_relocation(AOTModule *module, uint8 *target_section_addr, target_addr -= sizeof(int32); #endif if ((int32)target_addr != target_addr) { - set_error_buf(error_buf, error_buf_size, - "AOT module load failed: " - "relocation truncated to fit " + set_error_buf( + error_buf, error_buf_size, + "AOT module load failed: " + "relocation truncated to fit " #if !defined(BH_PLATFORM_WINDOWS) - "R_X86_64_PLT32 failed. " + "R_X86_64_PLT32 failed. " #else - "IMAGE_REL_AMD64_32 failed." + "IMAGE_REL_AMD64_32 failed." #endif - "Try using wamrc with --size-level=1 option."); + "Try using wamrc with --size-level=1 or 0 option."); return false; } *(int32 *)(target_section_addr + reloc_offset) = (int32)target_addr; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_xtensa.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_xtensa.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/arch/aot_reloc_xtensa.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/arch/aot_reloc_xtensa.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/LICENSE_NUTTX b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/LICENSE_NUTTX similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/LICENSE_NUTTX rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/LICENSE_NUTTX diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/NOTICE_NUTTX b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/NOTICE_NUTTX similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/NOTICE_NUTTX rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/NOTICE_NUTTX diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf32.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf32.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf32.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf32.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf64.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf64.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf64.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf64.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf_parser.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf_parser.c similarity index 87% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf_parser.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf_parser.c index 9fec281d32c..657f9530c27 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf_parser.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf_parser.c @@ -100,6 +100,12 @@ get_section64(Elf64_Ehdr *eh, Elf64_Shdr *section_header) return buf + section_header->sh_offset; } +static bool +is_text_section(const char *section_name) +{ + return !strcmp(section_name, ".text") || !strcmp(section_name, ".ltext"); +} + bool get_text_section(void *buf, uint64_t *offset, uint64_t *size) { @@ -107,6 +113,7 @@ get_text_section(void *buf, uint64_t *offset, uint64_t *size) uint32 i; char *sh_str; + /* Assumption: Only one of .text or .ltext is non-empty. */ if (is64Bit(buf)) { Elf64_Ehdr *eh = (Elf64_Ehdr *)buf; Elf64_Shdr **sh_table = @@ -115,14 +122,16 @@ get_text_section(void *buf, uint64_t *offset, uint64_t *size) read_section_header_table64(eh, sh_table); sh_str = get_section64(eh, sh_table[eh->e_shstrndx]); for (i = 0; i < eh->e_shnum; i++) { - if (!strcmp(sh_str + sh_table[i]->sh_name, ".text")) { + if (is_text_section(sh_str + sh_table[i]->sh_name)) { *offset = sh_table[i]->sh_offset; *size = sh_table[i]->sh_size; sh_table[i]->sh_addr = (Elf64_Addr)(uintptr_t)((char *)buf + sh_table[i]->sh_offset); ret = true; - break; + if (*size > 0) { + break; + } } } wasm_runtime_free(sh_table); @@ -136,14 +145,16 @@ get_text_section(void *buf, uint64_t *offset, uint64_t *size) read_section_header_table(eh, sh_table); sh_str = get_section(eh, sh_table[eh->e_shstrndx]); for (i = 0; i < eh->e_shnum; i++) { - if (!strcmp(sh_str + sh_table[i]->sh_name, ".text")) { + if (is_text_section(sh_str + sh_table[i]->sh_name)) { *offset = sh_table[i]->sh_offset; *size = sh_table[i]->sh_size; sh_table[i]->sh_addr = (Elf32_Addr)(uintptr_t)((char *)buf + sh_table[i]->sh_offset); ret = true; - break; + if (*size > 0) { + break; + } } } wasm_runtime_free(sh_table); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf_parser.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf_parser.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/elf_parser.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/elf_parser.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/jit_debug.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/jit_debug.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/jit_debug.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/jit_debug.c index 310662f559f..4b0e46f1d5c 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/jit_debug.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/jit_debug.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/jit_debug.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/jit_debug.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/debug/jit_debug.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/debug/jit_debug.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/iwasm_aot.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/iwasm_aot.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/aot/iwasm_aot.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/aot/iwasm_aot.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_aarch64.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_aarch64.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_aarch64.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_aarch64.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_aarch64_simd.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_aarch64_simd.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_aarch64_simd.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_aarch64_simd.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_arc.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_arc.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_arc.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_arc.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_arm.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_arm.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_arm.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_arm.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_arm_vfp.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_arm_vfp.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_arm_vfp.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_arm_vfp.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_em64.asm b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_em64.asm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_em64.asm rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_em64.asm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_em64.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_em64.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_em64.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_em64.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_em64_simd.asm b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_em64_simd.asm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_em64_simd.asm rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_em64_simd.asm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_em64_simd.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_em64_simd.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_em64_simd.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_em64_simd.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_general.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_general.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_general.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_general.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_ia32.asm b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_ia32.asm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_ia32.asm rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_ia32.asm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_ia32.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_ia32.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_ia32.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_ia32.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_mingw_x64.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_mingw_x64.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_mingw_x64.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_mingw_x64.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_mingw_x64_simd.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_mingw_x64_simd.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_mingw_x64_simd.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_mingw_x64_simd.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_mips.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_mips.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_mips.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_mips.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_osx_universal.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_osx_universal.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_osx_universal.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_osx_universal.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_riscv.S b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_riscv.S similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_riscv.S rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_riscv.S diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_thumb.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_thumb.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_thumb.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_thumb.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_thumb_vfp.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_thumb_vfp.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_thumb_vfp.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_thumb_vfp.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_xtensa.s b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_xtensa.s similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/arch/invokeNative_xtensa.s rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/arch/invokeNative_xtensa.s diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/iwasm_common.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/iwasm_common.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/iwasm_common.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/iwasm_common.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_application.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_application.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_application.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_application.c index 93c9342dace..e13f7f843d0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_application.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_application.c @@ -46,7 +46,7 @@ static union { char b; } __ue = { .a = 1 }; -#define is_little_endian() (__ue.b == 1) +#define is_little_endian() (__ue.b == 1) /* NOLINT */ /** * Implementation of wasm_application_execute_main() diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_blocking_op.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_blocking_op.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_blocking_op.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_blocking_op.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_c_api.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_c_api.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_c_api.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_c_api.c index 57c3ebd0d0c..a9fac87ba4b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_c_api.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_c_api.c @@ -299,6 +299,7 @@ wasm_config_new(void) memset(config, 0, sizeof(wasm_config_t)); config->mem_alloc_type = Alloc_With_System_Allocator; + return config; } @@ -330,7 +331,17 @@ wasm_config_set_linux_perf_opt(wasm_config_t *config, bool enable) if (!config) return NULL; - config->linux_perf_support = enable; + config->enable_linux_perf = enable; + return config; +} + +wasm_config_t * +wasm_config_set_segue_flags(wasm_config_t *config, uint32 segue_flags) +{ + if (!config) + return NULL; + + config->segue_flags = segue_flags; return config; } @@ -367,6 +378,9 @@ wasm_engine_new_internal(wasm_config_t *config) wasm_engine_t *engine = NULL; /* init runtime */ RuntimeInitArgs init_args = { 0 }; +#if WASM_ENABLE_JIT != 0 + LLVMJITOptions *jit_options = wasm_runtime_get_llvm_jit_options(); +#endif #ifndef NDEBUG bh_log_set_verbose_level(BH_LOG_LEVEL_VERBOSE); @@ -380,7 +394,12 @@ wasm_engine_new_internal(wasm_config_t *config) init_args.mem_alloc_type = config->mem_alloc_type; memcpy(&init_args.mem_alloc_option, &config->mem_alloc_option, sizeof(MemAllocOption)); - init_args.linux_perf_support = config->linux_perf_support; + init_args.enable_linux_perf = config->enable_linux_perf; + init_args.segue_flags = config->segue_flags; + +#if WASM_ENABLE_JIT != 0 + jit_options->quick_invoke_c_api_import = true; +#endif if (!wasm_runtime_full_init(&init_args)) { LOG_DEBUG("wasm_runtime_full_init failed"); @@ -1902,10 +1921,28 @@ wasm_frame_func_offset(const wasm_frame_t *frame) return frame ? frame->func_offset : 0; } +void +wasm_frame_vec_clone_internal(Vector *src, Vector *out) +{ + if (src->num_elems == 0) { + bh_vector_destroy(out); + return; + } + + if (!bh_vector_destroy(out) + || !bh_vector_init(out, src->num_elems, sizeof(WASMCApiFrame), false)) { + return; + } + + bh_memcpy_s(out->data, (uint32)(src->num_elems * sizeof(WASMCApiFrame)), + src->data, (uint32)(src->num_elems * sizeof(WASMCApiFrame))); + out->num_elems = src->num_elems; +} + static wasm_trap_t * wasm_trap_new_internal(wasm_store_t *store, WASMModuleInstanceCommon *inst_comm_rt, - const char *error_info) + const char *error_info, Vector *cluster_frames) { wasm_trap_t *trap; #if WASM_ENABLE_DUMP_CALL_STACK != 0 @@ -1935,7 +1972,9 @@ wasm_trap_new_internal(wasm_store_t *store, /* fill in frames */ #if WASM_ENABLE_DUMP_CALL_STACK != 0 - trap->frames = ((WASMModuleInstance *)inst_comm_rt)->frames; + trap->frames = cluster_frames + ? cluster_frames + : ((WASMModuleInstance *)inst_comm_rt)->frames; if (trap->frames) { /* fill in instances */ @@ -2046,10 +2085,7 @@ wasm_trap_trace(const wasm_trap_t *trap, own wasm_frame_vec_t *out) } for (i = 0; i < trap->frames->num_elems; i++) { - wasm_frame_t *frame; - - frame = ((wasm_frame_t *)trap->frames->data) + i; - + wasm_frame_t *frame = ((wasm_frame_t *)trap->frames->data) + i; if (!(out->data[i] = wasm_frame_new(frame->instance, frame->module_offset, frame->func_index, frame->func_offset))) { @@ -2258,7 +2294,7 @@ wasm_module_new(wasm_store_t *store, const wasm_byte_vec_t *binary) (uint8 *)module_ex->binary->data, (uint32)module_ex->binary->size, error_buf, (uint32)sizeof(error_buf)); if (!(module_ex->module_comm_rt)) { - LOG_ERROR(error_buf); + LOG_ERROR("%s", error_buf); goto free_vec; } @@ -2331,7 +2367,7 @@ wasm_module_validate(wasm_store_t *store, const wasm_byte_vec_t *binary) } else { ret = false; - LOG_VERBOSE(error_buf); + LOG_VERBOSE("%s", error_buf); } return ret; @@ -2926,6 +2962,10 @@ wasm_func_new_basic(wasm_store_t *store, const wasm_functype_t *type, if (!(func->type = wasm_functype_copy(type))) { goto failed; } + /* func type's param_count and result_count were checked in + loader and are no larger than UINT16_MAX */ + func->param_count = (uint16)func->type->params->num_elems; + func->result_count = (uint16)func->type->results->num_elems; RETURN_OBJ(func, wasm_func_delete) } @@ -2956,6 +2996,10 @@ wasm_func_new_with_env_basic(wasm_store_t *store, const wasm_functype_t *type, if (!(func->type = wasm_functype_copy(type))) { goto failed; } + /* func type's param_count and result_count were checked in + loader and are no larger than UINT16_MAX */ + func->param_count = (uint16)func->type->params->num_elems; + func->result_count = (uint16)func->type->results->num_elems; RETURN_OBJ(func, wasm_func_delete) } @@ -3045,6 +3089,10 @@ wasm_func_new_internal(wasm_store_t *store, uint16 func_idx_rt, if (!func->type) { goto failed; } + /* func type's param_count and result_count were checked in + loader and are no larger than UINT16_MAX */ + func->param_count = (uint16)func->type->params->num_elems; + func->result_count = (uint16)func->type->results->num_elems; /* will add name information when processing "exports" */ func->store = store; @@ -3136,48 +3184,31 @@ params_to_argv(const wasm_val_vec_t *params, const wasm_valtype_vec_t *param_defs, uint32 *argv, uint32 *ptr_argc) { - size_t i = 0; - - if (!param_defs->num_elems) { - return true; - } + uint32 *argv_org = argv; + const wasm_val_t *param, *param_end; - if (!params || !params->num_elems || !params->size || !params->data) { - LOG_ERROR("the parameter params is invalid"); - return false; - } + bh_assert(params && params->num_elems && params->size && params->data); - *ptr_argc = 0; - for (i = 0; i < param_defs->num_elems; ++i) { - const wasm_val_t *param = params->data + i; - bh_assert((*(param_defs->data + i))->kind == param->kind); + param = params->data; + param_end = param + param_defs->num_elems; + for (; param < param_end; param++) { switch (param->kind) { case WASM_I32: + case WASM_F32: *(int32 *)argv = param->of.i32; argv += 1; - *ptr_argc += 1; break; case WASM_I64: + case WASM_F64: *(int64 *)argv = param->of.i64; argv += 2; - *ptr_argc += 2; break; - case WASM_F32: - *(float32 *)argv = param->of.f32; - argv += 1; - *ptr_argc += 1; - break; - case WASM_F64: - *(float64 *)argv = param->of.f64; - argv += 2; - *ptr_argc += 2; break; #if WASM_ENABLE_REF_TYPES != 0 case WASM_ANYREF: *(uintptr_t *)argv = (uintptr_t)param->of.ref; argv += sizeof(uintptr_t) / sizeof(uint32); - *ptr_argc += 1; break; #endif default: @@ -3186,6 +3217,7 @@ params_to_argv(const wasm_val_vec_t *params, } } + *ptr_argc = (uint32)(argv - argv_org); return true; } @@ -3193,62 +3225,37 @@ static bool argv_to_results(const uint32 *argv, const wasm_valtype_vec_t *result_defs, wasm_val_vec_t *results) { - size_t i = 0, argv_i = 0; + wasm_valtype_t **result_def, **result_def_end; wasm_val_t *result; - if (!result_defs->num_elems) { - return true; - } + bh_assert(results && results->size && results->data); - if (!results || !results->size || !results->data) { - LOG_ERROR("the parameter results is invalid"); - return false; - } + result_def = result_defs->data; + result_def_end = result_def + result_defs->num_elems; + result = results->data; - for (i = 0, result = results->data, argv_i = 0; i < result_defs->num_elems; - i++, result++) { - switch (result_defs->data[i]->kind) { + for (; result_def < result_def_end; result_def++, result++) { + result->kind = result_def[0]->kind; + switch (result->kind) { case WASM_I32: - { - result->kind = WASM_I32; - result->of.i32 = *(int32 *)(argv + argv_i); - argv_i += 1; - break; - } - case WASM_I64: - { - result->kind = WASM_I64; - result->of.i64 = *(int64 *)(argv + argv_i); - argv_i += 2; - break; - } case WASM_F32: - { - result->kind = WASM_F32; - result->of.f32 = *(float32 *)(argv + argv_i); - argv_i += 1; + result->of.i32 = *(int32 *)argv; + argv += 1; break; - } + case WASM_I64: case WASM_F64: - { - result->kind = WASM_F64; - result->of.f64 = *(float64 *)(argv + argv_i); - argv_i += 2; + result->of.i64 = *(int64 *)argv; + argv += 2; break; - } #if WASM_ENABLE_REF_TYPES != 0 case WASM_ANYREF: - { - result->kind = WASM_ANYREF; - result->of.ref = - (struct wasm_ref_t *)(*(uintptr_t *)(argv + argv_i)); - argv_i += sizeof(uintptr_t) / sizeof(uint32); + result->of.ref = (struct wasm_ref_t *)(*(uintptr_t *)argv); + argv += sizeof(uintptr_t) / sizeof(uint32); break; - } #endif default: LOG_WARNING("%s meets unsupported type: %d", __FUNCTION__, - result_defs->data[i]->kind); + result->kind); return false; } } @@ -3268,10 +3275,9 @@ wasm_func_call(const wasm_func_t *func, const wasm_val_vec_t *params, WASMFunctionInstanceCommon *func_comm_rt = NULL; WASMExecEnv *exec_env = NULL; size_t param_count, result_count, alloc_count; + Vector *cluster_frames = NULL; - if (!func) { - return NULL; - } + bh_assert(func && func->type); if (!func->inst_comm_rt) { wasm_name_t message = { 0 }; @@ -3285,17 +3291,14 @@ wasm_func_call(const wasm_func_t *func, const wasm_val_vec_t *params, return trap; } - bh_assert(func->type); - -#if WASM_ENABLE_INTERP != 0 if (func->inst_comm_rt->module_type == Wasm_Module_Bytecode) { +#if WASM_ENABLE_INTERP != 0 func_comm_rt = ((WASMModuleInstance *)func->inst_comm_rt)->e->functions + func->func_idx_rt; - } #endif - + } + else if (func->inst_comm_rt->module_type == Wasm_Module_AoT) { #if WASM_ENABLE_AOT != 0 - if (func->inst_comm_rt->module_type == Wasm_Module_AoT) { if (!(func_comm_rt = func->func_comm_rt)) { AOTModuleInstance *inst_aot = (AOTModuleInstance *)func->inst_comm_rt; @@ -3316,8 +3319,8 @@ wasm_func_call(const wasm_func_t *func, const wasm_val_vec_t *params, } } } - } #endif + } /* * a wrong combination of module filetype and compilation flags @@ -3362,7 +3365,7 @@ wasm_func_call(const wasm_func_t *func, const wasm_val_vec_t *params, wasm_runtime_set_exception(func->inst_comm_rt, NULL); if (!wasm_runtime_call_wasm(exec_env, func_comm_rt, argc, argv)) { if (wasm_runtime_get_exception(func->inst_comm_rt)) { - LOG_DEBUG(wasm_runtime_get_exception(func->inst_comm_rt)); + LOG_DEBUG("%s", wasm_runtime_get_exception(func->inst_comm_rt)); goto failed; } } @@ -3385,27 +3388,32 @@ wasm_func_call(const wasm_func_t *func, const wasm_val_vec_t *params, if (argv != argv_buf) wasm_runtime_free(argv); - return wasm_trap_new_internal( +#if WASM_ENABLE_DUMP_CALL_STACK != 0 && WASM_ENABLE_THREAD_MGR != 0 + WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env); + cluster_frames = &cluster->exception_frames; + wasm_cluster_traverse_lock(exec_env); +#endif + + wasm_trap_t *trap = wasm_trap_new_internal( func->store, func->inst_comm_rt, - wasm_runtime_get_exception(func->inst_comm_rt)); + wasm_runtime_get_exception(func->inst_comm_rt), cluster_frames); + +#if WASM_ENABLE_DUMP_CALL_STACK != 0 && WASM_ENABLE_THREAD_MGR != 0 + wasm_cluster_traverse_unlock(exec_env); +#endif + return trap; } size_t wasm_func_param_arity(const wasm_func_t *func) { - if (!func || !func->type || !func->type->params) { - return 0; - } - return func->type->params->num_elems; + return func->param_count; } size_t wasm_func_result_arity(const wasm_func_t *func) { - if (!func || !func->type || !func->type->results) { - return 0; - } - return func->type->results->num_elems; + return func->result_count; } wasm_global_t * @@ -5042,7 +5050,7 @@ wasm_instance_new_with_args(wasm_store_t *store, const wasm_module_t *module, *trap = wasm_trap_new(store, &message); wasm_byte_vec_delete(&message); } - LOG_DEBUG(error_buf); + LOG_DEBUG("%s", error_buf); wasm_instance_delete_internal(instance); return NULL; } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_c_api_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_c_api_internal.h similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_c_api_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_c_api_internal.h index 6e05eea748c..3967bb274f0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_c_api_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_c_api_internal.h @@ -130,6 +130,8 @@ struct wasm_func_t { struct wasm_host_info host_info; wasm_functype_t *type; + uint16 param_count; + uint16 result_count; bool with_env; union { @@ -238,4 +240,7 @@ wasm_memory_new_internal(wasm_store_t *store, uint16 memory_idx_rt, wasm_table_t * wasm_table_new_internal(wasm_store_t *store, uint16 table_idx_rt, WASMModuleInstanceCommon *inst_comm_rt); + +void +wasm_frame_vec_clone_internal(Vector *src, Vector *out); #endif /* _WASM_C_API_INTERNAL_H */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_exec_env.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_exec_env.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_exec_env.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_exec_env.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_exec_env.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_exec_env.h similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_exec_env.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_exec_env.h index 132642ea8eb..39b782f05a8 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_exec_env.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_exec_env.h @@ -114,6 +114,9 @@ typedef struct WASMExecEnv { /* whether current thread is detached */ bool thread_is_detached; + + /* whether the aux stack is allocated */ + bool is_aux_stack_allocated; #endif #if WASM_ENABLE_DEBUG_INTERP != 0 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_memory.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_memory.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_memory.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_memory.c index 3941c224aa2..2f78b332789 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_memory.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_memory.c @@ -6,7 +6,6 @@ #include "wasm_runtime_common.h" #include "../interpreter/wasm_runtime.h" #include "../aot/aot_runtime.h" -#include "bh_platform.h" #include "mem_alloc.h" #include "wasm_memory.h" @@ -45,11 +44,11 @@ static unsigned int global_pool_size; static bool wasm_memory_init_with_pool(void *mem, unsigned int bytes) { - mem_allocator_t _allocator = mem_allocator_create(mem, bytes); + mem_allocator_t allocator = mem_allocator_create(mem, bytes); - if (_allocator) { + if (allocator) { memory_mode = MEMORY_MODE_POOL; - pool_allocator = _allocator; + pool_allocator = allocator; global_pool_size = bytes; return true; } @@ -76,18 +75,18 @@ wasm_memory_init_with_allocator(void *_user_data, void *_malloc_func, } #else static bool -wasm_memory_init_with_allocator(void *_malloc_func, void *_realloc_func, - void *_free_func) +wasm_memory_init_with_allocator(void *malloc_func_ptr, void *realloc_func_ptr, + void *free_func_ptr) { - if (_malloc_func && _free_func && _malloc_func != _free_func) { + if (malloc_func_ptr && free_func_ptr && malloc_func_ptr != free_func_ptr) { memory_mode = MEMORY_MODE_ALLOCATOR; - malloc_func = _malloc_func; - realloc_func = _realloc_func; - free_func = _free_func; + malloc_func = malloc_func_ptr; + realloc_func = realloc_func_ptr; + free_func = free_func_ptr; return true; } - LOG_ERROR("Init memory with allocator (%p, %p, %p) failed.\n", _malloc_func, - _realloc_func, _free_func); + LOG_ERROR("Init memory with allocator (%p, %p, %p) failed.\n", + malloc_func_ptr, realloc_func_ptr, free_func_ptr); return false; } #endif @@ -96,6 +95,10 @@ static inline bool is_bounds_checks_enabled(WASMModuleInstanceCommon *module_inst) { #if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0 + if (!module_inst) { + return true; + } + return wasm_runtime_is_bounds_checks_enabled(module_inst); #else return true; @@ -111,18 +114,13 @@ wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type, alloc_option->pool.heap_size); } else if (mem_alloc_type == Alloc_With_Allocator) { -#if WASM_MEM_ALLOC_WITH_USER_DATA != 0 return wasm_memory_init_with_allocator( +#if WASM_MEM_ALLOC_WITH_USER_DATA != 0 alloc_option->allocator.user_data, +#endif alloc_option->allocator.malloc_func, alloc_option->allocator.realloc_func, alloc_option->allocator.free_func); -#else - return wasm_memory_init_with_allocator( - alloc_option->allocator.malloc_func, - alloc_option->allocator.realloc_func, - alloc_option->allocator.free_func); -#endif } else if (mem_alloc_type == Alloc_With_System_Allocator) { memory_mode = MEMORY_MODE_SYSTEM_ALLOCATOR; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_memory.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_memory.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_memory.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_memory.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_native.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_native.c new file mode 100644 index 00000000000..d2492bc49f3 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_native.c @@ -0,0 +1,1491 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include "wasm_native.h" +#include "wasm_runtime_common.h" +#include "bh_log.h" +#if WASM_ENABLE_INTERP != 0 +#include "../interpreter/wasm_runtime.h" +#endif +#if WASM_ENABLE_AOT != 0 +#include "../aot/aot_runtime.h" +#endif +#if WASM_ENABLE_THREAD_MGR != 0 +#include "../libraries/thread-mgr/thread_manager.h" +#endif + +static NativeSymbolsList g_native_symbols_list = NULL; + +#if WASM_ENABLE_LIBC_WASI != 0 +static void *g_wasi_context_key; +#endif /* WASM_ENABLE_LIBC_WASI */ + +uint32 +get_libc_builtin_export_apis(NativeSymbol **p_libc_builtin_apis); + +#if WASM_ENABLE_SPEC_TEST != 0 +uint32 +get_spectest_export_apis(NativeSymbol **p_libc_builtin_apis); +#endif + +uint32 +get_libc_wasi_export_apis(NativeSymbol **p_libc_wasi_apis); + +uint32_t +get_wasi_nn_export_apis(NativeSymbol **p_libc_wasi_apis); + +uint32 +get_base_lib_export_apis(NativeSymbol **p_base_lib_apis); + +uint32 +get_ext_lib_export_apis(NativeSymbol **p_ext_lib_apis); + +#if WASM_ENABLE_LIB_PTHREAD != 0 +bool +lib_pthread_init(); + +void +lib_pthread_destroy(); + +uint32 +get_lib_pthread_export_apis(NativeSymbol **p_lib_pthread_apis); +#endif + +#if WASM_ENABLE_LIB_WASI_THREADS != 0 +bool +lib_wasi_threads_init(void); + +void +lib_wasi_threads_destroy(void); + +uint32 +get_lib_wasi_threads_export_apis(NativeSymbol **p_lib_wasi_threads_apis); +#endif + +uint32 +get_libc_emcc_export_apis(NativeSymbol **p_libc_emcc_apis); + +uint32 +get_lib_rats_export_apis(NativeSymbol **p_lib_rats_apis); + +static bool +compare_type_with_signautre(uint8 type, const char signature) +{ + const char num_sig_map[] = { 'F', 'f', 'I', 'i' }; + + if (VALUE_TYPE_F64 <= type && type <= VALUE_TYPE_I32 + && signature == num_sig_map[type - VALUE_TYPE_F64]) { + return true; + } + +#if WASM_ENABLE_REF_TYPES != 0 + if ('r' == signature && type == VALUE_TYPE_EXTERNREF) + return true; +#endif + + /* TODO: a v128 parameter */ + return false; +} + +static bool +check_symbol_signature(const WASMType *type, const char *signature) +{ + const char *p = signature, *p_end; + char sig; + uint32 i = 0; + + if (!p || strlen(p) < 2) + return false; + + p_end = p + strlen(signature); + + if (*p++ != '(') + return false; + + if ((uint32)(p_end - p) < (uint32)(type->param_count + 1)) + /* signatures of parameters, and ')' */ + return false; + + for (i = 0; i < type->param_count; i++) { + sig = *p++; + + /* a f64/f32/i64/i32/externref parameter */ + if (compare_type_with_signautre(type->types[i], sig)) + continue; + + /* a pointer/string paramter */ + if (type->types[i] != VALUE_TYPE_I32) + /* pointer and string must be i32 type */ + return false; + + if (sig == '*') { + /* it is a pointer */ + if (i + 1 < type->param_count + && type->types[i + 1] == VALUE_TYPE_I32 && *p == '~') { + /* pointer length followed */ + i++; + p++; + } + } + else if (sig == '$') { + /* it is a string */ + } + else { + /* invalid signature */ + return false; + } + } + + if (*p++ != ')') + return false; + + if (type->result_count) { + if (p >= p_end) + return false; + + /* result types includes: f64,f32,i64,i32,externref */ + if (!compare_type_with_signautre(type->types[i], *p)) + return false; + + p++; + } + + if (*p != '\0') + return false; + + return true; +} + +static int +native_symbol_cmp(const void *native_symbol1, const void *native_symbol2) +{ + return strcmp(((const NativeSymbol *)native_symbol1)->symbol, + ((const NativeSymbol *)native_symbol2)->symbol); +} + +static void * +lookup_symbol(NativeSymbol *native_symbols, uint32 n_native_symbols, + const char *symbol, const char **p_signature, void **p_attachment) +{ + NativeSymbol *native_symbol, key = { 0 }; + + key.symbol = symbol; + + if ((native_symbol = bsearch(&key, native_symbols, n_native_symbols, + sizeof(NativeSymbol), native_symbol_cmp))) { + *p_signature = native_symbol->signature; + *p_attachment = native_symbol->attachment; + return native_symbol->func_ptr; + } + + return NULL; +} + +/** + * allow func_type and all outputs, like p_signature, p_attachment and + * p_call_conv_raw to be NULL + */ +void * +wasm_native_resolve_symbol(const char *module_name, const char *field_name, + const WASMType *func_type, const char **p_signature, + void **p_attachment, bool *p_call_conv_raw) +{ + NativeSymbolsNode *node, *node_next; + const char *signature = NULL; + void *func_ptr = NULL, *attachment = NULL; + + node = g_native_symbols_list; + while (node) { + node_next = node->next; + if (!strcmp(node->module_name, module_name)) { + if ((func_ptr = + lookup_symbol(node->native_symbols, node->n_native_symbols, + field_name, &signature, &attachment)) + || (field_name[0] == '_' + && (func_ptr = lookup_symbol( + node->native_symbols, node->n_native_symbols, + field_name + 1, &signature, &attachment)))) + break; + } + node = node_next; + } + + if (!p_signature || !p_attachment || !p_call_conv_raw) + return func_ptr; + + if (func_ptr) { + if (signature && signature[0] != '\0') { + /* signature is not empty, check its format */ + if (!func_type || !check_symbol_signature(func_type, signature)) { +#if WASM_ENABLE_WAMR_COMPILER == 0 + /* Output warning except running aot compiler */ + LOG_WARNING("failed to check signature '%s' and resolve " + "pointer params for import function (%s %s)\n", + signature, module_name, field_name); +#endif + return NULL; + } + else + /* Save signature for runtime to do pointer check and + address conversion */ + *p_signature = signature; + } + else + /* signature is empty */ + *p_signature = NULL; + + *p_attachment = attachment; + *p_call_conv_raw = node->call_conv_raw; + } + + return func_ptr; +} + +static bool +register_natives(const char *module_name, NativeSymbol *native_symbols, + uint32 n_native_symbols, bool call_conv_raw) +{ + NativeSymbolsNode *node; + + if (!(node = wasm_runtime_malloc(sizeof(NativeSymbolsNode)))) + return false; +#if WASM_ENABLE_MEMORY_TRACING != 0 + os_printf("Register native, size: %u\n", sizeof(NativeSymbolsNode)); +#endif + + node->module_name = module_name; + node->native_symbols = native_symbols; + node->n_native_symbols = n_native_symbols; + node->call_conv_raw = call_conv_raw; + + /* Add to list head */ + node->next = g_native_symbols_list; + g_native_symbols_list = node; + + qsort(native_symbols, n_native_symbols, sizeof(NativeSymbol), + native_symbol_cmp); + + return true; +} + +bool +wasm_native_register_natives(const char *module_name, + NativeSymbol *native_symbols, + uint32 n_native_symbols) +{ + return register_natives(module_name, native_symbols, n_native_symbols, + false); +} + +bool +wasm_native_register_natives_raw(const char *module_name, + NativeSymbol *native_symbols, + uint32 n_native_symbols) +{ + return register_natives(module_name, native_symbols, n_native_symbols, + true); +} + +bool +wasm_native_unregister_natives(const char *module_name, + NativeSymbol *native_symbols) +{ + NativeSymbolsNode **prevp; + NativeSymbolsNode *node; + + prevp = &g_native_symbols_list; + while ((node = *prevp) != NULL) { + if (node->native_symbols == native_symbols + && !strcmp(node->module_name, module_name)) { + *prevp = node->next; + wasm_runtime_free(node); + return true; + } + prevp = &node->next; + } + return false; +} + +#if WASM_ENABLE_MODULE_INST_CONTEXT != 0 +static uint32 +context_key_to_idx(void *key) +{ + bh_assert(key != NULL); + uint32 idx = (uint32)(uintptr_t)key; + bh_assert(idx > 0); + bh_assert(idx <= WASM_MAX_INSTANCE_CONTEXTS); + return idx - 1; +} + +static void * +context_idx_to_key(uint32 idx) +{ + bh_assert(idx < WASM_MAX_INSTANCE_CONTEXTS); + return (void *)(uintptr_t)(idx + 1); +} + +typedef void (*dtor_t)(WASMModuleInstanceCommon *, void *); +static dtor_t g_context_dtors[WASM_MAX_INSTANCE_CONTEXTS]; + +static void +dtor_noop(WASMModuleInstanceCommon *inst, void *ctx) +{} + +void * +wasm_native_create_context_key(void (*dtor)(WASMModuleInstanceCommon *inst, + void *ctx)) +{ + uint32 i; + for (i = 0; i < WASM_MAX_INSTANCE_CONTEXTS; i++) { + if (g_context_dtors[i] == NULL) { + if (dtor == NULL) { + dtor = dtor_noop; + } + g_context_dtors[i] = dtor; + return context_idx_to_key(i); + } + } + LOG_ERROR("failed to allocate instance context key"); + return NULL; +} + +void +wasm_native_destroy_context_key(void *key) +{ + uint32 idx = context_key_to_idx(key); + bh_assert(g_context_dtors[idx] != NULL); + g_context_dtors[idx] = NULL; +} + +static WASMModuleInstanceExtraCommon * +wasm_module_inst_extra_common(WASMModuleInstanceCommon *inst) +{ +#if WASM_ENABLE_INTERP != 0 + if (inst->module_type == Wasm_Module_Bytecode) { + return &((WASMModuleInstance *)inst)->e->common; + } +#endif +#if WASM_ENABLE_AOT != 0 + if (inst->module_type == Wasm_Module_AoT) { + return &((AOTModuleInstanceExtra *)((AOTModuleInstance *)inst)->e) + ->common; + } +#endif + bh_assert(false); + return NULL; +} + +void +wasm_native_set_context(WASMModuleInstanceCommon *inst, void *key, void *ctx) +{ + uint32 idx = context_key_to_idx(key); + WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst); + common->contexts[idx] = ctx; +} + +void +wasm_native_set_context_spread(WASMModuleInstanceCommon *inst, void *key, + void *ctx) +{ +#if WASM_ENABLE_THREAD_MGR != 0 + wasm_cluster_set_context(inst, key, ctx); +#else + wasm_native_set_context(inst, key, ctx); +#endif +} + +void * +wasm_native_get_context(WASMModuleInstanceCommon *inst, void *key) +{ + uint32 idx = context_key_to_idx(key); + WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst); + return common->contexts[idx]; +} + +void +wasm_native_call_context_dtors(WASMModuleInstanceCommon *inst) +{ + WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst); + uint32 i; + for (i = 0; i < WASM_MAX_INSTANCE_CONTEXTS; i++) { + dtor_t dtor = g_context_dtors[i]; + if (dtor != NULL) { + dtor(inst, common->contexts[i]); + } + } +} + +void +wasm_native_inherit_contexts(WASMModuleInstanceCommon *child, + WASMModuleInstanceCommon *parent) +{ + WASMModuleInstanceExtraCommon *parent_common = + wasm_module_inst_extra_common(parent); + WASMModuleInstanceExtraCommon *child_common = + wasm_module_inst_extra_common(child); + bh_memcpy_s(child_common->contexts, + sizeof(*child_common->contexts) * WASM_MAX_INSTANCE_CONTEXTS, + parent_common->contexts, + sizeof(*parent_common->contexts) * WASM_MAX_INSTANCE_CONTEXTS); +} +#endif /* WASM_ENABLE_MODULE_INST_CONTEXT != 0 */ + +#if WASM_ENABLE_LIBC_WASI != 0 +WASIContext * +wasm_runtime_get_wasi_ctx(WASMModuleInstanceCommon *module_inst_comm) +{ + return wasm_native_get_context(module_inst_comm, g_wasi_context_key); +} + +void +wasm_runtime_set_wasi_ctx(WASMModuleInstanceCommon *module_inst_comm, + WASIContext *wasi_ctx) +{ + wasm_native_set_context(module_inst_comm, g_wasi_context_key, wasi_ctx); +} + +static void +wasi_context_dtor(WASMModuleInstanceCommon *inst, void *ctx) +{ + if (ctx == NULL) { + return; + } + wasm_runtime_destroy_wasi(inst); +} +#endif /* end of WASM_ENABLE_LIBC_WASI */ + +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 +static bool +quick_aot_entry_init(); +#endif + +bool +wasm_native_init() +{ +#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \ + || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \ + || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \ + || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \ + || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0 + NativeSymbol *native_symbols; + uint32 n_native_symbols; +#endif + +#if WASM_ENABLE_LIBC_BUILTIN != 0 + n_native_symbols = get_libc_builtin_export_apis(&native_symbols); + if (!wasm_native_register_natives("env", native_symbols, n_native_symbols)) + goto fail; +#endif /* WASM_ENABLE_LIBC_BUILTIN */ + +#if WASM_ENABLE_SPEC_TEST + n_native_symbols = get_spectest_export_apis(&native_symbols); + if (!wasm_native_register_natives("spectest", native_symbols, + n_native_symbols)) + goto fail; +#endif /* WASM_ENABLE_SPEC_TEST */ + +#if WASM_ENABLE_LIBC_WASI != 0 + g_wasi_context_key = wasm_native_create_context_key(wasi_context_dtor); + if (g_wasi_context_key == NULL) { + goto fail; + } + n_native_symbols = get_libc_wasi_export_apis(&native_symbols); + if (!wasm_native_register_natives("wasi_unstable", native_symbols, + n_native_symbols)) + goto fail; + if (!wasm_native_register_natives("wasi_snapshot_preview1", native_symbols, + n_native_symbols)) + goto fail; +#endif + +#if WASM_ENABLE_BASE_LIB != 0 + n_native_symbols = get_base_lib_export_apis(&native_symbols); + if (n_native_symbols > 0 + && !wasm_native_register_natives("env", native_symbols, + n_native_symbols)) + goto fail; +#endif + +#if WASM_ENABLE_APP_FRAMEWORK != 0 + n_native_symbols = get_ext_lib_export_apis(&native_symbols); + if (n_native_symbols > 0 + && !wasm_native_register_natives("env", native_symbols, + n_native_symbols)) + goto fail; +#endif + +#if WASM_ENABLE_LIB_PTHREAD != 0 + if (!lib_pthread_init()) + goto fail; + + n_native_symbols = get_lib_pthread_export_apis(&native_symbols); + if (n_native_symbols > 0 + && !wasm_native_register_natives("env", native_symbols, + n_native_symbols)) + goto fail; +#endif + +#if WASM_ENABLE_LIB_WASI_THREADS != 0 + if (!lib_wasi_threads_init()) + goto fail; + + n_native_symbols = get_lib_wasi_threads_export_apis(&native_symbols); + if (n_native_symbols > 0 + && !wasm_native_register_natives("wasi", native_symbols, + n_native_symbols)) + goto fail; +#endif + +#if WASM_ENABLE_LIBC_EMCC != 0 + n_native_symbols = get_libc_emcc_export_apis(&native_symbols); + if (n_native_symbols > 0 + && !wasm_native_register_natives("env", native_symbols, + n_native_symbols)) + goto fail; +#endif /* WASM_ENABLE_LIBC_EMCC */ + +#if WASM_ENABLE_LIB_RATS != 0 + n_native_symbols = get_lib_rats_export_apis(&native_symbols); + if (n_native_symbols > 0 + && !wasm_native_register_natives("env", native_symbols, + n_native_symbols)) + goto fail; +#endif /* WASM_ENABLE_LIB_RATS */ + +#if WASM_ENABLE_WASI_NN != 0 + n_native_symbols = get_wasi_nn_export_apis(&native_symbols); + if (!wasm_native_register_natives("wasi_nn", native_symbols, + n_native_symbols)) + goto fail; +#endif + +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 + if (!quick_aot_entry_init()) { +#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \ + || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \ + || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \ + || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \ + || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0 + goto fail; +#else + return false; +#endif + } +#endif + + return true; +#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \ + || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \ + || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \ + || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \ + || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0 +fail: + wasm_native_destroy(); + return false; +#endif +} + +void +wasm_native_destroy() +{ + NativeSymbolsNode *node, *node_next; + +#if WASM_ENABLE_LIBC_WASI != 0 + if (g_wasi_context_key != NULL) { + wasm_native_destroy_context_key(g_wasi_context_key); + g_wasi_context_key = NULL; + } +#endif +#if WASM_ENABLE_LIB_PTHREAD != 0 + lib_pthread_destroy(); +#endif + +#if WASM_ENABLE_LIB_WASI_THREADS != 0 + lib_wasi_threads_destroy(); +#endif + + node = g_native_symbols_list; + while (node) { + node_next = node->next; + wasm_runtime_free(node); + node = node_next; + } + + g_native_symbols_list = NULL; +} + +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 +static void +invoke_no_args_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *) = func_ptr; + native_code(exec_env); +} +static void +invoke_no_args_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *) = func_ptr; + argv_ret[0] = native_code(exec_env); +} +static void +invoke_no_args_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *) = func_ptr; + int64 ret = native_code(exec_env); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_i_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32) = func_ptr; + native_code(exec_env, argv[0]); +} +static void +invoke_i_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0]); +} +static void +invoke_i_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32) = func_ptr; + int64 ret = native_code(exec_env, argv[0]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_I_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv)); +} +static void +invoke_I_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv)); +} +static void +invoke_I_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_ii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int32) = func_ptr; + native_code(exec_env, argv[0], argv[1]); +} +static void +invoke_ii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0], argv[1]); +} +static void +invoke_ii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int32) = func_ptr; + int64 ret = native_code(exec_env, argv[0], argv[1]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int64) = func_ptr; + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1)); +} +static void +invoke_iI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int64) = func_ptr; + argv_ret[0] = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1)); +} +static void +invoke_iI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int64) = func_ptr; + int64 ret = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_Ii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int32) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2]); +} +static void +invoke_Ii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int32) = func_ptr; + argv_ret[0] = + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2]); +} +static void +invoke_Ii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int32) = func_ptr; + int64 ret = + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_II_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int64) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2)); +} +static void +invoke_II_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2)); +} +static void +invoke_II_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int64) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int32, int32) = func_ptr; + native_code(exec_env, argv[0], argv[1], argv[2]); +} +static void +invoke_iii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int32, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0], argv[1], argv[2]); +} +static void +invoke_iii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int32, int32) = func_ptr; + int64 ret = native_code(exec_env, argv[0], argv[1], argv[2]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int32, int64) = func_ptr; + native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2)); +} +static void +invoke_iiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int32, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2)); +} +static void +invoke_iiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int32, int64) = func_ptr; + int64 ret = native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int64, int32) = func_ptr; + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + argv[3]); +} +static void +invoke_iIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int64, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0], + GET_I64_FROM_ADDR((uint32 *)argv + 1), argv[3]); +} +static void +invoke_iIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int64, int32) = func_ptr; + int64 ret = native_code(exec_env, argv[0], + GET_I64_FROM_ADDR((uint32 *)argv + 1), argv[3]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int64, int64) = func_ptr; + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3)); +} +static void +invoke_iII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int64, int64) = func_ptr; + argv_ret[0] = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3)); +} +static void +invoke_iII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int64, int64) = func_ptr; + int64 ret = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_Iii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int32, int32) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], argv[3]); +} +static void +invoke_Iii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int32, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + argv[2], argv[3]); +} +static void +invoke_Iii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int32, int32) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + argv[2], argv[3]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int32, int64) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], + GET_I64_FROM_ADDR((uint32 *)argv + 3)); +} +static void +invoke_IiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int32, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + argv[2], GET_I64_FROM_ADDR((uint32 *)argv + 3)); +} +static void +invoke_IiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int32, int64) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + argv[2], GET_I64_FROM_ADDR((uint32 *)argv + 3)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int64, int32) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]); +} +static void +invoke_IIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int64, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]); +} +static void +invoke_IIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int64, int32) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_III_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int64, int64) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4)); +} +static void +invoke_III_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int64, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4)); +} +static void +invoke_III_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int64, int64) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iiii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int32, int32, int32) = func_ptr; + native_code(exec_env, argv[0], argv[1], argv[2], argv[3]); +} +static void +invoke_iiii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int32, int32, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0], argv[1], argv[2], argv[3]); +} +static void +invoke_iiii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int32, int32, int32) = func_ptr; + int64 ret = native_code(exec_env, argv[0], argv[1], argv[2], argv[3]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iiiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int32, int32, int64) = func_ptr; + native_code(exec_env, argv[0], argv[1], argv[2], + GET_I64_FROM_ADDR((uint32 *)argv + 3)); +} +static void +invoke_iiiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int32, int32, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0], argv[1], argv[2], + GET_I64_FROM_ADDR((uint32 *)argv + 3)); +} +static void +invoke_iiiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int32, int32, int64) = func_ptr; + int64 ret = native_code(exec_env, argv[0], argv[1], argv[2], + GET_I64_FROM_ADDR((uint32 *)argv + 3)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iiIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int32, int64, int32) = func_ptr; + native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]); +} +static void +invoke_iiIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int32, int64, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]); +} +static void +invoke_iiIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int32, int64, int32) = func_ptr; + int64 ret = native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iiII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int32, int64, int64) = func_ptr; + native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4)); +} +static void +invoke_iiII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int32, int64, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4)); +} +static void +invoke_iiII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int32, int64, int64) = func_ptr; + int64 ret = native_code(exec_env, argv[0], argv[1], + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iIii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int64, int32, int32) = func_ptr; + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + argv[3], argv[4]); +} +static void +invoke_iIii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int64, int32, int32) = func_ptr; + argv_ret[0] = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + argv[3], argv[4]); +} +static void +invoke_iIii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int64, int32, int32) = func_ptr; + int64 ret = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + argv[3], argv[4]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iIiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int64, int32, int64) = func_ptr; + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4)); +} +static void +invoke_iIiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int64, int32, int64) = func_ptr; + argv_ret[0] = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4)); +} +static void +invoke_iIiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int64, int32, int64) = func_ptr; + int64 ret = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iIIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int64, int64, int32) = func_ptr; + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]); +} +static void +invoke_iIIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int64, int64, int32) = func_ptr; + argv_ret[0] = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]); +} +static void +invoke_iIIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int64, int64, int32) = func_ptr; + int64 ret = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iIII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int64, int64, int64) = func_ptr; + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3), + GET_I64_FROM_ADDR((uint32 *)argv + 5)); +} +static void +invoke_iIII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int64, int64, int64) = func_ptr; + argv_ret[0] = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3), + GET_I64_FROM_ADDR((uint32 *)argv + 5)); +} +static void +invoke_iIII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int64, int64, int64) = func_ptr; + int64 ret = + native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1), + GET_I64_FROM_ADDR((uint32 *)argv + 3), + GET_I64_FROM_ADDR((uint32 *)argv + 5)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_Iiii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int32, int32, int32) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], argv[3], + argv[4]); +} +static void +invoke_Iiii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int32, int32, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + argv[2], argv[3], argv[4]); +} +static void +invoke_Iiii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int32, int32, int32) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + argv[2], argv[3], argv[4]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IiiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int32, int32, int64) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], argv[3], + GET_I64_FROM_ADDR((uint32 *)argv + 4)); +} + +static void +invoke_IiiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int32, int32, int64) = func_ptr; + argv_ret[0] = + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], + argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4)); +} + +static void +invoke_IiiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int32, int32, int64) = func_ptr; + int64 ret = + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], + argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IiIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int32, int64, int32) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], + GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]); +} +static void +invoke_IiIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int32, int64, int32) = func_ptr; + argv_ret[0] = + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], + GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]); +} +static void +invoke_IiIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int32, int64, int32) = func_ptr; + int64 ret = + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], + GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IiII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int32, int64, int64) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], + GET_I64_FROM_ADDR((uint32 *)argv + 3), + GET_I64_FROM_ADDR((uint32 *)argv + 5)); +} +static void +invoke_IiII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int32, int64, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + argv[2], GET_I64_FROM_ADDR((uint32 *)argv + 3), + GET_I64_FROM_ADDR((uint32 *)argv + 5)); +} +static void +invoke_IiII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int32, int64, int64) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + argv[2], GET_I64_FROM_ADDR((uint32 *)argv + 3), + GET_I64_FROM_ADDR((uint32 *)argv + 5)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IIii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int64, int32, int32) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], argv[5]); +} +static void +invoke_IIii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int64, int32, int32) = func_ptr; + argv_ret[0] = + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], argv[5]); +} +static void +invoke_IIii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int64, int32, int32) = func_ptr; + int64 ret = + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], argv[5]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IIiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int64, int32, int64) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], + GET_I64_FROM_ADDR((uint32 *)argv + 5)); +} +static void +invoke_IIiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int64, int32, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], + GET_I64_FROM_ADDR((uint32 *)argv + 5)); +} +static void +invoke_IIiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int64, int32, int64) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], + GET_I64_FROM_ADDR((uint32 *)argv + 5)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IIIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int64, int64, int32) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4), argv[6]); +} +static void +invoke_IIIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int64, int64, int32) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4), argv[6]); +} +static void +invoke_IIIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int64, int64, int32) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4), argv[6]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_IIII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int64, int64, int64, int64) = func_ptr; + native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4), + GET_I64_FROM_ADDR((uint32 *)argv + 6)); +} +static void +invoke_IIII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int64, int64, int64, int64) = func_ptr; + argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4), + GET_I64_FROM_ADDR((uint32 *)argv + 6)); +} +static void +invoke_IIII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int64, int64, int64, int64) = func_ptr; + int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), + GET_I64_FROM_ADDR((uint32 *)argv + 2), + GET_I64_FROM_ADDR((uint32 *)argv + 4), + GET_I64_FROM_ADDR((uint32 *)argv + 6)); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +static void +invoke_iiiii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + void (*native_code)(WASMExecEnv *, int32, int32, int32, int32, int32) = + func_ptr; + native_code(exec_env, argv[0], argv[1], argv[2], argv[3], argv[4]); +} +static void +invoke_iiiii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int32 (*native_code)(WASMExecEnv *, int32, int32, int32, int32, int32) = + func_ptr; + argv_ret[0] = + native_code(exec_env, argv[0], argv[1], argv[2], argv[3], argv[4]); +} +static void +invoke_iiiii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret) +{ + int64 (*native_code)(WASMExecEnv *, int32, int32, int32, int32, int32) = + func_ptr; + int64 ret = + native_code(exec_env, argv[0], argv[1], argv[2], argv[3], argv[4]); + PUT_I64_TO_ADDR(argv_ret, ret); +} + +typedef struct QuickAOTEntry { + const char *signature; + void *func_ptr; +} QuickAOTEntry; + +/* clang-format off */ +static QuickAOTEntry quick_aot_entries[] = { + { "()v", invoke_no_args_v }, + { "()i", invoke_no_args_i }, + { "()I", invoke_no_args_I }, + + { "(i)v", invoke_i_v }, { "(i)i", invoke_i_i }, { "(i)I", invoke_i_I }, + { "(I)v", invoke_I_v }, { "(I)i", invoke_I_i }, { "(I)I", invoke_I_I }, + + { "(ii)v", invoke_ii_v }, { "(ii)i", invoke_ii_i }, { "(ii)I", invoke_ii_I }, + { "(iI)v", invoke_iI_v }, { "(iI)i", invoke_iI_i }, { "(iI)I", invoke_iI_I }, + { "(Ii)v", invoke_Ii_v }, { "(Ii)i", invoke_Ii_i }, { "(Ii)I", invoke_Ii_I }, + { "(II)v", invoke_II_v }, { "(II)i", invoke_II_i }, { "(II)I", invoke_II_I }, + + { "(iii)v", invoke_iii_v }, { "(iii)i", invoke_iii_i }, { "(iii)I", invoke_iii_I }, + { "(iiI)v", invoke_iiI_v }, { "(iiI)i", invoke_iiI_i }, { "(iiI)I", invoke_iiI_I }, + { "(iIi)v", invoke_iIi_v }, { "(iIi)i", invoke_iIi_i }, { "(iIi)I", invoke_iIi_I }, + { "(iII)v", invoke_iII_v }, { "(iII)i", invoke_iII_i }, { "(iII)I", invoke_iII_I }, + { "(Iii)v", invoke_Iii_v }, { "(Iii)i", invoke_Iii_i }, { "(Iii)I", invoke_Iii_I }, + { "(IiI)v", invoke_IiI_v }, { "(IiI)i", invoke_IiI_i }, { "(IiI)I", invoke_IiI_I }, + { "(IIi)v", invoke_IIi_v }, { "(IIi)i", invoke_IIi_i }, { "(IIi)I", invoke_IIi_I }, + { "(III)v", invoke_III_v }, { "(III)i", invoke_III_i }, { "(III)I", invoke_III_I }, + + { "(iiii)v", invoke_iiii_v }, { "(iiii)i", invoke_iiii_i }, { "(iiii)I", invoke_iiii_I }, + { "(iiiI)v", invoke_iiiI_v }, { "(iiiI)i", invoke_iiiI_i }, { "(iiiI)I", invoke_iiiI_I }, + { "(iiIi)v", invoke_iiIi_v }, { "(iiIi)i", invoke_iiIi_i }, { "(iiIi)I", invoke_iiIi_I }, + { "(iiII)v", invoke_iiII_v }, { "(iiII)i", invoke_iiII_i }, { "(iiII)I", invoke_iiII_I }, + { "(iIii)v", invoke_iIii_v }, { "(iIii)i", invoke_iIii_i }, { "(iIii)I", invoke_iIii_I }, + { "(iIiI)v", invoke_iIiI_v }, { "(iIiI)i", invoke_iIiI_i }, { "(iIiI)I", invoke_iIiI_I }, + { "(iIIi)v", invoke_iIIi_v }, { "(iIIi)i", invoke_iIIi_i }, { "(iIIi)I", invoke_iIIi_I }, + { "(iIII)v", invoke_iIII_v }, { "(iIII)i", invoke_iIII_i }, { "(iIII)I", invoke_iIII_I }, + { "(Iiii)v", invoke_Iiii_v }, { "(Iiii)i", invoke_Iiii_i }, { "(Iiii)I", invoke_Iiii_I }, + { "(IiiI)v", invoke_IiiI_v }, { "(IiiI)i", invoke_IiiI_i }, { "(IiiI)I", invoke_IiiI_I }, + { "(IiIi)v", invoke_IiIi_v }, { "(IiIi)i", invoke_IiIi_i }, { "(IiIi)I", invoke_IiIi_I }, + { "(IiII)v", invoke_IiII_v }, { "(IiII)i", invoke_IiII_i }, { "(IiII)I", invoke_IiII_I }, + { "(IIii)v", invoke_IIii_v }, { "(IIii)i", invoke_IIii_i }, { "(IIii)I", invoke_IIii_I }, + { "(IIiI)v", invoke_IIiI_v }, { "(IIiI)i", invoke_IIiI_i }, { "(IIiI)I", invoke_IIiI_I }, + { "(IIIi)v", invoke_IIIi_v }, { "(IIIi)i", invoke_IIIi_i }, { "(IIIi)I", invoke_IIIi_I }, + { "(IIII)v", invoke_IIII_v }, { "(IIII)i", invoke_IIII_i }, { "(IIII)I", invoke_IIII_I }, + + { "(iiiii)v", invoke_iiiii_v }, { "(iiiii)i", invoke_iiiii_i }, { "(iiiii)I", invoke_iiiii_I }, +}; +/* clang-format on */ + +static int +quick_aot_entry_cmp(const void *quick_aot_entry1, const void *quick_aot_entry2) +{ + return strcmp(((const QuickAOTEntry *)quick_aot_entry1)->signature, + ((const QuickAOTEntry *)quick_aot_entry2)->signature); +} + +static bool +quick_aot_entry_init() +{ + qsort(quick_aot_entries, sizeof(quick_aot_entries) / sizeof(QuickAOTEntry), + sizeof(QuickAOTEntry), quick_aot_entry_cmp); + + return true; +} + +void * +wasm_native_lookup_quick_aot_entry(const WASMType *func_type) +{ + char signature[16] = { 0 }; + uint32 param_count = func_type->param_count; + uint32 result_count = func_type->result_count, i, j = 0; + const uint8 *types = func_type->types; + QuickAOTEntry *quick_aot_entry, key = { 0 }; + + if (param_count > 5 || result_count > 1) + return NULL; + + signature[j++] = '('; + + for (i = 0; i < param_count; i++) { + if (types[i] == VALUE_TYPE_I32) + signature[j++] = 'i'; + else if (types[i] == VALUE_TYPE_I64) + signature[j++] = 'I'; + else + return NULL; + } + + signature[j++] = ')'; + + if (result_count == 0) { + signature[j++] = 'v'; + } + else { + if (types[i] == VALUE_TYPE_I32) + signature[j++] = 'i'; + else if (types[i] == VALUE_TYPE_I64) + signature[j++] = 'I'; + else + return NULL; + } + + key.signature = signature; + if ((quick_aot_entry = + bsearch(&key, quick_aot_entries, + sizeof(quick_aot_entries) / sizeof(QuickAOTEntry), + sizeof(QuickAOTEntry), quick_aot_entry_cmp))) { + return quick_aot_entry->func_ptr; + } + + return NULL; +} +#endif /* end of WASM_ENABLE_QUICK_AOT_ENTRY != 0 */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_native.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_native.h similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_native.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_native.h index 9ca5265c3ba..591bbe2ff3e 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_native.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_native.h @@ -104,6 +104,11 @@ wasm_native_init(); void wasm_native_destroy(); +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 +void * +wasm_native_lookup_quick_aot_entry(const WASMType *func_type); +#endif + #ifdef __cplusplus } #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_runtime_common.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_runtime_common.c similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_runtime_common.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_runtime_common.c index 567e77bec40..c8b0d0d3cf4 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_runtime_common.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_runtime_common.c @@ -158,6 +158,8 @@ static JitCompOptions jit_options = { 0 }; #endif #if WASM_ENABLE_JIT != 0 +/* opt_level: 3, size_level: 3, segue-flags: 0, + quick_invoke_c_api_import: false */ static LLVMJITOptions llvm_jit_options = { 3, 3, 0, false }; #endif @@ -267,10 +269,10 @@ decode_insn(uint8 *insn) runtime_address); /* Print current instruction */ - /* +#if 0 os_printf("%012" PRIX64 " ", runtime_address); puts(buffer); - */ +#endif return instruction.length; } @@ -638,10 +640,10 @@ wasm_runtime_get_default_running_mode(void) } #if WASM_ENABLE_JIT != 0 -LLVMJITOptions +LLVMJITOptions * wasm_runtime_get_llvm_jit_options(void) { - return llvm_jit_options; + return &llvm_jit_options; } #endif @@ -662,14 +664,17 @@ wasm_runtime_full_init(RuntimeInitArgs *init_args) #endif #if WASM_ENABLE_JIT != 0 - LOG_DEBUG("Start LLVM_JIT, opt_sz=%u, opt_lvl=%u, segue=%s, linux_perf=%s", - init_args->llvm_jit_size_level, init_args->llvm_jit_opt_level, - init_args->segue_flags ? "Yes" : "No", - init_args->linux_perf_support ? "Yes" : "No"); llvm_jit_options.size_level = init_args->llvm_jit_size_level; llvm_jit_options.opt_level = init_args->llvm_jit_opt_level; llvm_jit_options.segue_flags = init_args->segue_flags; - llvm_jit_options.linux_perf_support = init_args->linux_perf_support; +#endif + +#if WASM_ENABLE_LINUX_PERF != 0 + wasm_runtime_set_linux_perf(init_args->enable_linux_perf); +#else + if (init_args->enable_linux_perf) + LOG_WARNING("warning: to enable linux perf support, please recompile " + "with -DWAMR_BUILD_LINUX_PERF=1"); #endif if (!wasm_runtime_env_init()) { @@ -701,6 +706,12 @@ wasm_runtime_full_init(RuntimeInitArgs *init_args) return true; } +void +wasm_runtime_set_log_level(log_level_t level) +{ + bh_log_set_verbose_level(level); +} + bool wasm_runtime_is_running_mode_supported(RunningMode running_mode) { @@ -774,6 +785,7 @@ align_ptr(const uint8 *p, uint32 b) return false; \ } while (0) +/* NOLINTNEXTLINE */ #define read_uint16(p, p_end, res) \ do { \ p = (uint8 *)align_ptr(p, sizeof(uint16)); \ @@ -782,6 +794,7 @@ align_ptr(const uint8 *p, uint32 b) p += sizeof(uint16); \ } while (0) +/* NOLINTNEXTLINE */ #define read_uint32(p, p_end, res) \ do { \ p = (uint8 *)align_ptr(p, sizeof(uint32)); \ @@ -933,7 +946,7 @@ wasm_runtime_register_module_internal(const char *module_name, /* module hasn't been registered */ node = runtime_malloc(sizeof(WASMRegisteredModule), NULL, NULL, 0); if (!node) { - LOG_DEBUG("malloc WASMRegisteredModule failed. SZ=%d", + LOG_DEBUG("malloc WASMRegisteredModule failed. SZ=%zu", sizeof(WASMRegisteredModule)); return false; } @@ -1679,8 +1692,43 @@ wasm_runtime_dump_perf_profiling(WASMModuleInstanceCommon *module_inst) } #endif } + +double +wasm_runtime_sum_wasm_exec_time(WASMModuleInstanceCommon *inst) +{ +#if WASM_ENABLE_INTERP != 0 + if (inst->module_type == Wasm_Module_Bytecode) + return wasm_summarize_wasm_execute_time((WASMModuleInstance *)inst); +#endif + +#if WASM_ENABLE_AOT != 0 + if (inst->module_type == Wasm_Module_AoT) + return aot_summarize_wasm_execute_time((AOTModuleInstance *)inst); #endif + return 0.0; +} + +double +wasm_runtime_get_wasm_func_exec_time(WASMModuleInstanceCommon *inst, + const char *func_name) +{ +#if WASM_ENABLE_INTERP != 0 + if (inst->module_type == Wasm_Module_Bytecode) + return wasm_get_wasm_func_exec_time((WASMModuleInstance *)inst, + func_name); +#endif + +#if WASM_ENABLE_AOT != 0 + if (inst->module_type == Wasm_Module_AoT) + return aot_get_wasm_func_exec_time((AOTModuleInstance *)inst, + func_name); +#endif + + return 0.0; +} +#endif /* WASM_ENABLE_PERF_PROFILING != 0 */ + WASMModuleInstanceCommon * wasm_runtime_get_module_inst(WASMExecEnv *exec_env) { @@ -2542,7 +2590,6 @@ wasm_runtime_clear_exception(WASMModuleInstanceCommon *module_inst_comm) wasm_runtime_set_exception(module_inst_comm, NULL); } -#if WASM_ENABLE_THREAD_MGR != 0 void wasm_runtime_terminate(WASMModuleInstanceCommon *module_inst_comm) { @@ -2552,7 +2599,6 @@ wasm_runtime_terminate(WASMModuleInstanceCommon *module_inst_comm) || module_inst_comm->module_type == Wasm_Module_AoT); wasm_set_exception(module_inst, "terminated by user"); } -#endif void wasm_runtime_set_custom_data_internal( @@ -2861,7 +2907,8 @@ copy_string_array(const char *array[], uint32 array_size, char **buf_ptr, /* We add +1 to generate null-terminated array of strings */ total_size = sizeof(char *) * ((uint64)array_size + 1); if (total_size >= UINT32_MAX - || (total_size > 0 && !(list = wasm_runtime_malloc((uint32)total_size))) + /* total_size must be larger than 0, don' check it again */ + || !(list = wasm_runtime_malloc((uint32)total_size)) || buf_size >= UINT32_MAX || (buf_size > 0 && !(buf = wasm_runtime_malloc((uint32)buf_size)))) { @@ -3492,7 +3539,7 @@ static union { char b; } __ue = { .a = 1 }; -#define is_little_endian() (__ue.b == 1) +#define is_little_endian() (__ue.b == 1) /* NOLINT */ bool wasm_runtime_register_natives(const char *module_name, @@ -3527,7 +3574,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr, { WASMModuleInstanceCommon *module = wasm_runtime_get_module_inst(exec_env); typedef void (*NativeRawFuncPtr)(WASMExecEnv *, uint64 *); - NativeRawFuncPtr invokeNativeRaw = (NativeRawFuncPtr)func_ptr; + NativeRawFuncPtr invoke_native_raw = (NativeRawFuncPtr)func_ptr; uint64 argv_buf[16] = { 0 }, *argv1 = argv_buf, *argv_dst, size; uint32 *argv_src = argv, i, argc1, ptr_len; uint32 arg_i32; @@ -3615,7 +3662,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr, } exec_env->attachment = attachment; - invokeNativeRaw(exec_env, argv1); + invoke_native_raw(exec_env, argv1); exec_env->attachment = NULL; if (func_type->result_count > 0) { @@ -4401,6 +4448,7 @@ typedef int64 (*Int64FuncPtr)(GenericFunctionPointer, uint64 *, uint64); typedef int32 (*Int32FuncPtr)(GenericFunctionPointer, uint64 *, uint64); typedef void (*VoidFuncPtr)(GenericFunctionPointer, uint64 *, uint64); +/* NOLINTBEGIN */ static volatile Float64FuncPtr invokeNative_Float64 = (Float64FuncPtr)(uintptr_t)invokeNative; static volatile Float32FuncPtr invokeNative_Float32 = @@ -4416,6 +4464,7 @@ static volatile VoidFuncPtr invokeNative_Void = typedef v128 (*V128FuncPtr)(GenericFunctionPointer, uint64 *, uint64); static V128FuncPtr invokeNative_V128 = (V128FuncPtr)(uintptr_t)invokeNative; #endif +/* NOLINTEND */ #if defined(_WIN32) || defined(_WIN32_) #define MAX_REG_FLOATS 4 @@ -4984,6 +5033,7 @@ wasm_externref_set_cleanup(WASMModuleInstanceCommon *module_inst, if (lookup_user_data.found) { void *key = (void *)(uintptr_t)lookup_user_data.externref_idx; ExternRefMapNode *node = bh_hash_map_find(externref_map, key); + bh_assert(node); node->cleanup = extern_obj_cleanup; ok = true; } @@ -5668,7 +5718,7 @@ wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst, wasm_val_t *params = params_buf, *results = results_buf; wasm_trap_t *trap = NULL; bool ret = false; - wasm_val_vec_t params_vec, results_vec; + wasm_val_vec_t params_vec = { 0 }, results_vec = { 0 }; if (func_type->param_count > 16) { if (!(params = @@ -5696,12 +5746,10 @@ wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst, params_vec.data = params; params_vec.num_elems = func_type->param_count; params_vec.size = func_type->param_count; - params_vec.size_of_elem = sizeof(wasm_val_t); results_vec.data = results; results_vec.num_elems = 0; results_vec.size = func_type->result_count; - results_vec.size_of_elem = sizeof(wasm_val_t); if (!with_env) { wasm_func_callback_t callback = (wasm_func_callback_t)func_ptr; @@ -5737,7 +5785,6 @@ wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst, wasm_runtime_set_exception(module_inst, "unsupported result type"); goto fail; } - results_vec.num_elems = func_type->result_count; ret = true; fail: @@ -5748,6 +5795,71 @@ wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst, return ret; } +bool +wasm_runtime_quick_invoke_c_api_native(WASMModuleInstanceCommon *inst_comm, + CApiFuncImport *c_api_import, + wasm_val_t *params, uint32 param_count, + wasm_val_t *results, uint32 result_count) +{ + WASMModuleInstance *module_inst = (WASMModuleInstance *)inst_comm; + void *func_ptr = c_api_import->func_ptr_linked; + bool with_env_arg = c_api_import->with_env_arg, ret = true; + wasm_val_vec_t params_vec = { 0 }, results_vec = { 0 }; + wasm_trap_t *trap = NULL; + + params_vec.data = params; + params_vec.num_elems = param_count; + params_vec.size = param_count; + + results_vec.data = results; + results_vec.num_elems = 0; + results_vec.size = result_count; + + if (!func_ptr) { + wasm_set_exception_with_id(module_inst, EXCE_CALL_UNLINKED_IMPORT_FUNC); + ret = false; + goto fail; + } + + if (!with_env_arg) { + wasm_func_callback_t callback = (wasm_func_callback_t)func_ptr; + trap = callback(¶ms_vec, &results_vec); + } + else { + void *wasm_c_api_env = c_api_import->env_arg; + wasm_func_callback_with_env_t callback = + (wasm_func_callback_with_env_t)func_ptr; + trap = callback(wasm_c_api_env, ¶ms_vec, &results_vec); + } + + if (trap) { + if (trap->message->data) { + /* since trap->message->data does not end with '\0' */ + char trap_message[108] = { 0 }; + uint32 max_size_to_copy = (uint32)sizeof(trap_message) - 1; + uint32 size_to_copy = (trap->message->size < max_size_to_copy) + ? (uint32)trap->message->size + : max_size_to_copy; + bh_memcpy_s(trap_message, (uint32)sizeof(trap_message), + trap->message->data, size_to_copy); + wasm_set_exception(module_inst, trap_message); + } + else { + wasm_set_exception(module_inst, + "native function throw unknown exception"); + } + wasm_trap_delete(trap); + ret = false; + } + +fail: +#ifdef OS_ENABLE_HW_BOUND_CHECK + if (!ret) + wasm_runtime_access_exce_check_guard_page(); +#endif + return ret; +} + void wasm_runtime_show_app_heap_corrupted_prompt() { @@ -5950,12 +6062,12 @@ wasm_runtime_load_depended_module(const WASMModuleCommon *parent_module, if (!ret) { LOG_DEBUG("read the file of %s failed", sub_module_name); set_error_buf_v(parent_module, error_buf, error_buf_size, - "unknown import", sub_module_name); + "unknown import %s", sub_module_name); goto delete_loading_module; } if (get_package_type(buffer, buffer_size) != parent_module->module_type) { LOG_DEBUG("moudle %s type error", sub_module_name); - goto delete_loading_module; + goto destroy_file_buffer; } if (get_package_type(buffer, buffer_size) == Wasm_Module_Bytecode) { #if WASM_ENABLE_INTERP != 0 @@ -6060,7 +6172,7 @@ wasm_runtime_sub_module_instantiate(WASMModuleCommon *module, sub_module_inst_list_node = loader_malloc(sizeof(WASMSubModInstNode), error_buf, error_buf_size); if (!sub_module_inst_list_node) { - LOG_DEBUG("Malloc WASMSubModInstNode failed, SZ:%d", + LOG_DEBUG("Malloc WASMSubModInstNode failed, SZ: %zu", sizeof(WASMSubModInstNode)); if (sub_module_inst) wasm_runtime_deinstantiate_internal(sub_module_inst, false); @@ -6142,3 +6254,83 @@ wasm_runtime_get_context(WASMModuleInstanceCommon *inst, void *key) return wasm_native_get_context(inst, key); } #endif /* WASM_ENABLE_MODULE_INST_CONTEXT != 0 */ + +#if WASM_ENABLE_LINUX_PERF != 0 +static bool enable_linux_perf = false; + +bool +wasm_runtime_get_linux_perf(void) +{ + return enable_linux_perf; +} + +void +wasm_runtime_set_linux_perf(bool flag) +{ + enable_linux_perf = flag; +} +#endif + +#ifdef WASM_LINEAR_MEMORY_MMAP +void +wasm_munmap_linear_memory(void *mapped_mem, uint64 commit_size, uint64 map_size) +{ +#ifdef BH_PLATFORM_WINDOWS + os_mem_decommit(mapped_mem, commit_size); +#else + (void)commit_size; +#endif + os_munmap(mapped_mem, map_size); +} + +void * +wasm_mmap_linear_memory(uint64_t map_size, uint64 *io_memory_data_size, + char *error_buf, uint32 error_buf_size) +{ + uint64 page_size = os_getpagesize(); + void *mapped_mem = NULL; + uint64 memory_data_size; + + bh_assert(io_memory_data_size); + + memory_data_size = + (*io_memory_data_size + page_size - 1) & ~(page_size - 1); + + if (memory_data_size > UINT32_MAX) + memory_data_size = UINT32_MAX; + + if (!(mapped_mem = os_mmap(NULL, map_size, MMAP_PROT_NONE, MMAP_MAP_NONE, + os_get_invalid_handle()))) { + set_error_buf(error_buf, error_buf_size, "mmap memory failed"); + goto fail1; + } + +#ifdef BH_PLATFORM_WINDOWS + if (memory_data_size > 0 + && !os_mem_commit(mapped_mem, memory_data_size, + MMAP_PROT_READ | MMAP_PROT_WRITE)) { + set_error_buf(error_buf, error_buf_size, "commit memory failed"); + os_munmap(mapped_mem, map_size); + goto fail1; + } +#endif + + if (os_mprotect(mapped_mem, memory_data_size, + MMAP_PROT_READ | MMAP_PROT_WRITE) + != 0) { + set_error_buf(error_buf, error_buf_size, "mprotect memory failed"); + goto fail2; + } + + /* Newly allocated pages are filled with zero by the OS, we don't fill it + * again here */ + + *io_memory_data_size = memory_data_size; + + return mapped_mem; +fail2: + wasm_munmap_linear_memory(mapped_mem, memory_data_size, map_size); +fail1: + return NULL; +} +#endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_runtime_common.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_runtime_common.h similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_runtime_common.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_runtime_common.h index 2908cafb5f8..070c44d4e1b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_runtime_common.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_runtime_common.h @@ -54,6 +54,12 @@ STORE_U16(void *addr, uint16_t value) { *(uint16_t *)(addr) = (uint16_t)(value); } +static inline void +STORE_U8(void *addr, uint8_t value) +{ + *(uint8 *)addr = value; +} + /* For LOAD opcodes */ #define LOAD_I64(addr) (*(int64 *)(addr)) #define LOAD_F64(addr) (*(float64 *)(addr)) @@ -173,6 +179,13 @@ STORE_U32(void *addr, uint32_t value) } } } + +static inline void +STORE_U8(void *addr, uint8_t value) +{ + *(uint8 *)addr = value; +} + static inline void STORE_U16(void *addr, uint16_t value) { @@ -307,6 +320,11 @@ LOAD_I16(void *addr) #define SHARED_MEMORY_UNLOCK(memory) (void)0 #endif +#if defined(OS_ENABLE_HW_BOUND_CHECK) \ + || (WASM_ENABLE_SHARED_MEMORY != 0 && WASM_ENABLE_SHARED_MEMORY_MMAP != 0) +#define WASM_LINEAR_MEMORY_MMAP +#endif + typedef struct WASMModuleCommon { /* Module type, for module loaded from WASM bytecode binary, this field is Wasm_Module_Bytecode, and this structure should @@ -318,7 +336,7 @@ typedef struct WASMModuleCommon { /* The following uint8[1] member is a dummy just to indicate some module_type dependent members follow. - Typically it should be accessed by casting to the corresponding + Typically, it should be accessed by casting to the corresponding actual module_type dependent structure, not via this member. */ uint8 module_data[1]; } WASMModuleCommon; @@ -334,7 +352,7 @@ typedef struct WASMModuleInstanceCommon { /* The following uint8[1] member is a dummy just to indicate some module_type dependent members follow. - Typically it should be accessed by casting to the corresponding + Typically, it should be accessed by casting to the corresponding actual module_type dependent structure, not via this member. */ uint8 module_inst_data[1]; } WASMModuleInstanceCommon; @@ -425,12 +443,12 @@ typedef struct wasm_frame_t { const char *func_name_wp; } WASMCApiFrame; -#ifdef WASM_ENABLE_JIT +#if WASM_ENABLE_JIT != 0 typedef struct LLVMJITOptions { uint32 opt_level; uint32 size_level; uint32 segue_flags; - bool linux_perf_support; + bool quick_invoke_c_api_import; } LLVMJITOptions; #endif @@ -464,7 +482,7 @@ wasm_runtime_get_default_running_mode(void); #if WASM_ENABLE_JIT != 0 /* Internal API */ -LLVMJITOptions +LLVMJITOptions * wasm_runtime_get_llvm_jit_options(void); #endif @@ -1067,9 +1085,27 @@ wasm_runtime_invoke_c_api_native(WASMModuleInstanceCommon *module_inst, uint32 argc, uint32 *argv, bool with_env, void *wasm_c_api_env); +struct CApiFuncImport; +/* A quick version of wasm_runtime_invoke_c_api_native to directly invoke + wasm-c-api import function from jitted code to improve performance */ +bool +wasm_runtime_quick_invoke_c_api_native(WASMModuleInstanceCommon *module_inst, + struct CApiFuncImport *c_api_import, + wasm_val_t *params, uint32 param_count, + wasm_val_t *results, + uint32 result_count); + void wasm_runtime_show_app_heap_corrupted_prompt(); +void +wasm_munmap_linear_memory(void *mapped_mem, uint64 commit_size, + uint64 map_size); + +void * +wasm_mmap_linear_memory(uint64_t map_size, uint64 *io_memory_data_size, + char *error_buf, uint32 error_buf_size); + #if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 void wasm_runtime_destroy_custom_sections(WASMCustomSection *section_list); @@ -1092,6 +1128,14 @@ wasm_runtime_end_blocking_op(WASMExecEnv *exec_env); void wasm_runtime_interrupt_blocking_op(WASMExecEnv *exec_env); +#if WASM_ENABLE_LINUX_PERF != 0 +bool +wasm_runtime_get_linux_perf(void); + +void +wasm_runtime_set_linux_perf(bool flag); +#endif + #ifdef __cplusplus } #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_shared_memory.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_shared_memory.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_shared_memory.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_shared_memory.c index 70e84a37504..3856b7d19c6 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_shared_memory.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_shared_memory.c @@ -176,8 +176,9 @@ acquire_wait_info(void *address, AtomicWaitNode *wait_node) AtomicWaitInfo *wait_info = NULL; bh_list_status ret; - if (address) - wait_info = (AtomicWaitInfo *)bh_hash_map_find(wait_map, address); + bh_assert(address != NULL); + + wait_info = (AtomicWaitInfo *)bh_hash_map_find(wait_map, address); if (!wait_node) { return wait_info; @@ -231,14 +232,14 @@ destroy_wait_info(void *wait_info) } static void -map_try_release_wait_info(HashMap *wait_map_, AtomicWaitInfo *wait_info, +map_try_release_wait_info(HashMap *wait_hash_map, AtomicWaitInfo *wait_info, void *address) { if (wait_info->wait_list->len > 0) { return; } - bh_hash_map_remove(wait_map_, address, NULL, NULL); + bh_hash_map_remove(wait_hash_map, address, NULL, NULL); destroy_wait_info(wait_info); } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_shared_memory.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_shared_memory.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_shared_memory.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_shared_memory.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_suspend_flags.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_suspend_flags.h similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_suspend_flags.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_suspend_flags.h index b182b2b5f00..92661b7bdee 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/common/wasm_suspend_flags.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/common/wasm_suspend_flags.h @@ -35,6 +35,8 @@ typedef union WASMSuspendFlags { #define WASM_SUSPEND_FLAGS_FETCH_AND(s_flags, val) \ BH_ATOMIC_32_FETCH_AND(s_flags.flags, val) +#define WASM_SUSPEND_FLAG_INHERIT_MASK (~WASM_SUSPEND_FLAG_BLOCKING) + #if WASM_SUSPEND_FLAGS_IS_ATOMIC != 0 #define WASM_SUSPEND_FLAGS_LOCK(lock) (void)0 #define WASM_SUSPEND_FLAGS_UNLOCK(lock) (void)0 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_compiler.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_compiler.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_compiler.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_compiler.c index 464ca61f321..6703a0e536a 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_compiler.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_compiler.c @@ -196,7 +196,9 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) location = dwarf_gen_location( comp_ctx, func_ctx, (frame_ip - 1) - comp_ctx->comp_data->wasm_module->buf_code); - LLVMSetCurrentDebugLocation2(comp_ctx->builder, location); + if (location != NULL) { + LLVMSetCurrentDebugLocation2(comp_ctx->builder, location); + } #endif switch (opcode) { @@ -1050,7 +1052,9 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) uint32 opcode1; read_leb_uint32(frame_ip, frame_ip_end, opcode1); - opcode = (uint32)opcode1; + /* opcode1 was checked in loader and is no larger than + UINT8_MAX */ + opcode = (uint8)opcode1; #if WASM_ENABLE_BULK_MEMORY != 0 if (WASM_OP_MEMORY_INIT <= opcode @@ -1211,10 +1215,13 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) case WASM_OP_ATOMIC_PREFIX: { uint8 bin_op, op_type; + uint32 opcode1; + + read_leb_uint32(frame_ip, frame_ip_end, opcode1); + /* opcode1 was checked in loader and is no larger than + UINT8_MAX */ + opcode = (uint8)opcode1; - if (frame_ip < frame_ip_end) { - opcode = *frame_ip++; - } if (opcode != WASM_OP_ATOMIC_FENCE) { read_leb_uint32(frame_ip, frame_ip_end, align); read_leb_uint32(frame_ip, frame_ip_end, offset); @@ -1364,11 +1371,17 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) #if WASM_ENABLE_SIMD != 0 case WASM_OP_SIMD_PREFIX: { + uint32 opcode1; + if (!comp_ctx->enable_simd) { goto unsupport_simd; } - opcode = *frame_ip++; + read_leb_uint32(frame_ip, frame_ip_end, opcode1); + /* opcode1 was checked in loader and is no larger than + UINT8_MAX */ + opcode = (uint8)opcode1; + /* follow the order of enum WASMSimdEXTOpcode in wasm_opcode.h */ switch (opcode) { @@ -2123,16 +2136,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) break; } - case SIMD_i32x4_narrow_i64x2_s: - case SIMD_i32x4_narrow_i64x2_u: - { - if (!aot_compile_simd_i32x4_narrow_i64x2( - comp_ctx, func_ctx, - SIMD_i32x4_narrow_i64x2_s == opcode)) - return false; - break; - } - case SIMD_i32x4_extend_low_i16x8_s: case SIMD_i32x4_extend_high_i16x8_s: { @@ -2172,16 +2175,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) break; } - case SIMD_i32x4_add_sat_s: - case SIMD_i32x4_add_sat_u: - { - if (!aot_compile_simd_i32x4_saturate( - comp_ctx, func_ctx, V128_ADD, - opcode == SIMD_i32x4_add_sat_s)) - return false; - break; - } - case SIMD_i32x4_sub: { if (!aot_compile_simd_i32x4_arith(comp_ctx, func_ctx, @@ -2190,16 +2183,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) break; } - case SIMD_i32x4_sub_sat_s: - case SIMD_i32x4_sub_sat_u: - { - if (!aot_compile_simd_i32x4_saturate( - comp_ctx, func_ctx, V128_SUB, - opcode == SIMD_i32x4_add_sat_s)) - return false; - break; - } - case SIMD_i32x4_mul: { if (!aot_compile_simd_i32x4_arith(comp_ctx, func_ctx, @@ -2236,13 +2219,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) break; } - case SIMD_i32x4_avgr_u: - { - if (!aot_compile_simd_i32x4_avgr_u(comp_ctx, func_ctx)) - return false; - break; - } - case SIMD_i32x4_extmul_low_i16x8_s: case SIMD_i32x4_extmul_high_i16x8_s: { @@ -2399,13 +2375,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) break; } - case SIMD_f32x4_round: - { - if (!aot_compile_simd_f32x4_round(comp_ctx, func_ctx)) - return false; - break; - } - case SIMD_f32x4_sqrt: { if (!aot_compile_simd_f32x4_sqrt(comp_ctx, func_ctx)) @@ -2459,13 +2428,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index) break; } - case SIMD_f64x2_round: - { - if (!aot_compile_simd_f64x2_round(comp_ctx, func_ctx)) - return false; - break; - } - case SIMD_f64x2_sqrt: { if (!aot_compile_simd_f64x2_sqrt(comp_ctx, func_ctx)) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_compiler.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_compiler.h similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_compiler.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_compiler.h index b6347c89d78..22f95ccfe32 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_compiler.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_compiler.h @@ -203,7 +203,12 @@ check_type_compatible(uint8 src_type, uint8 dst_type) goto fail; \ } \ memset(aot_value, 0, sizeof(AOTValue)); \ - aot_value->type = value_type; \ + if (comp_ctx->enable_ref_types \ + && (value_type == VALUE_TYPE_FUNCREF \ + || value_type == VALUE_TYPE_EXTERNREF)) \ + aot_value->type = VALUE_TYPE_I32; \ + else \ + aot_value->type = value_type; \ aot_value->value = llvm_value; \ aot_value_stack_push( \ &func_ctx->block_stack.block_list_end->value_stack, aot_value); \ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_aot_file.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_aot_file.c similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_aot_file.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_aot_file.c index 80bcdc7db48..e43c8939c3b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_aot_file.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_aot_file.c @@ -25,6 +25,7 @@ } \ } while (0) +#if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 static bool check_utf8_str(const uint8 *str, uint32 len) { @@ -89,6 +90,7 @@ check_utf8_str(const uint8 *str, uint32 len) } return (p == p_end); } +#endif /* end of WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 */ /* Internal function in object file */ typedef struct AOTObjectFunc { @@ -652,7 +654,8 @@ get_relocations_size(AOTObjectData *obj_data, /* ignore the relocations to aot_func_internal#n in text section for windows platform since they will be applied in aot_emit_text_section */ - if (!strcmp(relocation_group->section_name, ".text") + if ((!strcmp(relocation_group->section_name, ".text") + || !strcmp(relocation_group->section_name, ".ltext")) && !strncmp(relocation->symbol_name, AOT_FUNC_INTERNAL_PREFIX, strlen(AOT_FUNC_INTERNAL_PREFIX)) && ((!strncmp(obj_data->comp_ctx->target_arch, "x86_64", 6) @@ -912,9 +915,6 @@ get_native_symbol_list_size(AOTCompContext *comp_ctx) return len; } -static uint32 -get_name_section_size(AOTCompData *comp_data); - static uint32 get_custom_sections_size(AOTCompContext *comp_ctx, AOTCompData *comp_data); @@ -972,15 +972,6 @@ get_aot_file_size(AOTCompContext *comp_ctx, AOTCompData *comp_data, size += get_native_symbol_list_size(comp_ctx); } - if (comp_ctx->enable_aux_stack_frame) { - /* custom name section */ - size = align_uint(size, 4); - /* section id + section size + sub section id */ - size += (uint32)sizeof(uint32) * 3; - size += (comp_data->aot_name_section_size = - get_name_section_size(comp_data)); - } - size_custom_section = get_custom_sections_size(comp_ctx, comp_data); if (size_custom_section > 0) { size = align_uint(size, 4); @@ -1013,28 +1004,28 @@ exchange_uint32(uint8 *p_data) } static void -exchange_uint64(uint8 *pData) +exchange_uint64(uint8 *p_data) { uint32 value; - value = *(uint32 *)pData; - *(uint32 *)pData = *(uint32 *)(pData + 4); - *(uint32 *)(pData + 4) = value; - exchange_uint32(pData); - exchange_uint32(pData + 4); + value = *(uint32 *)p_data; + *(uint32 *)p_data = *(uint32 *)(p_data + 4); + *(uint32 *)(p_data + 4) = value; + exchange_uint32(p_data); + exchange_uint32(p_data + 4); } static void -exchange_uint128(uint8 *pData) +exchange_uint128(uint8 *p_data) { /* swap high 64bit and low 64bit */ - uint64 value = *(uint64 *)pData; - *(uint64 *)pData = *(uint64 *)(pData + 8); - *(uint64 *)(pData + 8) = value; + uint64 value = *(uint64 *)p_data; + *(uint64 *)p_data = *(uint64 *)(p_data + 8); + *(uint64 *)(p_data + 8) = value; /* exchange high 64bit */ - exchange_uint64(pData); + exchange_uint64(p_data); /* exchange low 64bit */ - exchange_uint64(pData + 8); + exchange_uint64(p_data + 8); } static union { @@ -1123,6 +1114,7 @@ static union { EMIT_BUF(s, str_len); \ } while (0) +#if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 static bool read_leb(uint8 **p_buf, const uint8 *buf_end, uint32 maxbits, bool sign, uint64 *p_result) @@ -1321,6 +1313,7 @@ get_name_section_size(AOTCompData *comp_data) fail: return 0; } +#endif /* end of WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 */ static uint32 get_custom_sections_size(AOTCompContext *comp_ctx, AOTCompData *comp_data) @@ -1333,6 +1326,21 @@ get_custom_sections_size(AOTCompContext *comp_ctx, AOTCompData *comp_data) const uint8 *content = NULL; uint32 length = 0; + if (strcmp(section_name, "name") == 0) { + /* custom name section */ + comp_data->aot_name_section_size = get_name_section_size(comp_data); + if (comp_data->aot_name_section_size == 0) { + LOG_WARNING("Can't find custom section [name], ignore it"); + continue; + } + + size = align_uint(size, 4); + /* section id + section size + sub section id */ + size += (uint32)sizeof(uint32) * 3; + size += comp_data->aot_name_section_size; + continue; + } + content = wasm_loader_get_custom_section(comp_data->wasm_module, section_name, &length); if (!content) { @@ -1812,7 +1820,8 @@ aot_emit_text_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset, for (i = 0; i < obj_data->relocation_group_count; i++, relocation_group++) { /* relocation in text section */ - if (!strcmp(relocation_group->section_name, ".text")) { + if ((!strcmp(relocation_group->section_name, ".text") + || !strcmp(relocation_group->section_name, ".ltext"))) { relocation = relocation_group->relocations; relocation_count = relocation_group->relocation_count; for (j = 0; j < relocation_count; j++) { @@ -2062,29 +2071,33 @@ aot_emit_native_symbol(uint8 *buf, uint8 *buf_end, uint32 *p_offset, return true; } +#if WASM_ENABLE_LOAD_CUSTOM_SECTION != 0 static bool aot_emit_name_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset, AOTCompData *comp_data, AOTCompContext *comp_ctx) { - if (comp_ctx->enable_aux_stack_frame) { - uint32 offset = *p_offset; + uint32 offset = *p_offset; - *p_offset = offset = align_uint(offset, 4); + if (comp_data->aot_name_section_size == 0) + return true; - EMIT_U32(AOT_SECTION_TYPE_CUSTOM); - /* sub section id + name section size */ - EMIT_U32(sizeof(uint32) * 1 + comp_data->aot_name_section_size); - EMIT_U32(AOT_CUSTOM_SECTION_NAME); - bh_memcpy_s((uint8 *)(buf + offset), (uint32)(buf_end - buf), - comp_data->aot_name_section_buf, - (uint32)comp_data->aot_name_section_size); - offset += comp_data->aot_name_section_size; + offset = align_uint(offset, 4); - *p_offset = offset; - } + EMIT_U32(AOT_SECTION_TYPE_CUSTOM); + /* sub section id + name section size */ + EMIT_U32(sizeof(uint32) * 1 + comp_data->aot_name_section_size); + EMIT_U32(AOT_CUSTOM_SECTION_NAME); + bh_memcpy_s((uint8 *)(buf + offset), (uint32)(buf_end - buf), + comp_data->aot_name_section_buf, + (uint32)comp_data->aot_name_section_size); + offset += comp_data->aot_name_section_size; + *p_offset = offset; + + LOG_DEBUG("emit name section"); return true; } +#endif static bool aot_emit_custom_sections(uint8 *buf, uint8 *buf_end, uint32 *p_offset, @@ -2098,6 +2111,16 @@ aot_emit_custom_sections(uint8 *buf, uint8 *buf_end, uint32 *p_offset, const uint8 *content = NULL; uint32 length = 0; + if (strcmp(section_name, "name") == 0) { + *p_offset = offset; + if (!aot_emit_name_section(buf, buf_end, p_offset, comp_data, + comp_ctx)) + return false; + + offset = *p_offset; + continue; + } + content = wasm_loader_get_custom_section(comp_data->wasm_module, section_name, &length); if (!content) { @@ -2359,17 +2382,19 @@ aot_resolve_text(AOTObjectData *obj_data) while ( !LLVMObjectFileIsSectionIteratorAtEnd(obj_data->binary, sec_itr)) { if ((name = (char *)LLVMGetSectionName(sec_itr))) { - if (!strcmp(name, ".text")) { + if (!strcmp(name, ".text") || !strcmp(name, ".ltext")) { obj_data->text = (char *)LLVMGetSectionContents(sec_itr); obj_data->text_size = (uint32)LLVMGetSectionSize(sec_itr); } - else if (!strcmp(name, ".text.unlikely.")) { + else if (!strcmp(name, ".text.unlikely.") + || !strcmp(name, ".ltext.unlikely.")) { obj_data->text_unlikely = (char *)LLVMGetSectionContents(sec_itr); obj_data->text_unlikely_size = (uint32)LLVMGetSectionSize(sec_itr); } - else if (!strcmp(name, ".text.hot.")) { + else if (!strcmp(name, ".text.hot.") + || !strcmp(name, ".ltext.hot.")) { obj_data->text_hot = (char *)LLVMGetSectionContents(sec_itr); obj_data->text_hot_size = @@ -2888,11 +2913,13 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data) (char *)LLVMGetSectionName(contain_section); LLVMDisposeSectionIterator(contain_section); - if (!strcmp(contain_section_name, ".text.unlikely.")) { + if (!strcmp(contain_section_name, ".text.unlikely.") + || !strcmp(contain_section_name, ".ltext.unlikely.")) { func->text_offset = align_uint(obj_data->text_size, 4) + LLVMGetSymbolAddress(sym_itr); } - else if (!strcmp(contain_section_name, ".text.hot.")) { + else if (!strcmp(contain_section_name, ".text.hot.") + || !strcmp(contain_section_name, ".ltext.hot.")) { func->text_offset = align_uint(obj_data->text_size, 4) + align_uint(obj_data->text_unlikely_size, 4) @@ -2924,12 +2951,14 @@ aot_resolve_functions(AOTCompContext *comp_ctx, AOTObjectData *obj_data) (char *)LLVMGetSectionName(contain_section); LLVMDisposeSectionIterator(contain_section); - if (!strcmp(contain_section_name, ".text.unlikely.")) { + if (!strcmp(contain_section_name, ".text.unlikely.") + || !strcmp(contain_section_name, ".ltext.unlikely.")) { func->text_offset_of_aot_func_internal = align_uint(obj_data->text_size, 4) + LLVMGetSymbolAddress(sym_itr); } - else if (!strcmp(contain_section_name, ".text.hot.")) { + else if (!strcmp(contain_section_name, ".text.hot.") + || !strcmp(contain_section_name, ".ltext.hot.")) { func->text_offset_of_aot_func_internal = align_uint(obj_data->text_size, 4) + align_uint(obj_data->text_unlikely_size, 4) @@ -3077,7 +3106,12 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data, * Note: aot_stack_sizes_section_name section only contains * stack_sizes table. */ - if (!strcmp(relocation->symbol_name, aot_stack_sizes_name)) { + if (!strcmp(relocation->symbol_name, aot_stack_sizes_name) + /* in windows 32, the symbol name may start with '_' */ + || (strlen(relocation->symbol_name) > 0 + && relocation->symbol_name[0] == '_' + && !strcmp(relocation->symbol_name + 1, + aot_stack_sizes_name))) { /* discard const */ relocation->symbol_name = (char *)aot_stack_sizes_section_name; } @@ -3190,6 +3224,12 @@ is_relocation_section_name(AOTObjectData *obj_data, char *section_name) || !strcmp(section_name, ".rel.text.unlikely.") || !strcmp(section_name, ".rela.text.hot.") || !strcmp(section_name, ".rel.text.hot.") + || !strcmp(section_name, ".rela.ltext") + || !strcmp(section_name, ".rel.ltext") + || !strcmp(section_name, ".rela.ltext.unlikely.") + || !strcmp(section_name, ".rel.ltext.unlikely.") + || !strcmp(section_name, ".rela.ltext.hot.") + || !strcmp(section_name, ".rel.ltext.hot.") || !strcmp(section_name, ".rela.literal") || !strcmp(section_name, ".rela.data") || !strcmp(section_name, ".rel.data") @@ -3228,7 +3268,9 @@ static bool is_readonly_section(const char *name) { return !strcmp(name, ".rel.text") || !strcmp(name, ".rela.text") - || !strcmp(name, ".rela.literal") || !strcmp(name, ".text"); + || !strcmp(name, ".rel.ltext") || !strcmp(name, ".rela.ltext") + || !strcmp(name, ".rela.literal") || !strcmp(name, ".text") + || !strcmp(name, ".ltext"); } static bool @@ -3321,12 +3363,24 @@ aot_resolve_object_relocation_groups(AOTObjectData *obj_data) || !strcmp(relocation_group->section_name, ".rela.text.hot.")) { relocation_group->section_name = ".rela.text"; } + else if (!strcmp(relocation_group->section_name, + ".rela.ltext.unlikely.") + || !strcmp(relocation_group->section_name, + ".rela.ltext.hot.")) { + relocation_group->section_name = ".rela.ltext"; + } else if (!strcmp(relocation_group->section_name, ".rel.text.unlikely.") || !strcmp(relocation_group->section_name, ".rel.text.hot.")) { relocation_group->section_name = ".rel.text"; } + else if (!strcmp(relocation_group->section_name, + ".rel.ltext.unlikely.") + || !strcmp(relocation_group->section_name, + ".rel.ltext.hot.")) { + relocation_group->section_name = ".rel.ltext"; + } /* * Relocations in read-only sections are problematic, @@ -3589,6 +3643,10 @@ aot_emit_aot_file_buf(AOTCompContext *comp_ctx, AOTCompData *comp_data, return NULL; aot_file_size = get_aot_file_size(comp_ctx, comp_data, obj_data); + if (aot_file_size == 0) { + aot_set_last_error("get aot file size failed"); + goto fail1; + } if (!(buf = aot_file_buf = wasm_runtime_malloc(aot_file_size))) { aot_set_last_error("allocate memory failed."); @@ -3610,7 +3668,6 @@ aot_emit_aot_file_buf(AOTCompContext *comp_ctx, AOTCompData *comp_data, || !aot_emit_relocation_section(buf, buf_end, &offset, comp_ctx, comp_data, obj_data) || !aot_emit_native_symbol(buf, buf_end, &offset, comp_ctx) - || !aot_emit_name_section(buf, buf_end, &offset, comp_data, comp_ctx) || !aot_emit_custom_sections(buf, buf_end, &offset, comp_data, comp_ctx)) goto fail2; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_compare.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_compare.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_compare.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_compare.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_compare.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_compare.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_compare.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_compare.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_const.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_const.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_const.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_const.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_const.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_const.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_const.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_const.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_control.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_control.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_control.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_control.c index a8ee938f253..fc7d72f7dca 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_control.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_control.c @@ -272,7 +272,9 @@ handle_next_reachable_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, goto fail; } #if WASM_ENABLE_DEBUG_AOT != 0 - LLVMInstructionSetDebugLoc(ret, return_location); + if (return_location != NULL) { + LLVMInstructionSetDebugLoc(ret, return_location); + } #endif } else { @@ -281,7 +283,9 @@ handle_next_reachable_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, goto fail; } #if WASM_ENABLE_DEBUG_AOT != 0 - LLVMInstructionSetDebugLoc(ret, return_location); + if (return_location != NULL) { + LLVMInstructionSetDebugLoc(ret, return_location); + } #endif } } @@ -1048,6 +1052,7 @@ aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, PUSH(values[j], target_block->result_types[j]); } wasm_runtime_free(values); + values = NULL; } target_block->is_reachable = true; if (i == br_count) @@ -1073,6 +1078,7 @@ aot_compile_op_br_table(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, PUSH(values[j], target_block->param_types[j]); } wasm_runtime_free(values); + values = NULL; } if (i == br_count) default_llvm_block = target_block->llvm_entry_block; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_control.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_control.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_control.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_control.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_conversion.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_conversion.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_conversion.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_conversion.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_conversion.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_conversion.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_conversion.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_conversion.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_exception.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_exception.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_exception.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_exception.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_exception.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_exception.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_exception.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_exception.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_function.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_function.c similarity index 85% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_function.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_function.c index bc8cb0a55a6..ef85941ab31 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_function.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_function.c @@ -288,6 +288,213 @@ call_aot_invoke_native_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, return true; } +static bool +call_aot_invoke_c_api_native(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, + uint32 import_func_idx, AOTFuncType *aot_func_type, + LLVMValueRef *params) +{ + LLVMTypeRef int8_ptr_type, param_types[6], ret_type; + LLVMTypeRef value_ptr_type = NULL, value_type = NULL; + LLVMTypeRef func_type, func_ptr_type; + LLVMValueRef param_values[6], res, func, value = NULL, offset; + LLVMValueRef c_api_func_imports, c_api_func_import; + LLVMValueRef c_api_params, c_api_results, value_ret; + LLVMValueRef c_api_param_kind, c_api_param_value; + LLVMValueRef c_api_result_value; + uint32 offset_c_api_func_imports, i; + uint32 offset_param_kind, offset_param_value; + char buf[16]; + + /* `int8 **` type */ + int8_ptr_type = LLVMPointerType(INT8_PTR_TYPE, 0); + if (!int8_ptr_type) { + aot_set_last_error("create llvm pointer type failed"); + return false; + } + + param_types[0] = INT8_PTR_TYPE; /* module_inst */ + param_types[1] = INT8_PTR_TYPE; /* CApiFuncImport *c_api_import */ + param_types[2] = INT8_PTR_TYPE; /* wasm_val_t *params */ + param_types[3] = I32_TYPE; /* uint32 param_count */ + param_types[4] = INT8_PTR_TYPE; /* wasm_val_t *results */ + param_types[5] = I32_TYPE; /* uint32 result_count */ + + ret_type = INT8_TYPE; + + GET_AOT_FUNCTION(wasm_runtime_quick_invoke_c_api_native, 6); + + param_values[0] = func_ctx->aot_inst; + + /* Get module_inst->e->common.c_api_func_imports */ + offset_c_api_func_imports = + get_module_inst_extra_offset(comp_ctx) + + (comp_ctx->is_jit_mode + ? offsetof(WASMModuleInstanceExtra, common.c_api_func_imports) + /* offsetof(AOTModuleInstanceExtra, common.c_api_func_imports) */ + : sizeof(uint64)); + offset = I32_CONST(offset_c_api_func_imports); + CHECK_LLVM_CONST(offset); + c_api_func_imports = + LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, func_ctx->aot_inst, + &offset, 1, "c_api_func_imports_addr"); + c_api_func_imports = + LLVMBuildBitCast(comp_ctx->builder, c_api_func_imports, int8_ptr_type, + "c_api_func_imports_ptr"); + c_api_func_imports = + LLVMBuildLoad2(comp_ctx->builder, INT8_PTR_TYPE, c_api_func_imports, + "c_api_func_imports"); + + /* Get &c_api_func_imports[func_idx], note size of CApiFuncImport + is pointer_size * 3 */ + offset = I32_CONST((comp_ctx->pointer_size * 3) * import_func_idx); + CHECK_LLVM_CONST(offset); + c_api_func_import = + LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, c_api_func_imports, + &offset, 1, "c_api_func_import"); + + param_values[1] = c_api_func_import; + param_values[2] = c_api_params = func_ctx->argv_buf; + param_values[3] = I32_CONST(aot_func_type->param_count); + CHECK_LLVM_CONST(param_values[3]); + + /* Ensure sizeof(wasm_val_t) is 16 bytes */ + offset = I32_CONST(sizeof(wasm_val_t) * aot_func_type->param_count); + c_api_results = + LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, func_ctx->argv_buf, + &offset, 1, "results"); + param_values[4] = c_api_results; + + param_values[5] = I32_CONST(aot_func_type->result_count); + CHECK_LLVM_CONST(param_values[5]); + + /* Set each c api param */ + for (i = 0; i < aot_func_type->param_count; i++) { + /* Ensure sizeof(wasm_val_t) is 16 bytes */ + offset_param_kind = sizeof(wasm_val_t) * i; + offset = I32_CONST(offset_param_kind); + CHECK_LLVM_CONST(offset); + c_api_param_kind = + LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, c_api_params, + &offset, 1, "c_api_param_kind_addr"); + c_api_param_kind = + LLVMBuildBitCast(comp_ctx->builder, c_api_param_kind, INT8_PTR_TYPE, + "c_api_param_kind_ptr"); + + switch (aot_func_type->types[i]) { + case VALUE_TYPE_I32: + value = I8_CONST(WASM_I32); + break; + case VALUE_TYPE_F32: + value = I8_CONST(WASM_F32); + break; + case VALUE_TYPE_I64: + value = I8_CONST(WASM_I64); + break; + case VALUE_TYPE_F64: + value = I8_CONST(WASM_F64); + break; + default: + bh_assert(0); + break; + } + CHECK_LLVM_CONST(value); + + LLVMBuildStore(comp_ctx->builder, value, c_api_param_kind); + + /* Ensure offsetof(wasm_val_t, of) is 8 bytes */ + offset_param_value = offset_param_kind + offsetof(wasm_val_t, of); + offset = I32_CONST(offset_param_value); + CHECK_LLVM_CONST(offset); + c_api_param_value = + LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, c_api_params, + &offset, 1, "c_api_param_value_addr"); + + switch (aot_func_type->types[i]) { + case VALUE_TYPE_I32: + value_ptr_type = INT32_PTR_TYPE; + break; + case VALUE_TYPE_F32: + value_ptr_type = F32_PTR_TYPE; + break; + case VALUE_TYPE_I64: + value_ptr_type = INT64_PTR_TYPE; + break; + case VALUE_TYPE_F64: + value_ptr_type = F64_PTR_TYPE; + break; + default: + bh_assert(0); + break; + } + + c_api_param_value = + LLVMBuildBitCast(comp_ctx->builder, c_api_param_value, + value_ptr_type, "c_api_param_value_ptr"); + LLVMBuildStore(comp_ctx->builder, params[i], c_api_param_value); + } + + /* Call the function */ + if (!(res = LLVMBuildCall2(comp_ctx->builder, func_type, func, param_values, + 6, "call"))) { + aot_set_last_error("LLVM build call failed."); + goto fail; + } + + /* Check whether exception was thrown when executing the function */ + if (comp_ctx->enable_bound_check + && !check_call_return(comp_ctx, func_ctx, res)) { + goto fail; + } + + for (i = 0; i < aot_func_type->result_count; i++) { + /* Ensure sizeof(wasm_val_t) is 16 bytes and + offsetof(wasm_val_t, of) is 8 bytes */ + uint32 offset_result_value = + sizeof(wasm_val_t) * i + offsetof(wasm_val_t, of); + + offset = I32_CONST(offset_result_value); + CHECK_LLVM_CONST(offset); + c_api_result_value = + LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, c_api_results, + &offset, 1, "c_api_result_value_addr"); + + switch (aot_func_type->types[aot_func_type->param_count + i]) { + case VALUE_TYPE_I32: + value_type = I32_TYPE; + value_ptr_type = INT32_PTR_TYPE; + break; + case VALUE_TYPE_F32: + value_type = F32_TYPE; + value_ptr_type = F32_PTR_TYPE; + break; + case VALUE_TYPE_I64: + value_type = I64_TYPE; + value_ptr_type = INT64_PTR_TYPE; + break; + case VALUE_TYPE_F64: + value_type = F64_TYPE; + value_ptr_type = F64_PTR_TYPE; + break; + default: + bh_assert(0); + break; + } + + c_api_result_value = + LLVMBuildBitCast(comp_ctx->builder, c_api_result_value, + value_ptr_type, "c_api_result_value_ptr"); + snprintf(buf, sizeof(buf), "%s%u", "ret", i); + value_ret = LLVMBuildLoad2(comp_ctx->builder, value_type, + c_api_result_value, buf); + + PUSH(value_ret, aot_func_type->types[aot_func_type->param_count + i]); + } + + return true; +fail: + return false; +} + #if (WASM_ENABLE_DUMP_CALL_STACK != 0) || (WASM_ENABLE_PERF_PROFILING != 0) static bool call_aot_alloc_frame_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, @@ -533,6 +740,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, const char *signature = NULL; bool ret = false; char buf[32]; + bool quick_invoke_c_api_import = false; #if WASM_ENABLE_THREAD_MGR != 0 /* Insert suspend check point */ @@ -702,17 +910,43 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, } if (!signature) { - /* call aot_invoke_native() */ - if (!call_aot_invoke_native_func( - comp_ctx, func_ctx, import_func_idx, func_type, - param_types + 1, param_values + 1, param_count, - param_cell_num, ret_type, wasm_ret_type, &value_ret, &res)) - goto fail; - /* Check whether there was exception thrown when executing - the function */ - if ((comp_ctx->enable_bound_check || is_win_platform(comp_ctx)) - && !check_call_return(comp_ctx, func_ctx, res)) - goto fail; + if (comp_ctx->quick_invoke_c_api_import) { + uint32 buf_size_needed = + sizeof(wasm_val_t) * (param_count + result_count); + + /* length of exec_env->argv_buf is 64 */ + if (buf_size_needed < sizeof(uint32) * 64) { + for (i = 0; i < param_count + result_count; i++) { + /* Only support i32/i64/f32/f64 now */ + if (!(func_type->types[i] == VALUE_TYPE_I32 + || func_type->types[i] == VALUE_TYPE_I64 + || func_type->types[i] == VALUE_TYPE_F32 + || func_type->types[i] == VALUE_TYPE_F64)) + break; + } + if (i == param_count + result_count) + quick_invoke_c_api_import = true; + } + } + if (quick_invoke_c_api_import) { + if (!call_aot_invoke_c_api_native(comp_ctx, func_ctx, func_idx, + func_type, param_values + 1)) + goto fail; + } + else { + /* call aot_invoke_native() */ + if (!call_aot_invoke_native_func( + comp_ctx, func_ctx, import_func_idx, func_type, + param_types + 1, param_values + 1, param_count, + param_cell_num, ret_type, wasm_ret_type, &value_ret, + &res)) + goto fail; + /* Check whether there was exception thrown when executing + the function */ + if ((comp_ctx->enable_bound_check || is_win_platform(comp_ctx)) + && !check_call_return(comp_ctx, func_ctx, res)) + goto fail; + } } else { /* call native func directly */ LLVMTypeRef native_func_type, func_ptr_type; @@ -854,10 +1088,6 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, goto fail; } - /* Set calling convention for the call with the func's calling - convention */ - LLVMSetInstructionCallConv(value_ret, LLVMGetFunctionCallConv(func)); - if (tail_call) LLVMSetTailCall(value_ret, true); @@ -869,7 +1099,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, goto fail; } - if (func_type->result_count > 0) { + if (func_type->result_count > 0 && !quick_invoke_c_api_import) { /* Push the first result to stack */ PUSH(value_ret, func_type->types[func_type->param_count]); /* Load extra result from its address and push to stack */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_function.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_function.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_function.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_function.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_memory.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_memory.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_memory.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_memory.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_memory.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_memory.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_memory.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_memory.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_numberic.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_numberic.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_numberic.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_numberic.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_numberic.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_numberic.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_numberic.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_numberic.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_parametric.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_parametric.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_parametric.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_parametric.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_parametric.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_parametric.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_parametric.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_parametric.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_table.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_table.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_table.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_table.c index d8a5efd9137..34e7d97006f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_table.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_table.c @@ -46,6 +46,18 @@ get_tbl_inst_offset(const AOTCompContext *comp_ctx, return offset; } +uint32 +get_module_inst_extra_offset(AOTCompContext *comp_ctx) +{ + const AOTCompData *comp_data = comp_ctx->comp_data; + uint32 table_count = comp_data->import_table_count + comp_data->table_count; + uint64 offset = get_tbl_inst_offset(comp_ctx, NULL, table_count); + uint32 offset_32 = (uint32)offset; + bh_assert(offset <= UINT32_MAX); + offset_32 = align_uint(offset_32, 8); + return offset_32; +} + #if WASM_ENABLE_REF_TYPES != 0 LLVMValueRef diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_table.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_table.h similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_table.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_table.h index e5ab0ed48b3..f294cca9aea 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_table.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_table.h @@ -49,6 +49,9 @@ uint64 get_tbl_inst_offset(const AOTCompContext *comp_ctx, const AOTFuncContext *func_ctx, uint32 tbl_idx); +uint32 +get_module_inst_extra_offset(AOTCompContext *comp_ctx); + LLVMValueRef aot_compile_get_tbl_inst(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, uint32 tbl_idx); @@ -56,4 +59,4 @@ aot_compile_get_tbl_inst(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, #ifdef __cplusplus } /* end of extern "C" */ #endif -#endif \ No newline at end of file +#endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_variable.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_variable.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_variable.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_variable.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_variable.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_variable.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_emit_variable.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_emit_variable.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm.c index bbf16f55c49..b6dfcf6f2df 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm.c @@ -263,12 +263,11 @@ get_inst_extra_offset(AOTCompContext *comp_ctx) * - update native_stack_top_min if necessary * - stack overflow check (if it does, trap) */ -static LLVMValueRef -aot_add_precheck_function(AOTCompContext *comp_ctx, LLVMModuleRef module, - uint32 func_index, uint32 orig_param_count, - LLVMTypeRef func_type, LLVMValueRef wrapped_func) +static bool +aot_build_precheck_function(AOTCompContext *comp_ctx, LLVMModuleRef module, + LLVMValueRef precheck_func, uint32 func_index, + LLVMTypeRef func_type, LLVMValueRef wrapped_func) { - LLVMValueRef precheck_func; LLVMBasicBlockRef begin = NULL; LLVMBasicBlockRef check_top_block = NULL; LLVMBasicBlockRef update_top_block = NULL; @@ -276,12 +275,6 @@ aot_add_precheck_function(AOTCompContext *comp_ctx, LLVMModuleRef module, LLVMBasicBlockRef call_wrapped_func_block = NULL; LLVMValueRef *params = NULL; - precheck_func = - aot_add_llvm_func1(comp_ctx, module, func_index, orig_param_count, - func_type, AOT_FUNC_PREFIX); - if (!precheck_func) { - goto fail; - } begin = LLVMAppendBasicBlockInContext(comp_ctx->context, precheck_func, "begin"); check_top_block = LLVMAppendBasicBlockInContext( @@ -533,18 +526,12 @@ aot_add_precheck_function(AOTCompContext *comp_ctx, LLVMModuleRef module, } wasm_runtime_free(params); params = NULL; - -#if LLVM_VERSION_MAJOR < 17 if (aot_target_precheck_can_use_musttail(comp_ctx)) { LLVMSetTailCallKind(retval, LLVMTailCallKindMustTail); } else { LLVMSetTailCallKind(retval, LLVMTailCallKindTail); } -#else - LLVMSetTailCall(retval, true); -#endif - if (ret_type == VOID_TYPE) { if (!LLVMBuildRetVoid(b)) { goto fail; @@ -556,13 +543,13 @@ aot_add_precheck_function(AOTCompContext *comp_ctx, LLVMModuleRef module, } } - return precheck_func; + return true; fail: if (params != NULL) { wasm_runtime_free(params); } aot_set_last_error("failed to build precheck wrapper function."); - return NULL; + return false; } /** @@ -632,7 +619,14 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module, const char *prefix = AOT_FUNC_PREFIX; const bool need_precheck = comp_ctx->enable_stack_bound_check || comp_ctx->enable_stack_estimation; + LLVMValueRef precheck_func = NULL; if (need_precheck) { + precheck_func = aot_add_llvm_func1(comp_ctx, module, func_index, + aot_func_type->param_count, + func_type, AOT_FUNC_PREFIX); + if (!precheck_func) { + goto fail; + } /* * REVISIT: probably this breaks windows hw bound check * (the RtlAddFunctionTable stuff) @@ -677,10 +671,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module, LLVMAddAttributeAtIndex(func, LLVMAttributeFunctionIndex, attr_noinline); - LLVMValueRef precheck_func = aot_add_precheck_function( - comp_ctx, module, func_index, aot_func_type->param_count, func_type, - func); - if (!precheck_func) + if (!aot_build_precheck_function(comp_ctx, module, precheck_func, + func_index, func_type, func)) goto fail; LLVMAddAttributeAtIndex(precheck_func, LLVMAttributeFunctionIndex, attr_noinline); @@ -2174,7 +2166,7 @@ jit_stack_size_callback(void *user_data, const char *name, size_t namelen, } static bool -orc_jit_create(AOTCompContext *comp_ctx, bool linux_perf_support) +orc_jit_create(AOTCompContext *comp_ctx) { LLVMErrorRef err; LLVMOrcLLLazyJITRef orc_jit = NULL; @@ -2214,13 +2206,15 @@ orc_jit_create(AOTCompContext *comp_ctx, bool linux_perf_support) /* Ownership transfer: LLVMOrcLLJITBuilderRef -> LLVMOrcLLJITRef */ builder = NULL; - if (linux_perf_support) { - LOG_DEBUG("Enable linux perf support"); +#if WASM_ENABLE_LINUX_PERF != 0 + if (wasm_runtime_get_linux_perf()) { + LOG_DEBUG("Enable linux perf support in JIT"); LLVMOrcObjectLayerRef obj_linking_layer = (LLVMOrcObjectLayerRef)LLVMOrcLLLazyJITGetObjLinkingLayer(orc_jit); LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener( obj_linking_layer, LLVMCreatePerfJITEventListener()); } +#endif /* Ownership transfer: local -> AOTCompContext */ comp_ctx->orc_jit = orc_jit; @@ -2320,7 +2314,8 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) goto fail; } - if (option->linux_perf_support) { +#if WASM_ENABLE_LINUX_PERF != 0 + if (wasm_runtime_get_linux_perf()) { /* FramePointerKind.All */ LLVMMetadataRef val = LLVMValueAsMetadata(LLVMConstInt(LLVMInt32Type(), 2, false)); @@ -2330,6 +2325,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) comp_ctx->emit_frame_pointer = true; } +#endif if (BH_LIST_ERROR == bh_list_init(&comp_ctx->native_symbols)) { goto fail; @@ -2394,6 +2390,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) if (option->enable_stack_estimation) comp_ctx->enable_stack_estimation = true; + if (option->quick_invoke_c_api_import) + comp_ctx->quick_invoke_c_api_import = true; + if (option->llvm_passes) comp_ctx->llvm_passes = option->llvm_passes; @@ -2434,7 +2433,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option) goto fail; /* Create LLJIT Instance */ - if (!orc_jit_create(comp_ctx, option->linux_perf_support)) + if (!orc_jit_create(comp_ctx)) goto fail; } else { diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm.h similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm.h index 32d7bbebacd..bb7534e5c9b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm.h @@ -321,10 +321,10 @@ typedef struct AOTCompContext { /* Bulk memory feature */ bool enable_bulk_memory; - /* Bounday Check */ + /* Boundary Check */ bool enable_bound_check; - /* Native stack bounday Check */ + /* Native stack boundary Check */ bool enable_stack_bound_check; /* Native stack usage estimation */ @@ -357,6 +357,10 @@ typedef struct AOTCompContext { /* Enable LLVM PGO (Profile-Guided Optimization) */ bool enable_llvm_pgo; + /* Treat unknown import function as wasm-c-api import function + and allow to directly invoke it from AOT/JIT code */ + bool quick_invoke_c_api_import; + /* Use profile file collected by LLVM PGO */ char *use_prof_file; @@ -454,6 +458,7 @@ typedef struct AOTCompOption { bool disable_llvm_lto; bool enable_llvm_pgo; bool enable_stack_estimation; + bool quick_invoke_c_api_import; char *use_prof_file; uint32 opt_level; uint32 size_level; @@ -461,7 +466,6 @@ typedef struct AOTCompOption { uint32 bounds_checks; uint32 stack_bounds_checks; uint32 segue_flags; - bool linux_perf_support; char **custom_sections; uint32 custom_sections_count; const char *stack_usage_file; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra.cpp similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra.cpp index ed0205c3c93..ed9447afc41 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra.cpp +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -315,8 +316,11 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module) } ModulePassManager MPM; + if (comp_ctx->is_jit_mode) { const char *Passes = + "loop-vectorize,slp-vectorizer," + "load-store-vectorizer,vector-combine," "mem2reg,instcombine,simplifycfg,jump-threading,indvars"; ExitOnErr(PB.parsePassPipeline(MPM, Passes)); } @@ -327,6 +331,7 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module) FPM.addPass(LoopVectorizePass()); FPM.addPass(SLPVectorizerPass()); FPM.addPass(LoadStoreVectorizerPass()); + FPM.addPass(VectorCombinePass()); if (comp_ctx->enable_llvm_pgo || comp_ctx->use_prof_file) { /* LICM pass: loop invariant code motion, attempting to remove @@ -404,7 +409,10 @@ aot_compress_aot_func_names(AOTCompContext *comp_ctx, uint32 *p_size) NameStrs.push_back(str); } - if (collectPGOFuncNameStrings(NameStrs, true, Result)) { +#if LLVM_VERSION_MAJOR < 18 +#define collectGlobalObjectNameStrings collectPGOFuncNameStrings +#endif + if (collectGlobalObjectNameStrings(NameStrs, true, Result)) { aot_set_last_error("collect pgo func name strings failed"); return NULL; } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra2.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra2.cpp similarity index 88% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra2.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra2.cpp index 8364e5ebf42..ccbccd1e003 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra2.cpp +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra2.cpp @@ -58,6 +58,7 @@ convert(LLVMRelocMode reloc_mode) #endif } +#if LLVM_VERSION_MAJOR < 18 static llvm::CodeGenOpt::Level convert(LLVMCodeGenOptLevel opt_level) { @@ -74,6 +75,24 @@ convert(LLVMCodeGenOptLevel opt_level) bh_assert(0); return llvm::CodeGenOpt::None; } +#else +static llvm::CodeGenOptLevel +convert(LLVMCodeGenOptLevel opt_level) +{ + switch (opt_level) { + case LLVMCodeGenLevelNone: + return llvm::CodeGenOptLevel::None; + case LLVMCodeGenLevelLess: + return llvm::CodeGenOptLevel::Less; + case LLVMCodeGenLevelDefault: + return llvm::CodeGenOptLevel::Default; + case LLVMCodeGenLevelAggressive: + return llvm::CodeGenOptLevel::Aggressive; + } + bh_assert(0); + return llvm::CodeGenOptLevel::None; +} +#endif static llvm::Optional convert(LLVMCodeModel code_model, bool *jit) @@ -144,7 +163,7 @@ LLVMCreateTargetMachineWithOpts(LLVMTargetRef ctarget, const char *triple, } /* https://reviews.llvm.org/D153107 */ -#if LLVM_VERSION_MAJOR < 17 +#if LLVM_VERSION_MAJOR < 18 using namespace llvm; LLVMTailCallKind diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra2.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra2.h similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra2.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra2.h index f3f89799436..be89faae085 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_llvm_extra2.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_llvm_extra2.h @@ -17,7 +17,7 @@ LLVMCreateTargetMachineWithOpts(LLVMTargetRef ctarget, const char *triple, const char *StackUsageOutput); /* https://reviews.llvm.org/D153107 */ -#if LLVM_VERSION_MAJOR < 17 +#if LLVM_VERSION_MAJOR < 18 typedef enum { LLVMTailCallKindNone = 0, LLVMTailCallKindTail = 1, diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_orc_extra.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_orc_extra.cpp similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_orc_extra.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_orc_extra.cpp index ad8c41c3fdd..90dafe09755 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_orc_extra.cpp +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_orc_extra.cpp @@ -3,6 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + #include "llvm-c/LLJIT.h" #include "llvm-c/Orc.h" #include "llvm-c/OrcEE.h" @@ -44,6 +48,7 @@ class InProgressLookupState; class OrcV2CAPIHelper { public: +#if LLVM_VERSION_MAJOR < 18 using PoolEntry = SymbolStringPtr::PoolEntry; using PoolEntryPtr = SymbolStringPtr::PoolEntryPtr; @@ -86,6 +91,7 @@ class OrcV2CAPIHelper S.S = P; } +#endif static InProgressLookupState *extractLookupState(LookupState &LS) { return LS.IPLS.release(); @@ -101,6 +107,20 @@ class OrcV2CAPIHelper } // namespace llvm // ORC.h +#if LLVM_VERSION_MAJOR >= 18 +inline LLVMOrcSymbolStringPoolEntryRef +wrap(SymbolStringPoolEntryUnsafe E) +{ + return reinterpret_cast(E.rawPtr()); +} + +inline SymbolStringPoolEntryUnsafe +unwrap(LLVMOrcSymbolStringPoolEntryRef E) +{ + return reinterpret_cast(E); +} +#endif + DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionSession, LLVMOrcExecutionSessionRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRTransformLayer, LLVMOrcIRTransformLayerRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(JITDylib, LLVMOrcJITDylibRef) @@ -108,8 +128,10 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(JITTargetMachineBuilder, LLVMOrcJITTargetMachineBuilderRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ObjectTransformLayer, LLVMOrcObjectTransformLayerRef) +#if LLVM_VERSION_MAJOR < 18 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(OrcV2CAPIHelper::PoolEntry, LLVMOrcSymbolStringPoolEntryRef) +#endif DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ObjectLayer, LLVMOrcObjectLayerRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SymbolStringPool, LLVMOrcSymbolStringPoolRef) DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ThreadSafeModule, LLVMOrcThreadSafeModuleRef) @@ -292,8 +314,13 @@ LLVMOrcSymbolStringPoolEntryRef LLVMOrcLLLazyJITMangleAndIntern(LLVMOrcLLLazyJITRef J, const char *UnmangledName) { +#if LLVM_VERSION_MAJOR < 18 return wrap(OrcV2CAPIHelper::moveFromSymbolStringPtr( unwrap(J)->mangleAndIntern(UnmangledName))); +#else + return wrap(SymbolStringPoolEntryUnsafe::take( + unwrap(J)->mangleAndIntern(UnmangledName))); +#endif } LLVMOrcJITDylibRef diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_orc_extra.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_orc_extra.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_orc_extra.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_orc_extra.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_orc_extra2.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_orc_extra2.cpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/aot_orc_extra2.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/aot_orc_extra2.cpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/debug/dwarf_extractor.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/debug/dwarf_extractor.cpp similarity index 86% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/debug/dwarf_extractor.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/debug/dwarf_extractor.cpp index 99182f82f99..e2e515ba0a1 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/debug/dwarf_extractor.cpp +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/debug/dwarf_extractor.cpp @@ -133,9 +133,10 @@ dwarf_gen_file_info(const AOTCompContext *comp_ctx) file_name = filespec.GetFilename(); dir_name = filespec.GetDirectory(); if (file_name || dir_name) { - file_info = LLVMDIBuilderCreateFile(comp_ctx->debug_builder, - file_name, strlen(file_name), - dir_name, strlen(dir_name)); + file_info = LLVMDIBuilderCreateFile( + comp_ctx->debug_builder, file_name, + file_name ? strlen(file_name) : 0, dir_name, + dir_name ? strlen(dir_name) : 0); } } return file_info; @@ -152,7 +153,7 @@ dwarf_gen_mock_vm_info(AOTCompContext *comp_ctx) comp_unit = LLVMDIBuilderCreateCompileUnit( comp_ctx->debug_builder, LLVMDWARFSourceLanguageC, file_info, - "ant compiler", 12, 0, NULL, 0, 1, NULL, 0, LLVMDWARFEmissionFull, 0, 0, + "WAMR AoT compiler", 12, 0, NULL, 0, 1, NULL, 0, LLVMDWARFEmissionFull, 0, 0, 0, "/", 1, "", 0); LLVMTypeRef ParamTys[] = { @@ -208,8 +209,8 @@ dwarf_gen_comp_unit_info(const AOTCompContext *comp_ctx) comp_unit = LLVMDIBuilderCreateCompileUnit( comp_ctx->debug_builder, LLDB_TO_LLVM_LANG_TYPE(lang_type), - comp_ctx->debug_file, "ant compiler", 12, 0, NULL, 0, 1, NULL, 0, - LLVMDWARFEmissionFull, 0, 0, 0, "/", 1, "", 0); + comp_ctx->debug_file, "WAMR AoT compiler", 12, 0, NULL, 0, 1, NULL, + 0, LLVMDWARFEmissionFull, 0, 0, 0, "/", 1, "", 0); } return comp_unit; } @@ -294,11 +295,33 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx, const size_t num_function_args = function_args.GetSize(); dwarf_extractor *extractor; + /* + * Process only known languages. + * We have a few assumptions which might not be true for non-C functions. + * + * At least it's known broken for C++ and Rust: + * https://github.com/bytecodealliance/wasm-micro-runtime/issues/3187 + * https://github.com/bytecodealliance/wasm-micro-runtime/issues/3163 + */ + LanguageType language_type = function.GetLanguage(); + switch (language_type) { + case eLanguageTypeC89: + case eLanguageTypeC: + case eLanguageTypeC99: + case eLanguageTypeC11: + case eLanguageTypeC17: + break; + default: + LOG_WARNING("func %s has unsuppoted language_type 0x%x", + function_name, (int)language_type); + return NULL; + } + if (!(extractor = TO_EXTACTOR(comp_ctx->comp_data->extractor))) return NULL; LLVMDIBuilderRef DIB = comp_ctx->debug_builder; - LLVMMetadataRef File = comp_ctx->debug_file; + LLVMMetadataRef File = comp_ctx->debug_file; /* a fallback */ LLVMMetadataRef ParamTypes[num_function_args + 1]; @@ -312,9 +335,35 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx, if (function_arg_type.IsValid()) { ParamTypes[function_arg_idx + 1] = lldb_type_to_type_dbi(comp_ctx, function_arg_type); + if (ParamTypes[function_arg_idx + 1] == NULL) { + LOG_WARNING( + "func %s arg %" PRIu32 + " has a type not implemented by lldb_type_to_type_dbi", + function_name, function_arg_idx); + } + } + else { + LOG_WARNING("func %s arg %" PRIu32 ": GetTypeAtIndex failed", + function_name, function_arg_idx); + ParamTypes[function_arg_idx + 1] = NULL; } } + auto compile_unit = sc.GetCompileUnit(); + auto file_spec = compile_unit.GetFileSpec(); + const char *file_name = file_spec.GetFilename(); + const char *dir_name = file_spec.GetDirectory(); + LLVMMetadataRef file_info = NULL; + if (file_name || dir_name) { + file_info = + LLVMDIBuilderCreateFile(comp_ctx->debug_builder, file_name, + file_name ? strlen(file_name) : 0, dir_name, + dir_name ? strlen(dir_name) : 0); + } + if (file_info) { + File = file_info; + } + LLVMMetadataRef FunctionTy = LLVMDIBuilderCreateSubroutineType( DIB, File, ParamTypes, num_function_args + 1, LLVMDIFlagZero); @@ -365,15 +414,16 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx, for (uint32_t function_arg_idx = 0; function_arg_idx < variable_list.GetSize(); ++function_arg_idx) { SBValue variable(variable_list.GetValueAtIndex(function_arg_idx)); - if (variable.IsValid()) { + if (variable.IsValid() && ParamTypes[function_arg_idx + 1] != NULL) { SBDeclaration dec(variable.GetDeclaration()); auto valtype = variable.GetType(); LLVMMetadataRef ParamLocation = LLVMDIBuilderCreateDebugLocation( comp_ctx->context, dec.GetLine(), dec.GetColumn(), FunctionMetadata, NULL); + const char *varname = variable.GetName(); LLVMMetadataRef ParamVar = LLVMDIBuilderCreateParameterVariable( - DIB, FunctionMetadata, variable.GetName(), - strlen(variable.GetName()), function_arg_idx + 1 + 1, + DIB, FunctionMetadata, varname, varname ? strlen(varname) : 0, + function_arg_idx + 1 + 1, File, // starts form 1, and 1 is exenv, dec.GetLine(), ParamTypes[function_arg_idx + 1], true, LLVMDIFlagZero); @@ -457,6 +507,8 @@ dwarf_gen_location(const AOTCompContext *comp_ctx, dwarf_extractor *extractor; AOTFunc *func = func_ctx->aot_func; + if (func_ctx->debug_func == NULL) + return NULL; if (!(extractor = TO_EXTACTOR(comp_ctx->comp_data->extractor))) return NULL; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/debug/dwarf_extractor.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/debug/dwarf_extractor.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/debug/dwarf_extractor.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/debug/dwarf_extractor.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/iwasm_compl.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/iwasm_compl.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/iwasm_compl.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/iwasm_compl.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_access_lanes.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_access_lanes.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_access_lanes.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_access_lanes.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_access_lanes.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_access_lanes.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_access_lanes.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_access_lanes.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bit_shifts.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bit_shifts.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bit_shifts.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bit_shifts.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bit_shifts.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bit_shifts.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bit_shifts.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bit_shifts.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bitmask_extracts.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bitmask_extracts.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bitmask_extracts.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bitmask_extracts.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bitmask_extracts.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bitmask_extracts.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bitmask_extracts.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bitmask_extracts.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bitwise_ops.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bitwise_ops.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bitwise_ops.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bitwise_ops.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bitwise_ops.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bitwise_ops.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bitwise_ops.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bitwise_ops.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bool_reductions.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bool_reductions.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bool_reductions.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bool_reductions.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bool_reductions.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bool_reductions.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_bool_reductions.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_bool_reductions.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_common.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_common.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_common.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_common.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_common.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_common.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_common.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_common.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_comparisons.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_comparisons.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_comparisons.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_comparisons.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_comparisons.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_comparisons.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_comparisons.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_comparisons.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_construct_values.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_construct_values.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_construct_values.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_construct_values.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_construct_values.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_construct_values.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_construct_values.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_construct_values.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_conversions.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_conversions.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_conversions.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_conversions.c index e9d30bfcb29..042e28089df 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_conversions.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_conversions.c @@ -158,11 +158,15 @@ simd_integer_narrow_common(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, return false; } - /* sat */ + /* Refer to: + * https://github.com/WebAssembly/spec/blob/main/proposals/simd/SIMD.md#integer-to-integer-narrowing + * Regardless of the whether the operation is signed or unsigned, the input + * lanes are interpreted as signed integers. + */ if (!(vec1 = simd_saturate(comp_ctx, func_ctx, e_sat_i16x8, vec1, min, max, - is_signed)) + true)) || !(vec2 = simd_saturate(comp_ctx, func_ctx, e_sat_i16x8, vec2, min, - max, is_signed))) { + max, true))) { return false; } @@ -222,15 +226,6 @@ aot_compile_simd_i16x8_narrow_i32x4(AOTCompContext *comp_ctx, } } -bool -aot_compile_simd_i32x4_narrow_i64x2(AOTCompContext *comp_ctx, - AOTFuncContext *func_ctx, bool is_signed) -{ - /* TODO: x86 intrinsics */ - return simd_integer_narrow_common(comp_ctx, func_ctx, e_sat_i64x2, - is_signed); -} - enum integer_extend_type { e_ext_i8x16, e_ext_i16x8, @@ -740,4 +735,4 @@ aot_compile_simd_i64x2_extmul_i32x4(AOTCompContext *comp_ctx, { return simd_integer_extmul(comp_ctx, func_ctx, lower_half, is_signed, e_i64x2_extmul_i32x4); -} \ No newline at end of file +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_conversions.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_conversions.h similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_conversions.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_conversions.h index 87b8bd684e9..e3a1a3521c5 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_conversions.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_conversions.h @@ -20,10 +20,6 @@ bool aot_compile_simd_i16x8_narrow_i32x4(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, bool is_signed); -bool -aot_compile_simd_i32x4_narrow_i64x2(AOTCompContext *comp_ctx, - AOTFuncContext *func_ctx, bool is_signed); - bool aot_compile_simd_i16x8_extend_i8x16(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, bool is_low, diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_floating_point.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_floating_point.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_floating_point.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_floating_point.c index 7fcc1ab655d..536ef5b289d 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_floating_point.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_floating_point.c @@ -129,20 +129,6 @@ aot_compile_simd_f64x2_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) "llvm.fabs.v2f64"); } -bool -aot_compile_simd_f32x4_round(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) -{ - return simd_float_intrinsic(comp_ctx, func_ctx, V128_f32x4_TYPE, - "llvm.round.v4f32"); -} - -bool -aot_compile_simd_f64x2_round(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) -{ - return simd_float_intrinsic(comp_ctx, func_ctx, V128_f64x2_TYPE, - "llvm.round.v2f64"); -} - bool aot_compile_simd_f32x4_sqrt(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) { diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_floating_point.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_floating_point.h similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_floating_point.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_floating_point.h index 213b4391f84..39e37c872e8 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_floating_point.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_floating_point.h @@ -32,14 +32,6 @@ aot_compile_simd_f32x4_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx); bool aot_compile_simd_f64x2_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx); -bool -aot_compile_simd_f32x4_round(AOTCompContext *comp_ctx, - AOTFuncContext *func_ctx); - -bool -aot_compile_simd_f64x2_round(AOTCompContext *comp_ctx, - AOTFuncContext *func_ctx); - bool aot_compile_simd_f32x4_sqrt(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_int_arith.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_int_arith.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_int_arith.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_int_arith.c index 1d0e6967b6c..6a1902d1fd8 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_int_arith.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_int_arith.c @@ -243,7 +243,6 @@ aot_compile_simd_i64x2_abs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) enum integer_avgr_u { e_avgr_u_i8x16, e_avgr_u_i16x8, - e_avgr_u_i32x4, }; /* TODO: try int_x86_mmx_pavg_b and int_x86_mmx_pavg_w */ @@ -257,9 +256,8 @@ simd_v128_avg(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, LLVMTypeRef vector_type[] = { V128_i8x16_TYPE, V128_i16x8_TYPE, - V128_i32x4_TYPE, }; - unsigned lanes[] = { 16, 8, 4 }; + unsigned lanes[] = { 16, 8 }; if (!(rhs = simd_pop_v128_and_bitcast(comp_ctx, func_ctx, vector_type[itype], "rhs")) @@ -325,13 +323,6 @@ aot_compile_simd_i16x8_avgr_u(AOTCompContext *comp_ctx, return simd_v128_avg(comp_ctx, func_ctx, e_avgr_u_i16x8); } -bool -aot_compile_simd_i32x4_avgr_u(AOTCompContext *comp_ctx, - AOTFuncContext *func_ctx) -{ - return simd_v128_avg(comp_ctx, func_ctx, e_avgr_u_i32x4); -} - bool aot_compile_simd_i32x4_dot_i16x8(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_int_arith.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_int_arith.h similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_int_arith.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_int_arith.h index a7a21170aec..49827d51d05 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_int_arith.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_int_arith.h @@ -76,10 +76,6 @@ bool aot_compile_simd_i16x8_avgr_u(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx); -bool -aot_compile_simd_i32x4_avgr_u(AOTCompContext *comp_ctx, - AOTFuncContext *func_ctx); - bool aot_compile_simd_i32x4_dot_i16x8(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_load_store.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_load_store.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_load_store.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_load_store.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_load_store.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_load_store.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_load_store.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_load_store.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_sat_int_arith.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_sat_int_arith.c similarity index 80% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_sat_int_arith.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_sat_int_arith.c index 1de4520a706..ea250b7e085 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_sat_int_arith.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_sat_int_arith.c @@ -64,18 +64,3 @@ aot_compile_simd_i16x8_saturate(AOTCompContext *comp_ctx, is_signed ? intrinsics[arith_op][0] : intrinsics[arith_op][1]); } - -bool -aot_compile_simd_i32x4_saturate(AOTCompContext *comp_ctx, - AOTFuncContext *func_ctx, - V128Arithmetic arith_op, bool is_signed) -{ - char *intrinsics[][2] = { - { "llvm.sadd.sat.v4i32", "llvm.uadd.sat.v4i32" }, - { "llvm.ssub.sat.v4i32", "llvm.usub.sat.v4i32" }, - }; - - return simd_sat_int_arith(comp_ctx, func_ctx, V128_i16x8_TYPE, - is_signed ? intrinsics[arith_op][0] - : intrinsics[arith_op][1]); -} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_sat_int_arith.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_sat_int_arith.h similarity index 79% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_sat_int_arith.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_sat_int_arith.h index e30acaaf44f..67c602fc55e 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/compilation/simd/simd_sat_int_arith.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/compilation/simd/simd_sat_int_arith.h @@ -22,10 +22,6 @@ aot_compile_simd_i16x8_saturate(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, V128Arithmetic arith_op, bool is_signed); -bool -aot_compile_simd_i32x4_saturate(AOTCompContext *comp_ctx, - AOTFuncContext *func_ctx, - V128Arithmetic arith_op, bool is_signed); #ifdef __cplusplus } /* end of extern "C" */ #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/classic_interpreter.MD b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/classic_interpreter.MD similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/classic_interpreter.MD rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/classic_interpreter.MD diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/export_function.excalidraw b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/export_function.excalidraw similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/export_function.excalidraw rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/export_function.excalidraw diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/stack_format_ci.excalidraw b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/stack_format_ci.excalidraw similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/stack_format_ci.excalidraw rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/stack_format_ci.excalidraw diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/stack_format_ci.svg b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/stack_format_ci.svg similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/stack_format_ci.svg rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/stack_format_ci.svg diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_exports.svg b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_exports.svg similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_exports.svg rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_exports.svg diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_function.excalidraw b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_function.excalidraw similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_function.excalidraw rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_function.excalidraw diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_function.svg b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_function.svg similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_function.svg rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_function.svg diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_globals.excalidraw b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_globals.excalidraw similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_globals.excalidraw rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_globals.excalidraw diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_globals.svg b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_globals.svg similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/images/wasm_globals.svg rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/images/wasm_globals.svg diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/wasm_exports.MD b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/wasm_exports.MD similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/wasm_exports.MD rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/wasm_exports.MD diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/wasm_function.MD b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/wasm_function.MD similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/wasm_function.MD rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/wasm_function.MD diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/wasm_globals.MD b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/wasm_globals.MD similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/doc/wasm_globals.MD rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/doc/wasm_globals.MD diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/asmjit_sgx_patch.diff b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/asmjit_sgx_patch.diff similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/asmjit_sgx_patch.diff rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/asmjit_sgx_patch.diff diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/cg/LICENSE_ASMJIT b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/cg/LICENSE_ASMJIT similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/cg/LICENSE_ASMJIT rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/cg/LICENSE_ASMJIT diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/cg/LICENSE_ZYDIS b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/cg/LICENSE_ZYDIS similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/cg/LICENSE_ZYDIS rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/cg/LICENSE_ZYDIS diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp index e28acf98a62..020f4f35f43 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/cg/x86-64/jit_codegen_x86_64.cpp @@ -4379,13 +4379,18 @@ cmp_r_r_to_r_i32(x86::Assembler &a, int32 reg_no_dst, int32 reg_no1_src, * @return true if success, false otherwise */ static bool -cmp_imm_imm_to_r_i64(x86::Assembler &a, int32 reg_no_dst, int32 data1_src, - int32 data2_src) +cmp_imm_imm_to_r_i64(x86::Assembler &a, int32 reg_no_dst, int64 data1_src, + int64 data2_src) { - Imm imm(data1_src); - a.mov(regs_i64[REG_I64_FREE_IDX], imm); - imm.setValue(data2_src); - a.cmp(regs_i64[REG_I64_FREE_IDX], imm); + /* imm -> m64 */ + const JitHardRegInfo *hreg_info = jit_codegen_get_hreg_info(); + x86::Mem mem = x86::qword_ptr(regs_i64[hreg_info->exec_env_hreg_index], + offsetof(WASMExecEnv, jit_cache)); + Imm imm(data2_src); + mov_imm_to_m(a, mem, imm, 8); + + a.mov(regs_i64[REG_I64_FREE_IDX], data1_src); + a.cmp(regs_i64[REG_I64_FREE_IDX], mem); (void)reg_no_dst; return true; } @@ -7506,7 +7511,7 @@ at_rmw_xor_r_base_r_offset_r(x86::Assembler &a, uint32 bytes_dst, CHECK_KIND(r3, JIT_REG_KIND_I64); \ } \ /* r0: read/return value r2: memory base addr can't be const */ \ - /* already check it's not const in LOAD_4ARGS(); */ \ + /* already check it's not const in LOAD_4ARGS() */ \ reg_no_dst = jit_reg_no(r0); \ CHECK_REG_NO(reg_no_dst, jit_reg_kind(r0)); \ /* mem_data base address has to be non-const */ \ @@ -9288,8 +9293,8 @@ jit_codegen_init() imm.setValue(INT32_MAX); a.jne(imm); - char *stream = (char *)a.code()->sectionById(0)->buffer().data() - + a.code()->sectionById(0)->buffer().size(); + char *stream_old = (char *)a.code()->sectionById(0)->buffer().data() + + a.code()->sectionById(0)->buffer().size(); /* If yes, call jit_set_exception_with_id to throw exception, and then set eax to JIT_INTERP_ACTION_THROWN, and jump to @@ -9314,7 +9319,7 @@ jit_codegen_init() /* Patch the offset of jne instruction */ char *stream_new = (char *)a.code()->sectionById(0)->buffer().data() + a.code()->sectionById(0)->buffer().size(); - *(int32 *)(stream - 4) = (int32)(stream_new - stream); + *(int32 *)(stream_old - 4) = (int32)(stream_new - stream_old); } /* Load compiled func ptr and call it */ @@ -9414,7 +9419,7 @@ static uint8 hreg_info_F64[3][16] = { 1, 1, 1, 1, 1, 1, 1, 0 }, /* caller_saved_jitted */ }; -static const JitHardRegInfo hreg_info = { +static const JitHardRegInfo g_hreg_info = { { { 0, NULL, NULL, NULL }, /* VOID */ @@ -9454,7 +9459,7 @@ static const JitHardRegInfo hreg_info = { const JitHardRegInfo * jit_codegen_get_hreg_info() { - return &hreg_info; + return &g_hreg_info; } static const char *reg_names_i32[] = { diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_compare.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_compare.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_compare.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_compare.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_compare.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_compare.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_compare.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_compare.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_const.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_const.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_const.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_const.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_const.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_const.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_const.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_const.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_control.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_control.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_control.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_control.c index 5438bc62cfe..fc6b9737e5d 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_control.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_control.c @@ -396,9 +396,8 @@ handle_func_return(JitCompContext *cc, JitBlock *block) #endif #if WASM_ENABLE_PERF_PROFILING != 0 - /* time_end = os_time_get_boot_microsecond() */ - if (!jit_emit_callnative(cc, os_time_get_boot_microsecond, time_end, NULL, - 0)) { + /* time_end = os_time_get_boot_us() */ + if (!jit_emit_callnative(cc, os_time_get_boot_us, time_end, NULL, 0)) { return false; } /* time_start = cur_frame->time_started */ @@ -1102,7 +1101,7 @@ jit_compile_op_br_if(JitCompContext *cc, uint32 br_depth, } } - /* Only opy parameters or results when their count > 0 and + /* Only copy parameters or results when their count > 0 and the src/dst addr are different */ copy_arities = check_copy_arities(block_dst, jit_frame); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_control.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_control.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_control.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_control.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_conversion.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_conversion.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_conversion.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_conversion.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_conversion.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_conversion.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_conversion.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_conversion.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_exception.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_exception.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_exception.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_exception.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_exception.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_exception.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_exception.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_exception.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_function.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_function.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_function.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_function.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_function.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_function.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_function.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_function.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_memory.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_memory.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_memory.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_memory.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_memory.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_memory.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_memory.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_memory.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_numberic.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_numberic.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_numberic.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_numberic.c index 6a1e93edeee..00f608f84d1 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_numberic.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_numberic.c @@ -1066,13 +1066,15 @@ DEF_UNI_INT_CONST_OPS(shru) static int32 do_i32_const_shl(int32 lhs, int32 rhs) { + rhs &= 31; return (int32)((uint32)lhs << (uint32)rhs); } static int64 do_i64_const_shl(int64 lhs, int64 rhs) { - return (int32)((uint64)lhs << (uint64)rhs); + rhs &= 63LL; + return (uint64)lhs << (uint64)rhs; } DEF_BI_INT_CONST_OPS(shrs, >>) @@ -1080,12 +1082,14 @@ DEF_BI_INT_CONST_OPS(shrs, >>) static int32 do_i32_const_shru(int32 lhs, int32 rhs) { + rhs &= 31; return (uint32)lhs >> rhs; } static int64 do_i64_const_shru(int64 lhs, int64 rhs) { + rhs &= 63LL; return (uint64)lhs >> rhs; } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_numberic.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_numberic.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_numberic.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_numberic.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_parametric.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_parametric.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_parametric.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_parametric.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_parametric.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_parametric.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_parametric.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_parametric.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_table.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_table.c similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_table.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_table.c index b8ed6a1d502..26bc35394b9 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_table.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_table.c @@ -88,17 +88,21 @@ jit_compile_op_table_set(JitCompContext *cc, uint32 tbl_idx) } static int -wasm_init_table(WASMModuleInstance *inst, uint32 tbl_idx, uint32 elem_idx, +wasm_init_table(WASMModuleInstance *inst, uint32 tbl_idx, uint32 seg_idx, uint32 dst_offset, uint32 len, uint32 src_offset) { WASMTableInstance *tbl; uint32 tbl_sz; - WASMTableSeg *elem; - uint32 elem_len; + WASMTableSeg *tbl_seg = inst->module->table_segments + seg_idx; + uint32 *tbl_seg_elems = NULL, tbl_seg_len = 0; - elem = inst->module->table_segments + elem_idx; - elem_len = elem->function_count; - if (offset_len_out_of_bounds(src_offset, len, elem_len)) + if (!bh_bitmap_get_bit(inst->e->common.elem_dropped, seg_idx)) { + /* table segment isn't dropped */ + tbl_seg_elems = tbl_seg->func_indexes; + tbl_seg_len = tbl_seg->function_count; + } + + if (offset_len_out_of_bounds(src_offset, len, tbl_seg_len)) goto out_of_bounds; tbl = inst->tables[tbl_idx]; @@ -109,14 +113,10 @@ wasm_init_table(WASMModuleInstance *inst, uint32 tbl_idx, uint32 elem_idx, if (!len) return 0; - if (bh_bitmap_get_bit(inst->e->common.elem_dropped, elem_idx)) - goto out_of_bounds; - bh_memcpy_s((uint8 *)tbl + offsetof(WASMTableInstance, elems) + dst_offset * sizeof(uint32), (uint32)((tbl_sz - dst_offset) * sizeof(uint32)), - elem->func_indexes + src_offset, - (uint32)(len * sizeof(uint32))); + tbl_seg_elems + src_offset, (uint32)(len * sizeof(uint32))); return 0; out_of_bounds: diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_table.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_table.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_table.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_table.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_variable.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_variable.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_variable.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_variable.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_variable.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_variable.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/fe/jit_emit_variable.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/fe/jit_emit_variable.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/iwasm_fast_jit.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/iwasm_fast_jit.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/iwasm_fast_jit.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/iwasm_fast_jit.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_codecache.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_codecache.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_codecache.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_codecache.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_codecache.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_codecache.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_codecache.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_codecache.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_codegen.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_codegen.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_codegen.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_codegen.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_codegen.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_codegen.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_codegen.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_codegen.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_compiler.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_compiler.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_compiler.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_compiler.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_compiler.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_compiler.h similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_compiler.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_compiler.h index dee2631d14a..9a49cffdd1a 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_compiler.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_compiler.h @@ -70,7 +70,6 @@ typedef struct JitInterpSwitchInfo { typedef struct JitCompOptions { uint32 code_cache_size; uint32 opt_level; - bool linux_perf_support; } JitCompOptions; bool diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_dump.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_dump.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_dump.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_dump.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_dump.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_dump.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_dump.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_dump.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_frontend.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_frontend.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_frontend.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_frontend.c index c9c22e0adf3..e9d7a3ff348 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_frontend.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_frontend.c @@ -1157,11 +1157,10 @@ init_func_translation(JitCompContext *cc) func_inst = jit_cc_new_reg_ptr(cc); #if WASM_ENABLE_PERF_PROFILING != 0 time_started = jit_cc_new_reg_I64(cc); - /* Call os_time_get_boot_microsecond() to get time_started firstly + /* Call os_time_get_boot_us() to get time_started firstly as there is stack frame switching below, calling native in them may cause register spilling work inproperly */ - if (!jit_emit_callnative(cc, os_time_get_boot_microsecond, time_started, - NULL, 0)) { + if (!jit_emit_callnative(cc, os_time_get_boot_us, time_started, NULL, 0)) { return NULL; } #endif @@ -2258,7 +2257,9 @@ jit_compile_func(JitCompContext *cc) uint32 opcode1; read_leb_uint32(frame_ip, frame_ip_end, opcode1); - opcode = (uint32)opcode1; + /* opcode1 was checked in loader and is no larger than + UINT8_MAX */ + opcode = (uint8)opcode1; switch (opcode) { case WASM_OP_I32_TRUNC_SAT_S_F32: @@ -2397,10 +2398,13 @@ jit_compile_func(JitCompContext *cc) case WASM_OP_ATOMIC_PREFIX: { uint8 bin_op, op_type; + uint32 opcode1; + + read_leb_uint32(frame_ip, frame_ip_end, opcode1); + /* opcode1 was checked in loader and is no larger than + UINT8_MAX */ + opcode = (uint8)opcode1; - if (frame_ip < frame_ip_end) { - opcode = *frame_ip++; - } if (opcode != WASM_OP_ATOMIC_FENCE) { read_leb_uint32(frame_ip, frame_ip_end, align); read_leb_uint32(frame_ip, frame_ip_end, offset); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_frontend.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_frontend.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_frontend.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_frontend.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_ir.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_ir.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_ir.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_ir.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_ir.def b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_ir.def similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_ir.def rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_ir.def diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_ir.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_ir.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_ir.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_ir.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_regalloc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_regalloc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_regalloc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_regalloc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_utils.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_utils.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/fast-jit/jit_utils.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/fast-jit/jit_utils.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/aot_export.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/aot_export.h similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/aot_export.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/aot_export.h index f2184033a54..e1837e64f85 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/aot_export.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/aot_export.h @@ -58,6 +58,7 @@ typedef struct AOTCompOption { bool disable_llvm_lto; bool enable_llvm_pgo; bool enable_stack_estimation; + bool quick_invoke_c_api_import; char *use_prof_file; uint32_t opt_level; uint32_t size_level; @@ -65,7 +66,6 @@ typedef struct AOTCompOption { uint32_t bounds_checks; uint32_t stack_bounds_checks; uint32_t segue_flags; - bool linux_perf_support; char **custom_sections; uint32_t custom_sections_count; const char *stack_usage_file; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/lib_export.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/lib_export.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/lib_export.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/lib_export.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/wasm_c_api.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/wasm_c_api.h similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/wasm_c_api.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/wasm_c_api.h index eaad941e45f..304b3a4ee85 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/wasm_c_api.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/wasm_c_api.h @@ -22,12 +22,12 @@ #endif #if defined(__GNUC__) || defined(__clang__) -#define DEPRECATED __attribute__((deprecated)) +#define WASM_API_DEPRECATED __attribute__((deprecated)) #elif defined(_MSC_VER) -#define DEPRECATED __declspec(deprecated) +#define WASM_API_DEPRECATED __declspec(deprecated) #else #pragma message("WARNING: You need to implement DEPRECATED for this compiler") -#define DEPRECATED +#define WASM_API_DEPRECATED #endif #ifdef __cplusplus @@ -181,7 +181,8 @@ typedef union MemAllocOption { struct wasm_config_t { mem_alloc_type_t mem_alloc_type; MemAllocOption mem_alloc_option; - bool linux_perf_support; + uint32_t segue_flags; + bool enable_linux_perf; /*TODO: wasi args*/ }; @@ -189,7 +190,7 @@ struct wasm_config_t { * by default: * - mem_alloc_type is Alloc_With_System_Allocator * - mem_alloc_option is all 0 - * - linux_perf_support is false + * - enable_linux_perf is false */ WASM_API_EXTERN own wasm_config_t* wasm_config_new(void); @@ -200,6 +201,17 @@ wasm_config_set_mem_alloc_opt(wasm_config_t *, mem_alloc_type_t, MemAllocOption WASM_API_EXTERN own wasm_config_t* wasm_config_set_linux_perf_opt(wasm_config_t *, bool); +/** + * Enable using GS register as the base address of linear memory in linux x86_64, + * which may speedup the linear memory access for LLVM AOT/JIT: + * bit0 to bit4 denotes i32.load, i64.load, f32.load, f64.load, v128.load + * bit8 to bit12 denotes i32.store, i64.store, f32.store, f64.store, v128.store + * For example, 0x01 enables i32.load, 0x0100 enables i32.store. + * To enable all load/store operations, use 0x1F1F + */ +WASM_API_EXTERN wasm_config_t* +wasm_config_set_segue_flags(wasm_config_t *config, uint32_t segue_flags); + // Engine WASM_DECLARE_OWN(engine) @@ -219,7 +231,7 @@ WASM_DECLARE_OWN(engine) */ WASM_API_EXTERN own wasm_engine_t* wasm_engine_new(void); WASM_API_EXTERN own wasm_engine_t* wasm_engine_new_with_config(wasm_config_t*); -DEPRECATED WASM_API_EXTERN own wasm_engine_t * +WASM_API_DEPRECATED WASM_API_EXTERN own wasm_engine_t * wasm_engine_new_with_args(mem_alloc_type_t type, const MemAllocOption *opts); // Store @@ -405,6 +417,7 @@ struct wasm_ref_t; typedef struct wasm_val_t { wasm_valkind_t kind; + uint8_t __paddings[7]; union { int32_t i32; int64_t i64; @@ -815,12 +828,12 @@ static inline void* wasm_val_ptr(const wasm_val_t* val) { #endif } -#define WASM_I32_VAL(i) {.kind = WASM_I32, .of = {.i32 = i}} -#define WASM_I64_VAL(i) {.kind = WASM_I64, .of = {.i64 = i}} -#define WASM_F32_VAL(z) {.kind = WASM_F32, .of = {.f32 = z}} -#define WASM_F64_VAL(z) {.kind = WASM_F64, .of = {.f64 = z}} -#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, .of = {.ref = r}} -#define WASM_INIT_VAL {.kind = WASM_ANYREF, .of = {.ref = NULL}} +#define WASM_I32_VAL(i) {.kind = WASM_I32, .__paddings = {0}, .of = {.i32 = i}} +#define WASM_I64_VAL(i) {.kind = WASM_I64, .__paddings = {0}, .of = {.i64 = i}} +#define WASM_F32_VAL(z) {.kind = WASM_F32, .__paddings = {0}, .of = {.f32 = z}} +#define WASM_F64_VAL(z) {.kind = WASM_F64, .__paddings = {0}, .of = {.f64 = z}} +#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, .__paddings = {0}, .of = {.ref = r}} +#define WASM_INIT_VAL {.kind = WASM_ANYREF, .__paddings = {0}, .of = {.ref = NULL}} #define KILOBYTE(n) ((n) * 1024) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/wasm_export.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/wasm_export.h similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/wasm_export.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/wasm_export.h index d8e761e83e5..dda058d084a 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/include/wasm_export.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/include/wasm_export.h @@ -172,12 +172,12 @@ typedef struct RuntimeInitArgs { /** * If enabled * - llvm-jit will output a jitdump file for `perf inject` - * - aot. TBD + * - aot will output a perf-${pid}.map for `perf record` * - fast-jit. TBD * - multi-tier-jit. TBD * - interpreter. TBD */ - bool linux_perf_support; + bool enable_linux_perf; } RuntimeInitArgs; #ifndef WASM_VALKIND_T_DEFINED @@ -199,6 +199,7 @@ struct wasm_ref_t; typedef struct wasm_val_t { wasm_valkind_t kind; + uint8_t __paddings[7]; union { /* also represent a function index */ int32_t i32; @@ -212,6 +213,14 @@ typedef struct wasm_val_t { } wasm_val_t; #endif +typedef enum { + WASM_LOG_LEVEL_FATAL = 0, + WASM_LOG_LEVEL_ERROR = 1, + WASM_LOG_LEVEL_WARNING = 2, + WASM_LOG_LEVEL_DEBUG = 3, + WASM_LOG_LEVEL_VERBOSE = 4 +} log_level_t; + /** * Initialize the WASM runtime environment, and also initialize * the memory allocator with system allocator, which calls os_malloc @@ -234,6 +243,14 @@ wasm_runtime_init(void); WASM_RUNTIME_API_EXTERN bool wasm_runtime_full_init(RuntimeInitArgs *init_args); +/** + * Set the log level. To be called after the runtime is initialized. + * + * @param level the log level to set + */ +WASM_RUNTIME_API_EXTERN void +wasm_runtime_set_log_level(log_level_t level); + /** * Query whether a certain running mode is supported for the runtime * @@ -924,9 +941,6 @@ wasm_runtime_clear_exception(wasm_module_inst_t module_inst); * - Another thread has a copy of `wasm_module_inst_t` of * the module instance and wants to terminate it asynchronously. * - * This function is provided only when WAMR is built with threading enabled. - * (`WASM_ENABLE_THREAD_MGR=1`) - * * @param module_inst the WASM module instance */ WASM_RUNTIME_API_EXTERN void @@ -1260,6 +1274,26 @@ wasm_runtime_dump_mem_consumption(wasm_exec_env_t exec_env); WASM_RUNTIME_API_EXTERN void wasm_runtime_dump_perf_profiling(wasm_module_inst_t module_inst); +/** + * Return total wasm functions' execution time in ms + * + * @param module_inst the WASM module instance to profile + */ +WASM_RUNTIME_API_EXTERN double +wasm_runtime_sum_wasm_exec_time(wasm_module_inst_t module_inst); + +/** + * Return execution time in ms of a given wasm funciton with +* func_name. If the function is not found, return 0. + * + * @param module_inst the WASM module instance to profile + * @param func_name could be an export name or a name in the + * name section + */ +WASM_RUNTIME_API_EXTERN double +wasm_runtime_get_wasm_func_exec_time(wasm_module_inst_t inst, + const char *func_name); + /* wasm thread callback function type */ typedef void *(*wasm_thread_callback_t)(wasm_exec_env_t, void *); /* wasm thread type */ @@ -1573,6 +1607,9 @@ wasm_runtime_get_context(wasm_module_inst_t inst, void *key); * host functions. It wraps an operation which possibly blocks for long * to prepare for async termination. * + * For simplicity, we recommend to wrap only the very minimum piece of + * the code with this. Ideally, just a single system call. + * * eg. * * if (!wasm_runtime_begin_blocking_op(exec_env)) { diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/iwasm_interp.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/iwasm_interp.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/iwasm_interp.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/iwasm_interp.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm.h similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm.h index ee537aa63b2..60e1238ad3e 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm.h @@ -65,6 +65,9 @@ extern "C" { #if WASM_ENABLE_BULK_MEMORY != 0 #define SECTION_TYPE_DATACOUNT 12 #endif +#if WASM_ENABLE_TAGS != 0 +#define SECTION_TYPE_TAG 13 +#endif #define SUB_SECTION_TYPE_MODULE 0 #define SUB_SECTION_TYPE_FUNC 1 @@ -74,20 +77,34 @@ extern "C" { #define IMPORT_KIND_TABLE 1 #define IMPORT_KIND_MEMORY 2 #define IMPORT_KIND_GLOBAL 3 +#if WASM_ENABLE_TAGS != 0 +#define IMPORT_KIND_TAG 4 +#endif #define EXPORT_KIND_FUNC 0 #define EXPORT_KIND_TABLE 1 #define EXPORT_KIND_MEMORY 2 #define EXPORT_KIND_GLOBAL 3 +#if WASM_ENABLE_TAGS != 0 +#define EXPORT_KIND_TAG 4 +#endif #define LABEL_TYPE_BLOCK 0 #define LABEL_TYPE_LOOP 1 #define LABEL_TYPE_IF 2 #define LABEL_TYPE_FUNCTION 3 +#if WASM_ENABLE_EXCE_HANDLING != 0 +#define LABEL_TYPE_TRY 4 +#define LABEL_TYPE_CATCH 5 +#define LABEL_TYPE_CATCH_ALL 6 +#endif typedef struct WASMModule WASMModule; typedef struct WASMFunction WASMFunction; typedef struct WASMGlobal WASMGlobal; +#if WASM_ENABLE_TAGS != 0 +typedef struct WASMTag WASMTag; +#endif typedef union V128 { int8 i8x16[16]; @@ -129,6 +146,10 @@ typedef struct WASMType { /* Code block to call llvm jit functions of this kind of function type from fast jit jitted code */ void *call_to_llvm_jit_from_fast_jit; +#endif +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 + /* Quick AOT/JIT entry of this func type */ + void *quick_aot_entry; #endif /* types of params and results */ uint8 types[1]; @@ -197,6 +218,24 @@ typedef struct WASMFunctionImport { bool call_conv_wasm_c_api; } WASMFunctionImport; +#if WASM_ENABLE_TAGS != 0 +typedef struct WASMTagImport { + char *module_name; + char *field_name; + uint8 attribute; /* the type of the tag (numerical) */ + uint32 type; /* the type of the catch function (numerical)*/ + WASMType *tag_type; + void *tag_ptr_linked; + +#if WASM_ENABLE_MULTI_MODULE != 0 + /* imported tag pointer after linked */ + WASMModule *import_module; + WASMTag *import_tag_linked; + uint32 import_tag_index_linked; +#endif +} WASMTagImport; +#endif + typedef struct WASMGlobalImport { char *module_name; char *field_name; @@ -223,6 +262,9 @@ typedef struct WASMImport { WASMFunctionImport function; WASMTableImport table; WASMMemoryImport memory; +#if WASM_ENABLE_TAGS != 0 + WASMTagImport tag; +#endif WASMGlobalImport global; struct { char *module_name; @@ -261,6 +303,10 @@ struct WASMFunction { uint32 const_cell_num; #endif +#if WASM_ENABLE_EXCE_HANDLING != 0 + uint32 exception_handler_count; +#endif + #if WASM_ENABLE_FAST_JIT != 0 || WASM_ENABLE_JIT != 0 \ || WASM_ENABLE_WAMR_COMPILER != 0 /* Whether function has opcode memory.grow */ @@ -290,6 +336,14 @@ struct WASMFunction { #endif }; +#if WASM_ENABLE_TAGS != 0 +struct WASMTag { + uint8 attribute; /* the attribute property of the tag (expected to be 0) */ + uint32 type; /* the type of the tag (expected valid inden in type table) */ + WASMType *tag_type; +}; +#endif + struct WASMGlobal { uint8 type; bool is_mutable; @@ -416,6 +470,9 @@ struct WASMModule { uint32 function_count; uint32 table_count; uint32 memory_count; +#if WASM_ENABLE_TAGS != 0 + uint32 tag_count; +#endif uint32 global_count; uint32 export_count; uint32 table_seg_count; @@ -429,11 +486,17 @@ struct WASMModule { uint32 import_function_count; uint32 import_table_count; uint32 import_memory_count; +#if WASM_ENABLE_TAGS != 0 + uint32 import_tag_count; +#endif uint32 import_global_count; WASMImport *import_functions; WASMImport *import_tables; WASMImport *import_memories; +#if WASM_ENABLE_TAGS != 0 + WASMImport *import_tags; +#endif WASMImport *import_globals; WASMType **types; @@ -441,6 +504,9 @@ struct WASMModule { WASMFunction **functions; WASMTable *tables; WASMMemory *memories; +#if WASM_ENABLE_TAGS != 0 + WASMTag **tags; +#endif WASMGlobal *globals; WASMExport *exports; WASMTableSeg *table_segments; @@ -624,6 +690,11 @@ typedef struct WASMBranchBlock { uint8 *target_addr; uint32 *frame_sp; uint32 cell_num; +#if WASM_ENABLE_EXCE_HANDLING != 0 + /* in exception handling, label_type needs to be stored to lookup exception + * handlers */ + uint8 label_type; +#endif } WASMBranchBlock; /** diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp.h similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp.h index d3692ff21b0..2b5a51ea8e7 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp.h @@ -34,6 +34,14 @@ typedef struct WASMInterpFrame { uint64 time_started; #endif +#if WASM_ENABLE_EXCE_HANDLING != 0 + /* set to true if the callee returns an exception rather than + * result values on the stack + */ + bool exception_raised; + uint32 tag_index; +#endif + #if WASM_ENABLE_FAST_INTERP != 0 /* Return offset of the first return value of current frame, the callee will put return values here continuously */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp_classic.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp_classic.c similarity index 82% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp_classic.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp_classic.c index e27b16544f2..31dc5930c25 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp_classic.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp_classic.c @@ -338,10 +338,19 @@ read_leb(const uint8 *buf, uint32 *p_offset, uint32 maxbits, bool sign) frame_sp += 2; \ } while (0) +/* in exception handling, label_type needs to be stored to lookup exception + * handlers */ + +#if WASM_ENABLE_EXCE_HANDLING != 0 +#define SET_LABEL_TYPE(_label_type) frame_csp->label_type = _label_type +#else +#define SET_LABEL_TYPE(_label_type) (void)0 +#endif + #define PUSH_CSP(_label_type, param_cell_num, cell_num, _target_addr) \ do { \ bh_assert(frame_csp < frame->csp_boundary); \ - /* frame_csp->label_type = _label_type; */ \ + SET_LABEL_TYPE(_label_type); \ frame_csp->cell_num = cell_num; \ frame_csp->begin_addr = frame_ip; \ frame_csp->target_addr = _target_addr; \ @@ -392,6 +401,18 @@ read_leb(const uint8 *buf, uint32 *p_offset, uint32 maxbits, bool sign) frame_sp -= n; \ } while (0) +#if WASM_ENABLE_EXCE_HANDLING != 0 +/* unwind the CSP to a given label and optionally modify the labeltype */ +#define UNWIND_CSP(N, T) \ + do { \ + /* unwind to function frame */ \ + frame_csp -= N; \ + /* drop handlers and values pushd in try block */ \ + frame_sp = (frame_csp - 1)->frame_sp; \ + (frame_csp - 1)->label_type = T ? T : (frame_csp - 1)->label_type; \ + } while (0) +#endif + #define SYNC_ALL_TO_FRAME() \ do { \ frame->sp = frame_sp; \ @@ -707,7 +728,7 @@ trunc_f64_to_int(WASMModuleInstance *module, uint32 *frame_sp, float64 src_min, addr = POP_I32(); \ \ if (opcode == WASM_OP_ATOMIC_RMW_I32_##OP_NAME##8_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); \ + CHECK_MEMORY_OVERFLOW(1); \ CHECK_ATOMIC_MEMORY_ACCESS(); \ \ shared_memory_lock(memory); \ @@ -716,7 +737,7 @@ trunc_f64_to_int(WASMModuleInstance *module, uint32 *frame_sp, float64 src_min, shared_memory_unlock(memory); \ } \ else if (opcode == WASM_OP_ATOMIC_RMW_I32_##OP_NAME##16_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); \ + CHECK_MEMORY_OVERFLOW(2); \ CHECK_ATOMIC_MEMORY_ACCESS(); \ \ shared_memory_lock(memory); \ @@ -725,7 +746,7 @@ trunc_f64_to_int(WASMModuleInstance *module, uint32 *frame_sp, float64 src_min, shared_memory_unlock(memory); \ } \ else { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); \ + CHECK_MEMORY_OVERFLOW(4); \ CHECK_ATOMIC_MEMORY_ACCESS(); \ \ shared_memory_lock(memory); \ @@ -747,7 +768,7 @@ trunc_f64_to_int(WASMModuleInstance *module, uint32 *frame_sp, float64 src_min, addr = POP_I32(); \ \ if (opcode == WASM_OP_ATOMIC_RMW_I64_##OP_NAME##8_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); \ + CHECK_MEMORY_OVERFLOW(1); \ CHECK_ATOMIC_MEMORY_ACCESS(); \ \ shared_memory_lock(memory); \ @@ -756,7 +777,7 @@ trunc_f64_to_int(WASMModuleInstance *module, uint32 *frame_sp, float64 src_min, shared_memory_unlock(memory); \ } \ else if (opcode == WASM_OP_ATOMIC_RMW_I64_##OP_NAME##16_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); \ + CHECK_MEMORY_OVERFLOW(2); \ CHECK_ATOMIC_MEMORY_ACCESS(); \ \ shared_memory_lock(memory); \ @@ -765,7 +786,7 @@ trunc_f64_to_int(WASMModuleInstance *module, uint32 *frame_sp, float64 src_min, shared_memory_unlock(memory); \ } \ else if (opcode == WASM_OP_ATOMIC_RMW_I64_##OP_NAME##32_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); \ + CHECK_MEMORY_OVERFLOW(4); \ CHECK_ATOMIC_MEMORY_ACCESS(); \ \ shared_memory_lock(memory); \ @@ -775,7 +796,7 @@ trunc_f64_to_int(WASMModuleInstance *module, uint32 *frame_sp, float64 src_min, } \ else { \ uint64 op_result; \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); \ + CHECK_MEMORY_OVERFLOW(8); \ CHECK_ATOMIC_MEMORY_ACCESS(); \ \ shared_memory_lock(memory); \ @@ -850,7 +871,7 @@ ALLOC_FRAME(WASMExecEnv *exec_env, uint32 size, WASMInterpFrame *prev_frame) if (frame) { frame->prev_frame = prev_frame; #if WASM_ENABLE_PERF_PROFILING != 0 - frame->time_started = os_time_get_boot_microsecond(); + frame->time_started = os_time_thread_cputime_us(); #endif } else { @@ -866,9 +887,13 @@ FREE_FRAME(WASMExecEnv *exec_env, WASMInterpFrame *frame) { #if WASM_ENABLE_PERF_PROFILING != 0 if (frame->function) { - frame->function->total_exec_time += - os_time_get_boot_microsecond() - frame->time_started; + WASMInterpFrame *prev_frame = frame->prev_frame; + uint64 elapsed = os_time_thread_cputime_us() - frame->time_started; + frame->function->total_exec_time += elapsed; frame->function->total_exec_cnt++; + + if (prev_frame && prev_frame->function) + prev_frame->function->children_exec_time += elapsed; } #endif wasm_exec_env_free_wasm_frame(exec_env, frame); @@ -1184,6 +1209,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint32 local_idx, local_offset, global_idx; uint8 local_type, *global_addr; uint32 cache_index, type_index, param_cell_num, cell_num; +#if WASM_ENABLE_EXCE_HANDLING != 0 + int32_t exception_tag_index; +#endif uint8 value_type; #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 @@ -1194,6 +1222,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, bool disable_bounds_checks = false; #endif #endif +#if WASM_ENABLE_TAIL_CALL != 0 + bool is_return_call = false; +#endif #if WASM_ENABLE_DEBUG_INTERP != 0 uint8 *frame_ip_orig = NULL; @@ -1226,6 +1257,390 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP(WASM_OP_NOP) { HANDLE_OP_END(); } +#if WASM_ENABLE_EXCE_HANDLING != 0 + + HANDLE_OP(WASM_OP_RETHROW) + { + int32_t relative_depth; + read_leb_int32(frame_ip, frame_ip_end, relative_depth); + + /* No frame found with exception handler; validation should + * catch it */ + bh_assert(frame_csp >= frame->csp_bottom + relative_depth); + + /* go up the frame stack */ + WASMBranchBlock *tgtframe = (frame_csp - 1) - relative_depth; + + bh_assert(tgtframe->label_type == LABEL_TYPE_CATCH + || tgtframe->label_type == LABEL_TYPE_CATCH_ALL); + + /* tgtframe points to the frame containing a thrown + * exception */ + + uint32 *tgtframe_sp = tgtframe->frame_sp; + + /* frame sp of tgtframe points to catched exception */ + exception_tag_index = *((uint32 *)tgtframe_sp); + tgtframe_sp++; + + /* get tag type */ + uint8 tag_type_index = + module->module->tags[exception_tag_index]->type; + uint32 cell_num_to_copy = + wasm_types[tag_type_index]->param_cell_num; + + /* move exception parameters (if there are any) onto top + * of stack */ + if (cell_num_to_copy > 0) { + word_copy(frame_sp, tgtframe_sp - cell_num_to_copy, + cell_num_to_copy); + } + + frame_sp += cell_num_to_copy; + goto find_a_catch_handler; + } + + HANDLE_OP(WASM_OP_THROW) + { + read_leb_int32(frame_ip, frame_ip_end, exception_tag_index); + + /* landing pad for the rethrow ? */ + find_a_catch_handler: + { + WASMType *tag_type = NULL; + uint32 cell_num_to_copy = 0; + if (IS_INVALID_TAGINDEX(exception_tag_index)) { + /* + * invalid exception index, + * generated if a submodule throws an exception + * that has not been imported here + * + * This should result in a branch to the CATCH_ALL block, + * if there is one + */ + tag_type = NULL; + cell_num_to_copy = 0; + } + else { + if (module->e->tags[exception_tag_index].is_import_tag) { + tag_type = module->e->tags[exception_tag_index] + .u.tag_import->tag_type; + } + else { + tag_type = module->e->tags[exception_tag_index] + .u.tag->tag_type; + } + cell_num_to_copy = tag_type->param_cell_num; + } + + /* browse through frame stack */ + uint32 relative_depth = 0; + do { + POP_CSP_CHECK_OVERFLOW(relative_depth - 1); + WASMBranchBlock *tgtframe = frame_csp - relative_depth - 1; + + switch (tgtframe->label_type) { + case LABEL_TYPE_BLOCK: + case LABEL_TYPE_IF: + case LABEL_TYPE_LOOP: + case LABEL_TYPE_CATCH: + case LABEL_TYPE_CATCH_ALL: + /* + * skip that blocks in search + * BLOCK, IF and LOOP do not contain handlers and + * cannot catch exceptions. + * blocks marked as CATCH or + * CATCH_ALL did already caugth an exception and can + * only be a target for RETHROW, but cannot catch an + * exception again + */ + break; + case LABEL_TYPE_TRY: + { + uint32 handler_number = 0; + uint8 **handlers = (uint8 **)tgtframe->frame_sp; + uint8 *handler = NULL; + while ((handler = handlers[handler_number]) != 0) { + uint8 handler_opcode = *handler; + uint8 *target_addr = + handler + + 1; /* first instruction or leb-immediate + behind the handler opcode */ + switch (handler_opcode) { + case WASM_OP_CATCH: + { + int32 lookup_index = 0; + /* read the tag_index and advance + * target_addr to the first instruction + * in the block */ + read_leb_int32(target_addr, 0, + lookup_index); + + if (exception_tag_index + == lookup_index) { + /* set ip */ + frame_ip = target_addr; + /* save frame_sp (points to + * exception values) */ + uint32 *frame_sp_old = frame_sp; + + UNWIND_CSP(relative_depth, + LABEL_TYPE_CATCH); + + /* push exception_tag_index and + * exception values for rethrow */ + PUSH_I32(exception_tag_index); + if (cell_num_to_copy > 0) { + word_copy( + frame_sp, + frame_sp_old + - cell_num_to_copy, + cell_num_to_copy); + frame_sp += cell_num_to_copy; + /* push exception values for + * catch + */ + word_copy( + frame_sp, + frame_sp_old + - cell_num_to_copy, + cell_num_to_copy); + frame_sp += cell_num_to_copy; + } + + /* advance to handler */ + HANDLE_OP_END(); + } + break; + } + case WASM_OP_DELEGATE: + { + int32 lookup_depth = 0; + /* read the depth */ + read_leb_int32(target_addr, 0, + lookup_depth); + + /* save frame_sp (points to exception + * values) */ + uint32 *frame_sp_old = frame_sp; + + UNWIND_CSP(relative_depth, + LABEL_TYPE_CATCH); + + /* leave the block (the delegate is + * technically not inside the frame) */ + frame_csp--; + + /* unwind to delegated frame */ + frame_csp -= lookup_depth; + + /* push exception values for catch */ + if (cell_num_to_copy > 0) { + word_copy(frame_sp, + frame_sp_old + - cell_num_to_copy, + cell_num_to_copy); + frame_sp += cell_num_to_copy; + } + + /* tag_index is already stored in + * exception_tag_index */ + goto find_a_catch_handler; + } + case WASM_OP_CATCH_ALL: + { + /* no immediate */ + /* save frame_sp (points to exception + * values) */ + uint32 *frame_sp_old = frame_sp; + /* set ip */ + frame_ip = target_addr; + + UNWIND_CSP(relative_depth, + LABEL_TYPE_CATCH_ALL); + + /* push exception_tag_index and + * exception values for rethrow */ + PUSH_I32(exception_tag_index); + if (cell_num_to_copy > 0) { + word_copy(frame_sp, + frame_sp_old + - cell_num_to_copy, + cell_num_to_copy); + frame_sp += cell_num_to_copy; + } + /* catch_all has no exception values */ + + /* advance to handler */ + HANDLE_OP_END(); + } + default: + wasm_set_exception( + module, "WASM_OP_THROW found " + "unexpected handler type"); + goto got_exception; + } + handler_number++; + } + /* exception not catched in this frame */ + break; + } + case LABEL_TYPE_FUNCTION: + { + /* save frame_sp (points to exception values) */ + uint32 *frame_sp_old = frame_sp; + + UNWIND_CSP(relative_depth, LABEL_TYPE_FUNCTION); + /* push exception values for catch + * The values are copied to the CALLER FRAME + * (prev_frame->sp) same behvior ad WASM_OP_RETURN + */ + if (cell_num_to_copy > 0) { + word_copy(prev_frame->sp, + frame_sp_old - cell_num_to_copy, + cell_num_to_copy); + prev_frame->sp += cell_num_to_copy; + } + *((int32 *)(prev_frame->sp)) = exception_tag_index; + prev_frame->sp++; + + /* mark frame as raised exception */ + wasm_set_exception(module, + "uncaught wasm exception"); + + /* end of function, treat as WASM_OP_RETURN */ + goto return_func; + } + default: + wasm_set_exception( + module, + "unexpected or invalid label in THROW or " + "RETHROW when searching a catch handler"); + goto got_exception; + } + + relative_depth++; + + } while (1); + } + + /* something went wrong. normally, we should always find the + * func label. if not, stop the interpreter */ + wasm_set_exception( + module, "WASM_OP_THROW hit the bottom of the frame stack"); + goto got_exception; + } + + HANDLE_OP(EXT_OP_TRY) + { + /* read the blocktype */ + read_leb_uint32(frame_ip, frame_ip_end, type_index); + param_cell_num = wasm_types[type_index]->param_cell_num; + cell_num = wasm_types[type_index]->ret_cell_num; + goto handle_op_try; + } + + HANDLE_OP(WASM_OP_TRY) + { + value_type = *frame_ip++; + param_cell_num = 0; + cell_num = wasm_value_type_cell_num(value_type); + + handle_op_try: + + cache_index = ((uintptr_t)frame_ip) + & (uintptr_t)(BLOCK_ADDR_CACHE_SIZE - 1); + cache_items = exec_env->block_addr_cache[cache_index]; + if (cache_items[0].start_addr == frame_ip) { + cache_items[0].start_addr = 0; + } + if (cache_items[1].start_addr == frame_ip) { + cache_items[1].start_addr = 0; + } + + /* start at the first opcode following the try and its blocktype + */ + uint8 *lookup_cursor = frame_ip; + uint8 handler_opcode = WASM_OP_UNREACHABLE; + + /* target_addr filled in when END or DELEGATE is found */ + PUSH_CSP(LABEL_TYPE_TRY, param_cell_num, cell_num, 0); + + /* reset to begin of block */ + lookup_cursor = frame_ip; + do { + /* lookup the next CATCH, CATCH_ALL or END for this TRY */ + if (!wasm_loader_find_block_addr( + exec_env, (BlockAddr *)exec_env->block_addr_cache, + lookup_cursor, (uint8 *)-1, LABEL_TYPE_TRY, + &else_addr, &end_addr)) { + /* something went wrong */ + wasm_set_exception(module, "find block address failed"); + goto got_exception; + } + + /* place cursor for continuation past opcode */ + lookup_cursor = end_addr + 1; + + /* end_addr points to CATCH, CATCH_ALL, DELEGATE or END */ + handler_opcode = *end_addr; + switch (handler_opcode) { + case WASM_OP_CATCH: + skip_leb(lookup_cursor); /* skip tag_index */ + PUSH_I64(end_addr); + break; + case WASM_OP_CATCH_ALL: + PUSH_I64(end_addr); + break; + case WASM_OP_DELEGATE: + skip_leb(lookup_cursor); /* skip depth */ + PUSH_I64(end_addr); + /* patch target_addr */ + (frame_csp - 1)->target_addr = lookup_cursor; + break; + case WASM_OP_END: + PUSH_I64(0); + /* patch target_addr */ + (frame_csp - 1)->target_addr = end_addr; + break; + default: + /* something went wrong */ + wasm_set_exception(module, + "find block address returned an " + "unexpected opcode"); + goto got_exception; + } + /* ... search until the returned address is the END of the + * TRY block */ + } while (handler_opcode != WASM_OP_END + && handler_opcode != WASM_OP_DELEGATE); + /* handler setup on stack complete */ + + HANDLE_OP_END(); + } + HANDLE_OP(WASM_OP_CATCH) + { + /* skip the tag_index */ + skip_leb(frame_ip); + /* leave the frame */ + POP_CSP_N(0); + HANDLE_OP_END(); + } + HANDLE_OP(WASM_OP_CATCH_ALL) + { + /* leave the frame */ + POP_CSP_N(0); + HANDLE_OP_END(); + } + HANDLE_OP(WASM_OP_DELEGATE) + { + /* skip the delegate depth */ + skip_leb(frame_ip); + /* leave the frame like WASM_OP_END */ + POP_CSP(); + HANDLE_OP_END(); + } +#endif HANDLE_OP(EXT_OP_BLOCK) { read_leb_uint32(frame_ip, frame_ip_end, type_index); @@ -2149,7 +2564,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \ || WASM_ENABLE_BULK_MEMORY != 0 - linear_mem_size = get_linear_mem_size(); + linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); #endif } @@ -3099,6 +3514,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint32 opcode1; read_leb_uint32(frame_ip, frame_ip_end, opcode1); + /* opcode1 was checked in loader and is no larger than + UINT8_MAX */ opcode = (uint8)opcode1; switch (opcode) { @@ -3257,6 +3674,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint32 tbl_idx, elem_idx; uint32 n, s, d; WASMTableInstance *tbl_inst; + uint32 *tbl_seg_elems = NULL, tbl_seg_len = 0; read_leb_uint32(frame_ip, frame_ip_end, elem_idx); bh_assert(elem_idx < module->module->table_seg_count); @@ -3270,10 +3688,18 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, s = (uint32)POP_I32(); d = (uint32)POP_I32(); - if (offset_len_out_of_bounds( - s, n, + if (!bh_bitmap_get_bit(module->e->common.elem_dropped, + elem_idx)) { + /* table segment isn't dropped */ + tbl_seg_elems = + module->module->table_segments[elem_idx] + .func_indexes; + tbl_seg_len = module->module->table_segments[elem_idx] - .function_count) + .function_count; + } + + if (offset_len_out_of_bounds(s, n, tbl_seg_len) || offset_len_out_of_bounds(d, n, tbl_inst->cur_size)) { wasm_set_exception(module, @@ -3285,30 +3711,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, break; } - if (bh_bitmap_get_bit(module->e->common.elem_dropped, - elem_idx)) { - wasm_set_exception(module, - "out of bounds table access"); - goto got_exception; - } - - if (!wasm_elem_is_passive( - module->module->table_segments[elem_idx] - .mode)) { - wasm_set_exception(module, - "out of bounds table access"); - goto got_exception; - } - bh_memcpy_s( (uint8 *)tbl_inst + offsetof(WASMTableInstance, elems) + d * sizeof(uint32), (uint32)((tbl_inst->cur_size - d) * sizeof(uint32)), - module->module->table_segments[elem_idx] - .func_indexes - + s, - (uint32)(n * sizeof(uint32))); + tbl_seg_elems + s, (uint32)(n * sizeof(uint32))); break; } @@ -3439,9 +3847,13 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #if WASM_ENABLE_SHARED_MEMORY != 0 HANDLE_OP(WASM_OP_ATOMIC_PREFIX) { - uint32 offset = 0, align, addr; + uint32 offset = 0, align = 0, addr; + uint32 opcode1; - opcode = *frame_ip++; + read_leb_uint32(frame_ip, frame_ip_end, opcode1); + /* opcode1 was checked in loader and is no larger than + UINT8_MAX */ + opcode = (uint8)opcode1; if (opcode != WASM_OP_ATOMIC_FENCE) { read_leb_uint32(frame_ip, frame_ip_end, align); @@ -3455,7 +3867,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, notify_count = POP_I32(); addr = POP_I32(); - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(); ret = wasm_runtime_atomic_notify( @@ -3475,7 +3887,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, timeout = POP_I64(); expect = POP_I32(); addr = POP_I32(); - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(); ret = wasm_runtime_atomic_wait( @@ -3499,7 +3911,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, timeout = POP_I64(); expect = POP_I64(); addr = POP_I32(); - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); + CHECK_MEMORY_OVERFLOW(8); CHECK_ATOMIC_MEMORY_ACCESS(); ret = wasm_runtime_atomic_wait( @@ -3532,21 +3944,21 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_I32_LOAD8_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); readv = (uint32)(*(uint8 *)maddr); shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I32_LOAD16_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); readv = (uint32)LOAD_U16(maddr); shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); readv = LOAD_I32(maddr); @@ -3567,28 +3979,28 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_I64_LOAD8_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); readv = (uint64)(*(uint8 *)maddr); shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I64_LOAD16_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); readv = (uint64)LOAD_U16(maddr); shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I64_LOAD32_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); readv = (uint64)LOAD_U32(maddr); shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); + CHECK_MEMORY_OVERFLOW(8); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); readv = LOAD_I64(maddr); @@ -3609,21 +4021,21 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_I32_STORE8) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); *(uint8 *)maddr = (uint8)sval; shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I32_STORE16) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); STORE_U16(maddr, (uint16)sval); shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); STORE_U32(maddr, sval); @@ -3643,28 +4055,28 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_I64_STORE8) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); *(uint8 *)maddr = (uint8)sval; shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I64_STORE16) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); STORE_U16(maddr, (uint16)sval); shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I64_STORE32) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); STORE_U32(maddr, (uint32)sval); shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); + CHECK_MEMORY_OVERFLOW(8); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); PUT_I64_TO_ADDR((uint32 *)maddr, sval); @@ -3684,7 +4096,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_RMW_I32_CMPXCHG8_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(); expect = (uint8)expect; @@ -3695,7 +4107,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_RMW_I32_CMPXCHG16_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(); expect = (uint16)expect; @@ -3706,7 +4118,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); @@ -3730,7 +4142,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_RMW_I64_CMPXCHG8_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(); expect = (uint8)expect; @@ -3741,7 +4153,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_RMW_I64_CMPXCHG16_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(); expect = (uint16)expect; @@ -3752,7 +4164,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_RMW_I64_CMPXCHG32_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(); expect = (uint32)expect; @@ -3763,7 +4175,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); + CHECK_MEMORY_OVERFLOW(8); CHECK_ATOMIC_MEMORY_ACCESS(); shared_memory_lock(memory); @@ -3796,6 +4208,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, frame_ip = frame->ip; frame_sp = frame->sp; frame_csp = frame->csp; +#if WASM_ENABLE_TAIL_CALL != 0 + is_return_call = false; +#endif goto call_func_from_entry; } @@ -3819,10 +4234,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #endif #if WASM_ENABLE_LABELS_AS_VALUES != 0 - HANDLE_OP(WASM_OP_UNUSED_0x06) - HANDLE_OP(WASM_OP_UNUSED_0x07) - HANDLE_OP(WASM_OP_UNUSED_0x08) - HANDLE_OP(WASM_OP_UNUSED_0x09) HANDLE_OP(WASM_OP_UNUSED_0x0a) #if WASM_ENABLE_TAIL_CALL == 0 HANDLE_OP(WASM_OP_RETURN_CALL) @@ -3838,13 +4249,26 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP(WASM_OP_REF_NULL) HANDLE_OP(WASM_OP_REF_IS_NULL) HANDLE_OP(WASM_OP_REF_FUNC) +#endif +#if WASM_ENABLE_EXCE_HANDLING == 0 + HANDLE_OP(WASM_OP_TRY) + HANDLE_OP(WASM_OP_CATCH) + HANDLE_OP(WASM_OP_THROW) + HANDLE_OP(WASM_OP_RETHROW) + HANDLE_OP(WASM_OP_DELEGATE) + HANDLE_OP(WASM_OP_CATCH_ALL) + HANDLE_OP(EXT_OP_TRY) +#endif +#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SIMD != 0 + /* SIMD isn't supported by interpreter, but when JIT is + enabled, `iwasm --interp ` may be run to + trigger the SIMD opcode in interpreter */ + HANDLE_OP(WASM_OP_SIMD_PREFIX) #endif HANDLE_OP(WASM_OP_UNUSED_0x14) HANDLE_OP(WASM_OP_UNUSED_0x15) HANDLE_OP(WASM_OP_UNUSED_0x16) HANDLE_OP(WASM_OP_UNUSED_0x17) - HANDLE_OP(WASM_OP_UNUSED_0x18) - HANDLE_OP(WASM_OP_UNUSED_0x19) HANDLE_OP(WASM_OP_UNUSED_0x27) /* Used by fast interpreter */ HANDLE_OP(EXT_OP_SET_LOCAL_FAST_I64) @@ -3873,6 +4297,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, } FREE_FRAME(exec_env, frame); wasm_exec_env_set_cur_frame(exec_env, prev_frame); + is_return_call = true; goto call_func_from_entry; } #endif @@ -3886,6 +4311,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, word_copy(outs_area->lp, frame_sp, cur_func->param_cell_num); } prev_frame = frame; +#if WASM_ENABLE_TAIL_CALL != 0 + is_return_call = false; +#endif } call_func_from_entry: @@ -3895,18 +4323,84 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, if (cur_func->import_func_inst) { wasm_interp_call_func_import(module, exec_env, cur_func, prev_frame); +#if WASM_ENABLE_TAIL_CALL != 0 + if (is_return_call) { + /* the frame was freed before tail calling and + the prev_frame was set as exec_env's cur_frame, + so here we recover context from prev_frame */ + RECOVER_CONTEXT(prev_frame); + } + else +#endif + { + prev_frame = frame->prev_frame; + cur_func = frame->function; + UPDATE_ALL_FROM_FRAME(); + } + +#if WASM_ENABLE_EXCE_HANDLING != 0 + char uncaught_exception[128] = { 0 }; + bool has_exception = + wasm_copy_exception(module, uncaught_exception); + if (has_exception + && strstr(uncaught_exception, "uncaught wasm exception")) { + uint32 import_exception; + /* initialize imported exception index to be invalid */ + SET_INVALID_TAGINDEX(import_exception); + + /* pull external exception */ + uint32 ext_exception = POP_I32(); + + /* external function came back with an exception or trap */ + /* lookup exception in import tags */ + WASMTagInstance *tag = module->e->tags; + for (uint32 t = 0; t < module->module->import_tag_count; + tag++, t++) { + + /* compare the module and the external index with the + * imort tag data */ + if ((cur_func->u.func_import->import_module + == tag->u.tag_import->import_module) + && (ext_exception + == tag->u.tag_import + ->import_tag_index_linked)) { + /* set the import_exception to the import tag */ + import_exception = t; + break; + } + } + /* + * excange the thrown exception (index valid in submodule) + * with the imported exception index (valid in this module) + * if the module did not import the exception, + * that results in a "INVALID_TAGINDEX", that triggers + * an CATCH_ALL block, if there is one. + */ + PUSH_I32(import_exception); + } +#endif } else #endif { wasm_interp_call_func_native(module, exec_env, cur_func, prev_frame); +#if WASM_ENABLE_TAIL_CALL != 0 + if (is_return_call) { + /* the frame was freed before tail calling and + the prev_frame was set as exec_env's cur_frame, + so here we recover context from prev_frame */ + RECOVER_CONTEXT(prev_frame); + } + else +#endif + { + prev_frame = frame->prev_frame; + cur_func = frame->function; + UPDATE_ALL_FROM_FRAME(); + } } - prev_frame = frame->prev_frame; - cur_func = frame->function; - UPDATE_ALL_FROM_FRAME(); - /* update memory size, no need to update memory ptr as it isn't changed in wasm_enlarge_memory */ #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ @@ -3915,19 +4409,57 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, if (memory) linear_mem_size = get_linear_mem_size(); #endif - if (wasm_copy_exception(module, NULL)) + if (wasm_copy_exception(module, NULL)) { +#if WASM_ENABLE_EXCE_HANDLING != 0 + /* the caller raised an exception */ + char uncaught_exception[128] = { 0 }; + bool has_exception = + wasm_copy_exception(module, uncaught_exception); + + /* libc_builtin signaled a "exception thrown by stdc++" trap */ + if (has_exception + && strstr(uncaught_exception, + "exception thrown by stdc++")) { + wasm_set_exception(module, NULL); + + /* setup internal c++ rethrow */ + exception_tag_index = 0; + goto find_a_catch_handler; + } + + /* when throw hits the end of a function it signalles with a + * "uncaught wasm exception" trap */ + if (has_exception + && strstr(uncaught_exception, "uncaught wasm exception")) { + wasm_set_exception(module, NULL); + exception_tag_index = POP_I32(); + + /* rethrow the exception into that frame */ + goto find_a_catch_handler; + } +#endif goto got_exception; + } } else { WASMFunction *cur_wasm_func = cur_func->u.func; WASMType *func_type; +#if WASM_ENABLE_EXCE_HANDLING != 0 + /* account for exception handlers */ + /* bundle them here */ + uint32 eh_size = + cur_wasm_func->exception_handler_count * sizeof(uint8 *); + cur_wasm_func->max_stack_cell_num += eh_size; +#endif + func_type = cur_wasm_func->func_type; all_cell_num = cur_func->param_cell_num + cur_func->local_cell_num + cur_wasm_func->max_stack_cell_num + cur_wasm_func->max_block_num * (uint32)sizeof(WASMBranchBlock) / 4; + /* param_cell_num, local_cell_num, max_stack_cell_num and max_block_num are all no larger than UINT16_MAX (checked in loader), all_cell_num must be smaller than 1MB */ @@ -3976,11 +4508,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, FREE_FRAME(exec_env, frame); wasm_exec_env_set_cur_frame(exec_env, prev_frame); - if (!prev_frame->ip) + if (!prev_frame->ip) { /* Called from native. */ return; + } RECOVER_CONTEXT(prev_frame); +#if WASM_ENABLE_EXCE_HANDLING != 0 + if (wasm_get_exception(module)) { + wasm_set_exception(module, NULL); + exception_tag_index = POP_I32(); + goto find_a_catch_handler; + } +#endif HANDLE_OP_END(); } @@ -4109,7 +4649,7 @@ llvm_jit_call_func_bytecode(WASMModuleInstance *module_inst, uint32 result_count = func_type->result_count; uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0; uint32 func_idx = (uint32)(function - module_inst->e->functions); - bool ret; + bool ret = false; #if (WASM_ENABLE_DUMP_CALL_STACK != 0) || (WASM_ENABLE_PERF_PROFILING != 0) if (!llvm_jit_alloc_frame(exec_env, function - module_inst->e->functions)) { @@ -4137,7 +4677,8 @@ llvm_jit_call_func_bytecode(WASMModuleInstance *module_inst, if (size > UINT32_MAX || !(argv1 = wasm_runtime_malloc((uint32)size))) { wasm_set_exception(module_inst, "allocate memory failed"); - return false; + ret = false; + goto fail; } } @@ -4161,7 +4702,7 @@ llvm_jit_call_func_bytecode(WASMModuleInstance *module_inst, if (!ret) { if (argv1 != argv1_buf) wasm_runtime_free(argv1); - return ret; + goto fail; } /* Get extra result values */ @@ -4195,15 +4736,38 @@ llvm_jit_call_func_bytecode(WASMModuleInstance *module_inst, if (argv1 != argv1_buf) wasm_runtime_free(argv1); - return true; + ret = true; } else { - ret = wasm_runtime_invoke_native( - exec_env, module_inst->func_ptrs[func_idx], func_type, NULL, NULL, - argv, argc, argv); +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 + /* Quick call if the quick jit entry is registered */ + if (func_type->quick_aot_entry) { + void (*invoke_native)(void *func_ptr, void *exec_env, uint32 *argv, + uint32 *argv_ret) = + func_type->quick_aot_entry; + invoke_native(module_inst->func_ptrs[func_idx], exec_env, argv, + argv); + ret = !wasm_copy_exception(module_inst, NULL); + } + else +#endif + { + ret = wasm_runtime_invoke_native( + exec_env, module_inst->func_ptrs[func_idx], func_type, NULL, + NULL, argv, argc, argv); - return ret && !wasm_copy_exception(module_inst, NULL) ? true : false; + if (ret) + ret = !wasm_copy_exception(module_inst, NULL); + } } + +fail: + +#if (WASM_ENABLE_DUMP_CALL_STACK != 0) || (WASM_ENABLE_PERF_PROFILING != 0) + llvm_jit_free_frame(exec_env); +#endif + + return ret; } #endif /* end of WASM_ENABLE_JIT != 0 */ @@ -4212,16 +4776,11 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, WASMFunctionInstance *function, uint32 argc, uint32 argv[]) { - WASMRuntimeFrame *prev_frame = wasm_exec_env_get_cur_frame(exec_env); - WASMInterpFrame *frame, *outs_area; + WASMRuntimeFrame *frame = NULL, *prev_frame, *outs_area; + RunningMode running_mode = + wasm_runtime_get_running_mode((WASMModuleInstanceCommon *)module_inst); /* Allocate sufficient cells for all kinds of return values. */ - unsigned all_cell_num = - function->ret_cell_num > 2 ? function->ret_cell_num : 2; - /* This frame won't be used by JITed code, so only allocate interp - frame here. */ - unsigned frame_size = wasm_interp_interp_frame_size(all_cell_num); - unsigned i; - bool copy_argv_from_frame = true; + bool alloc_frame = true; if (argc < function->param_cell_num) { char buf[128]; @@ -4244,25 +4803,56 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, } #endif - if (!(frame = ALLOC_FRAME(exec_env, frame_size, prev_frame))) - return; + if (!function->is_import_func) { + /* No need to alloc frame when calling LLVM JIT function */ +#if WASM_ENABLE_JIT != 0 + if (running_mode == Mode_LLVM_JIT) { + alloc_frame = false; + } +#if WASM_ENABLE_LAZY_JIT != 0 && WASM_ENABLE_FAST_JIT != 0 + else if (running_mode == Mode_Multi_Tier_JIT) { + /* Tier-up from Fast JIT to LLVM JIT, call llvm jit function + if it is compiled, else call fast jit function */ + uint32 func_idx = (uint32)(function - module_inst->e->functions); + if (module_inst->module->func_ptrs_compiled + [func_idx - module_inst->module->import_function_count]) { + alloc_frame = false; + } + } +#endif +#endif + } - outs_area = wasm_exec_env_wasm_stack_top(exec_env); - frame->function = NULL; - frame->ip = NULL; - /* There is no local variable. */ - frame->sp = frame->lp + 0; + if (alloc_frame) { + unsigned all_cell_num = + function->ret_cell_num > 2 ? function->ret_cell_num : 2; + unsigned frame_size; - if ((uint8 *)(outs_area->lp + function->param_cell_num) - > exec_env->wasm_stack.s.top_boundary) { - wasm_set_exception(module_inst, "wasm operand stack overflow"); - return; - } + prev_frame = wasm_exec_env_get_cur_frame(exec_env); + /* This frame won't be used by JITed code, so only allocate interp + frame here. */ + frame_size = wasm_interp_interp_frame_size(all_cell_num); - if (argc > 0) - word_copy(outs_area->lp, argv, argc); + if (!(frame = ALLOC_FRAME(exec_env, frame_size, prev_frame))) + return; - wasm_exec_env_set_cur_frame(exec_env, frame); + outs_area = wasm_exec_env_wasm_stack_top(exec_env); + frame->function = NULL; + frame->ip = NULL; + /* There is no local variable. */ + frame->sp = frame->lp + 0; + + if ((uint8 *)(outs_area->lp + function->param_cell_num) + > exec_env->wasm_stack.s.top_boundary) { + wasm_set_exception(module_inst, "wasm operand stack overflow"); + return; + } + + if (argc > 0) + word_copy(outs_area->lp, argv, argc); + + wasm_exec_env_set_cur_frame(exec_env, frame); + } #if defined(os_writegsbase) { @@ -4288,9 +4878,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, } } else { - RunningMode running_mode = - wasm_runtime_get_running_mode((wasm_module_inst_t)module_inst); - if (running_mode == Mode_Interp) { wasm_interp_call_func_bytecode(module_inst, exec_env, function, frame); @@ -4304,9 +4891,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, else if (running_mode == Mode_LLVM_JIT) { llvm_jit_call_func_bytecode(module_inst, exec_env, function, argc, argv); - /* For llvm jit, the results have been stored in argv, - no need to copy them from stack frame again */ - copy_argv_from_frame = false; } #endif #if WASM_ENABLE_LAZY_JIT != 0 && WASM_ENABLE_FAST_JIT != 0 \ @@ -4319,9 +4903,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, [func_idx - module_inst->module->import_function_count]) { llvm_jit_call_func_bytecode(module_inst, exec_env, function, argc, argv); - /* For llvm jit, the results have been stored in argv, - no need to copy them from stack frame again */ - copy_argv_from_frame = false; } else { fast_jit_call_func_bytecode(module_inst, exec_env, function, @@ -4342,7 +4923,8 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, /* Output the return value to the caller */ if (!wasm_copy_exception(module_inst, NULL)) { - if (copy_argv_from_frame) { + if (alloc_frame) { + uint32 i; for (i = 0; i < function->ret_cell_num; i++) { argv[i] = *(frame->sp + i - function->ret_cell_num); } @@ -4356,6 +4938,8 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, #endif } - wasm_exec_env_set_cur_frame(exec_env, prev_frame); - FREE_FRAME(exec_env, frame); + if (alloc_frame) { + wasm_exec_env_set_cur_frame(exec_env, prev_frame); + FREE_FRAME(exec_env, frame); + } } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp_fast.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp_fast.c similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp_fast.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp_fast.c index d3cebc334b3..eb7d44f5f27 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_interp_fast.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_interp_fast.c @@ -479,7 +479,7 @@ LOAD_PTR(void *addr) addr = POP_I32(); \ \ if (opcode == WASM_OP_ATOMIC_RMW_I32_##OP_NAME##8_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); \ + CHECK_MEMORY_OVERFLOW(1); \ CHECK_ATOMIC_MEMORY_ACCESS(1); \ \ shared_memory_lock(memory); \ @@ -488,7 +488,7 @@ LOAD_PTR(void *addr) shared_memory_unlock(memory); \ } \ else if (opcode == WASM_OP_ATOMIC_RMW_I32_##OP_NAME##16_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); \ + CHECK_MEMORY_OVERFLOW(2); \ CHECK_ATOMIC_MEMORY_ACCESS(2); \ \ shared_memory_lock(memory); \ @@ -497,7 +497,7 @@ LOAD_PTR(void *addr) shared_memory_unlock(memory); \ } \ else { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); \ + CHECK_MEMORY_OVERFLOW(4); \ CHECK_ATOMIC_MEMORY_ACCESS(4); \ \ shared_memory_lock(memory); \ @@ -519,7 +519,7 @@ LOAD_PTR(void *addr) addr = POP_I32(); \ \ if (opcode == WASM_OP_ATOMIC_RMW_I64_##OP_NAME##8_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); \ + CHECK_MEMORY_OVERFLOW(1); \ CHECK_ATOMIC_MEMORY_ACCESS(1); \ \ shared_memory_lock(memory); \ @@ -528,7 +528,7 @@ LOAD_PTR(void *addr) shared_memory_unlock(memory); \ } \ else if (opcode == WASM_OP_ATOMIC_RMW_I64_##OP_NAME##16_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); \ + CHECK_MEMORY_OVERFLOW(2); \ CHECK_ATOMIC_MEMORY_ACCESS(2); \ \ shared_memory_lock(memory); \ @@ -537,7 +537,7 @@ LOAD_PTR(void *addr) shared_memory_unlock(memory); \ } \ else if (opcode == WASM_OP_ATOMIC_RMW_I64_##OP_NAME##32_U) { \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); \ + CHECK_MEMORY_OVERFLOW(4); \ CHECK_ATOMIC_MEMORY_ACCESS(4); \ \ shared_memory_lock(memory); \ @@ -547,7 +547,7 @@ LOAD_PTR(void *addr) } \ else { \ uint64 op_result; \ - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); \ + CHECK_MEMORY_OVERFLOW(8); \ CHECK_ATOMIC_MEMORY_ACCESS(8); \ \ shared_memory_lock(memory); \ @@ -884,7 +884,7 @@ ALLOC_FRAME(WASMExecEnv *exec_env, uint32 size, WASMInterpFrame *prev_frame) if (frame) { frame->prev_frame = prev_frame; #if WASM_ENABLE_PERF_PROFILING != 0 - frame->time_started = os_time_get_boot_microsecond(); + frame->time_started = os_time_thread_cputime_us(); #endif } else { @@ -900,9 +900,13 @@ FREE_FRAME(WASMExecEnv *exec_env, WASMInterpFrame *frame) { #if WASM_ENABLE_PERF_PROFILING != 0 if (frame->function) { - frame->function->total_exec_time += - os_time_get_boot_microsecond() - frame->time_started; + WASMInterpFrame *prev_frame = frame->prev_frame; + uint64 elapsed = os_time_thread_cputime_us() - frame->time_started; + frame->function->total_exec_time += elapsed; frame->function->total_exec_cnt++; + + if (prev_frame && prev_frame->function) + prev_frame->function->children_exec_time += elapsed; } #endif wasm_exec_env_free_wasm_frame(exec_env, frame); @@ -1220,6 +1224,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, bool disable_bounds_checks = false; #endif #endif +#if WASM_ENABLE_TAIL_CALL != 0 + bool is_return_call = false; +#endif #if WASM_ENABLE_LABELS_AS_VALUES != 0 #define HANDLE_OPCODE(op) &&HANDLE_##op @@ -1433,6 +1440,20 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, goto call_func_from_interp; } +#if WASM_ENABLE_EXCE_HANDLING != 0 + HANDLE_OP(WASM_OP_TRY) + HANDLE_OP(WASM_OP_CATCH) + HANDLE_OP(WASM_OP_THROW) + HANDLE_OP(WASM_OP_RETHROW) + HANDLE_OP(WASM_OP_DELEGATE) + HANDLE_OP(WASM_OP_CATCH_ALL) + HANDLE_OP(EXT_OP_TRY) + { + wasm_set_exception(module, "unsupported opcode"); + goto got_exception; + } +#endif + /* parametric instructions */ HANDLE_OP(WASM_OP_SELECT) { @@ -1692,7 +1713,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, frame_ip += 2; addr_ret = GET_OFFSET(); CHECK_MEMORY_OVERFLOW(1); - frame_lp[addr_ret] = (uint32)(*(uint8 *)maddr); + frame_lp[addr_ret] = (uint32)(*(uint8 *)(maddr)); HANDLE_OP_END(); } @@ -1817,7 +1838,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = GET_OPERAND(uint32, I32, 2); frame_ip += 4; CHECK_MEMORY_OVERFLOW(1); - *(uint8 *)maddr = (uint8)sval; + STORE_U8(maddr, (uint8_t)sval); HANDLE_OP_END(); } @@ -1917,7 +1938,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \ || WASM_ENABLE_BULK_MEMORY != 0 - linear_mem_size = get_linear_mem_size(); + linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); #endif } @@ -2863,8 +2884,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, { addr1 = GET_OFFSET(); addr2 = GET_OFFSET(); - frame_lp[addr2] = frame_lp[addr1]; - frame_lp[addr2 + 1] = frame_lp[addr1 + 1]; + PUT_I64_TO_ADDR(frame_lp + addr2, + GET_I64_FROM_ADDR(frame_lp + addr1)); HANDLE_OP_END(); } @@ -2999,7 +3020,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, offset = (uint64)(uint32)POP_I32(); addr = POP_I32(); -#if WASM_ENABLE_THREAD_MGR +#if WASM_ENABLE_THREAD_MGR != 0 linear_mem_size = get_linear_mem_size(); #endif @@ -3017,7 +3038,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, data = NULL; } else { - seg_len = (uint64)module->module->data_segments[segment] ->data_length; @@ -3048,7 +3068,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, src = POP_I32(); dst = POP_I32(); -#if WASM_ENABLE_THREAD_MGR +#if WASM_ENABLE_THREAD_MGR != 0 linear_mem_size = get_linear_mem_size(); #endif @@ -3078,7 +3098,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, fill_val = POP_I32(); dst = POP_I32(); -#if WASM_ENABLE_THREAD_MGR +#if WASM_ENABLE_THREAD_MGR != 0 linear_mem_size = get_linear_mem_size(); #endif @@ -3100,6 +3120,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint32 tbl_idx, elem_idx; uint32 n, s, d; WASMTableInstance *tbl_inst; + uint32 *tbl_seg_elems = NULL, tbl_seg_len = 0; elem_idx = read_uint32(frame_ip); bh_assert(elem_idx < module->module->table_seg_count); @@ -3113,10 +3134,18 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, s = (uint32)POP_I32(); d = (uint32)POP_I32(); - if (offset_len_out_of_bounds( - s, n, + if (!bh_bitmap_get_bit(module->e->common.elem_dropped, + elem_idx)) { + /* table segment isn't dropped */ + tbl_seg_elems = module->module->table_segments[elem_idx] - .function_count) + .func_indexes; + tbl_seg_len = + module->module->table_segments[elem_idx] + .function_count; + } + + if (offset_len_out_of_bounds(s, n, tbl_seg_len) || offset_len_out_of_bounds(d, n, tbl_inst->cur_size)) { wasm_set_exception(module, @@ -3128,30 +3157,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, break; } - if (bh_bitmap_get_bit(module->e->common.elem_dropped, - elem_idx)) { - wasm_set_exception(module, - "out of bounds table access"); - goto got_exception; - } - - if (!wasm_elem_is_passive( - module->module->table_segments[elem_idx] - .mode)) { - wasm_set_exception(module, - "out of bounds table access"); - goto got_exception; - } - bh_memcpy_s( (uint8 *)tbl_inst + offsetof(WASMTableInstance, elems) + d * sizeof(uint32), (uint32)((tbl_inst->cur_size - d) * sizeof(uint32)), - module->module->table_segments[elem_idx] - .func_indexes - + s, - (uint32)(n * sizeof(uint32))); + tbl_seg_elems + s, (uint32)(n * sizeof(uint32))); break; } case WASM_OP_ELEM_DROP: @@ -3295,7 +3306,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, notify_count = POP_I32(); addr = POP_I32(); - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(4); ret = wasm_runtime_atomic_notify( @@ -3315,7 +3326,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, timeout = POP_I64(); expect = POP_I32(); addr = POP_I32(); - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(4); ret = wasm_runtime_atomic_wait( @@ -3339,7 +3350,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, timeout = POP_I64(); expect = POP_I64(); addr = POP_I32(); - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); + CHECK_MEMORY_OVERFLOW(8); CHECK_ATOMIC_MEMORY_ACCESS(8); ret = wasm_runtime_atomic_wait( @@ -3370,21 +3381,21 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_I32_LOAD8_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(1); shared_memory_lock(memory); readv = (uint32)(*(uint8 *)maddr); shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I32_LOAD16_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(2); shared_memory_lock(memory); readv = (uint32)LOAD_U16(maddr); shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(4); shared_memory_lock(memory); readv = LOAD_I32(maddr); @@ -3405,28 +3416,28 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_I64_LOAD8_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(1); shared_memory_lock(memory); readv = (uint64)(*(uint8 *)maddr); shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I64_LOAD16_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(2); shared_memory_lock(memory); readv = (uint64)LOAD_U16(maddr); shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I64_LOAD32_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(4); shared_memory_lock(memory); readv = (uint64)LOAD_U32(maddr); shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); + CHECK_MEMORY_OVERFLOW(8); CHECK_ATOMIC_MEMORY_ACCESS(8); shared_memory_lock(memory); readv = LOAD_I64(maddr); @@ -3446,21 +3457,21 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_I32_STORE8) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(1); shared_memory_lock(memory); *(uint8 *)maddr = (uint8)sval; shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I32_STORE16) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(2); shared_memory_lock(memory); STORE_U16(maddr, (uint16)sval); shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(4); shared_memory_lock(memory); STORE_U32(maddr, sval); @@ -3480,28 +3491,28 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_I64_STORE8) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(1); shared_memory_lock(memory); *(uint8 *)maddr = (uint8)sval; shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I64_STORE16) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(2); shared_memory_lock(memory); STORE_U16(maddr, (uint16)sval); shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_I64_STORE32) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(4); shared_memory_lock(memory); STORE_U32(maddr, (uint32)sval); shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); + CHECK_MEMORY_OVERFLOW(8); CHECK_ATOMIC_MEMORY_ACCESS(8); shared_memory_lock(memory); STORE_I64(maddr, sval); @@ -3521,7 +3532,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_RMW_I32_CMPXCHG8_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(1); expect = (uint8)expect; @@ -3532,7 +3543,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_RMW_I32_CMPXCHG16_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(2); expect = (uint16)expect; @@ -3543,7 +3554,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(4); shared_memory_lock(memory); @@ -3567,7 +3578,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, addr = POP_I32(); if (opcode == WASM_OP_ATOMIC_RMW_I64_CMPXCHG8_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr); + CHECK_MEMORY_OVERFLOW(1); CHECK_ATOMIC_MEMORY_ACCESS(1); expect = (uint8)expect; @@ -3578,7 +3589,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_RMW_I64_CMPXCHG16_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr); + CHECK_MEMORY_OVERFLOW(2); CHECK_ATOMIC_MEMORY_ACCESS(2); expect = (uint16)expect; @@ -3589,7 +3600,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else if (opcode == WASM_OP_ATOMIC_RMW_I64_CMPXCHG32_U) { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr); + CHECK_MEMORY_OVERFLOW(4); CHECK_ATOMIC_MEMORY_ACCESS(4); expect = (uint32)expect; @@ -3600,7 +3611,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, shared_memory_unlock(memory); } else { - CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 8, maddr); + CHECK_MEMORY_OVERFLOW(8); CHECK_ATOMIC_MEMORY_ACCESS(8); shared_memory_lock(memory); @@ -3631,6 +3642,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, { frame = prev_frame; frame_ip = frame->ip; +#if WASM_ENABLE_TAIL_CALL != 0 + is_return_call = false; +#endif goto call_func_from_entry; } @@ -3676,10 +3690,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, #endif #if WASM_ENABLE_LABELS_AS_VALUES != 0 - HANDLE_OP(WASM_OP_UNUSED_0x06) - HANDLE_OP(WASM_OP_UNUSED_0x07) - HANDLE_OP(WASM_OP_UNUSED_0x08) - HANDLE_OP(WASM_OP_UNUSED_0x09) HANDLE_OP(WASM_OP_UNUSED_0x0a) #if WASM_ENABLE_TAIL_CALL == 0 HANDLE_OP(WASM_OP_RETURN_CALL) @@ -3694,6 +3704,16 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP(WASM_OP_REF_NULL) HANDLE_OP(WASM_OP_REF_IS_NULL) HANDLE_OP(WASM_OP_REF_FUNC) +#endif +#if WASM_ENABLE_EXCE_HANDLING == 0 + /* if exception handling is disabled, these opcodes issue a trap */ + HANDLE_OP(WASM_OP_TRY) + HANDLE_OP(WASM_OP_CATCH) + HANDLE_OP(WASM_OP_THROW) + HANDLE_OP(WASM_OP_RETHROW) + HANDLE_OP(WASM_OP_DELEGATE) + HANDLE_OP(WASM_OP_CATCH_ALL) + HANDLE_OP(EXT_OP_TRY) #endif /* SELECT_T is converted to SELECT or SELECT_64 */ HANDLE_OP(WASM_OP_SELECT_T) @@ -3701,8 +3721,6 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, HANDLE_OP(WASM_OP_UNUSED_0x15) HANDLE_OP(WASM_OP_UNUSED_0x16) HANDLE_OP(WASM_OP_UNUSED_0x17) - HANDLE_OP(WASM_OP_UNUSED_0x18) - HANDLE_OP(WASM_OP_UNUSED_0x19) HANDLE_OP(WASM_OP_UNUSED_0x27) /* optimized op code */ HANDLE_OP(WASM_OP_F32_STORE) @@ -3767,6 +3785,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, FREE_FRAME(exec_env, frame); frame_ip += cur_func->param_count * sizeof(int16); wasm_exec_env_set_cur_frame(exec_env, (WASMRuntimeFrame *)prev_frame); + is_return_call = true; goto call_func_from_entry; } #endif /* WASM_ENABLE_TAIL_CALL */ @@ -3827,6 +3846,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, } SYNC_ALL_TO_FRAME(); prev_frame = frame; +#if WASM_ENABLE_TAIL_CALL != 0 + is_return_call = false; +#endif } call_func_from_entry: @@ -3844,9 +3866,20 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, prev_frame); } - prev_frame = frame->prev_frame; - cur_func = frame->function; - UPDATE_ALL_FROM_FRAME(); +#if WASM_ENABLE_TAIL_CALL != 0 + if (is_return_call) { + /* the frame was freed before tail calling and + the prev_frame was set as exec_env's cur_frame, + so here we recover context from prev_frame */ + RECOVER_CONTEXT(prev_frame); + } + else +#endif + { + prev_frame = frame->prev_frame; + cur_func = frame->function; + UPDATE_ALL_FROM_FRAME(); + } /* update memory size, no need to update memory ptr as it isn't changed in wasm_enlarge_memory */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_loader.c similarity index 90% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_loader.c index 2a06f42e36e..4a35b13b2a2 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_loader.c @@ -131,7 +131,7 @@ read_leb(uint8 **p_buf, const uint8 *buf_end, uint32 maxbits, bool sign, } else if (sign && maxbits == 32) { if (shift < maxbits) { - /* Sign extend, second highest bit is the sign bit */ + /* Sign extend, second-highest bit is the sign bit */ if ((uint8)byte & 0x40) result |= (~((uint64)0)) << shift; } @@ -146,7 +146,7 @@ read_leb(uint8 **p_buf, const uint8 *buf_end, uint32 maxbits, bool sign, } else if (sign && maxbits == 64) { if (shift < maxbits) { - /* Sign extend, second highest bit is the sign bit */ + /* Sign extend, second-highest bit is the sign bit */ if ((uint8)byte & 0x40) result |= (~((uint64)0)) << shift; } @@ -219,7 +219,10 @@ type2str(uint8 type) static bool is_32bit_type(uint8 type) { - if (type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32 + if (type == VALUE_TYPE_I32 + || type == VALUE_TYPE_F32 + /* the operand stack is in polymorphic state */ + || type == VALUE_TYPE_ANY #if WASM_ENABLE_REF_TYPES != 0 || type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF #endif @@ -327,7 +330,7 @@ check_utf8_str(const uint8 *str, uint32 len) return false; } } - else if (chr >= 0xE1 && chr <= 0xEF) { + else { /* chr >= 0xE1 && chr <= 0xEF */ if (p[1] < 0x80 || p[1] > 0xBF || p[2] < 0x80 || p[2] > 0xBF) { return false; } @@ -341,13 +344,13 @@ check_utf8_str(const uint8 *str, uint32 len) return false; } } - else if (chr >= 0xF1 && chr <= 0xF3) { + else if (chr <= 0xF3) { /* and also chr >= 0xF1 */ if (p[1] < 0x80 || p[1] > 0xBF || p[2] < 0x80 || p[2] > 0xBF || p[3] < 0x80 || p[3] > 0xBF) { return false; } } - else if (chr == 0xF4) { + else { /* chr == 0xF4 */ if (p[1] < 0x80 || p[1] > 0x8F || p[2] < 0x80 || p[2] > 0xBF || p[3] < 0x80 || p[3] > 0xBF) { return false; @@ -641,6 +644,10 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, type->param_cell_num = (uint16)param_cell_num; type->ret_cell_num = (uint16)ret_cell_num; +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 + type->quick_aot_entry = wasm_native_lookup_quick_aot_entry(type); +#endif + /* If there is already a same type created, use it instead */ for (j = 0; j < i; j++) { if (wasm_type_equal(type, module->types[j])) { @@ -703,7 +710,6 @@ wasm_loader_find_export(const WASMModule *module, const char *module_name, WASMExport *export = loader_find_export((WASMModuleCommon *)module, module_name, field_name, export_kind, error_buf, error_buf_size); - ; return export; } #endif @@ -894,6 +900,58 @@ wasm_loader_resolve_global(const char *module_name, const char *global_name, return global; } +#if WASM_ENABLE_TAGS != 0 +static WASMTag * +wasm_loader_resolve_tag(const char *module_name, const char *tag_name, + const WASMType *expected_tag_type, + uint32 *linked_tag_index, char *error_buf, + uint32 error_buf_size) +{ + WASMModuleCommon *module_reg; + WASMTag *tag = NULL; + WASMExport *export = NULL; + WASMModule *module = NULL; + + 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 tag %s", module_name, + tag_name); + set_error_buf(error_buf, error_buf_size, "unknown import"); + return NULL; + } + + module = (WASMModule *)module_reg; + export = + wasm_loader_find_export(module, module_name, tag_name, EXPORT_KIND_TAG, + error_buf, error_buf_size); + if (!export) { + return NULL; + } + + /* resolve tag type and tag */ + if (export->index < module->import_tag_count) { + /* importing an imported tag from the submodule */ + tag = module->import_tags[export->index].u.tag.import_tag_linked; + } + else { + /* importing an section tag from the submodule */ + tag = module->tags[export->index - module->import_tag_count]; + } + + /* check function type */ + if (!wasm_type_equal(expected_tag_type, tag->tag_type)) { + LOG_DEBUG("%s.%s failed the type check", module_name, tag_name); + set_error_buf(error_buf, error_buf_size, "incompatible import type"); + return NULL; + } + + if (linked_tag_index != NULL) { + *linked_tag_index = export->index; + } + + return tag; +} +#endif #endif /* end of WASM_ENABLE_MULTI_MODULE */ static bool @@ -1169,23 +1227,31 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end, (WASMModuleCommon *)parent_module, sub_module_name, error_buf, error_buf_size); if (!sub_module) { +#if WASM_ENABLE_LIB_WASI_THREADS != 0 + /* Avoid memory import failure when wasi-threads is enabled + and the memory is shared */ + if (!(declare_max_page_count_flag & 2)) + return false; +#else return false; +#endif /* WASM_ENABLE_LIB_WASI_THREADS */ } + else { + linked_memory = wasm_loader_resolve_memory( + sub_module_name, memory_name, declare_init_page_count, + declare_max_page_count, error_buf, error_buf_size); + if (!linked_memory) { + return false; + } - linked_memory = wasm_loader_resolve_memory( - sub_module_name, memory_name, declare_init_page_count, - declare_max_page_count, error_buf, error_buf_size); - if (!linked_memory) { - return false; + /** + * reset with linked memory limit + */ + memory->import_module = sub_module; + memory->import_memory_linked = linked_memory; + declare_init_page_count = linked_memory->init_page_count; + declare_max_page_count = linked_memory->max_page_count; } - - /** - * reset with linked memory limit - */ - memory->import_module = sub_module; - memory->import_memory_linked = linked_memory; - declare_init_page_count = linked_memory->init_page_count; - declare_max_page_count = linked_memory->max_page_count; } #endif @@ -1225,6 +1291,89 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end, return false; } +#if WASM_ENABLE_TAGS != 0 +static bool +load_tag_import(const uint8 **p_buf, const uint8 *buf_end, + const WASMModule *parent_module, /* this module ! */ + const char *sub_module_name, const char *tag_name, + WASMTagImport *tag, /* structure to fill */ + char *error_buf, uint32 error_buf_size) +{ + /* attribute and type of the import statement */ + uint8 declare_tag_attribute; + uint32 declare_type_index; + const uint8 *p = *p_buf, *p_end = buf_end; +#if WASM_ENABLE_MULTI_MODULE != 0 + WASMModule *sub_module = NULL; +#endif + + /* get the one byte attribute */ + CHECK_BUF(p, p_end, 1); + declare_tag_attribute = read_uint8(p); + if (declare_tag_attribute != 0) { + set_error_buf(error_buf, error_buf_size, "unknown tag attribute"); + goto fail; + } + + /* get type */ + read_leb_uint32(p, p_end, declare_type_index); + /* compare against module->types */ + if (declare_type_index >= parent_module->type_count) { + set_error_buf(error_buf, error_buf_size, "unknown tag type"); + goto fail; + } + + WASMType *declare_tag_type = parent_module->types[declare_type_index]; + + /* check, that the type of the declared tag returns void */ + if (declare_tag_type->result_count != 0) { + set_error_buf(error_buf, error_buf_size, + "tag type signature does not return void"); + + goto fail; + } + +#if WASM_ENABLE_MULTI_MODULE != 0 + if (!wasm_runtime_is_built_in_module(sub_module_name)) { + sub_module = (WASMModule *)wasm_runtime_load_depended_module( + (WASMModuleCommon *)parent_module, sub_module_name, error_buf, + error_buf_size); + if (!sub_module) { + return false; + } + /* wasm_loader_resolve_tag checks, that the imported tag + * and the declared tag have the same type + */ + uint32 linked_tag_index = 0; + WASMTag *linked_tag = wasm_loader_resolve_tag( + sub_module_name, tag_name, declare_tag_type, + &linked_tag_index /* out */, error_buf, error_buf_size); + if (linked_tag) { + tag->import_module = sub_module; + tag->import_tag_linked = linked_tag; + tag->import_tag_index_linked = linked_tag_index; + } + } +#endif + /* store to module tag declarations */ + tag->attribute = declare_tag_attribute; + tag->type = declare_type_index; + + tag->module_name = (char *)sub_module_name; + tag->field_name = (char *)tag_name; + tag->tag_type = declare_tag_type; + + *p_buf = p; + (void)parent_module; + + LOG_VERBOSE("Load tag import success\n"); + + return true; +fail: + return false; +} +#endif + static bool load_global_import(const uint8 **p_buf, const uint8 *buf_end, const WASMModule *parent_module, char *sub_module_name, @@ -1446,6 +1595,9 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, WASMImport *import; WASMImport *import_functions = NULL, *import_tables = NULL; WASMImport *import_memories = NULL, *import_globals = NULL; +#if WASM_ENABLE_TAGS != 0 + WASMImport *import_tags = NULL; +#endif char *sub_module_name, *field_name; uint8 u8, kind; @@ -1474,7 +1626,7 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, p += name_len; CHECK_BUF(p, p_end, 1); - /* 0x00/0x01/0x02/0x03 */ + /* 0x00/0x01/0x02/0x03/0x04 */ kind = read_uint8(p); switch (kind) { @@ -1515,6 +1667,16 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, } break; +#if WASM_ENABLE_TAGS != 0 + case IMPORT_KIND_TAG: /* import tags */ + /* it only counts the number of tags to import */ + module->import_tag_count++; + CHECK_BUF(p, p_end, 1); + u8 = read_uint8(p); + read_leb_uint32(p, p_end, type_index); + break; +#endif + case IMPORT_KIND_GLOBAL: /* import global */ CHECK_BUF(p, p_end, 2); p += 2; @@ -1537,10 +1699,23 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, import_memories = module->import_memories = module->imports + module->import_function_count + module->import_table_count; + +#if WASM_ENABLE_TAGS != 0 + if (module->import_tag_count) + import_tags = module->import_tags = + module->imports + module->import_function_count + + module->import_table_count + module->import_memory_count; + if (module->import_global_count) + import_globals = module->import_globals = + module->imports + module->import_function_count + + module->import_table_count + module->import_memory_count + + module->import_tag_count; +#else if (module->import_global_count) import_globals = module->import_globals = module->imports + module->import_function_count + module->import_table_count + module->import_memory_count; +#endif p = p_old; @@ -1567,7 +1742,7 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, p += name_len; CHECK_BUF(p, p_end, 1); - /* 0x00/0x01/0x02/0x03 */ + /* 0x00/0x01/0x02/0x03/0x4 */ kind = read_uint8(p); switch (kind) { @@ -1603,6 +1778,18 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, } break; +#if WASM_ENABLE_TAGS != 0 + case IMPORT_KIND_TAG: + bh_assert(import_tags); + import = import_tags++; + if (!load_tag_import(&p, p_end, module, sub_module_name, + field_name, &import->u.tag, error_buf, + error_buf_size)) { + return false; + } + break; +#endif + case IMPORT_KIND_GLOBAL: /* import global */ bh_assert(import_globals); import = import_globals++; @@ -2114,6 +2301,16 @@ load_export_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, return false; } break; +#if WASM_ENABLE_TAGS != 0 + /* export tag */ + case EXPORT_KIND_TAG: + if (index >= module->tag_count + module->import_tag_count) { + set_error_buf(error_buf, error_buf_size, "unknown tag"); + return false; + } + break; +#endif + /* global index */ case EXPORT_KIND_GLOBAL: if (index @@ -2123,6 +2320,7 @@ load_export_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, return false; } break; + default: set_error_buf(error_buf, error_buf_size, "invalid export kind"); @@ -2529,6 +2727,83 @@ load_datacount_section(const uint8 *buf, const uint8 *buf_end, } #endif +#if WASM_ENABLE_TAGS != 0 +static bool +load_tag_section(const uint8 *buf, const uint8 *buf_end, const uint8 *buf_code, + const uint8 *buf_code_end, WASMModule *module, char *error_buf, + uint32 error_buf_size) +{ + (void)buf_code; + (void)buf_code_end; + + const uint8 *p = buf, *p_end = buf_end; + size_t total_size = 0; + /* number of tags defined in the section */ + uint32 section_tag_count = 0; + uint8 tag_attribute; + uint32 tag_type; + WASMTag *tag = NULL; + + /* get tag count */ + read_leb_uint32(p, p_end, section_tag_count); + module->tag_count = section_tag_count; + + if (section_tag_count) { + total_size = sizeof(WASMTag *) * module->tag_count; + if (!(module->tags = + loader_malloc(total_size, error_buf, error_buf_size))) { + return false; + } + /* load each tag, imported tags precede the tags */ + uint32 tag_index; + for (tag_index = 0; tag_index < section_tag_count; tag_index++) { + + /* get the one byte attribute */ + CHECK_BUF(p, p_end, 1); + tag_attribute = read_uint8(p); + + /* get type */ + read_leb_uint32(p, p_end, tag_type); + /* compare against module->types */ + if (tag_type >= module->type_count) { + set_error_buf(error_buf, error_buf_size, "unknown type"); + return false; + } + + /* get return type (must be 0) */ + /* check, that the type of the referred tag returns void */ + WASMType *func_type = (WASMType *)module->types[tag_type]; + if (func_type->result_count != 0) { + set_error_buf(error_buf, error_buf_size, + "non-empty tag result type"); + + goto fail; + } + + if (!(tag = module->tags[tag_index] = loader_malloc( + sizeof(WASMTag), error_buf, error_buf_size))) { + return false; + } + + /* store to module tag declarations */ + tag->attribute = tag_attribute; + tag->type = tag_type; + tag->tag_type = func_type; + } + } + + if (p != p_end) { + set_error_buf(error_buf, error_buf_size, "section size mismatch"); + return false; + } + + LOG_VERBOSE("Load tag section success.\n"); + return true; +fail: + return false; +} +#endif + static bool load_code_section(const uint8 *buf, const uint8 *buf_end, const uint8 *buf_func, const uint8 *buf_func_end, WASMModule *module, @@ -2667,8 +2942,12 @@ handle_name_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, if (!(module->functions[func_index]->field_name = const_str_list_insert( p, func_name_len, module, - is_load_from_file_buf, error_buf, - error_buf_size))) { +#if WASM_ENABLE_WAMR_COMPILER != 0 + false, +#else + is_load_from_file_buf, +#endif + error_buf, error_buf_size))) { return false; } } @@ -2840,7 +3119,7 @@ static bool init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf, uint32 error_buf_size) { - LLVMJITOptions llvm_jit_options = wasm_runtime_get_llvm_jit_options(); + LLVMJITOptions *llvm_jit_options = wasm_runtime_get_llvm_jit_options(); AOTCompOption option = { 0 }; char *aot_last_error; uint64 size; @@ -2880,11 +3159,11 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf, option.is_jit_mode = true; - llvm_jit_options = wasm_runtime_get_llvm_jit_options(); - option.opt_level = llvm_jit_options.opt_level; - option.size_level = llvm_jit_options.size_level; - option.segue_flags = llvm_jit_options.segue_flags; - option.linux_perf_support = llvm_jit_options.linux_perf_support; + option.opt_level = llvm_jit_options->opt_level; + option.size_level = llvm_jit_options->size_level; + option.segue_flags = llvm_jit_options->segue_flags; + option.quick_invoke_c_api_import = + llvm_jit_options->quick_invoke_c_api_import; #if WASM_ENABLE_BULK_MEMORY != 0 option.enable_bulk_memory = true; @@ -3320,6 +3599,14 @@ load_from_sections(WASMModule *module, WASMSection *sections, error_buf_size)) return false; break; +#if WASM_ENABLE_TAGS != 0 + case SECTION_TYPE_TAG: + /* load tag declaration section */ + if (!load_tag_section(buf, buf_end, buf_code, buf_code_end, + module, error_buf, error_buf_size)) + return false; + break; +#endif case SECTION_TYPE_GLOBAL: if (!load_global_section(buf, buf_end, module, error_buf, error_buf_size)) @@ -3789,6 +4076,9 @@ static uint8 section_ids[] = { SECTION_TYPE_FUNC, SECTION_TYPE_TABLE, SECTION_TYPE_MEMORY, +#if WASM_ENABLE_TAGS != 0 + SECTION_TYPE_TAG, +#endif SECTION_TYPE_GLOBAL, SECTION_TYPE_EXPORT, SECTION_TYPE_START, @@ -3980,33 +4270,51 @@ check_wasi_abi_compatibility(const WASMModule *module, /* clang-format on */ WASMExport *initialize = NULL, *memory = NULL, *start = NULL; + uint32 import_function_count = module->import_function_count; + WASMType *func_type; /* (func (export "_start") (...) */ start = wasm_loader_find_export(module, "", "_start", EXPORT_KIND_FUNC, error_buf, error_buf_size); if (start) { - WASMType *func_type = - module->functions[start->index - module->import_function_count] - ->func_type; + if (start->index < import_function_count) { + set_error_buf( + error_buf, error_buf_size, + "the builtin _start function can not be an import function"); + return false; + } + + func_type = + module->functions[start->index - import_function_count]->func_type; if (func_type->param_count || func_type->result_count) { set_error_buf(error_buf, error_buf_size, "the signature of builtin _start function is wrong"); return false; } } + else { + /* (func (export "_initialize") (...) */ + initialize = + wasm_loader_find_export(module, "", "_initialize", EXPORT_KIND_FUNC, + error_buf, error_buf_size); - /* (func (export "_initialize") (...) */ - initialize = wasm_loader_find_export( - module, "", "_initialize", EXPORT_KIND_FUNC, error_buf, error_buf_size); - if (initialize) { - WASMType *func_type = - module->functions[initialize->index - module->import_function_count] - ->func_type; - if (func_type->param_count || func_type->result_count) { - set_error_buf( - error_buf, error_buf_size, - "the signature of builtin _initialize function is wrong"); - return false; + if (initialize) { + if (initialize->index < import_function_count) { + set_error_buf(error_buf, error_buf_size, + "the builtin _initialize function can not be an " + "import function"); + return false; + } + + func_type = + module->functions[initialize->index - import_function_count] + ->func_type; + if (func_type->param_count || func_type->result_count) { + set_error_buf( + error_buf, error_buf_size, + "the signature of builtin _initialize function is wrong"); + return false; + } } } @@ -4026,15 +4334,6 @@ check_wasi_abi_compatibility(const WASMModule *module, * according to the assumption, they should be all wasi compatiable */ - /* always can not have both at the same time */ - if (start && initialize) { - set_error_buf( - error_buf, error_buf_size, - "neither a command nor a reactor can both have _start function " - "and _initialize function at the same time"); - return false; - } - #if WASM_ENABLE_MULTI_MODULE != 0 /* filter out commands (with `_start`) cases */ if (start && !main_module) { @@ -4199,6 +4498,16 @@ wasm_loader_unload(WASMModule *module) if (module->memories) wasm_runtime_free(module->memories); +#if WASM_ENABLE_TAGS != 0 + if (module->tags) { + for (i = 0; i < module->tag_count; i++) { + if (module->tags[i]) + wasm_runtime_free(module->tags[i]); + } + wasm_runtime_free(module->tags); + } +#endif + if (module->globals) wasm_runtime_free(module->globals); @@ -4339,6 +4648,65 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, case WASM_OP_NOP: break; +#if WASM_ENABLE_EXCE_HANDLING != 0 + case WASM_OP_TRY: + u8 = read_uint8(p); + if (block_nested_depth + < sizeof(block_stack) / sizeof(BlockAddr)) { + block_stack[block_nested_depth].start_addr = p; + block_stack[block_nested_depth].else_addr = NULL; + } + block_nested_depth++; + break; + case EXT_OP_TRY: + skip_leb_uint32(p, p_end); + if (block_nested_depth + < sizeof(block_stack) / sizeof(BlockAddr)) { + block_stack[block_nested_depth].start_addr = p; + block_stack[block_nested_depth].else_addr = NULL; + } + block_nested_depth++; + break; + case WASM_OP_CATCH: + if (block_nested_depth == 1) { + *p_end_addr = (uint8 *)(p - 1); + /* stop search and return the address of the catch block */ + return true; + } + break; + case WASM_OP_CATCH_ALL: + if (block_nested_depth == 1) { + *p_end_addr = (uint8 *)(p - 1); + /* stop search and return the address of the catch_all block + */ + return true; + } + break; + case WASM_OP_THROW: + /* skip tag_index */ + skip_leb(p); + break; + case WASM_OP_RETHROW: + /* skip depth */ + skip_leb(p); + break; + case WASM_OP_DELEGATE: + if (block_nested_depth == 1) { + *p_end_addr = (uint8 *)(p - 1); + return true; + } + else { + skip_leb(p); + /* the DELEGATE opcode ends the tryblock, */ + block_nested_depth--; + if (block_nested_depth + < sizeof(block_stack) / sizeof(BlockAddr)) + block_stack[block_nested_depth].end_addr = + (uint8 *)(p - 1); + } + break; +#endif + case WASM_OP_BLOCK: case WASM_OP_LOOP: case WASM_OP_IF: @@ -4741,9 +5109,13 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, #if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0) case WASM_OP_SIMD_PREFIX: { - /* TODO: shall we ceate a table to be friendly to branch - * prediction */ - opcode = read_uint8(p); + uint32 opcode1; + + read_leb_uint32(p, p_end, opcode1); + /* opcode1 was checked in wasm_loader_prepare_bytecode and + is no larger than UINT8_MAX */ + opcode = (uint8)opcode1; + /* follow the order of enum WASMSimdEXTOpcode in wasm_opcode.h */ switch (opcode) { @@ -4833,8 +5205,14 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, #if WASM_ENABLE_SHARED_MEMORY != 0 case WASM_OP_ATOMIC_PREFIX: { - /* atomic_op (1 u8) + memarg (2 u32_leb) */ - opcode = read_uint8(p); + uint32 opcode1; + + /* atomic_op (u32_leb) + memarg (2 u32_leb) */ + read_leb_uint32(p, p_end, opcode1); + /* opcode1 was checked in wasm_loader_prepare_bytecode and + is no larger than UINT8_MAX */ + opcode = (uint8)opcode1; + if (opcode != WASM_OP_ATOMIC_FENCE) { skip_leb_uint32(p, p_end); /* align */ skip_leb_uint32(p, p_end); /* offset */ @@ -4929,6 +5307,8 @@ typedef struct BranchBlock { BranchBlockPatch *patch_list; /* This is used to save params frame_offset of of if block */ int16 *param_frame_offsets; + /* This is used to recover dynamic offset for else branch */ + uint16 start_dynamic_offset; #endif /* Indicate the operand stack is in polymorphic state. @@ -5207,6 +5587,10 @@ wasm_loader_ctx_init(WASMFunction *func, char *error_buf, uint32 error_buf_size) goto fail; loader_ctx->frame_csp_boundary = loader_ctx->frame_csp_bottom + 8; +#if WASM_ENABLE_EXCE_HANDLING != 0 + func->exception_handler_count = 0; +#endif + #if WASM_ENABLE_FAST_INTERP != 0 loader_ctx->frame_offset_size = sizeof(int16) * 32; if (!(loader_ctx->frame_offset_bottom = loader_ctx->frame_offset = @@ -5250,7 +5634,7 @@ wasm_loader_push_frame_ref(WASMLoaderContext *ctx, uint8 type, char *error_buf, *ctx->frame_ref++ = type; ctx->stack_cell_num++; - if (is_32bit_type(type) || type == VALUE_TYPE_ANY) + if (is_32bit_type(type)) goto check_stack_and_return; if (!check_stack_push(ctx, error_buf, error_buf_size)) @@ -5451,11 +5835,11 @@ wasm_loader_pop_frame_csp(WASMLoaderContext *ctx, char *error_buf, wasm_loader_emit_ptr(loader_ctx, NULL); \ } while (0) -#define emit_br_info(frame_csp) \ - do { \ - if (!wasm_loader_emit_br_info(loader_ctx, frame_csp, error_buf, \ - error_buf_size)) \ - goto fail; \ +#define emit_br_info(frame_csp, is_br) \ + do { \ + if (!wasm_loader_emit_br_info(loader_ctx, frame_csp, is_br, error_buf, \ + error_buf_size)) \ + goto fail; \ } while (0) #define LAST_OP_OUTPUT_I32() \ @@ -5842,7 +6226,7 @@ apply_label_patch(WASMLoaderContext *ctx, uint8 depth, uint8 patch_type) static bool wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp, - char *error_buf, uint32 error_buf_size) + bool is_br, char *error_buf, uint32 error_buf_size) { /* br info layout: * a) arity of target block @@ -5890,6 +6274,8 @@ wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp, /* Part e */ dynamic_offset = frame_csp->dynamic_offset + wasm_get_cell_num(types, arity); + if (is_br) + ctx->dynamic_offset = dynamic_offset; for (i = (int32)arity - 1; i >= 0; i--) { cell = (uint8)wasm_value_type_cell_num(types[i]); dynamic_offset -= cell; @@ -6491,13 +6877,6 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, local_offset = local_offsets[local_idx]; \ } while (0) -#define CHECK_BR(depth) \ - do { \ - if (!wasm_loader_check_br(loader_ctx, depth, error_buf, \ - error_buf_size)) \ - goto fail; \ - } while (0) - static bool check_memory(WASMModule *module, char *error_buf, uint32 error_buf_size) { @@ -6680,7 +7059,7 @@ check_memory_align_equal(uint8 opcode, uint32 align, char *error_buf, #endif /* end of WASM_ENABLE_SHARED_MEMORY */ static bool -wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, +wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, uint8 opcode, char *error_buf, uint32 error_buf_size) { BranchBlock *target_block, *cur_block; @@ -6690,7 +7069,22 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, int32 i, available_stack_cell; uint16 cell_num; - if (loader_ctx->csp_num < depth + 1) { + uint8 *frame_ref_old = loader_ctx->frame_ref; + uint8 *frame_ref_after_popped = NULL; + uint8 frame_ref_tmp[4] = { 0 }; + uint8 *frame_ref_buf = frame_ref_tmp; + uint32 stack_cell_num_old = loader_ctx->stack_cell_num; +#if WASM_ENABLE_FAST_INTERP != 0 + int16 *frame_offset_old = loader_ctx->frame_offset; + int16 *frame_offset_after_popped = NULL; + int16 frame_offset_tmp[4] = { 0 }; + int16 *frame_offset_buf = frame_offset_tmp; + uint16 dynamic_offset_old = (loader_ctx->frame_csp - 1)->dynamic_offset; +#endif + bool ret = false; + + bh_assert(loader_ctx->csp_num > 0); + if (loader_ctx->csp_num - 1 < depth) { set_error_buf(error_buf, error_buf_size, "unknown label, " "unexpected end of section or function"); @@ -6720,7 +7114,39 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, #endif POP_TYPE(types[i]); } - for (i = 0; i < (int32)arity; i++) { + + /* Backup stack data since it may be changed in the below + push operations, and the stack data may be used when + checking other target blocks of opcode br_table */ + if (opcode == WASM_OP_BR_TABLE) { + uint64 total_size; + + frame_ref_after_popped = loader_ctx->frame_ref; + total_size = (uint64)sizeof(uint8) + * (frame_ref_old - frame_ref_after_popped); + if (total_size > sizeof(frame_ref_tmp) + && !(frame_ref_buf = loader_malloc(total_size, error_buf, + error_buf_size))) { + goto fail; + } + bh_memcpy_s(frame_ref_buf, (uint32)total_size, + frame_ref_after_popped, (uint32)total_size); + +#if WASM_ENABLE_FAST_INTERP != 0 + frame_offset_after_popped = loader_ctx->frame_offset; + total_size = (uint64)sizeof(int16) + * (frame_offset_old - frame_offset_after_popped); + if (total_size > sizeof(frame_offset_tmp) + && !(frame_offset_buf = loader_malloc(total_size, error_buf, + error_buf_size))) { + goto fail; + } + bh_memcpy_s(frame_offset_buf, (uint32)total_size, + frame_offset_after_popped, (uint32)total_size); +#endif + } + + for (i = 0; i < (int32)arity; i++) { #if WASM_ENABLE_FAST_INTERP != 0 bool disable_emit = true; int16 operand_offset = 0; @@ -6728,7 +7154,41 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, #endif PUSH_TYPE(types[i]); } - return true; + +#if WASM_ENABLE_FAST_INTERP != 0 + emit_br_info(target_block, opcode == WASM_OP_BR); +#endif + + /* Restore the stack data, note that frame_ref_bottom, + frame_offset_bottom may be re-allocated in the above + push operations */ + if (opcode == WASM_OP_BR_TABLE) { + uint32 total_size; + + /* The stack operand num should not be smaller than before + after pop and push operations */ + bh_assert(loader_ctx->stack_cell_num >= stack_cell_num_old); + loader_ctx->stack_cell_num = stack_cell_num_old; + loader_ctx->frame_ref = + loader_ctx->frame_ref_bottom + stack_cell_num_old; + total_size = (uint32)sizeof(uint8) + * (frame_ref_old - frame_ref_after_popped); + bh_memcpy_s((uint8 *)loader_ctx->frame_ref - total_size, total_size, + frame_ref_buf, total_size); + +#if WASM_ENABLE_FAST_INTERP != 0 + loader_ctx->frame_offset = + loader_ctx->frame_offset_bottom + stack_cell_num_old; + total_size = (uint32)sizeof(int16) + * (frame_offset_old - frame_offset_after_popped); + bh_memcpy_s((uint8 *)loader_ctx->frame_offset - total_size, + total_size, frame_offset_buf, total_size); + (loader_ctx->frame_csp - 1)->dynamic_offset = dynamic_offset_old; +#endif + } + + ret = true; + goto cleanup_and_return; } available_stack_cell = @@ -6738,31 +7198,78 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, for (i = (int32)arity - 1; i >= 0; i--) { if (!check_stack_top_values(frame_ref, available_stack_cell, types[i], error_buf, error_buf_size)) - return false; + goto fail; cell_num = wasm_value_type_cell_num(types[i]); frame_ref -= cell_num; available_stack_cell -= cell_num; } - return true; +#if WASM_ENABLE_FAST_INTERP != 0 + emit_br_info(target_block, opcode == WASM_OP_BR); +#endif + ret = true; + +cleanup_and_return: fail: - return false; + if (frame_ref_buf && frame_ref_buf != frame_ref_tmp) + wasm_runtime_free(frame_ref_buf); +#if WASM_ENABLE_FAST_INTERP != 0 + if (frame_offset_buf && frame_offset_buf != frame_offset_tmp) + wasm_runtime_free(frame_offset_buf); +#endif + + return ret; } static BranchBlock * check_branch_block(WASMLoaderContext *loader_ctx, uint8 **p_buf, uint8 *buf_end, - char *error_buf, uint32 error_buf_size) + uint8 opcode, char *error_buf, uint32 error_buf_size) { uint8 *p = *p_buf, *p_end = buf_end; BranchBlock *frame_csp_tmp; uint32 depth; read_leb_uint32(p, p_end, depth); - CHECK_BR(depth); + bh_assert(loader_ctx->csp_num > 0); + if (!wasm_loader_check_br(loader_ctx, depth, opcode, error_buf, + error_buf_size)) { + goto fail; + } + frame_csp_tmp = loader_ctx->frame_csp - depth - 1; + + *p_buf = p; + return frame_csp_tmp; +fail: + return NULL; +} + +#if WASM_ENABLE_EXCE_HANDLING != 0 +static BranchBlock * +check_branch_block_for_delegate(WASMLoaderContext *loader_ctx, uint8 **p_buf, + uint8 *buf_end, char *error_buf, + uint32 error_buf_size) +{ + uint8 *p = *p_buf, *p_end = buf_end; + BranchBlock *frame_csp_tmp; + uint32 depth; + + read_leb_uint32(p, p_end, depth); + /* + * Note: "delegate 0" means the surrounding block, not the + * try-delegate block itself. + * + * Note: the caller hasn't popped the try-delegate frame yet. + */ + bh_assert(loader_ctx->csp_num > 0); + if (loader_ctx->csp_num - 1 <= depth) { + set_error_buf(error_buf, error_buf_size, "unknown delegate label"); + goto fail; + } + frame_csp_tmp = loader_ctx->frame_csp - depth - 2; #if WASM_ENABLE_FAST_INTERP != 0 - emit_br_info(frame_csp_tmp); + emit_br_info(frame_csp_tmp, false); #endif *p_buf = p; @@ -6770,6 +7277,7 @@ check_branch_block(WASMLoaderContext *loader_ctx, uint8 **p_buf, uint8 *buf_end, fail: return NULL; } +#endif static bool check_block_stack(WASMLoaderContext *loader_ctx, BranchBlock *block, @@ -6818,11 +7326,26 @@ check_block_stack(WASMLoaderContext *loader_ctx, BranchBlock *block, return true; } - /* Check stack cell num equals return cell num */ if (available_stack_cell != return_cell_num) { +#if WASM_ENABLE_EXCE_HANDLING != 0 + /* testspec: this error message format is expected by try_catch.wast */ + snprintf( + error_buf, error_buf_size, "type mismatch: %s requires [%s]%s[%s]", + block->label_type == LABEL_TYPE_TRY + || (block->label_type == LABEL_TYPE_CATCH + && return_cell_num > 0) + ? "instruction" + : "block", + return_cell_num > 0 ? type2str(return_types[0]) : "", + " but stack has ", + available_stack_cell > 0 ? type2str(*(loader_ctx->frame_ref - 1)) + : ""); + goto fail; +#else set_error_buf(error_buf, error_buf_size, "type mismatch: stack size does not match block type"); goto fail; +#endif } /* Check stack values match return types */ @@ -6871,6 +7394,7 @@ copy_params_to_dynamic_space(WASMLoaderContext *loader_ctx, bool is_if_block, int16 operand_offset = 0; uint64 size = (uint64)param_count * (sizeof(*cells) + sizeof(*src_offsets)); + bh_assert(size > 0); /* For if block, we also need copy the condition operand offset. */ if (is_if_block) @@ -6900,7 +7424,6 @@ copy_params_to_dynamic_space(WASMLoaderContext *loader_ctx, bool is_if_block, src_offsets[i] = *frame_offset; frame_offset += cell; } - /* emit copy instruction */ emit_label(EXT_OP_COPY_STACK_VALUES); /* Part a) */ @@ -7059,7 +7582,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 *func_const_end, *func_const = NULL; int16 operand_offset = 0; uint8 last_op = 0; - bool disable_emit, preserve_local = false; + bool disable_emit, preserve_local = false, if_condition_available = true; float32 f32_const; float64 f64_const; @@ -7129,13 +7652,44 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_IF: + { #if WASM_ENABLE_FAST_INTERP != 0 + BranchBlock *parent_block = loader_ctx->frame_csp - 1; + int32 available_stack_cell = + (int32)(loader_ctx->stack_cell_num + - parent_block->stack_cell_num); + + if (available_stack_cell <= 0 + && parent_block->is_stack_polymorphic) + if_condition_available = false; + else + if_condition_available = true; + PRESERVE_LOCAL_FOR_BLOCK(); #endif POP_I32(); goto handle_op_block_and_loop; + } case WASM_OP_BLOCK: case WASM_OP_LOOP: +#if WASM_ENABLE_EXCE_HANDLING != 0 + case WASM_OP_TRY: + if (opcode == WASM_OP_TRY) { + /* + * keep track of exception handlers to account for + * memory allocation + */ + func->exception_handler_count++; + + /* + * try is a block + * do nothing special, but execution continues to + * to handle_op_block_and_loop, + * and that be pushes the csp + */ + } + +#endif #if WASM_ENABLE_FAST_INTERP != 0 PRESERVE_LOCAL_FOR_BLOCK(); #endif @@ -7143,6 +7697,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint8 value_type; BlockType block_type; +#if WASM_ENABLE_FAST_INTERP != 0 + uint32 available_params = 0; +#endif p_org = p - 1; CHECK_BUF(p, p_end, 1); @@ -7184,35 +7741,95 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* Pop block parameters from stack */ if (BLOCK_HAS_PARAM(block_type)) { WASMType *wasm_type = block_type.u.type; - for (i = 0; i < block_type.u.type->param_count; i++) + + BranchBlock *cur_block = loader_ctx->frame_csp - 1; +#if WASM_ENABLE_FAST_INTERP != 0 + uint32 cell_num; + available_params = block_type.u.type->param_count; +#endif + for (i = 0; i < block_type.u.type->param_count; i++) { + + int32 available_stack_cell = + (int32)(loader_ctx->stack_cell_num + - cur_block->stack_cell_num); + if (available_stack_cell <= 0 + && cur_block->is_stack_polymorphic) { +#if WASM_ENABLE_FAST_INTERP != 0 + available_params = i; +#endif + break; + } + POP_TYPE( wasm_type->types[wasm_type->param_count - i - 1]); +#if WASM_ENABLE_FAST_INTERP != 0 + /* decrease the frame_offset pointer accordingly to keep + * consistent with frame_ref stack */ + cell_num = wasm_value_type_cell_num( + wasm_type->types[wasm_type->param_count - i - 1]); + loader_ctx->frame_offset -= cell_num; +#endif + } } - PUSH_CSP(LABEL_TYPE_BLOCK + (opcode - WASM_OP_BLOCK), block_type, p); /* Pass parameters to block */ if (BLOCK_HAS_PARAM(block_type)) { - for (i = 0; i < block_type.u.type->param_count; i++) + for (i = 0; i < block_type.u.type->param_count; i++) { +#if WASM_ENABLE_FAST_INTERP != 0 + uint32 cell_num = wasm_value_type_cell_num( + block_type.u.type->types[i]); + if (i >= available_params) { + /* If there isn't enough data on stack, push a dummy + * offset to keep the stack consistent with + * frame_ref. + * Since the stack is already in polymorphic state, + * the opcode will not be executed, so the dummy + * offset won't cause any error */ + uint32 n; + + for (n = 0; n < cell_num; n++) { + if (loader_ctx->p_code_compiled == NULL) { + if (!check_offset_push(loader_ctx, + error_buf, + error_buf_size)) + goto fail; + } + *loader_ctx->frame_offset++ = 0; + } + } + else { + loader_ctx->frame_offset += cell_num; + } +#endif PUSH_TYPE(block_type.u.type->types[i]); + } } #if WASM_ENABLE_FAST_INTERP != 0 if (opcode == WASM_OP_BLOCK || opcode == WASM_OP_LOOP) { skip_label(); + if (BLOCK_HAS_PARAM(block_type)) { /* Make sure params are in dynamic space */ if (!copy_params_to_dynamic_space( loader_ctx, false, error_buf, error_buf_size)) goto fail; } + if (opcode == WASM_OP_LOOP) { (loader_ctx->frame_csp - 1)->code_compiled = loader_ctx->p_code_compiled; } } +#if WASM_ENABLE_EXCE_HANDLING != 0 + else if (opcode == WASM_OP_TRY) { + skip_label(); + } +#endif else if (opcode == WASM_OP_IF) { + BranchBlock *block = loader_ctx->frame_csp - 1; /* If block has parameters, we should make sure they are in * dynamic space. Otherwise, when else branch is missing, * the later opcode may consume incorrect operand offset. @@ -7231,11 +7848,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, * */ if (BLOCK_HAS_PARAM(block_type)) { - BranchBlock *block = loader_ctx->frame_csp - 1; uint64 size; - /* skip the if condition operand offset */ - wasm_loader_emit_backspace(loader_ctx, sizeof(int16)); + /* In polymorphic state, there may be no if condition on + * the stack, so the offset may not emitted */ + if (if_condition_available) { + /* skip the if condition operand offset */ + wasm_loader_emit_backspace(loader_ctx, + sizeof(int16)); + } /* skip the if label */ skip_label(); /* Emit a copy instruction */ @@ -7262,32 +7883,239 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, (uint32)size); } + block->start_dynamic_offset = loader_ctx->dynamic_offset; + emit_empty_label_addr_and_frame_ip(PATCH_ELSE); emit_empty_label_addr_and_frame_ip(PATCH_END); } #endif break; } +#if WASM_ENABLE_EXCE_HANDLING != 0 + case WASM_OP_THROW: + { + SET_CUR_BLOCK_STACK_POLYMORPHIC_STATE(true); + + BranchBlock *cur_block = loader_ctx->frame_csp - 1; + + uint8 label_type = cur_block->label_type; + uint32 tag_index = 0; + read_leb_int32(p, p_end, tag_index); + + /* check validity of tag_index against module->tag_count */ + /* check tag index is within the tag index space */ + if (tag_index >= module->import_tag_count + module->tag_count) { + snprintf(error_buf, error_buf_size, "unknown tag %d", + tag_index); + goto fail; + } + + /* the tag_type is stored in either the WASMTag (section tags) + * or WASMTagImport (import tag) */ + WASMType *tag_type = NULL; + if (tag_index < module->import_tag_count) { + tag_type = module->import_tags[tag_index].u.tag.tag_type; + } + else { + tag_type = + module->tags[tag_index - module->import_tag_count] + ->tag_type; + } + + if (tag_type->result_count != 0) { + set_error_buf(error_buf, error_buf_size, + "tag type signature does not return void"); + goto fail; + } + + int32 available_stack_cell = + (int32)(loader_ctx->stack_cell_num + - cur_block->stack_cell_num); + /* Check stack values match return types by comparing tag param + * types with stack cells */ + uint8 *frame_ref = loader_ctx->frame_ref; + for (int tti = (int32)tag_type->param_count - 1; tti >= 0; + tti--) { + if (!check_stack_top_values(frame_ref, available_stack_cell, + tag_type->types[tti], error_buf, + error_buf_size)) { + snprintf(error_buf, error_buf_size, + "type mismatch: instruction requires [%s] but " + "stack has [%s]", + tag_type->param_count > 0 + ? type2str(tag_type->types[tti]) + : "", + available_stack_cell > 0 + ? type2str(*(loader_ctx->frame_ref - 1)) + : ""); + goto fail; + } + frame_ref -= wasm_value_type_cell_num(tag_type->types[tti]); + available_stack_cell -= + wasm_value_type_cell_num(tag_type->types[tti]); + } + + /* throw is stack polymorphic */ + (void)label_type; + RESET_STACK(); + + break; + } + case WASM_OP_RETHROW: + { + /* must be done before checking branch block */ + SET_CUR_BLOCK_STACK_POLYMORPHIC_STATE(true); + + /* check the target catching block: LABEL_TYPE_CATCH */ + if (!(frame_csp_tmp = + check_branch_block(loader_ctx, &p, p_end, opcode, + error_buf, error_buf_size))) + goto fail; + + if (frame_csp_tmp->label_type != LABEL_TYPE_CATCH + && frame_csp_tmp->label_type != LABEL_TYPE_CATCH_ALL) { + /* trap according to spectest (rethrow.wast) */ + set_error_buf(error_buf, error_buf_size, + "invalid rethrow label"); + goto fail; + } + + BranchBlock *cur_block = loader_ctx->frame_csp - 1; + uint8 label_type = cur_block->label_type; + (void)label_type; + /* rethrow is stack polymorphic */ + RESET_STACK(); + break; + } + case WASM_OP_DELEGATE: + { + /* check target block is valid */ + if (!(frame_csp_tmp = check_branch_block_for_delegate( + loader_ctx, &p, p_end, error_buf, error_buf_size))) + goto fail; + + BranchBlock *cur_block = loader_ctx->frame_csp - 1; + uint8 label_type = cur_block->label_type; + + (void)label_type; + /* DELEGATE ends the block */ + POP_CSP(); + break; + } + case WASM_OP_CATCH: + { + BranchBlock *cur_block = loader_ctx->frame_csp - 1; + + uint8 label_type = cur_block->label_type; + uint32 tag_index = 0; + read_leb_int32(p, p_end, tag_index); + + /* check validity of tag_index against module->tag_count */ + /* check tag index is within the tag index space */ + if (tag_index >= module->import_tag_count + module->tag_count) { + LOG_VERBOSE("In %s, unknown tag at WASM_OP_CATCH\n", + __FUNCTION__); + set_error_buf(error_buf, error_buf_size, "unknown tag"); + goto fail; + } + + /* the tag_type is stored in either the WASMTag (section tags) + * or WASMTagImport (import tag) */ + WASMType *func_type = NULL; + if (tag_index < module->import_tag_count) { + func_type = module->import_tags[tag_index].u.tag.tag_type; + } + else { + func_type = + module->tags[tag_index - module->import_tag_count] + ->tag_type; + } + + if (func_type->result_count != 0) { + set_error_buf(error_buf, error_buf_size, + "tag type signature does not return void"); + goto fail; + } + + /* check validity of current label (expect LABEL_TYPE_TRY or + * LABEL_TYPE_CATCH) */ + if ((LABEL_TYPE_CATCH != label_type) + && (LABEL_TYPE_TRY != label_type)) { + set_error_buf(error_buf, error_buf_size, + "Unexpected block sequence encountered."); + goto fail; + } + + BlockType new_block_type; + new_block_type.is_value_type = false; + new_block_type.u.type = func_type; + + /* + * replace frame_csp by LABEL_TYPE_CATCH + */ + cur_block->label_type = LABEL_TYPE_CATCH; + + /* RESET_STACK removes the values pushed in TRY or pervious + * CATCH Blocks */ + RESET_STACK(); + + /* push types on the stack according to catched type */ + if (BLOCK_HAS_PARAM(new_block_type)) { + for (i = 0; i < new_block_type.u.type->param_count; i++) + PUSH_TYPE(new_block_type.u.type->types[i]); + } + break; + } + case WASM_OP_CATCH_ALL: + { + BranchBlock *cur_block = loader_ctx->frame_csp - 1; + + /* expecting a TRY or CATCH, anything else will be considered an + * error */ + if ((LABEL_TYPE_CATCH != cur_block->label_type) + && (LABEL_TYPE_TRY != cur_block->label_type)) { + set_error_buf(error_buf, error_buf_size, + "Unexpected block sequence encountered."); + goto fail; + } + + /* no immediates */ + /* replace frame_csp by LABEL_TYPE_CATCH_ALL */ + cur_block->label_type = LABEL_TYPE_CATCH_ALL; + + /* RESET_STACK removes the values pushed in TRY or pervious + * CATCH Blocks */ + RESET_STACK(); + + /* catch_all has no tagtype and therefore no parameters */ + break; + } +#endif case WASM_OP_ELSE: { - BlockType block_type = (loader_ctx->frame_csp - 1)->block_type; + BranchBlock *block = NULL; + BlockType block_type; if (loader_ctx->csp_num < 2 - || (loader_ctx->frame_csp - 1)->label_type - != LABEL_TYPE_IF) { + /* the matched if isn't found */ + || (loader_ctx->frame_csp - 1)->label_type != LABEL_TYPE_IF + /* duplicated else is found */ + || (loader_ctx->frame_csp - 1)->else_addr) { set_error_buf( error_buf, error_buf_size, "opcode else found without matched opcode if"); goto fail; } + block = loader_ctx->frame_csp - 1; /* check whether if branch's stack matches its result type */ - if (!check_block_stack(loader_ctx, loader_ctx->frame_csp - 1, - error_buf, error_buf_size)) + if (!check_block_stack(loader_ctx, block, error_buf, + error_buf_size)) goto fail; - (loader_ctx->frame_csp - 1)->else_addr = p - 1; + block->else_addr = p - 1; + block_type = block->block_type; #if WASM_ENABLE_FAST_INTERP != 0 /* if the result of if branch is in local or const area, add a @@ -7310,12 +8138,12 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* Recover top param_count values of frame_offset stack */ if (BLOCK_HAS_PARAM((block_type))) { uint32 size; - BranchBlock *block = loader_ctx->frame_csp - 1; size = sizeof(int16) * block_type.u.type->param_cell_num; bh_memcpy_s(loader_ctx->frame_offset, size, block->param_frame_offsets, size); loader_ctx->frame_offset += (size / sizeof(int16)); } + loader_ctx->dynamic_offset = block->start_dynamic_offset; #endif break; @@ -7399,8 +8227,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_BR: { - if (!(frame_csp_tmp = check_branch_block( - loader_ctx, &p, p_end, error_buf, error_buf_size))) + if (!(frame_csp_tmp = + check_branch_block(loader_ctx, &p, p_end, opcode, + error_buf, error_buf_size))) goto fail; RESET_STACK(); @@ -7412,8 +8241,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { POP_I32(); - if (!(frame_csp_tmp = check_branch_block( - loader_ctx, &p, p_end, error_buf, error_buf_size))) + if (!(frame_csp_tmp = + check_branch_block(loader_ctx, &p, p_end, opcode, + error_buf, error_buf_size))) goto fail; break; @@ -7422,13 +8252,11 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_BR_TABLE: { uint8 *ret_types = NULL; - uint32 ret_count = 0; + uint32 ret_count = 0, depth = 0; #if WASM_ENABLE_FAST_INTERP == 0 - uint8 *p_depth_begin, *p_depth; - uint32 depth, j; BrTableCache *br_table_cache = NULL; - - p_org = p - 1; + uint8 *p_depth_begin, *p_depth, *p_opcode = p - 1; + uint32 j; #endif read_leb_uint32(p, p_end, count); @@ -7437,12 +8265,26 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif POP_I32(); + /* Get each depth and check it */ + p_org = p; + for (i = 0; i <= count; i++) { + read_leb_uint32(p, p_end, depth); + bh_assert(loader_ctx->csp_num > 0); + if (loader_ctx->csp_num - 1 < depth) { + set_error_buf(error_buf, error_buf_size, + "unknown label, " + "unexpected end of section or function"); + goto fail; + } + } + p = p_org; + #if WASM_ENABLE_FAST_INTERP == 0 p_depth_begin = p_depth = p; #endif for (i = 0; i <= count; i++) { if (!(frame_csp_tmp = - check_branch_block(loader_ctx, &p, p_end, + check_branch_block(loader_ctx, &p, p_end, opcode, error_buf, error_buf_size))) goto fail; @@ -7490,7 +8332,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* The depth cannot be stored in one byte, create br_table cache to store each depth */ #if WASM_ENABLE_DEBUG_INTERP != 0 - if (!record_fast_op(module, p_org, *p_org, + if (!record_fast_op(module, p_opcode, *p_opcode, error_buf, error_buf_size)) { goto fail; } @@ -7502,8 +8344,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, error_buf, error_buf_size))) { goto fail; } - *p_org = EXT_OP_BR_TABLE_CACHE; - br_table_cache->br_table_op_addr = p_org; + *p_opcode = EXT_OP_BR_TABLE_CACHE; + br_table_cache->br_table_op_addr = p_opcode; br_table_cache->br_count = count; /* Copy previous depths which are one byte */ for (j = 0; j < i; j++) { @@ -7543,11 +8385,11 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, idx--) { ret_type = *(func->func_type->types + func->func_type->param_count + idx); - POP_TYPE(ret_type); #if WASM_ENABLE_FAST_INTERP != 0 /* emit the offset after return opcode */ POP_OFFSET_TYPE(ret_type); #endif + POP_TYPE(ret_type); } RESET_STACK(); @@ -7587,10 +8429,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, if (func_type->param_count > 0) { for (idx = (int32)(func_type->param_count - 1); idx >= 0; idx--) { - POP_TYPE(func_type->types[idx]); #if WASM_ENABLE_FAST_INTERP != 0 POP_OFFSET_TYPE(func_type->types[idx]); #endif + POP_TYPE(func_type->types[idx]); } } @@ -7688,10 +8530,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, if (func_type->param_count > 0) { for (idx = (int32)(func_type->param_count - 1); idx >= 0; idx--) { - POP_TYPE(func_type->types[idx]); #if WASM_ENABLE_FAST_INTERP != 0 POP_OFFSET_TYPE(func_type->types[idx]); #endif + POP_TYPE(func_type->types[idx]); } } @@ -7758,8 +8600,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } if (available_stack_cell > 0) { - if (is_32bit_type(*(loader_ctx->frame_ref - 1)) - || *(loader_ctx->frame_ref - 1) == VALUE_TYPE_ANY) { + if (is_32bit_type(*(loader_ctx->frame_ref - 1))) { loader_ctx->frame_ref--; loader_ctx->stack_cell_num--; #if WASM_ENABLE_FAST_INTERP != 0 @@ -7837,6 +8678,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, switch (*(loader_ctx->frame_ref - 1)) { case REF_I32: case REF_F32: + case REF_ANY: break; case REF_I64_2: case REF_F64_2: @@ -8050,13 +8892,33 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_REF_IS_NULL: { #if WASM_ENABLE_FAST_INTERP != 0 - if (!wasm_loader_pop_frame_ref_offset(loader_ctx, - VALUE_TYPE_FUNCREF, - error_buf, error_buf_size) - && !wasm_loader_pop_frame_ref_offset( - loader_ctx, VALUE_TYPE_EXTERNREF, error_buf, - error_buf_size)) { - goto fail; + BranchBlock *cur_block = loader_ctx->frame_csp - 1; + int32 block_stack_cell_num = + (int32)(loader_ctx->stack_cell_num + - cur_block->stack_cell_num); + if (block_stack_cell_num <= 0) { + if (!cur_block->is_stack_polymorphic) { + set_error_buf( + error_buf, error_buf_size, + "type mismatch: expect data but stack was empty"); + goto fail; + } + } + else { + if (*(loader_ctx->frame_ref - 1) == VALUE_TYPE_FUNCREF + || *(loader_ctx->frame_ref - 1) == VALUE_TYPE_EXTERNREF + || *(loader_ctx->frame_ref - 1) == VALUE_TYPE_ANY) { + if (!wasm_loader_pop_frame_ref_offset( + loader_ctx, *(loader_ctx->frame_ref - 1), + error_buf, error_buf_size)) { + goto fail; + } + } + else { + set_error_buf(error_buf, error_buf_size, + "type mismatch"); + goto fail; + } } #else if (!wasm_loader_pop_frame_ref(loader_ctx, VALUE_TYPE_FUNCREF, @@ -8079,24 +8941,44 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, goto fail; } - /* Refer to a forward-declared function */ - if (func_idx >= cur_func_idx + module->import_function_count) { + /* Refer to a forward-declared function: + the function must be an import, exported, or present in + a table elem segment or global initializer to be used as + the operand to ref.func */ + if (func_idx >= module->import_function_count) { WASMTableSeg *table_seg = module->table_segments; bool func_declared = false; uint32 j; - /* Check whether the function is declared in table segs */ - for (i = 0; i < module->table_seg_count; i++, table_seg++) { - if (table_seg->elem_type == VALUE_TYPE_FUNCREF - && wasm_elem_is_declarative(table_seg->mode)) { - for (j = 0; j < table_seg->function_count; j++) { - if (table_seg->func_indexes[j] == func_idx) { - func_declared = true; - break; + for (i = 0; i < module->global_count; i++) { + if (module->globals[i].type == VALUE_TYPE_FUNCREF + && module->globals[i].init_expr.init_expr_type + == INIT_EXPR_TYPE_FUNCREF_CONST + && module->globals[i].init_expr.u.u32 == func_idx) { + func_declared = true; + break; + } + } + + if (!func_declared) { + /* Check whether the function is declared in table segs, + note that it doesn't matter whether the table seg's + mode is passive, active or declarative. */ + for (i = 0; i < module->table_seg_count; + i++, table_seg++) { + if (table_seg->elem_type == VALUE_TYPE_FUNCREF) { + for (j = 0; j < table_seg->function_count; + j++) { + if (table_seg->func_indexes[j] + == func_idx) { + func_declared = true; + break; + } } } } } + if (!func_declared) { /* Check whether the function is exported */ for (i = 0; i < module->export_count; i++) { @@ -8159,7 +9041,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { p_org = p - 1; GET_LOCAL_INDEX_TYPE_AND_OFFSET(); - POP_TYPE(local_type); #if WASM_ENABLE_FAST_INTERP != 0 if (!(preserve_referenced_local( @@ -8216,6 +9097,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } #endif #endif /* end of WASM_ENABLE_FAST_INTERP != 0 */ + POP_TYPE(local_type); break; } @@ -8353,8 +9235,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, - module->import_global_count] .type; - POP_TYPE(global_type); - #if WASM_ENABLE_FAST_INTERP == 0 if (global_type == VALUE_TYPE_I64 || global_type == VALUE_TYPE_F64) { @@ -8393,6 +9273,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, emit_uint32(loader_ctx, global_idx); POP_OFFSET_TYPE(global_type); #endif /* end of WASM_ENABLE_FAST_INTERP */ + + POP_TYPE(global_type); + break; } @@ -8577,6 +9460,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_F32_CONST: + CHECK_BUF(p, p_end, sizeof(float32)); p += sizeof(float32); #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); @@ -8595,6 +9479,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_F64_CONST: + CHECK_BUF(p, p_end, sizeof(float64)); p += sizeof(float64); #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); @@ -8916,6 +9801,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_MEMORY_COPY: { + CHECK_BUF(p, p_end, sizeof(int16)); /* both src and dst memory index should be 0 */ if (*(int16 *)p != 0x0000) goto fail_zero_byte_expected; @@ -9113,8 +9999,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 opcode1; - CHECK_BUF(p, p_end, 1); - opcode1 = read_uint8(p); + read_leb_uint32(p, p_end, opcode1); + /* follow the order of enum WASMSimdEXTOpcode in wasm_opcode.h */ switch (opcode1) { @@ -9601,13 +10487,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; } - case SIMD_i32x4_narrow_i64x2_s: - case SIMD_i32x4_narrow_i64x2_u: - { - POP2_AND_PUSH(VALUE_TYPE_V128, VALUE_TYPE_V128); - break; - } - case SIMD_i32x4_extend_low_i16x8_s: case SIMD_i32x4_extend_high_i16x8_s: case SIMD_i32x4_extend_low_i16x8_u: @@ -9634,7 +10513,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case SIMD_i32x4_max_s: case SIMD_i32x4_max_u: case SIMD_i32x4_dot_i16x8_s: - case SIMD_i32x4_avgr_u: case SIMD_i32x4_extmul_low_i16x8_s: case SIMD_i32x4_extmul_high_i16x8_s: case SIMD_i32x4_extmul_low_i16x8_u: @@ -9698,7 +10576,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* f32x4 operation */ case SIMD_f32x4_abs: case SIMD_f32x4_neg: - case SIMD_f32x4_round: case SIMD_f32x4_sqrt: { POP_AND_PUSH(VALUE_TYPE_V128, VALUE_TYPE_V128); @@ -9721,7 +10598,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* f64x2 operation */ case SIMD_f64x2_abs: case SIMD_f64x2_neg: - case SIMD_f64x2_round: case SIMD_f64x2_sqrt: { POP_AND_PUSH(VALUE_TYPE_V128, VALUE_TYPE_V128); @@ -9775,8 +10651,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint32 opcode1; - CHECK_BUF(p, p_end, 1); - opcode1 = read_uint8(p); + read_leb_uint32(p, p_end, opcode1); + #if WASM_ENABLE_FAST_INTERP != 0 emit_byte(loader_ctx, opcode1); #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_loader.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_loader.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_mini_loader.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_mini_loader.c similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_mini_loader.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_mini_loader.c index 47ec549eedb..0939ad48974 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_mini_loader.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_mini_loader.c @@ -51,7 +51,10 @@ set_error_buf(char *error_buf, uint32 error_buf_size, const char *string) static bool is_32bit_type(uint8 type) { - if (type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32 + if (type == VALUE_TYPE_I32 + || type == VALUE_TYPE_F32 + /* the operand stack is in polymorphic state */ + || type == VALUE_TYPE_ANY #if WASM_ENABLE_REF_TYPES != 0 || type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF #endif @@ -418,6 +421,10 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module, type->param_cell_num = (uint16)param_cell_num; type->ret_cell_num = (uint16)ret_cell_num; +#if WASM_ENABLE_QUICK_AOT_ENTRY != 0 + type->quick_aot_entry = wasm_native_lookup_quick_aot_entry(type); +#endif + /* If there is already a same type created, use it instead */ for (j = 0; j < i; ++j) { if (wasm_type_equal(type, module->types[j])) { @@ -1874,10 +1881,11 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf, } option.is_jit_mode = true; - option.opt_level = llvm_jit_options.opt_level; - option.size_level = llvm_jit_options.size_level; - option.segue_flags = llvm_jit_options.segue_flags; - option.linux_perf_support = llvm_jit_options.linux_perf_support; + option.opt_level = llvm_jit_options->opt_level; + option.size_level = llvm_jit_options->size_level; + option.segue_flags = llvm_jit_options->segue_flags; + option.quick_invoke_c_api_import = + llvm_jit_options->quick_invoke_c_api_import; #if WASM_ENABLE_BULK_MEMORY != 0 option.enable_bulk_memory = true; @@ -3254,6 +3262,17 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, u8 = read_uint8(p); /* 0x00 */ break; +#if WASM_ENABLE_EXCE_HANDLING != 0 + case WASM_OP_TRY: + case WASM_OP_CATCH: + case WASM_OP_THROW: + case WASM_OP_RETHROW: + case WASM_OP_DELEGATE: + case WASM_OP_CATCH_ALL: + /* TODO */ + return false; +#endif + case WASM_OP_DROP: case WASM_OP_SELECT: case WASM_OP_DROP_64: @@ -3476,8 +3495,11 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, uint32 opcode1; read_leb_uint32(p, p_end, opcode1); + /* opcode1 was checked in wasm_loader_prepare_bytecode and + is no larger than UINT8_MAX */ + opcode = (uint8)opcode1; - switch (opcode1) { + switch (opcode) { case WASM_OP_I32_TRUNC_SAT_S_F32: case WASM_OP_I32_TRUNC_SAT_U_F32: case WASM_OP_I32_TRUNC_SAT_S_F64: @@ -3533,8 +3555,14 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache, #if WASM_ENABLE_SHARED_MEMORY != 0 case WASM_OP_ATOMIC_PREFIX: { - /* atomic_op (1 u8) + memarg (2 u32_leb) */ - opcode = read_uint8(p); + uint32 opcode1; + + /* atomic_op (u32_leb) + memarg (2 u32_leb) */ + read_leb_uint32(p, p_end, opcode1); + /* opcode1 was checked in wasm_loader_prepare_bytecode and + is no larger than UINT8_MAX */ + opcode = (uint8)opcode1; + if (opcode != WASM_OP_ATOMIC_FENCE) { skip_leb_uint32(p, p_end); /* align */ skip_leb_uint32(p, p_end); /* offset */ @@ -3595,6 +3623,11 @@ typedef struct BranchBlock { BranchBlockPatch *patch_list; /* This is used to save params frame_offset of of if block */ int16 *param_frame_offsets; + /* This is used to store available param num for if/else branch, so the else + * opcode can know how many parameters should be copied to the stack */ + uint32 available_param_num; + /* This is used to recover dynamic offset for else branch */ + uint16 start_dynamic_offset; #endif /* Indicate the operand stack is in polymorphic state. @@ -4057,11 +4090,11 @@ wasm_loader_pop_frame_csp(WASMLoaderContext *ctx, char *error_buf, wasm_loader_emit_ptr(loader_ctx, NULL); \ } while (0) -#define emit_br_info(frame_csp) \ - do { \ - if (!wasm_loader_emit_br_info(loader_ctx, frame_csp, error_buf, \ - error_buf_size)) \ - goto fail; \ +#define emit_br_info(frame_csp, is_br) \ + do { \ + if (!wasm_loader_emit_br_info(loader_ctx, frame_csp, is_br, error_buf, \ + error_buf_size)) \ + goto fail; \ } while (0) #define LAST_OP_OUTPUT_I32() \ @@ -4446,7 +4479,7 @@ apply_label_patch(WASMLoaderContext *ctx, uint8 depth, uint8 patch_type) static bool wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp, - char *error_buf, uint32 error_buf_size) + bool is_br, char *error_buf, uint32 error_buf_size) { /* br info layout: * a) arity of target block @@ -4495,6 +4528,8 @@ wasm_loader_emit_br_info(WASMLoaderContext *ctx, BranchBlock *frame_csp, /* Part e */ dynamic_offset = frame_csp->dynamic_offset + wasm_get_cell_num(types, arity); + if (is_br) + ctx->dynamic_offset = dynamic_offset; for (i = (int32)arity - 1; i >= 0; i--) { cell = (uint8)wasm_value_type_cell_num(types[i]); dynamic_offset -= cell; @@ -5173,20 +5208,13 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode, local_offset = local_offsets[local_idx]; \ } while (0) -#define CHECK_BR(depth) \ - do { \ - if (!wasm_loader_check_br(loader_ctx, depth, error_buf, \ - error_buf_size)) \ - goto fail; \ - } while (0) - #define CHECK_MEMORY() \ do { \ bh_assert(module->import_memory_count + module->memory_count > 0); \ } while (0) static bool -wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, +wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, uint8 opcode, char *error_buf, uint32 error_buf_size) { BranchBlock *target_block, *cur_block; @@ -5196,7 +5224,22 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, int32 i, available_stack_cell; uint16 cell_num; - if (loader_ctx->csp_num < depth + 1) { + uint8 *frame_ref_old = loader_ctx->frame_ref; + uint8 *frame_ref_after_popped = NULL; + uint8 frame_ref_tmp[4] = { 0 }; + uint8 *frame_ref_buf = frame_ref_tmp; + uint32 stack_cell_num_old = loader_ctx->stack_cell_num; +#if WASM_ENABLE_FAST_INTERP != 0 + int16 *frame_offset_old = loader_ctx->frame_offset; + int16 *frame_offset_after_popped = NULL; + int16 frame_offset_tmp[4] = { 0 }; + int16 *frame_offset_buf = frame_offset_tmp; + uint16 dynamic_offset_old = (loader_ctx->frame_csp - 1)->dynamic_offset; +#endif + bool ret = false; + + bh_assert(loader_ctx->csp_num > 0); + if (loader_ctx->csp_num - 1 < depth) { set_error_buf(error_buf, error_buf_size, "unknown label, " "unexpected end of section or function"); @@ -5226,6 +5269,38 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, #endif POP_TYPE(types[i]); } + + /* Backup stack data since it may be changed in the below + push operations, and the stack data may be used when + checking other target blocks of opcode br_table */ + if (opcode == WASM_OP_BR_TABLE) { + uint64 total_size; + + frame_ref_after_popped = loader_ctx->frame_ref; + total_size = (uint64)sizeof(uint8) + * (frame_ref_old - frame_ref_after_popped); + if (total_size > sizeof(frame_ref_tmp) + && !(frame_ref_buf = loader_malloc(total_size, error_buf, + error_buf_size))) { + goto fail; + } + bh_memcpy_s(frame_ref_buf, (uint32)total_size, + frame_ref_after_popped, (uint32)total_size); + +#if WASM_ENABLE_FAST_INTERP != 0 + frame_offset_after_popped = loader_ctx->frame_offset; + total_size = (uint64)sizeof(int16) + * (frame_offset_old - frame_offset_after_popped); + if (total_size > sizeof(frame_offset_tmp) + && !(frame_offset_buf = loader_malloc(total_size, error_buf, + error_buf_size))) { + goto fail; + } + bh_memcpy_s(frame_offset_buf, (uint32)total_size, + frame_offset_after_popped, (uint32)total_size); +#endif + } + for (i = 0; i < (int32)arity; i++) { #if WASM_ENABLE_FAST_INTERP != 0 bool disable_emit = true; @@ -5234,7 +5309,41 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, #endif PUSH_TYPE(types[i]); } - return true; + +#if WASM_ENABLE_FAST_INTERP != 0 + emit_br_info(target_block, opcode == WASM_OP_BR); +#endif + + /* Restore the stack data, note that frame_ref_bottom, + frame_offset_bottom may be re-allocated in the above + push operations */ + if (opcode == WASM_OP_BR_TABLE) { + uint32 total_size; + + /* The stack operand num should not be smaller than before + after pop and push operations */ + bh_assert(loader_ctx->stack_cell_num >= stack_cell_num_old); + loader_ctx->stack_cell_num = stack_cell_num_old; + loader_ctx->frame_ref = + loader_ctx->frame_ref_bottom + stack_cell_num_old; + total_size = (uint32)sizeof(uint8) + * (frame_ref_old - frame_ref_after_popped); + bh_memcpy_s((uint8 *)loader_ctx->frame_ref - total_size, total_size, + frame_ref_buf, total_size); + +#if WASM_ENABLE_FAST_INTERP != 0 + loader_ctx->frame_offset = + loader_ctx->frame_offset_bottom + stack_cell_num_old; + total_size = (uint32)sizeof(int16) + * (frame_offset_old - frame_offset_after_popped); + bh_memcpy_s((uint8 *)loader_ctx->frame_offset - total_size, + total_size, frame_offset_buf, total_size); + (loader_ctx->frame_csp - 1)->dynamic_offset = dynamic_offset_old; +#endif + } + + ret = true; + goto cleanup_and_return; } available_stack_cell = @@ -5244,32 +5353,46 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth, for (i = (int32)arity - 1; i >= 0; i--) { if (!check_stack_top_values(frame_ref, available_stack_cell, types[i], error_buf, error_buf_size)) - return false; + goto fail; cell_num = wasm_value_type_cell_num(types[i]); frame_ref -= cell_num; available_stack_cell -= cell_num; } - return true; +#if WASM_ENABLE_FAST_INTERP != 0 + emit_br_info(target_block, opcode == WASM_OP_BR); +#endif + + ret = true; +cleanup_and_return: fail: - return false; + if (frame_ref_buf && frame_ref_buf != frame_ref_tmp) + wasm_runtime_free(frame_ref_buf); +#if WASM_ENABLE_FAST_INTERP != 0 + if (frame_offset_buf && frame_offset_buf != frame_offset_tmp) + wasm_runtime_free(frame_offset_buf); +#endif + + return ret; } static BranchBlock * check_branch_block(WASMLoaderContext *loader_ctx, uint8 **p_buf, uint8 *buf_end, - char *error_buf, uint32 error_buf_size) + uint8 opcode, char *error_buf, uint32 error_buf_size) { uint8 *p = *p_buf, *p_end = buf_end; BranchBlock *frame_csp_tmp; uint32 depth; read_leb_uint32(p, p_end, depth); - CHECK_BR(depth); + bh_assert(loader_ctx->csp_num > 0); + if (!wasm_loader_check_br(loader_ctx, depth, opcode, error_buf, + error_buf_size)) { + goto fail; + } + frame_csp_tmp = loader_ctx->frame_csp - depth - 1; -#if WASM_ENABLE_FAST_INTERP != 0 - emit_br_info(frame_csp_tmp); -#endif *p_buf = p; return frame_csp_tmp; @@ -5354,6 +5477,7 @@ static bool copy_params_to_dynamic_space(WASMLoaderContext *loader_ctx, bool is_if_block, char *error_buf, uint32 error_buf_size) { + bool ret = false; int16 *frame_offset = NULL; uint8 *cells = NULL, cell; int16 *src_offsets = NULL; @@ -5368,6 +5492,7 @@ copy_params_to_dynamic_space(WASMLoaderContext *loader_ctx, bool is_if_block, int16 operand_offset = 0; uint64 size = (uint64)param_count * (sizeof(*cells) + sizeof(*src_offsets)); + bh_assert(size > 0); /* For if block, we also need copy the condition operand offset. */ if (is_if_block) @@ -5397,7 +5522,6 @@ copy_params_to_dynamic_space(WASMLoaderContext *loader_ctx, bool is_if_block, src_offsets[i] = *frame_offset; frame_offset += cell; } - /* emit copy instruction */ emit_label(EXT_OP_COPY_STACK_VALUES); /* Part a) */ @@ -5424,14 +5548,13 @@ copy_params_to_dynamic_space(WASMLoaderContext *loader_ctx, bool is_if_block, if (is_if_block) PUSH_OFFSET_TYPE(VALUE_TYPE_I32); - /* Free the emit data */ - wasm_runtime_free(emit_data); - return true; + ret = true; fail: /* Free the emit data */ wasm_runtime_free(emit_data); - return false; + + return ret; } #endif @@ -5498,7 +5621,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, uint8 *func_const_end, *func_const = NULL; int16 operand_offset = 0; uint8 last_op = 0; - bool disable_emit, preserve_local = false; + bool disable_emit, preserve_local = false, if_condition_available = true; + ; float32 f32_const; float64 f64_const; @@ -5568,11 +5692,23 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_IF: + { #if WASM_ENABLE_FAST_INTERP != 0 + BranchBlock *parent_block = loader_ctx->frame_csp - 1; + int32 available_stack_cell = + (int32)(loader_ctx->stack_cell_num + - parent_block->stack_cell_num); + + if (available_stack_cell <= 0 + && parent_block->is_stack_polymorphic) + if_condition_available = false; + else + if_condition_available = true; PRESERVE_LOCAL_FOR_BLOCK(); #endif POP_I32(); goto handle_op_block_and_loop; + } case WASM_OP_BLOCK: case WASM_OP_LOOP: #if WASM_ENABLE_FAST_INTERP != 0 @@ -5582,6 +5718,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { uint8 value_type; BlockType block_type; +#if WASM_ENABLE_FAST_INTERP != 0 + uint32 available_params = 0; +#endif p_org = p - 1; value_type = read_uint8(p); @@ -5612,9 +5751,35 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* Pop block parameters from stack */ if (BLOCK_HAS_PARAM(block_type)) { WASMType *wasm_type = block_type.u.type; - for (i = 0; i < block_type.u.type->param_count; i++) + + BranchBlock *cur_block = loader_ctx->frame_csp - 1; +#if WASM_ENABLE_FAST_INTERP != 0 + uint32 cell_num; + available_params = block_type.u.type->param_count; +#endif + for (i = 0; i < block_type.u.type->param_count; i++) { + + int32 available_stack_cell = + (int32)(loader_ctx->stack_cell_num + - cur_block->stack_cell_num); + if (available_stack_cell <= 0 + && cur_block->is_stack_polymorphic) { +#if WASM_ENABLE_FAST_INTERP != 0 + available_params = i; +#endif + break; + } + POP_TYPE( wasm_type->types[wasm_type->param_count - i - 1]); +#if WASM_ENABLE_FAST_INTERP != 0 + /* decrease the frame_offset pointer accordingly to keep + * consistent with frame_ref stack */ + cell_num = wasm_value_type_cell_num( + wasm_type->types[wasm_type->param_count - i - 1]); + loader_ctx->frame_offset -= cell_num; +#endif + } } PUSH_CSP(LABEL_TYPE_BLOCK + (opcode - WASM_OP_BLOCK), @@ -5622,8 +5787,35 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* Pass parameters to block */ if (BLOCK_HAS_PARAM(block_type)) { - for (i = 0; i < block_type.u.type->param_count; i++) + for (i = 0; i < block_type.u.type->param_count; i++) { +#if WASM_ENABLE_FAST_INTERP != 0 + uint32 cell_num = wasm_value_type_cell_num( + block_type.u.type->types[i]); + if (i >= available_params) { + /* If there isn't enough data on stack, push a dummy + * offset to keep the stack consistent with + * frame_ref. + * Since the stack is already in polymorphic state, + * the opcode will not be executed, so the dummy + * offset won't cause any error */ + uint32 n; + + for (n = 0; n < cell_num; n++) { + if (loader_ctx->p_code_compiled == NULL) { + if (!check_offset_push(loader_ctx, + error_buf, + error_buf_size)) + goto fail; + } + *loader_ctx->frame_offset++ = 0; + } + } + else { + loader_ctx->frame_offset += cell_num; + } +#endif PUSH_TYPE(block_type.u.type->types[i]); + } } #if WASM_ENABLE_FAST_INTERP != 0 @@ -5641,6 +5833,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } } else if (opcode == WASM_OP_IF) { + BranchBlock *block = loader_ctx->frame_csp - 1; /* If block has parameters, we should make sure they are in * dynamic space. Otherwise, when else branch is missing, * the later opcode may consume incorrect operand offset. @@ -5659,11 +5852,15 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, * */ if (BLOCK_HAS_PARAM(block_type)) { - BranchBlock *block = loader_ctx->frame_csp - 1; uint64 size; - /* skip the if condition operand offset */ - wasm_loader_emit_backspace(loader_ctx, sizeof(int16)); + /* In polymorphic state, there may be no if condition on + * the stack, so the offset may not emitted */ + if (if_condition_available) { + /* skip the if condition operand offset */ + wasm_loader_emit_backspace(loader_ctx, + sizeof(int16)); + } /* skip the if label */ skip_label(); /* Emit a copy instruction */ @@ -5690,6 +5887,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, (uint32)size); } + block->start_dynamic_offset = loader_ctx->dynamic_offset; + emit_empty_label_addr_and_frame_ip(PATCH_ELSE); emit_empty_label_addr_and_frame_ip(PATCH_END); } @@ -5699,17 +5898,22 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_ELSE: { + BranchBlock *block = NULL; BlockType block_type = (loader_ctx->frame_csp - 1)->block_type; bh_assert(loader_ctx->csp_num >= 2 + /* the matched if is found */ && (loader_ctx->frame_csp - 1)->label_type - == LABEL_TYPE_IF); + == LABEL_TYPE_IF + /* duplicated else isn't found */ + && !(loader_ctx->frame_csp - 1)->else_addr); + block = loader_ctx->frame_csp - 1; /* check whether if branch's stack matches its result type */ - if (!check_block_stack(loader_ctx, loader_ctx->frame_csp - 1, - error_buf, error_buf_size)) + if (!check_block_stack(loader_ctx, block, error_buf, + error_buf_size)) goto fail; - (loader_ctx->frame_csp - 1)->else_addr = p - 1; + block->else_addr = p - 1; #if WASM_ENABLE_FAST_INTERP != 0 /* if the result of if branch is in local or const area, add a @@ -5732,12 +5936,12 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, /* Recover top param_count values of frame_offset stack */ if (BLOCK_HAS_PARAM((block_type))) { uint32 size; - BranchBlock *block = loader_ctx->frame_csp - 1; size = sizeof(int16) * block_type.u.type->param_cell_num; bh_memcpy_s(loader_ctx->frame_offset, size, block->param_frame_offsets, size); loader_ctx->frame_offset += (size / sizeof(int16)); } + loader_ctx->dynamic_offset = block->start_dynamic_offset; #endif break; @@ -5816,8 +6020,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_BR: { - if (!(frame_csp_tmp = check_branch_block( - loader_ctx, &p, p_end, error_buf, error_buf_size))) + if (!(frame_csp_tmp = + check_branch_block(loader_ctx, &p, p_end, opcode, + error_buf, error_buf_size))) goto fail; RESET_STACK(); @@ -5829,8 +6034,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { POP_I32(); - if (!(frame_csp_tmp = check_branch_block( - loader_ctx, &p, p_end, error_buf, error_buf_size))) + if (!(frame_csp_tmp = + check_branch_block(loader_ctx, &p, p_end, opcode, + error_buf, error_buf_size))) goto fail; break; @@ -5839,13 +6045,11 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_BR_TABLE: { uint8 *ret_types = NULL; - uint32 ret_count = 0; + uint32 ret_count = 0, depth = 0; #if WASM_ENABLE_FAST_INTERP == 0 - uint8 *p_depth_begin, *p_depth; - uint32 depth, j; BrTableCache *br_table_cache = NULL; - - p_org = p - 1; + uint8 *p_depth_begin, *p_depth, *p_opcode = p - 1; + uint32 j; #endif read_leb_uint32(p, p_end, count); @@ -5854,12 +6058,22 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #endif POP_I32(); + /* Get each depth and check it */ + p_org = p; + for (i = 0; i <= count; i++) { + read_leb_uint32(p, p_end, depth); + bh_assert(loader_ctx->csp_num > 0); + bh_assert(loader_ctx->csp_num - 1 >= depth); + (void)depth; + } + p = p_org; + #if WASM_ENABLE_FAST_INTERP == 0 p_depth_begin = p_depth = p; #endif for (i = 0; i <= count; i++) { if (!(frame_csp_tmp = - check_branch_block(loader_ctx, &p, p_end, + check_branch_block(loader_ctx, &p, p_end, opcode, error_buf, error_buf_size))) goto fail; @@ -5879,8 +6093,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, error_buf, error_buf_size))) { goto fail; } - *p_org = EXT_OP_BR_TABLE_CACHE; - br_table_cache->br_table_op_addr = p_org; + *p_opcode = EXT_OP_BR_TABLE_CACHE; + br_table_cache->br_table_op_addr = p_opcode; br_table_cache->br_count = count; /* Copy previous depths which are one byte */ for (j = 0; j < i; j++) { @@ -5923,11 +6137,11 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, idx--) { ret_type = *(func->func_type->types + func->func_type->param_count + idx); - POP_TYPE(ret_type); #if WASM_ENABLE_FAST_INTERP != 0 /* emit the offset after return opcode */ POP_OFFSET_TYPE(ret_type); #endif + POP_TYPE(ret_type); } RESET_STACK(); @@ -5966,10 +6180,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, if (func_type->param_count > 0) { for (idx = (int32)(func_type->param_count - 1); idx >= 0; idx--) { - POP_TYPE(func_type->types[idx]); #if WASM_ENABLE_FAST_INTERP != 0 POP_OFFSET_TYPE(func_type->types[idx]); #endif + POP_TYPE(func_type->types[idx]); } } @@ -6047,10 +6261,10 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, if (func_type->param_count > 0) { for (idx = (int32)(func_type->param_count - 1); idx >= 0; idx--) { - POP_TYPE(func_type->types[idx]); #if WASM_ENABLE_FAST_INTERP != 0 POP_OFFSET_TYPE(func_type->types[idx]); #endif + POP_TYPE(func_type->types[idx]); } } @@ -6088,6 +6302,18 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; } +#if WASM_ENABLE_EXCE_HANDLING != 0 + case WASM_OP_TRY: + case WASM_OP_CATCH: + case WASM_OP_THROW: + case WASM_OP_RETHROW: + case WASM_OP_DELEGATE: + case WASM_OP_CATCH_ALL: + /* TODO */ + set_error_buf(error_buf, error_buf_size, "unsupported opcode"); + goto fail; +#endif + case WASM_OP_DROP: { BranchBlock *cur_block = loader_ctx->frame_csp - 1; @@ -6099,8 +6325,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, && !cur_block->is_stack_polymorphic)); if (available_stack_cell > 0) { - if (is_32bit_type(*(loader_ctx->frame_ref - 1)) - || *(loader_ctx->frame_ref - 1) == VALUE_TYPE_ANY) { + if (is_32bit_type(*(loader_ctx->frame_ref - 1))) { loader_ctx->frame_ref--; loader_ctx->stack_cell_num--; #if WASM_ENABLE_FAST_INTERP != 0 @@ -6162,6 +6387,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, switch (*(loader_ctx->frame_ref - 1)) { case REF_I32: case REF_F32: + case REF_ANY: break; case REF_I64_2: case REF_F64_2: @@ -6356,13 +6582,33 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, case WASM_OP_REF_IS_NULL: { #if WASM_ENABLE_FAST_INTERP != 0 - if (!wasm_loader_pop_frame_ref_offset(loader_ctx, - VALUE_TYPE_FUNCREF, - error_buf, error_buf_size) - && !wasm_loader_pop_frame_ref_offset( - loader_ctx, VALUE_TYPE_EXTERNREF, error_buf, - error_buf_size)) { - goto fail; + BranchBlock *cur_block = loader_ctx->frame_csp - 1; + int32 block_stack_cell_num = + (int32)(loader_ctx->stack_cell_num + - cur_block->stack_cell_num); + if (block_stack_cell_num <= 0) { + if (!cur_block->is_stack_polymorphic) { + set_error_buf( + error_buf, error_buf_size, + "type mismatch: expect data but stack was empty"); + goto fail; + } + } + else { + if (*(loader_ctx->frame_ref - 1) == VALUE_TYPE_FUNCREF + || *(loader_ctx->frame_ref - 1) == VALUE_TYPE_EXTERNREF + || *(loader_ctx->frame_ref - 1) == VALUE_TYPE_ANY) { + if (!wasm_loader_pop_frame_ref_offset( + loader_ctx, *(loader_ctx->frame_ref - 1), + error_buf, error_buf_size)) { + goto fail; + } + } + else { + set_error_buf(error_buf, error_buf_size, + "type mismatch"); + goto fail; + } } #else if (!wasm_loader_pop_frame_ref(loader_ctx, VALUE_TYPE_FUNCREF, @@ -6386,24 +6632,44 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, goto fail; } - /* Refer to a forward-declared function */ - if (func_idx >= cur_func_idx + module->import_function_count) { + /* Refer to a forward-declared function: + the function must be an import, exported, or present in + a table elem segment or global initializer to be used as + the operand to ref.func */ + if (func_idx >= module->import_function_count) { WASMTableSeg *table_seg = module->table_segments; bool func_declared = false; uint32 j; - /* Check whether the function is declared in table segs */ - for (i = 0; i < module->table_seg_count; i++, table_seg++) { - if (table_seg->elem_type == VALUE_TYPE_FUNCREF - && wasm_elem_is_declarative(table_seg->mode)) { - for (j = 0; j < table_seg->function_count; j++) { - if (table_seg->func_indexes[j] == func_idx) { - func_declared = true; - break; + for (i = 0; i < module->global_count; i++) { + if (module->globals[i].type == VALUE_TYPE_FUNCREF + && module->globals[i].init_expr.init_expr_type + == INIT_EXPR_TYPE_FUNCREF_CONST + && module->globals[i].init_expr.u.u32 == func_idx) { + func_declared = true; + break; + } + } + + if (!func_declared) { + /* Check whether the function is declared in table segs, + note that it doesn't matter whether the table seg's + mode is passive, active or declarative. */ + for (i = 0; i < module->table_seg_count; + i++, table_seg++) { + if (table_seg->elem_type == VALUE_TYPE_FUNCREF) { + for (j = 0; j < table_seg->function_count; + j++) { + if (table_seg->func_indexes[j] + == func_idx) { + func_declared = true; + break; + } } } } } + if (!func_declared) { /* Check whether the function is exported */ for (i = 0; i < module->export_count; i++) { @@ -6459,7 +6725,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, { p_org = p - 1; GET_LOCAL_INDEX_TYPE_AND_OFFSET(); - POP_TYPE(local_type); #if WASM_ENABLE_FAST_INTERP != 0 if (!(preserve_referenced_local( @@ -6513,6 +6778,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } #endif #endif + POP_TYPE(local_type); break; } @@ -6630,8 +6896,6 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, - module->import_global_count] .type; - POP_TYPE(global_type); - #if WASM_ENABLE_FAST_INTERP == 0 if (is_64bit_type(global_type)) { *p_org = WASM_OP_SET_GLOBAL_64; @@ -6657,6 +6921,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, POP_OFFSET_TYPE(global_type); #endif /* end of WASM_ENABLE_FAST_INTERP */ + POP_TYPE(global_type); + (void)is_mutable; break; } @@ -6832,6 +7098,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_F32_CONST: + CHECK_BUF(p, p_end, sizeof(float32)); p += sizeof(float32); #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); @@ -6850,6 +7117,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, break; case WASM_OP_F64_CONST: + CHECK_BUF(p, p_end, sizeof(float64)); p += sizeof(float64); #if WASM_ENABLE_FAST_INTERP != 0 skip_label(); @@ -7157,6 +7425,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, } case WASM_OP_MEMORY_COPY: { + CHECK_BUF(p, p_end, sizeof(int16)); /* both src and dst memory index should be 0 */ bh_assert(*(int16 *)p == 0x0000); p += 2; @@ -7339,11 +7608,14 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #if WASM_ENABLE_SHARED_MEMORY != 0 case WASM_OP_ATOMIC_PREFIX: { - opcode = read_uint8(p); + uint32 opcode1; + + read_leb_uint32(p, p_end, opcode1); + #if WASM_ENABLE_FAST_INTERP != 0 - emit_byte(loader_ctx, opcode); + emit_byte(loader_ctx, opcode1); #endif - if (opcode != WASM_OP_ATOMIC_FENCE) { + if (opcode1 != WASM_OP_ATOMIC_FENCE) { CHECK_MEMORY(); read_leb_uint32(p, p_end, align); /* align */ read_leb_uint32(p, p_end, mem_offset); /* offset */ @@ -7354,7 +7626,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func, #if WASM_ENABLE_JIT != 0 || WASM_ENABLE_WAMR_COMPILER != 0 func->has_memory_operations = true; #endif - switch (opcode) { + switch (opcode1) { case WASM_OP_ATOMIC_NOTIFY: POP2_AND_PUSH(VALUE_TYPE_I32, VALUE_TYPE_I32); break; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_opcode.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_opcode.h similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_opcode.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_opcode.h index ce5e358a2d8..0144b119880 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_opcode.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_opcode.h @@ -20,11 +20,10 @@ typedef enum WASMOpcode { WASM_OP_LOOP = 0x03, /* loop */ WASM_OP_IF = 0x04, /* if */ WASM_OP_ELSE = 0x05, /* else */ - - WASM_OP_UNUSED_0x06 = 0x06, - WASM_OP_UNUSED_0x07 = 0x07, - WASM_OP_UNUSED_0x08 = 0x08, - WASM_OP_UNUSED_0x09 = 0x09, + WASM_OP_TRY = 0x06, /* try */ + WASM_OP_CATCH = 0x07, /* catch* */ + WASM_OP_THROW = 0x08, /* throw of a try catch */ + WASM_OP_RETHROW = 0x09, /* rethrow of a try catch */ WASM_OP_UNUSED_0x0a = 0x0a, WASM_OP_END = 0x0b, /* end */ @@ -41,8 +40,9 @@ typedef enum WASMOpcode { WASM_OP_UNUSED_0x15 = 0x15, WASM_OP_UNUSED_0x16 = 0x16, WASM_OP_UNUSED_0x17 = 0x17, - WASM_OP_UNUSED_0x18 = 0x18, - WASM_OP_UNUSED_0x19 = 0x19, + + WASM_OP_DELEGATE = 0x18, /* delegate block of the try catch*/ + WASM_OP_CATCH_ALL = 0x19, /* a catch_all handler in a try block */ /* parametric instructions */ WASM_OP_DROP = 0x1a, /* drop */ @@ -268,8 +268,10 @@ typedef enum WASMOpcode { EXT_OP_IF = 0xd5, /* if with blocktype */ EXT_OP_BR_TABLE_CACHE = 0xd6, /* br_table from cache */ + EXT_OP_TRY = 0xd7, /* try block with blocktype */ + #if WASM_ENABLE_DEBUG_INTERP != 0 - DEBUG_OP_BREAK = 0xd7, /* debug break point */ + DEBUG_OP_BREAK = 0xd8, /* debug break point */ #endif /* Post-MVP extend op prefix */ @@ -494,8 +496,8 @@ typedef enum WASMSimdEXTOpcode { /* placeholder = 0xa2 */ SIMD_i32x4_all_true = 0xa3, SIMD_i32x4_bitmask = 0xa4, - SIMD_i32x4_narrow_i64x2_s = 0xa5, - SIMD_i32x4_narrow_i64x2_u = 0xa6, + /* placeholder = 0xa5 */ + /* placeholder = 0xa6 */ SIMD_i32x4_extend_low_i16x8_s = 0xa7, SIMD_i32x4_extend_high_i16x8_s = 0xa8, SIMD_i32x4_extend_low_i16x8_u = 0xa9, @@ -504,19 +506,19 @@ typedef enum WASMSimdEXTOpcode { SIMD_i32x4_shr_s = 0xac, SIMD_i32x4_shr_u = 0xad, SIMD_i32x4_add = 0xae, - SIMD_i32x4_add_sat_s = 0xaf, - SIMD_i32x4_add_sat_u = 0xb0, + /* placeholder = 0xaf */ + /* placeholder = 0xb0 */ SIMD_i32x4_sub = 0xb1, - SIMD_i32x4_sub_sat_s = 0xb2, - SIMD_i32x4_sub_sat_u = 0xb3, - /* placeholder = 0xb4 */ + /* placeholder = 0xb2 */ + /* placeholder = 0xb3 */ + /* placeholder = 0xb4 */ SIMD_i32x4_mul = 0xb5, SIMD_i32x4_min_s = 0xb6, SIMD_i32x4_min_u = 0xb7, SIMD_i32x4_max_s = 0xb8, SIMD_i32x4_max_u = 0xb9, SIMD_i32x4_dot_i16x8_s = 0xba, - SIMD_i32x4_avgr_u = 0xbb, + /* placeholder = 0xbb */ SIMD_i32x4_extmul_low_i16x8_s = 0xbc, SIMD_i32x4_extmul_high_i16x8_s = 0xbd, SIMD_i32x4_extmul_low_i16x8_u = 0xbe, @@ -559,7 +561,7 @@ typedef enum WASMSimdEXTOpcode { /* f32x4 operation */ SIMD_f32x4_abs = 0xe0, SIMD_f32x4_neg = 0xe1, - SIMD_f32x4_round = 0xe2, + /* placeholder = 0xe2 */ SIMD_f32x4_sqrt = 0xe3, SIMD_f32x4_add = 0xe4, SIMD_f32x4_sub = 0xe5, @@ -573,7 +575,7 @@ typedef enum WASMSimdEXTOpcode { /* f64x2 operation */ SIMD_f64x2_abs = 0xec, SIMD_f64x2_neg = 0xed, - SIMD_f64x2_round = 0xee, + /* placeholder = 0xee */ SIMD_f64x2_sqrt = 0xef, SIMD_f64x2_add = 0xf0, SIMD_f64x2_sub = 0xf1, @@ -683,6 +685,13 @@ typedef enum WASMAtomicEXTOpcode { #define SET_GOTO_TABLE_ELEM(opcode) [opcode] = HANDLE_OPCODE(opcode) +#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_SIMD != 0 +#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() \ + SET_GOTO_TABLE_ELEM(WASM_OP_SIMD_PREFIX), +#else +#define SET_GOTO_TABLE_SIMD_PREFIX_ELEM() +#endif + /* * Macro used to generate computed goto tables for the C interpreter. */ @@ -696,10 +705,10 @@ typedef enum WASMAtomicEXTOpcode { HANDLE_OPCODE(WASM_OP_LOOP), /* 0x03 */ \ HANDLE_OPCODE(WASM_OP_IF), /* 0x04 */ \ HANDLE_OPCODE(WASM_OP_ELSE), /* 0x05 */ \ - HANDLE_OPCODE(WASM_OP_UNUSED_0x06), /* 0x06 */ \ - HANDLE_OPCODE(WASM_OP_UNUSED_0x07), /* 0x07 */ \ - HANDLE_OPCODE(WASM_OP_UNUSED_0x08), /* 0x08 */ \ - HANDLE_OPCODE(WASM_OP_UNUSED_0x09), /* 0x09 */ \ + HANDLE_OPCODE(WASM_OP_TRY), /* 0x06 */ \ + HANDLE_OPCODE(WASM_OP_CATCH), /* 0x07 */ \ + HANDLE_OPCODE(WASM_OP_THROW), /* 0x08 */ \ + HANDLE_OPCODE(WASM_OP_RETHROW), /* 0x09 */ \ HANDLE_OPCODE(WASM_OP_UNUSED_0x0a), /* 0x0a */ \ HANDLE_OPCODE(WASM_OP_END), /* 0x0b */ \ HANDLE_OPCODE(WASM_OP_BR), /* 0x0c */ \ @@ -714,8 +723,8 @@ typedef enum WASMAtomicEXTOpcode { HANDLE_OPCODE(WASM_OP_UNUSED_0x15), /* 0x15 */ \ HANDLE_OPCODE(WASM_OP_UNUSED_0x16), /* 0x16 */ \ HANDLE_OPCODE(WASM_OP_UNUSED_0x17), /* 0x17 */ \ - HANDLE_OPCODE(WASM_OP_UNUSED_0x18), /* 0x18 */ \ - HANDLE_OPCODE(WASM_OP_UNUSED_0x19), /* 0x19 */ \ + HANDLE_OPCODE(WASM_OP_DELEGATE), /* 0x18 */ \ + HANDLE_OPCODE(WASM_OP_CATCH_ALL), /* 0x19 */ \ HANDLE_OPCODE(WASM_OP_DROP), /* 0x1a */ \ HANDLE_OPCODE(WASM_OP_SELECT), /* 0x1b */ \ HANDLE_OPCODE(WASM_OP_SELECT_T), /* 0x1c */ \ @@ -905,7 +914,9 @@ typedef enum WASMAtomicEXTOpcode { HANDLE_OPCODE(EXT_OP_LOOP), /* 0xd4 */ \ HANDLE_OPCODE(EXT_OP_IF), /* 0xd5 */ \ HANDLE_OPCODE(EXT_OP_BR_TABLE_CACHE), /* 0xd6 */ \ + HANDLE_OPCODE(EXT_OP_TRY), /* 0xd7 */ \ SET_GOTO_TABLE_ELEM(WASM_OP_MISC_PREFIX), /* 0xfc */ \ + SET_GOTO_TABLE_SIMD_PREFIX_ELEM() /* 0xfd */ \ SET_GOTO_TABLE_ELEM(WASM_OP_ATOMIC_PREFIX), /* 0xfe */ \ DEF_DEBUG_BREAK_HANDLE() \ }; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_runtime.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_runtime.c similarity index 90% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_runtime.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_runtime.c index 205c6d4b6fb..659d788754b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_runtime.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_runtime.c @@ -115,6 +115,9 @@ static void memories_deinstantiate(WASMModuleInstance *module_inst, WASMMemoryInstance **memories, uint32 count) { +#ifdef WASM_LINEAR_MEMORY_MMAP + uint64 map_size; +#endif uint32 i; if (memories) { for (i = 0; i < count; i++) { @@ -142,15 +145,21 @@ memories_deinstantiate(WASMModuleInstance *module_inst, } if (memories[i]->memory_data) { #ifndef OS_ENABLE_HW_BOUND_CHECK - wasm_runtime_free(memories[i]->memory_data); -#else -#ifdef BH_PLATFORM_WINDOWS - os_mem_decommit(memories[i]->memory_data, - memories[i]->num_bytes_per_page - * memories[i]->cur_page_count); +#ifdef WASM_LINEAR_MEMORY_MMAP + if (shared_memory_is_shared(memories[i])) { + map_size = (uint64)memories[i]->num_bytes_per_page + * memories[i]->max_page_count; + wasm_munmap_linear_memory(memories[i]->memory_data, + map_size, map_size); + } + else #endif - os_munmap((uint8 *)memories[i]->memory_data, - 8 * (uint64)BH_GB); + wasm_runtime_free(memories[i]->memory_data); +#else + map_size = (uint64)memories[i]->num_bytes_per_page + * memories[i]->cur_page_count; + wasm_munmap_linear_memory(memories[i]->memory_data, + map_size, 8 * (uint64)BH_GB); #endif } } @@ -173,10 +182,9 @@ memory_instantiate(WASMModuleInstance *module_inst, WASMModuleInstance *parent, uint32 inc_page_count, aux_heap_base, global_idx; uint32 bytes_of_last_page, bytes_to_page_end; uint8 *global_addr; -#ifdef OS_ENABLE_HW_BOUND_CHECK - uint8 *mapped_mem; - uint64 map_size = 8 * (uint64)BH_GB; - uint64 page_size = os_getpagesize(); +#ifdef WASM_LINEAR_MEMORY_MMAP + uint8 *mapped_mem = NULL; + uint64 map_size; #endif #if WASM_ENABLE_SHARED_MEMORY != 0 @@ -295,18 +303,29 @@ memory_instantiate(WASMModuleInstance *module_inst, WASMModuleInstance *parent, (void)max_memory_data_size; bh_assert(memory != NULL); + #ifndef OS_ENABLE_HW_BOUND_CHECK #if WASM_ENABLE_SHARED_MEMORY != 0 if (is_shared_memory) { /* Allocate maximum memory size when memory is shared */ +#if WASM_ENABLE_SHARED_MEMORY_MMAP != 0 + map_size = max_memory_data_size; + if (max_memory_data_size > 0 + && !(memory->memory_data = mapped_mem = + wasm_mmap_linear_memory(map_size, &max_memory_data_size, + error_buf, error_buf_size))) { + goto fail1; + } +#else if (max_memory_data_size > 0 && !(memory->memory_data = runtime_malloc( max_memory_data_size, error_buf, error_buf_size))) { goto fail1; } +#endif } else -#endif +#endif /* end of WASM_ENABLE_SHARED_MEMORY != 0 */ { /* Allocate initial memory size when memory is not shared */ if (memory_data_size > 0 @@ -315,43 +334,18 @@ memory_instantiate(WASMModuleInstance *module_inst, WASMModuleInstance *parent, goto fail1; } } -#else /* else of OS_ENABLE_HW_BOUND_CHECK */ - memory_data_size = (memory_data_size + page_size - 1) & ~(page_size - 1); - +#else /* else of OS_ENABLE_HW_BOUND_CHECK */ /* Totally 8G is mapped, the opcode load/store address range is 0 to 8G: * ea = i + memarg.offset * both i and memarg.offset are u32 in range 0 to 4G * so the range of ea is 0 to 8G */ - if (!(memory->memory_data = mapped_mem = - os_mmap(NULL, map_size, MMAP_PROT_NONE, MMAP_MAP_NONE, - os_get_invalid_handle()))) { + map_size = 8 * (uint64)BH_GB; + if (!(memory->memory_data = mapped_mem = wasm_mmap_linear_memory( + map_size, &memory_data_size, error_buf, error_buf_size))) { set_error_buf(error_buf, error_buf_size, "mmap memory failed"); goto fail1; } - -#ifdef BH_PLATFORM_WINDOWS - if (memory_data_size > 0 - && !os_mem_commit(mapped_mem, memory_data_size, - MMAP_PROT_READ | MMAP_PROT_WRITE)) { - set_error_buf(error_buf, error_buf_size, "commit memory failed"); - os_munmap(mapped_mem, map_size); - goto fail1; - } -#endif - - if (os_mprotect(mapped_mem, memory_data_size, - MMAP_PROT_READ | MMAP_PROT_WRITE) - != 0) { - set_error_buf(error_buf, error_buf_size, "mprotect memory failed"); - goto fail2; - } - - /* Newly allocated pages are filled with zero by the OS, we don't fill it - * again here */ - - if (memory_data_size > UINT32_MAX) - memory_data_size = UINT32_MAX; #endif /* end of OS_ENABLE_HW_BOUND_CHECK */ memory->module_type = Wasm_Module_Bytecode; @@ -398,15 +392,15 @@ memory_instantiate(WASMModuleInstance *module_inst, WASMModuleInstance *parent, if (heap_size > 0) wasm_runtime_free(memory->heap_handle); fail2: -#ifndef OS_ENABLE_HW_BOUND_CHECK - if (memory->memory_data) - wasm_runtime_free(memory->memory_data); -#else -#ifdef BH_PLATFORM_WINDOWS - os_mem_decommit(mapped_mem, memory_data_size); -#endif - os_munmap(mapped_mem, map_size); +#ifdef WASM_LINEAR_MEMORY_MMAP + if (mapped_mem) + wasm_munmap_linear_memory(mapped_mem, memory_data_size, map_size); + else #endif + { + if (memory->memory_data) + wasm_runtime_free(memory->memory_data); + } fail1: return NULL; } @@ -738,6 +732,101 @@ functions_instantiate(const WASMModule *module, WASMModuleInstance *module_inst, return functions; } +#if WASM_ENABLE_TAGS != 0 +/** + * Destroy tags instances. + */ +static void +tags_deinstantiate(WASMTagInstance *tags, void **import_tag_ptrs) +{ + if (tags) { + wasm_runtime_free(tags); + } + if (import_tag_ptrs) { + wasm_runtime_free(import_tag_ptrs); + } +} + +/** + * Instantiate tags in a module. + */ +static WASMTagInstance * +tags_instantiate(const WASMModule *module, WASMModuleInstance *module_inst, + char *error_buf, uint32 error_buf_size) +{ + WASMImport *import; + uint32 i, tag_count = module->import_tag_count + module->tag_count; + uint64 total_size = sizeof(WASMTagInstance) * (uint64)tag_count; + WASMTagInstance *tags, *tag; + + if (!(tags = runtime_malloc(total_size, error_buf, error_buf_size))) { + return NULL; + } + + total_size = sizeof(void *) * (uint64)module->import_tag_count; + if (total_size > 0 + && !(module_inst->e->import_tag_ptrs = + runtime_malloc(total_size, error_buf, error_buf_size))) { + wasm_runtime_free(tags); + return NULL; + } + + /* instantiate tags from import section */ + tag = tags; + import = module->import_tags; + for (i = 0; i < module->import_tag_count; i++, import++) { + tag->is_import_tag = true; + tag->u.tag_import = &import->u.tag; + tag->type = import->u.tag.type; + tag->attribute = import->u.tag.attribute; +#if WASM_ENABLE_MULTI_MODULE != 0 + if (import->u.tag.import_module) { + if (!(tag->import_module_inst = get_sub_module_inst( + module_inst, import->u.tag.import_module))) { + set_error_buf(error_buf, error_buf_size, "unknown tag"); + goto fail; + } + + if (!(tag->import_tag_inst = + wasm_lookup_tag(tag->import_module_inst, + import->u.tag.field_name, NULL))) { + set_error_buf(error_buf, error_buf_size, "unknown tag"); + goto fail; + } + + /* Copy the imported tag to current instance */ + module_inst->e->import_tag_ptrs[i] = + tag->u.tag_import->import_tag_linked; + } +#endif + tag++; + } + + /* instantiate tags from tag section */ + for (i = 0; i < module->tag_count; i++) { + tag->is_import_tag = false; + tag->type = module->tags[i]->type; + tag->u.tag = module->tags[i]; + +#if WASM_ENABLE_FAST_INTERP != 0 + /* tag->const_cell_num = function->u.func->const_cell_num; */ +#endif + tag++; + } + bh_assert((uint32)(tag - tags) == tag_count); + + return tags; + +#if WASM_ENABLE_MULTI_MODULE != 0 +fail: + tags_deinstantiate(tags, module_inst->e->import_tag_ptrs); + /* clean up */ + module_inst->e->import_tag_ptrs = NULL; + return NULL; +#endif +} +#endif + /** * Destroy global instances. */ @@ -937,6 +1026,52 @@ export_functions_instantiate(const WASMModule *module, return export_funcs; } +#if WASM_ENABLE_TAGS != 0 +/** + * Destroy export function instances. + */ +static void +export_tags_deinstantiate(WASMExportTagInstance *tags) +{ + if (tags) + wasm_runtime_free(tags); +} + +/** + * Instantiate export functions in a module. + */ +static WASMExportTagInstance * +export_tags_instantiate(const WASMModule *module, + WASMModuleInstance *module_inst, + uint32 export_tag_count, char *error_buf, + uint32 error_buf_size) +{ + WASMExportTagInstance *export_tags, *export_tag; + WASMExport *export = module->exports; + uint32 i; + uint64 total_size = + sizeof(WASMExportTagInstance) * (uint64)export_tag_count; + + if (!(export_tag = export_tags = + runtime_malloc(total_size, error_buf, error_buf_size))) { + return NULL; + } + + for (i = 0; i < module->export_count; i++, export ++) + if (export->kind == EXPORT_KIND_TAG) { + export_tag->name = export->name; + + bh_assert(module_inst->e->tags); + + export_tag->tag = &module_inst->e->tags[export->index]; + export_tag++; + } + + bh_assert((uint32)(export_tag - export_tags) == export_tag_count); + return export_tags; +} +#endif + #if WASM_ENABLE_MULTI_MODULE != 0 static void export_globals_deinstantiate(WASMExportGlobInstance *globals) @@ -1676,6 +1811,10 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, "failed to allocate bitmaps"); goto fail; } + for (i = 0; i < module->data_seg_count; i++) { + if (!module->data_segments[i]->is_passive) + bh_bitmap_set_bit(module_inst->e->common.data_dropped, i); + } } #endif #if WASM_ENABLE_REF_TYPES != 0 @@ -1688,6 +1827,10 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, "failed to allocate bitmaps"); goto fail; } + for (i = 0; i < module->table_seg_count; i++) { + if (wasm_elem_is_active(module->table_segments[i].mode)) + bh_bitmap_set_bit(module_inst->e->common.elem_dropped, i); + } } #endif @@ -1718,6 +1861,9 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, module_inst->table_count = module->import_table_count + module->table_count; module_inst->e->function_count = module->import_function_count + module->function_count; +#if WASM_ENABLE_TAGS != 0 + module_inst->e->tag_count = module->import_tag_count + module->tag_count; +#endif /* export */ module_inst->export_func_count = get_export_count(module, EXPORT_KIND_FUNC); @@ -1726,11 +1872,15 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, get_export_count(module, EXPORT_KIND_TABLE); module_inst->export_memory_count = get_export_count(module, EXPORT_KIND_MEMORY); +#if WASM_ENABLE_TAGS != 0 + module_inst->e->export_tag_count = + get_export_count(module, EXPORT_KIND_TAG); +#endif module_inst->export_global_count = get_export_count(module, EXPORT_KIND_GLOBAL); #endif - /* Instantiate memories/tables/functions */ + /* Instantiate memories/tables/functions/tags */ if ((module_inst->memory_count > 0 && !(module_inst->memories = memories_instantiate(module, module_inst, parent, heap_size, @@ -1746,6 +1896,15 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, && !(module_inst->export_functions = export_functions_instantiate( module, module_inst, module_inst->export_func_count, error_buf, error_buf_size))) +#if WASM_ENABLE_TAGS != 0 + || (module_inst->e->tag_count > 0 + && !(module_inst->e->tags = tags_instantiate( + module, module_inst, error_buf, error_buf_size))) + || (module_inst->e->export_tag_count > 0 + && !(module_inst->e->export_tags = export_tags_instantiate( + module, module_inst, module_inst->e->export_tag_count, + error_buf, error_buf_size))) +#endif #if WASM_ENABLE_MULTI_MODULE != 0 || (module_inst->export_global_count > 0 && !(module_inst->export_globals = export_globals_instantiate( @@ -1763,7 +1922,6 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, ) { goto fail; } - if (global_count > 0) { /* Initialize the global data */ global_data = module_inst->global_data; @@ -1859,7 +2017,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, /* check offset */ if (base_offset > memory_size) { - LOG_DEBUG("base_offset(%d) > memory_size(%d)", base_offset, + LOG_DEBUG("base_offset(%u) > memory_size(%" PRIu64 ")", base_offset, memory_size); #if WASM_ENABLE_REF_TYPES != 0 set_error_buf(error_buf, error_buf_size, @@ -1874,7 +2032,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, /* check offset + length(could be zero) */ length = data_seg->data_length; if ((uint64)base_offset + length > memory_size) { - LOG_DEBUG("base_offset(%d) + length(%d) > memory_size(%d)", + LOG_DEBUG("base_offset(%u) + length(%u) > memory_size(%" PRIu64 ")", base_offset, length, memory_size); #if WASM_ENABLE_REF_TYPES != 0 set_error_buf(error_buf, error_buf_size, @@ -2186,8 +2344,16 @@ wasm_deinstantiate(WASMModuleInstance *module_inst, bool is_sub_inst) tables_deinstantiate(module_inst); functions_deinstantiate(module_inst->e->functions, module_inst->e->function_count); +#if WASM_ENABLE_TAGS != 0 + tags_deinstantiate(module_inst->e->tags, module_inst->e->import_tag_ptrs); +#endif + globals_deinstantiate(module_inst->e->globals); export_functions_deinstantiate(module_inst->export_functions); +#if WASM_ENABLE_TAGS != 0 + export_tags_deinstantiate(module_inst->e->export_tags); +#endif + #if WASM_ENABLE_MULTI_MODULE != 0 export_globals_deinstantiate(module_inst->export_globals); #endif @@ -2268,10 +2434,24 @@ wasm_lookup_table(const WASMModuleInstance *module_inst, const char *name) (void)module_inst->export_tables; return module_inst->tables[0]; } + +#if WASM_ENABLE_TAGS != 0 +WASMTagInstance * +wasm_lookup_tag(const WASMModuleInstance *module_inst, const char *name, + const char *signature) +{ + uint32 i; + for (i = 0; i < module_inst->e->export_tag_count; i++) + if (!strcmp(module_inst->e->export_tags[i].name, name)) + return module_inst->e->export_tags[i].tag; + (void)signature; + return NULL; +} #endif -#ifdef OS_ENABLE_HW_BOUND_CHECK +#endif +#ifdef OS_ENABLE_HW_BOUND_CHECK static void call_wasm_with_hw_bound_check(WASMModuleInstance *module_inst, WASMExecEnv *exec_env, @@ -2301,19 +2481,26 @@ call_wasm_with_hw_bound_check(WASMModuleInstance *module_inst, return; } - if (exec_env_tls && (exec_env_tls != exec_env)) { - wasm_set_exception(module_inst, "invalid exec env"); - return; - } + if (!exec_env_tls) { + if (!os_thread_signal_inited()) { + wasm_set_exception(module_inst, "thread signal env not inited"); + return; + } - if (!os_thread_signal_inited()) { - wasm_set_exception(module_inst, "thread signal env not inited"); - return; + /* Set thread handle and stack boundary if they haven't been set */ + wasm_exec_env_set_thread_info(exec_env); + + wasm_runtime_set_exec_env_tls(exec_env); + } + else { + if (exec_env_tls != exec_env) { + wasm_set_exception(module_inst, "invalid exec env"); + return; + } } wasm_exec_env_push_jmpbuf(exec_env, &jmpbuf_node); - wasm_runtime_set_exec_env_tls(exec_env); if (os_setjmp(jmpbuf_node.jmpbuf) == 0) { #ifndef BH_PLATFORM_WINDOWS wasm_interp_call_wasm(module_inst, exec_env, function, argc, argv); @@ -2323,7 +2510,7 @@ call_wasm_with_hw_bound_check(WASMModuleInstance *module_inst, } __except (wasm_copy_exception(module_inst, NULL) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { - /* exception was thrown in wasm_exception_handler */ + /* Exception was thrown in wasm_exception_handler */ ret = false; } has_exception = wasm_copy_exception(module_inst, exception); @@ -2377,63 +2564,118 @@ wasm_call_function(WASMExecEnv *exec_env, WASMFunctionInstance *function, WASMModuleInstance *module_inst = (WASMModuleInstance *)exec_env->module_inst; - /* set thread handle and stack boundary */ +#ifndef OS_ENABLE_HW_BOUND_CHECK + /* Set thread handle and stack boundary */ wasm_exec_env_set_thread_info(exec_env); +#else + /* Set thread info in call_wasm_with_hw_bound_check when + hw bound check is enabled */ +#endif - /* set exec env so it can be later retrieved from instance */ + /* Set exec env so it can be later retrieved from instance */ module_inst->e->common.cur_exec_env = exec_env; interp_call_wasm(module_inst, exec_env, function, argc, argv); return !wasm_copy_exception(module_inst, NULL); } +#if WASM_ENABLE_PERF_PROFILING != 0 || WASM_ENABLE_DUMP_CALL_STACK != 0 +/* look for the function name */ +static char * +get_func_name_from_index(const WASMModuleInstance *inst, uint32 func_index) +{ + char *func_name = NULL; + WASMFunctionInstance *func_inst = inst->e->functions + func_index; + + if (func_inst->is_import_func) { + func_name = func_inst->u.func_import->field_name; + } + else { +#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0 + func_name = func_inst->u.func->field_name; +#endif + /* if custom name section is not generated, + search symbols from export table */ + if (!func_name) { + unsigned j; + for (j = 0; j < inst->export_func_count; j++) { + WASMExportFuncInstance *export_func = + inst->export_functions + j; + if (export_func->function == func_inst) { + func_name = export_func->name; + break; + } + } + } + } + + return func_name; +} +#endif /*WASM_ENABLE_PERF_PROFILING != 0 || WASM_ENABLE_DUMP_CALL_STACK != 0*/ + #if WASM_ENABLE_PERF_PROFILING != 0 void wasm_dump_perf_profiling(const WASMModuleInstance *module_inst) { - WASMExportFuncInstance *export_func; WASMFunctionInstance *func_inst; char *func_name; - uint32 i, j; + uint32 i; os_printf("Performance profiler data:\n"); for (i = 0; i < module_inst->e->function_count; i++) { func_inst = module_inst->e->functions + i; - if (func_inst->is_import_func) { - func_name = func_inst->u.func_import->field_name; - } -#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0 - else if (func_inst->u.func->field_name) { - func_name = func_inst->u.func->field_name; - } -#endif - else { - func_name = NULL; - for (j = 0; j < module_inst->export_func_count; j++) { - export_func = module_inst->export_functions + j; - if (export_func->function == func_inst) { - func_name = export_func->name; - break; - } - } - } + if (func_inst->total_exec_cnt == 0) + continue; + + func_name = get_func_name_from_index(module_inst, i); if (func_name) os_printf( " func %s, execution time: %.3f ms, execution count: %" PRIu32 - " times\n", - func_name, - module_inst->e->functions[i].total_exec_time / 1000.0f, - module_inst->e->functions[i].total_exec_cnt); + " times, children execution time: %.3f ms\n", + func_name, func_inst->total_exec_time / 1000.0f, + func_inst->total_exec_cnt, + func_inst->children_exec_time / 1000.0f); else os_printf(" func %" PRIu32 ", execution time: %.3f ms, execution count: %" PRIu32 - " times\n", - i, module_inst->e->functions[i].total_exec_time / 1000.0f, - module_inst->e->functions[i].total_exec_cnt); + " times, children execution time: %.3f ms\n", + i, func_inst->total_exec_time / 1000.0f, + func_inst->total_exec_cnt, + func_inst->children_exec_time / 1000.0f); } } -#endif + +double +wasm_summarize_wasm_execute_time(const WASMModuleInstance *inst) +{ + double ret = 0; + + unsigned i; + for (i = 0; i < inst->e->function_count; i++) { + WASMFunctionInstance *func = inst->e->functions + i; + ret += (func->total_exec_time - func->children_exec_time) / 1000.0f; + } + + return ret; +} + +double +wasm_get_wasm_func_exec_time(const WASMModuleInstance *inst, + const char *func_name) +{ + unsigned i; + for (i = 0; i < inst->e->function_count; i++) { + char *name_in_wasm = get_func_name_from_index(inst, i); + if (name_in_wasm && strcmp(name_in_wasm, func_name) == 0) { + WASMFunctionInstance *func = inst->e->functions + i; + return (func->total_exec_time - func->children_exec_time) / 1000.0f; + } + } + + return -1.0; +} +#endif /*WASM_ENABLE_PERF_PROFILING != 0*/ uint32 wasm_module_malloc_internal(WASMModuleInstance *module_inst, @@ -2928,29 +3170,7 @@ wasm_interp_create_call_stack(struct WASMExecEnv *exec_env) frame.func_offset = (uint32)(cur_frame->ip - func_code_base); } - /* look for the function name */ - if (func_inst->is_import_func) { - func_name = func_inst->u.func_import->field_name; - } - else { -#if WASM_ENABLE_CUSTOM_NAME_SECTION != 0 - func_name = func_inst->u.func->field_name; -#endif - /* if custom name section is not generated, - search symbols from export table */ - if (!func_name) { - uint32 i; - for (i = 0; i < module_inst->export_func_count; i++) { - WASMExportFuncInstance *export_func = - module_inst->export_functions + i; - if (export_func->function == func_inst) { - func_name = export_func->name; - break; - } - } - } - } - + func_name = get_func_name_from_index(module_inst, frame.func_index); frame.func_name_wp = func_name; if (!bh_vector_append(module_inst->frames, &frame)) { @@ -3245,6 +3465,7 @@ llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx, { WASMTableInstance *tbl_inst; WASMTableSeg *tbl_seg; + uint32 *tbl_seg_elems = NULL, tbl_seg_len = 0; bh_assert(module_inst->module_type == Wasm_Module_Bytecode); @@ -3254,31 +3475,26 @@ llvm_jit_table_init(WASMModuleInstance *module_inst, uint32 tbl_idx, bh_assert(tbl_inst); bh_assert(tbl_seg); - if (offset_len_out_of_bounds(src_offset, length, tbl_seg->function_count) - || offset_len_out_of_bounds(dst_offset, length, tbl_inst->cur_size)) { - jit_set_exception_with_id(module_inst, EXCE_OUT_OF_BOUNDS_TABLE_ACCESS); - return; - } - - if (!length) { - return; + if (!bh_bitmap_get_bit(module_inst->e->common.elem_dropped, tbl_seg_idx)) { + /* table segment isn't dropped */ + tbl_seg_elems = tbl_seg->func_indexes; + tbl_seg_len = tbl_seg->function_count; } - if (bh_bitmap_get_bit(module_inst->e->common.elem_dropped, tbl_seg_idx)) { + if (offset_len_out_of_bounds(src_offset, length, tbl_seg_len) + || offset_len_out_of_bounds(dst_offset, length, tbl_inst->cur_size)) { jit_set_exception_with_id(module_inst, EXCE_OUT_OF_BOUNDS_TABLE_ACCESS); return; } - if (!wasm_elem_is_passive(tbl_seg->mode)) { - jit_set_exception_with_id(module_inst, EXCE_OUT_OF_BOUNDS_TABLE_ACCESS); + if (!length) { return; } bh_memcpy_s((uint8 *)tbl_inst + offsetof(WASMTableInstance, elems) + dst_offset * sizeof(uint32), (uint32)sizeof(uint32) * (tbl_inst->cur_size - dst_offset), - tbl_seg->func_indexes + src_offset, - (uint32)(length * sizeof(uint32))); + tbl_seg_elems + src_offset, (uint32)(length * sizeof(uint32))); } void @@ -3397,7 +3613,7 @@ llvm_jit_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) frame->ip = NULL; frame->sp = frame->lp; #if WASM_ENABLE_PERF_PROFILING != 0 - frame->time_started = os_time_get_boot_microsecond(); + frame->time_started = os_time_thread_cputime_us(); #endif frame->prev_frame = wasm_exec_env_get_cur_frame(exec_env); wasm_exec_env_set_cur_frame(exec_env, frame); @@ -3418,9 +3634,13 @@ llvm_jit_free_frame(WASMExecEnv *exec_env) #if WASM_ENABLE_PERF_PROFILING != 0 if (frame->function) { - frame->function->total_exec_time += - os_time_get_boot_microsecond() - frame->time_started; + uint64 elapsed = os_time_thread_cputime_us() - frame->time_started; + frame->function->total_exec_time += elapsed; frame->function->total_exec_cnt++; + + /* parent function */ + if (prev_frame) + prev_frame->function->children_exec_time += elapsed; } #endif wasm_exec_env_free_wasm_frame(exec_env, frame); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_runtime.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_runtime.h similarity index 93% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_runtime.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_runtime.h index bb5fdc80bbe..b1224863efc 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_runtime.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/interpreter/wasm_runtime.h @@ -28,6 +28,9 @@ typedef struct WASMFunctionInstance WASMFunctionInstance; typedef struct WASMMemoryInstance WASMMemoryInstance; typedef struct WASMTableInstance WASMTableInstance; typedef struct WASMGlobalInstance WASMGlobalInstance; +#if WASM_ENABLE_TAGS != 0 +typedef struct WASMTagInstance WASMTagInstance; +#endif /** * When LLVM JIT, WAMR compiler or AOT is enabled, we should ensure that @@ -186,9 +189,35 @@ struct WASMFunctionInstance { uint64 total_exec_time; /* total execution count */ uint32 total_exec_cnt; + /* children execution time */ + uint64 children_exec_time; +#endif +}; + +#if WASM_ENABLE_TAGS != 0 +struct WASMTagInstance { + bool is_import_tag; + /* tag attribute */ + uint8 attribute; + /* tag type index */ + uint32 type; + union { + WASMTagImport *tag_import; + WASMTag *tag; + } u; + +#if WASM_ENABLE_MULTI_MODULE != 0 + WASMModuleInstance *import_module_inst; + WASMTagInstance *import_tag_inst; #endif }; +#endif +#if WASM_ENABLE_EXCE_HANDLING != 0 +#define INVALID_TAGINDEX ((uint32)0xFFFFFFFF) +#define SET_INVALID_TAGINDEX(tag) (tag = INVALID_TAGINDEX) +#define IS_INVALID_TAGINDEX(tag) ((tag & INVALID_TAGINDEX) == INVALID_TAGINDEX) +#endif typedef struct WASMExportFuncInstance { char *name; WASMFunctionInstance *function; @@ -209,6 +238,13 @@ typedef struct WASMExportMemInstance { WASMMemoryInstance *memory; } WASMExportMemInstance; +#if WASM_ENABLE_TAGS != 0 +typedef struct WASMExportTagInstance { + char *name; + WASMTagInstance *tag; +} WASMExportTagInstance; +#endif + /* wasm-c-api import function info */ typedef struct CApiFuncImport { /* host func pointer after linked */ @@ -221,8 +257,8 @@ typedef struct CApiFuncImport { /* The common part of WASMModuleInstanceExtra and AOTModuleInstanceExtra */ typedef struct WASMModuleInstanceExtraCommon { - void *contexts[WASM_MAX_INSTANCE_CONTEXTS]; CApiFuncImport *c_api_func_imports; + void *contexts[WASM_MAX_INSTANCE_CONTEXTS]; /* pointer to the exec env currently used */ WASMExecEnv *cur_exec_env; #if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0 @@ -261,6 +297,14 @@ typedef struct WASMModuleInstanceExtra { WASMTableInstance **table_insts_linked; #endif +#if WASM_ENABLE_TAGS != 0 + uint32 tag_count; + uint32 export_tag_count; + WASMTagInstance *tags; + WASMExportTagInstance *export_tags; + void **import_tag_ptrs; +#endif + #if WASM_ENABLE_MEMORY_PROFILING != 0 uint32 max_aux_stack_used; #endif @@ -432,6 +476,13 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, void wasm_dump_perf_profiling(const WASMModuleInstance *module_inst); +double +wasm_summarize_wasm_execute_time(const WASMModuleInstance *inst); + +double +wasm_get_wasm_func_exec_time(const WASMModuleInstance *inst, + const char *func_name); + void wasm_deinstantiate(WASMModuleInstance *module_inst, bool is_sub_inst); @@ -452,6 +503,13 @@ wasm_lookup_memory(const WASMModuleInstance *module_inst, const char *name); WASMTableInstance * wasm_lookup_table(const WASMModuleInstance *module_inst, const char *name); + +#if WASM_ENABLE_TAGS != 0 +WASMTagInstance * +wasm_lookup_tag(const WASMModuleInstance *module_inst, const char *name, + const char *signature); +#endif + #endif bool diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/debug_engine.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/debug_engine.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/debug_engine.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/debug_engine.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/debug_engine.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/debug_engine.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/debug_engine.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/debug_engine.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/debug_engine.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/debug_engine.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/debug_engine.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/debug_engine.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/gdbserver.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/gdbserver.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/gdbserver.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/gdbserver.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/gdbserver.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/gdbserver.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/gdbserver.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/gdbserver.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/handler.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/handler.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/handler.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/handler.c index 8d451b1a358..905ca2f7c20 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/handler.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/handler.c @@ -309,9 +309,11 @@ handle_general_query(WASMGDBServer *server, char *payload) } if (!strcmp(name, "WasmData")) { + write_packet(server, ""); } if (!strcmp(name, "WasmMem")) { + write_packet(server, ""); } if (!strcmp(name, "Symbol")) { @@ -447,7 +449,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid) "thread-pcs:%" PRIx64 ";00:%s;reason:%s;", pc, pc_string, "trace"); } - else if (status > 0) { + else { /* status > 0 (== 0 is checked at the function beginning) */ len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "thread-pcs:%" PRIx64 ";00:%s;reason:%s;", pc, pc_string, "signal"); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/handler.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/handler.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/handler.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/handler.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/packets.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/packets.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/packets.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/packets.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/packets.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/packets.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/packets.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/packets.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/utils.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/utils.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/utils.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/utils.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/utils.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/utils.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/debug-engine/utils.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/debug-engine/utils.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-pthread/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-pthread/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-pthread/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-pthread/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-pthread/lib_pthread.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-pthread/lib_pthread.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-pthread/lib_pthread.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-pthread/lib_pthread.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c index 56deaff32f1..3092f5d0310 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-pthread/lib_pthread_wrapper.c @@ -468,7 +468,7 @@ get_thread_info(wasm_exec_env_t exec_env, uint32 handle) WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env); ClusterInfoNode *info = get_cluster_info(cluster); - if (!info) { + if (!info || !handle) { return NULL; } @@ -558,6 +558,7 @@ pthread_create_wrapper(wasm_exec_env_t exec_env, ThreadRoutineArgs *routine_args = NULL; uint32 thread_handle; uint32 stack_size = 8192; + uint32 aux_stack_start = 0, aux_stack_size; int32 ret = -1; bh_assert(module); @@ -609,10 +610,22 @@ pthread_create_wrapper(wasm_exec_env_t exec_env, routine_args->info_node = info_node; routine_args->module_inst = new_module_inst; + /* Allocate aux stack previously since exec_env->wait_lock is acquired + below, and if the stack is allocated in wasm_cluster_create_thread, + runtime may call the exported malloc function to allocate the stack, + which acquires exec_env->wait again in wasm_exec_env_set_thread_info, + and recursive lock (or hang) occurs */ + if (!wasm_cluster_allocate_aux_stack(exec_env, &aux_stack_start, + &aux_stack_size)) { + LOG_ERROR("thread manager error: " + "failed to allocate aux stack space for new thread"); + goto fail; + } + os_mutex_lock(&exec_env->wait_lock); - ret = - wasm_cluster_create_thread(exec_env, new_module_inst, true, - pthread_start_routine, (void *)routine_args); + ret = wasm_cluster_create_thread( + exec_env, new_module_inst, true, aux_stack_start, aux_stack_size, + pthread_start_routine, (void *)routine_args); if (ret != 0) { os_mutex_unlock(&exec_env->wait_lock); goto fail; @@ -636,6 +649,8 @@ pthread_create_wrapper(wasm_exec_env_t exec_env, wasm_runtime_free(info_node); if (routine_args) wasm_runtime_free(routine_args); + if (aux_stack_start) + wasm_cluster_free_aux_stack(exec_env, aux_stack_start); return ret; } @@ -1129,6 +1144,10 @@ sem_open_wrapper(wasm_exec_env_t exec_env, const char *name, int32 oflags, * For Unix like system, it's dedicated for multiple processes. */ + if (!name) { /* avoid passing NULL to bh_hash_map_find and os_sem_open */ + return -1; + } + if ((info_node = bh_hash_map_find(sem_info_map, (void *)name))) { return info_node->handle; } @@ -1261,7 +1280,13 @@ sem_unlink_wrapper(wasm_exec_env_t exec_env, const char *name) (void)exec_env; int32 ret_val; - ThreadInfoNode *info_node = bh_hash_map_find(sem_info_map, (void *)name); + ThreadInfoNode *info_node; + + if (!name) { /* avoid passing NULL to bh_hash_map_find */ + return -1; + } + + info_node = bh_hash_map_find(sem_info_map, (void *)name); if (!info_node || info_node->type != T_SEM) return -1; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-rats/lib_rats.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-rats/lib_rats.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-rats/lib_rats.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-rats/lib_rats.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-rats/lib_rats_common.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-rats/lib_rats_common.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-rats/lib_rats_common.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-rats/lib_rats_common.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-rats/lib_rats_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-rats/lib_rats_wrapper.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-rats/lib_rats_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-rats/lib_rats_wrapper.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-rats/lib_rats_wrapper.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-rats/lib_rats_wrapper.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-rats/lib_rats_wrapper.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-rats/lib_rats_wrapper.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake similarity index 90% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake index 209b0c4c9c3..8ddddffebad 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/lib_socket_wasi.cmake @@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 2.8...3.16) -project(socket_wasi_ext) +project(socket_wasi_ext LANGUAGES C) add_library(${PROJECT_NAME} STATIC ${CMAKE_CURRENT_LIST_DIR}/src/wasi/wasi_socket_ext.c) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc/) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/test/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/test/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/test/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/test/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/test/manifest.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/test/manifest.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/test/manifest.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/test/manifest.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/test/nslookup.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/test/nslookup.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/test/nslookup.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/test/nslookup.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/test/tcp_udp.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/test/tcp_udp.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-socket/test/tcp_udp.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-socket/test/tcp_udp.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads_wrapper.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads_wrapper.c index 7e557be9009..3922661136f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads_wrapper.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/lib_wasi_threads_wrapper.c @@ -119,7 +119,7 @@ thread_spawn_wrapper(wasm_exec_env_t exec_env, uint32 start_arg) thread_start_arg->arg = start_arg; thread_start_arg->start_func = start_func; - ret = wasm_cluster_create_thread(exec_env, new_module_inst, false, + ret = wasm_cluster_create_thread(exec_env, new_module_inst, false, 0, 0, thread_start, thread_start_arg); if (ret != 0) { LOG_ERROR("Failed to spawn a new thread"); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/errorcheck_mutex_stress_test.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/errorcheck_mutex_stress_test.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/errorcheck_mutex_stress_test.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/errorcheck_mutex_stress_test.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/manifest.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/manifest.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/manifest.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/manifest.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/mutex_common.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/mutex_common.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/mutex_common.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/mutex_common.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/normal_mutex_stress_test.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/normal_mutex_stress_test.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/normal_mutex_stress_test.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/normal_mutex_stress_test.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/recursive_mutex_stress_test.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/recursive_mutex_stress_test.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/recursive_mutex_stress_test.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/recursive_mutex_stress_test.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/spawn_stress_test.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/spawn_stress_test.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/spawn_stress_test.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/spawn_stress_test.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/stress_test_threads_creation.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/stress_test_threads_creation.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/stress-test/stress_test_threads_creation.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/stress-test/stress_test_threads_creation.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/common.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/common.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/common.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/common.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/create_threads_until_limit.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/create_threads_until_limit.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/create_threads_until_limit.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/create_threads_until_limit.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/global_atomic.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/global_atomic.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/global_atomic.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/global_atomic.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/linear_memory_size_update.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/linear_memory_size_update.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/linear_memory_size_update.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/linear_memory_size_update.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_busy.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_busy.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_busy.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_busy.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_busy.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_busy.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_busy.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_busy.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_sleep.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_sleep.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_sleep.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_sleep.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_sleep.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_sleep.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_sleep.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_sleep.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_wait.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_wait.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_wait.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_wait.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_wait.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_wait.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_wait.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_proc_exit_wait.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_busy.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_busy.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_busy.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_busy.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_busy.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_busy.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_busy.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_busy.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_sleep.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_sleep.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_sleep.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_sleep.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_sleep.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_sleep.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_sleep.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_sleep.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_wait.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_wait.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_wait.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_wait.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_wait.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_wait.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/main_trap_wait.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/main_trap_wait.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/manifest.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/manifest.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/manifest.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/manifest.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_busy.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_busy.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_busy.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_busy.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_busy.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_busy.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_busy.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_busy.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_sleep.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_sleep.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_sleep.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_sleep.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_sleep.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_sleep.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_sleep.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_sleep.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_wait.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_wait.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_wait.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_wait.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_wait.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_wait.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_wait.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_proc_exit_wait.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_busy.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_busy.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_busy.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_busy.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_busy.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_busy.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_busy.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_busy.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_sleep.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_sleep.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_sleep.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_sleep.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_sleep.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_sleep.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_sleep.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_sleep.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_wait.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_wait.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_wait.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_wait.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_wait.json b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_wait.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_wait.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/nonmain_trap_wait.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/spawn_multiple_times.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/spawn_multiple_times.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/spawn_multiple_times.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/spawn_multiple_times.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/trap_after_main_thread_finishes.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/trap_after_main_thread_finishes.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/trap_after_main_thread_finishes.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/trap_after_main_thread_finishes.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/update_shared_data_and_alloc_heap.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/update_shared_data_and_alloc_heap.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/test/update_shared_data_and_alloc_heap.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/test/update_shared_data_and_alloc_heap.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/tid_allocator.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/tid_allocator.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/tid_allocator.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/tid_allocator.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/unit-test/lib_wasi_threads_unit_tests.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/unit-test/lib_wasi_threads_unit_tests.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/unit-test/lib_wasi_threads_unit_tests.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/unit-test/lib_wasi_threads_unit_tests.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/unit-test/test_tid_allocator.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/unit-test/test_tid_allocator.cpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/lib-wasi-threads/unit-test/test_tid_allocator.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/lib-wasi-threads/unit-test/test_tid_allocator.cpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-builtin/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-builtin/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-builtin/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-builtin/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-builtin/libc_builtin.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-builtin/libc_builtin.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-builtin/libc_builtin.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-builtin/libc_builtin.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c index 55916deb469..923840f3b51 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c @@ -426,7 +426,7 @@ sprintf_wrapper(wasm_exec_env_t exec_env, char *str, const char *format, if (!wasm_runtime_get_native_addr_range(module_inst, (uint8 *)str, NULL, &native_end_offset)) { wasm_runtime_set_exception(module_inst, "out of bounds memory access"); - return false; + return 0; } ctx.str = str; @@ -473,12 +473,16 @@ snprintf_wrapper(wasm_exec_env_t exec_env, char *str, uint32 size, static int puts_wrapper(wasm_exec_env_t exec_env, const char *str) { + (void)exec_env; + return os_printf("%s\n", str); } static int putchar_wrapper(wasm_exec_env_t exec_env, int c) { + (void)exec_env; + os_printf("%c", c); return 1; } @@ -585,6 +589,8 @@ strchr_wrapper(wasm_exec_env_t exec_env, const char *s, int32 c) static int32 strcmp_wrapper(wasm_exec_env_t exec_env, const char *s1, const char *s2) { + (void)exec_env; + /* s1 and s2 have been checked by runtime */ return strcmp(s1, s2); } @@ -641,6 +647,8 @@ strncpy_wrapper(wasm_exec_env_t exec_env, char *dst, const char *src, static uint32 strlen_wrapper(wasm_exec_env_t exec_env, const char *s) { + (void)exec_env; + /* s has been checked by runtime */ return (uint32)strlen(s); } @@ -693,6 +701,7 @@ free_wrapper(wasm_exec_env_t exec_env, void *ptr) static int32 atoi_wrapper(wasm_exec_env_t exec_env, const char *s) { + (void)exec_env; /* s has been checked by runtime */ return atoi(s); } @@ -757,6 +766,8 @@ static int32 strncasecmp_wrapper(wasm_exec_env_t exec_env, const char *s1, const char *s2, uint32 n) { + (void)exec_env; + /* s1 and s2 have been checked by runtime */ return strncasecmp(s1, s2, n); } @@ -764,6 +775,8 @@ strncasecmp_wrapper(wasm_exec_env_t exec_env, const char *s1, const char *s2, static uint32 strspn_wrapper(wasm_exec_env_t exec_env, const char *s, const char *accept) { + (void)exec_env; + /* s and accept have been checked by runtime */ return (uint32)strspn(s, accept); } @@ -771,6 +784,8 @@ strspn_wrapper(wasm_exec_env_t exec_env, const char *s, const char *accept) static uint32 strcspn_wrapper(wasm_exec_env_t exec_env, const char *s, const char *reject) { + (void)exec_env; + /* s and reject have been checked by runtime */ return (uint32)strcspn(s, reject); } @@ -787,60 +802,80 @@ strstr_wrapper(wasm_exec_env_t exec_env, const char *s, const char *find) static int32 isupper_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return isupper(c); } static int32 isalpha_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return isalpha(c); } static int32 isspace_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return isspace(c); } static int32 isgraph_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return isgraph(c); } static int32 isprint_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return isprint(c); } static int32 isdigit_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return isdigit(c); } static int32 isxdigit_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return isxdigit(c); } static int32 tolower_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return tolower(c); } static int32 toupper_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return toupper(c); } static int32 isalnum_wrapper(wasm_exec_env_t exec_env, int32 c) { + (void)exec_env; + return isalnum(c); } @@ -899,7 +934,10 @@ __cxa_allocate_exception_wrapper(wasm_exec_env_t exec_env, uint32 thrown_size) static void __cxa_begin_catch_wrapper(wasm_exec_env_t exec_env, void *exception_object) -{} +{ + (void)exec_env; + (void)exception_object; +} static void __cxa_throw_wrapper(wasm_exec_env_t exec_env, void *thrown_exception, @@ -908,6 +946,10 @@ __cxa_throw_wrapper(wasm_exec_env_t exec_env, void *thrown_exception, wasm_module_inst_t module_inst = get_module_inst(exec_env); char buf[32]; + (void)thrown_exception; + (void)tinfo; + (void)table_elem_idx; + snprintf(buf, sizeof(buf), "%s", "exception thrown by stdc++"); wasm_runtime_set_exception(module_inst, buf); } @@ -924,10 +966,12 @@ clock_gettime_wrapper(wasm_exec_env_t exec_env, uint32 clk_id, wasm_module_inst_t module_inst = get_module_inst(exec_env); uint64 time; + (void)clk_id; + if (!validate_native_addr(ts_app, sizeof(struct timespec_app))) return (uint32)-1; - time = os_time_get_boot_microsecond(); + time = os_time_get_boot_us(); ts_app->tv_sec = time / 1000000; ts_app->tv_nsec = (time % 1000000) * 1000; @@ -937,9 +981,11 @@ clock_gettime_wrapper(wasm_exec_env_t exec_env, uint32 clk_id, static uint64 clock_wrapper(wasm_exec_env_t exec_env) { + (void)exec_env; + /* Convert to nano seconds as CLOCKS_PER_SEC in wasi-sdk */ - return os_time_get_boot_microsecond() * 1000; + return os_time_get_boot_us() * 1000; } #if WASM_ENABLE_SPEC_TEST != 0 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-emcc/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-emcc/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-emcc/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-emcc/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-emcc/libc_emcc.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-emcc/libc_emcc.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-emcc/libc_emcc.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-emcc/libc_emcc.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-emcc/libc_emcc_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-emcc/libc_emcc_wrapper.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-emcc/libc_emcc_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-emcc/libc_emcc_wrapper.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/FindLIBUV.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/FindLIBUV.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/FindLIBUV.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/FindLIBUV.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/FindUVWASI.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/FindUVWASI.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/FindUVWASI.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/FindUVWASI.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/LICENSE_LIBUV b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/LICENSE_LIBUV similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/LICENSE_LIBUV rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/LICENSE_LIBUV diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/LICENSE_UVWASI b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/LICENSE_UVWASI similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/LICENSE_UVWASI rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/LICENSE_UVWASI diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/libc_uvwasi.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-uvwasi/libc_uvwasi_wrapper.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/libc_wasi.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/libc_wasi.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/libc_wasi.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/libc_wasi.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c similarity index 91% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c index 9f35b81a7f8..0b69de6b92f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c @@ -72,7 +72,7 @@ min_uint32(uint32_t a, uint32_t b) } static inline struct fd_table * -wasi_ctx_get_curfds(wasm_module_inst_t module_inst, wasi_ctx_t wasi_ctx) +wasi_ctx_get_curfds(wasi_ctx_t wasi_ctx) { if (!wasi_ctx) return NULL; @@ -88,7 +88,7 @@ wasi_ctx_get_argv_environ(wasm_module_inst_t module_inst, wasi_ctx_t wasi_ctx) } static inline struct fd_prestats * -wasi_ctx_get_prestats(wasm_module_inst_t module_inst, wasi_ctx_t wasi_ctx) +wasi_ctx_get_prestats(wasi_ctx_t wasi_ctx) { if (!wasi_ctx) return NULL; @@ -96,7 +96,7 @@ wasi_ctx_get_prestats(wasm_module_inst_t module_inst, wasi_ctx_t wasi_ctx) } static inline struct addr_pool * -wasi_ctx_get_addr_pool(wasm_module_inst_t module_inst, wasi_ctx_t wasi_ctx) +wasi_ctx_get_addr_pool(wasi_ctx_t wasi_ctx) { if (!wasi_ctx) return NULL; @@ -292,7 +292,7 @@ wasi_fd_prestat_get(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_prestats *prestats = wasi_ctx_get_prestats(module_inst, wasi_ctx); + struct fd_prestats *prestats = wasi_ctx_get_prestats(wasi_ctx); wasi_prestat_t prestat; wasi_errno_t err; @@ -317,7 +317,7 @@ wasi_fd_prestat_dir_name(wasm_exec_env_t exec_env, wasi_fd_t fd, char *path, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_prestats *prestats = wasi_ctx_get_prestats(module_inst, wasi_ctx); + struct fd_prestats *prestats = wasi_ctx_get_prestats(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -330,8 +330,8 @@ wasi_fd_close(wasm_exec_env_t exec_env, wasi_fd_t fd) { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); - struct fd_prestats *prestats = wasi_ctx_get_prestats(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); + struct fd_prestats *prestats = wasi_ctx_get_prestats(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -344,7 +344,7 @@ wasi_fd_datasync(wasm_exec_env_t exec_env, wasi_fd_t fd) { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -358,7 +358,7 @@ wasi_fd_pread(wasm_exec_env_t exec_env, wasi_fd_t fd, iovec_app_t *iovec_app, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); wasi_iovec_t *iovec, *iovec_begin; uint64 total_size; size_t nread; @@ -412,7 +412,7 @@ wasi_fd_pwrite(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); wasi_ciovec_t *ciovec, *ciovec_begin; uint64 total_size; size_t nwritten; @@ -465,7 +465,7 @@ wasi_fd_read(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); wasi_iovec_t *iovec, *iovec_begin; uint64 total_size; size_t nread; @@ -517,8 +517,8 @@ wasi_fd_renumber(wasm_exec_env_t exec_env, wasi_fd_t from, wasi_fd_t to) { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); - struct fd_prestats *prestats = wasi_ctx_get_prestats(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); + struct fd_prestats *prestats = wasi_ctx_get_prestats(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -532,7 +532,7 @@ wasi_fd_seek(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_filedelta_t offset, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -549,7 +549,7 @@ wasi_fd_tell(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_filesize_t *newoffset) { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -566,7 +566,7 @@ wasi_fd_fdstat_get(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); wasi_fdstat_t fdstat; wasi_errno_t err; @@ -590,7 +590,7 @@ wasi_fd_fdstat_set_flags(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -605,7 +605,7 @@ wasi_fd_fdstat_set_rights(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -619,7 +619,7 @@ wasi_fd_sync(wasm_exec_env_t exec_env, wasi_fd_t fd) { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -634,7 +634,7 @@ wasi_fd_write(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); wasi_ciovec_t *ciovec, *ciovec_begin; uint64 total_size; size_t nwritten; @@ -687,7 +687,7 @@ wasi_fd_advise(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_filesize_t offset, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -701,7 +701,7 @@ wasi_fd_allocate(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_filesize_t offset, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -715,7 +715,7 @@ wasi_path_create_directory(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -732,8 +732,8 @@ wasi_path_link(wasm_exec_env_t exec_env, wasi_fd_t old_fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); - struct fd_prestats *prestats = wasi_ctx_get_prestats(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); + struct fd_prestats *prestats = wasi_ctx_get_prestats(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -752,7 +752,7 @@ wasi_path_open(wasm_exec_env_t exec_env, wasi_fd_t dirfd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); wasi_fd_t fd = (wasi_fd_t)-1; /* set fd_app -1 if path open failed */ wasi_errno_t err; @@ -776,7 +776,7 @@ wasi_fd_readdir(wasm_exec_env_t exec_env, wasi_fd_t fd, void *buf, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); size_t bufused; wasi_errno_t err; @@ -802,7 +802,7 @@ wasi_path_readlink(wasm_exec_env_t exec_env, wasi_fd_t fd, const char *path, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); size_t bufused; wasi_errno_t err; @@ -828,7 +828,7 @@ wasi_path_rename(wasm_exec_env_t exec_env, wasi_fd_t old_fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -844,7 +844,7 @@ wasi_fd_filestat_get(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -862,7 +862,7 @@ wasi_fd_filestat_set_times(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -877,7 +877,7 @@ wasi_fd_filestat_set_size(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -892,7 +892,7 @@ wasi_path_filestat_get(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -912,7 +912,7 @@ wasi_path_filestat_set_times(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -929,8 +929,8 @@ wasi_path_symlink(wasm_exec_env_t exec_env, const char *old_path, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); - struct fd_prestats *prestats = wasi_ctx_get_prestats(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); + struct fd_prestats *prestats = wasi_ctx_get_prestats(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -945,7 +945,7 @@ wasi_path_unlink_file(wasm_exec_env_t exec_env, wasi_fd_t fd, const char *path, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -959,7 +959,7 @@ wasi_path_remove_directory(wasm_exec_env_t exec_env, wasi_fd_t fd, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return (wasi_errno_t)-1; @@ -1047,7 +1047,7 @@ execute_interruptible_poll_oneoff( if (wasm_cluster_is_thread_terminated(exec_env)) { wasm_runtime_free(in_copy); - return EINTR; + return __WASI_EINTR; } else if (*nevents > 0) { all_outs_are_type_clock = true; @@ -1076,7 +1076,7 @@ wasi_poll_oneoff(wasm_exec_env_t exec_env, const wasi_subscription_t *in, { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); size_t nevents = 0; wasi_errno_t err; @@ -1128,6 +1128,8 @@ wasi_proc_raise(wasm_exec_env_t exec_env, wasi_signal_t sig) static wasi_errno_t wasi_random_get(wasm_exec_env_t exec_env, void *buf, uint32 buf_len) { + (void)exec_env; + return wasmtime_ssp_random_get(buf, buf_len); } @@ -1142,7 +1144,7 @@ wasi_sock_accept(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_fdflags_t flags, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasi_ssp_sock_accept(exec_env, curfds, fd, flags, fd_new); } @@ -1161,7 +1163,7 @@ wasi_sock_addr_local(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(addr, sizeof(__wasi_addr_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasi_ssp_sock_addr_local(exec_env, curfds, fd, addr); } @@ -1180,7 +1182,7 @@ wasi_sock_addr_remote(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(addr, sizeof(__wasi_addr_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasi_ssp_sock_addr_remote(exec_env, curfds, fd, addr); } @@ -1200,7 +1202,7 @@ wasi_sock_addr_resolve(wasm_exec_env_t exec_env, const char *host, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); ns_lookup_list = wasi_ctx_get_ns_lookup_list(wasi_ctx); return wasi_ssp_sock_addr_resolve(exec_env, curfds, ns_lookup_list, host, @@ -1219,8 +1221,8 @@ wasi_sock_bind(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_addr_t *addr) if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); - addr_pool = wasi_ctx_get_addr_pool(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); + addr_pool = wasi_ctx_get_addr_pool(wasi_ctx); return wasi_ssp_sock_bind(exec_env, curfds, addr_pool, fd, addr); } @@ -1228,6 +1230,9 @@ wasi_sock_bind(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_addr_t *addr) static wasi_errno_t wasi_sock_close(wasm_exec_env_t exec_env, wasi_fd_t fd) { + (void)exec_env; + (void)fd; + return __WASI_ENOSYS; } @@ -1242,8 +1247,8 @@ wasi_sock_connect(wasm_exec_env_t exec_env, wasi_fd_t fd, wasi_addr_t *addr) if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); - addr_pool = wasi_ctx_get_addr_pool(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); + addr_pool = wasi_ctx_get_addr_pool(wasi_ctx); return wasi_ssp_sock_connect(exec_env, curfds, addr_pool, fd, addr); } @@ -1262,7 +1267,7 @@ wasi_sock_get_broadcast(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_broadcast(exec_env, curfds, fd, is_enabled); } @@ -1281,7 +1286,7 @@ wasi_sock_get_keep_alive(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_keep_alive(exec_env, curfds, fd, is_enabled); } @@ -1301,7 +1306,7 @@ wasi_sock_get_linger(wasm_exec_env_t exec_env, wasi_fd_t fd, bool *is_enabled, || !validate_native_addr(linger_s, sizeof(int))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_linger(exec_env, curfds, fd, is_enabled, linger_s); @@ -1321,7 +1326,7 @@ wasi_sock_get_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(size, sizeof(wasi_size_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_recv_buf_size(exec_env, curfds, fd, size); } @@ -1340,7 +1345,7 @@ wasi_sock_get_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(timeout_us, sizeof(uint64_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_recv_timeout(exec_env, curfds, fd, timeout_us); } @@ -1359,7 +1364,7 @@ wasi_sock_get_reuse_addr(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_reuse_addr(exec_env, curfds, fd, is_enabled); } @@ -1378,7 +1383,7 @@ wasi_sock_get_reuse_port(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_reuse_port(exec_env, curfds, fd, is_enabled); } @@ -1397,7 +1402,7 @@ wasi_sock_get_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(size, sizeof(__wasi_size_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_send_buf_size(exec_env, curfds, fd, size); } @@ -1416,7 +1421,7 @@ wasi_sock_get_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(timeout_us, sizeof(uint64_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_send_timeout(exec_env, curfds, fd, timeout_us); } @@ -1435,7 +1440,7 @@ wasi_sock_get_tcp_fastopen_connect(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_tcp_fastopen_connect(exec_env, curfds, fd, is_enabled); @@ -1455,7 +1460,7 @@ wasi_sock_get_tcp_no_delay(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_tcp_no_delay(exec_env, curfds, fd, is_enabled); } @@ -1474,7 +1479,7 @@ wasi_sock_get_tcp_quick_ack(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_tcp_quick_ack(exec_env, curfds, fd, is_enabled); @@ -1494,7 +1499,7 @@ wasi_sock_get_tcp_keep_idle(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(time_s, sizeof(uint32_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_tcp_keep_idle(exec_env, curfds, fd, time_s); } @@ -1513,7 +1518,7 @@ wasi_sock_get_tcp_keep_intvl(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(time_s, sizeof(uint32_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_tcp_keep_intvl(exec_env, curfds, fd, time_s); } @@ -1532,7 +1537,7 @@ wasi_sock_get_ip_multicast_loop(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_ip_multicast_loop(exec_env, curfds, fd, ipv6, is_enabled); @@ -1551,7 +1556,7 @@ wasi_sock_get_ip_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8_t *ttl_s) if (!validate_native_addr(ttl_s, sizeof(uint8_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_ip_ttl(exec_env, curfds, fd, ttl_s); } @@ -1570,7 +1575,7 @@ wasi_sock_get_ip_multicast_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(ttl_s, sizeof(uint8_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_ip_multicast_ttl(exec_env, curfds, fd, ttl_s); } @@ -1589,7 +1594,7 @@ wasi_sock_get_ipv6_only(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(is_enabled, sizeof(bool))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_get_ipv6_only(exec_env, curfds, fd, is_enabled); } @@ -1604,7 +1609,7 @@ wasi_sock_listen(wasm_exec_env_t exec_env, wasi_fd_t fd, uint32 backlog) if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasi_ssp_sock_listen(exec_env, curfds, fd, backlog); } @@ -1621,7 +1626,7 @@ wasi_sock_open(wasm_exec_env_t exec_env, wasi_fd_t poolfd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasi_ssp_sock_open(exec_env, curfds, poolfd, af, socktype, sockfd); } @@ -1636,7 +1641,7 @@ wasi_sock_set_broadcast(wasm_exec_env_t exec_env, wasi_fd_t fd, bool is_enabled) if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_broadcast(exec_env, curfds, fd, is_enabled); } @@ -1652,7 +1657,7 @@ wasi_sock_set_keep_alive(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_keep_alive(exec_env, curfds, fd, is_enabled); } @@ -1668,7 +1673,7 @@ wasi_sock_set_linger(wasm_exec_env_t exec_env, wasi_fd_t fd, bool is_enabled, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_linger(exec_env, curfds, fd, is_enabled, linger_s); @@ -1684,7 +1689,7 @@ wasi_sock_set_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd, size_t size) if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_recv_buf_size(exec_env, curfds, fd, size); } @@ -1700,7 +1705,7 @@ wasi_sock_set_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_recv_timeout(exec_env, curfds, fd, timeout_us); } @@ -1716,7 +1721,7 @@ wasi_sock_set_reuse_addr(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_reuse_addr(exec_env, curfds, fd, is_enabled); } @@ -1732,7 +1737,7 @@ wasi_sock_set_reuse_port(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_reuse_port(exec_env, curfds, fd, is_enabled); } @@ -1747,7 +1752,7 @@ wasi_sock_set_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd, size_t size) if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_send_buf_size(exec_env, curfds, fd, size); } @@ -1763,7 +1768,7 @@ wasi_sock_set_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_send_timeout(exec_env, curfds, fd, timeout_us); } @@ -1779,7 +1784,7 @@ wasi_sock_set_tcp_fastopen_connect(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_tcp_fastopen_connect(exec_env, curfds, fd, is_enabled); @@ -1796,7 +1801,7 @@ wasi_sock_set_tcp_no_delay(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_tcp_no_delay(exec_env, curfds, fd, is_enabled); } @@ -1812,7 +1817,7 @@ wasi_sock_set_tcp_quick_ack(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_tcp_quick_ack(exec_env, curfds, fd, is_enabled); @@ -1829,7 +1834,7 @@ wasi_sock_set_tcp_keep_idle(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_tcp_keep_idle(exec_env, curfds, fd, time_s); } @@ -1845,7 +1850,7 @@ wasi_sock_set_tcp_keep_intvl(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_tcp_keep_intvl(exec_env, curfds, fd, time_s); } @@ -1861,7 +1866,7 @@ wasi_sock_set_ip_multicast_loop(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_ip_multicast_loop(exec_env, curfds, fd, ipv6, is_enabled); @@ -1882,7 +1887,7 @@ wasi_sock_set_ip_add_membership(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(imr_multiaddr, sizeof(__wasi_addr_ip_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_ip_add_membership( exec_env, curfds, fd, imr_multiaddr, imr_interface); @@ -1903,7 +1908,7 @@ wasi_sock_set_ip_drop_membership(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!validate_native_addr(imr_multiaddr, sizeof(__wasi_addr_ip_t))) return __WASI_EINVAL; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_ip_drop_membership( exec_env, curfds, fd, imr_multiaddr, imr_interface); @@ -1919,7 +1924,7 @@ wasi_sock_set_ip_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd, uint8_t ttl_s) if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_ip_ttl(exec_env, curfds, fd, ttl_s); } @@ -1935,7 +1940,7 @@ wasi_sock_set_ip_multicast_ttl(wasm_exec_env_t exec_env, wasi_fd_t fd, if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_ip_multicast_ttl(exec_env, curfds, fd, ttl_s); } @@ -1950,7 +1955,7 @@ wasi_sock_set_ipv6_only(wasm_exec_env_t exec_env, wasi_fd_t fd, bool is_enabled) if (!wasi_ctx) return __WASI_EACCES; - curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + curfds = wasi_ctx_get_curfds(wasi_ctx); return wasmtime_ssp_sock_set_ipv6_only(exec_env, curfds, fd, is_enabled); } @@ -2013,7 +2018,8 @@ copy_buffer_to_iovec_app(wasm_module_inst_t module_inst, uint8 *buf_begin, } if (buf >= buf_begin + buf_size - || buf + data->buf_len < buf /* integer overflow */ + /* integer overflow */ + || data->buf_len > UINTPTR_MAX - (uintptr_t)buf || buf + data->buf_len > buf_begin + buf_size || size_to_copy == 0) { break; @@ -2048,7 +2054,7 @@ wasi_sock_recv_from(wasm_exec_env_t exec_env, wasi_fd_t sock, **/ wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); uint64 total_size; uint8 *buf_begin = NULL; wasi_errno_t err; @@ -2152,7 +2158,7 @@ wasi_sock_send(wasm_exec_env_t exec_env, wasi_fd_t sock, **/ wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); uint64 buf_size = 0; uint8 *buf = NULL; wasi_errno_t err; @@ -2192,12 +2198,12 @@ wasi_sock_send_to(wasm_exec_env_t exec_env, wasi_fd_t sock, **/ wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); uint64 buf_size = 0; uint8 *buf = NULL; wasi_errno_t err; size_t send_bytes = 0; - struct addr_pool *addr_pool = wasi_ctx_get_addr_pool(module_inst, wasi_ctx); + struct addr_pool *addr_pool = wasi_ctx_get_addr_pool(wasi_ctx); if (!wasi_ctx) { return __WASI_EINVAL; @@ -2226,7 +2232,7 @@ wasi_sock_shutdown(wasm_exec_env_t exec_env, wasi_fd_t sock, wasi_sdflags_t how) { wasm_module_inst_t module_inst = get_module_inst(exec_env); wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst); - struct fd_table *curfds = wasi_ctx_get_curfds(module_inst, wasi_ctx); + struct fd_table *curfds = wasi_ctx_get_curfds(wasi_ctx); if (!wasi_ctx) return __WASI_EINVAL; @@ -2237,6 +2243,8 @@ wasi_sock_shutdown(wasm_exec_env_t exec_env, wasi_fd_t sock, wasi_sdflags_t how) static wasi_errno_t wasi_sched_yield(wasm_exec_env_t exec_env) { + (void)exec_env; + return wasmtime_ssp_sched_yield(); } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/include/wasmtime_ssp.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c similarity index 91% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c index ec1481c2ef0..4dcc4f5b0b8 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c @@ -7,6 +7,7 @@ #include "ssp_config.h" #include "blocking_op.h" +#include "libc_errno.h" __wasi_errno_t blocking_op_close(wasm_exec_env_t exec_env, os_file_handle handle, @@ -170,3 +171,23 @@ blocking_op_openat(wasm_exec_env_t exec_env, os_file_handle handle, wasm_runtime_end_blocking_op(exec_env); return error; } + +#ifndef BH_PLATFORM_WINDOWS +/* REVISIT: apply the os_file_handle style abstraction for pollfd? */ +__wasi_errno_t +blocking_op_poll(wasm_exec_env_t exec_env, struct pollfd *pfds, nfds_t nfds, + int timeout_ms, int *retp) +{ + int ret; + if (!wasm_runtime_begin_blocking_op(exec_env)) { + return __WASI_EINTR; + } + ret = poll(pfds, nfds, timeout_ms); + wasm_runtime_end_blocking_op(exec_env); + if (ret == -1) { + return convert_errno(errno); + } + *retp = ret; + return 0; +} +#endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.h similarity index 89% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.h index afaa4a4f0cb..a32e5d662ed 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.h @@ -3,6 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +#ifndef _BLOCKING_OP_H_ +#define _BLOCKING_OP_H_ + #include "bh_platform.h" #include "wasm_export.h" @@ -50,4 +53,12 @@ __wasi_errno_t blocking_op_openat(wasm_exec_env_t exec_env, os_file_handle handle, const char *path, __wasi_oflags_t oflags, __wasi_fdflags_t fd_flags, __wasi_lookupflags_t lookup_flags, - wasi_libc_file_access_mode access_mode, os_file_handle *out); \ No newline at end of file + wasi_libc_file_access_mode access_mode, os_file_handle *out); + +#ifndef BH_PLATFORM_WINDOWS +__wasi_errno_t +blocking_op_poll(wasm_exec_env_t exec_env, struct pollfd *pfds, nfds_t nfds, + int timeout, int *retp); +#endif + +#endif /* end of _BLOCKING_OP_H_ */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/locking.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/locking.h similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/locking.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/locking.h index 5e0778c3f22..0ad40ecfd3d 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/locking.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/locking.h @@ -88,7 +88,7 @@ struct LOCKABLE rwlock { }; static inline bool -rwlock_init(struct rwlock *lock) REQUIRES_UNLOCKED(*lock) +rwlock_initialize(struct rwlock *lock) REQUIRES_UNLOCKED(*lock) { return os_rwlock_init(&lock->object) == 0 ? true : false; } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c index b59035f349e..03ff50a3f4f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c @@ -204,7 +204,7 @@ struct fd_prestat { bool fd_prestats_init(struct fd_prestats *pt) { - if (!rwlock_init(&pt->lock)) + if (!rwlock_initialize(&pt->lock)) return false; pt->prestats = NULL; pt->size = 0; @@ -340,7 +340,7 @@ struct fd_entry { bool fd_table_init(struct fd_table *ft) { - if (!rwlock_init(&ft->lock)) + if (!rwlock_initialize(&ft->lock)) return false; ft->entries = NULL; ft->size = 0; @@ -1017,9 +1017,13 @@ wasmtime_ssp_fd_fdstat_get(wasm_exec_env_t exec_env, struct fd_table *curfds, __wasi_fd_t fd, __wasi_fdstat_t *buf) { struct fd_table *ft = curfds; - rwlock_rdlock(&ft->lock); struct fd_entry *fe; - __wasi_errno_t error = fd_table_get_entry(ft, fd, 0, 0, &fe); + __wasi_errno_t error; + + (void)exec_env; + + rwlock_rdlock(&ft->lock); + error = fd_table_get_entry(ft, fd, 0, 0, &fe); if (error != __WASI_ESUCCESS) { rwlock_unlock(&ft->lock); return error; @@ -1071,9 +1075,13 @@ wasmtime_ssp_fd_fdstat_set_rights(wasm_exec_env_t exec_env, __wasi_rights_t fs_rights_inheriting) { struct fd_table *ft = curfds; - rwlock_wrlock(&ft->lock); struct fd_entry *fe; - __wasi_errno_t error = + __wasi_errno_t error; + + (void)exec_env; + + rwlock_wrlock(&ft->lock); + error = fd_table_get_entry(ft, fd, fs_rights_base, fs_rights_inheriting, &fe); if (error != 0) { rwlock_unlock(&ft->lock); @@ -1891,7 +1899,13 @@ wasmtime_ssp_fd_filestat_set_times(wasm_exec_env_t exec_env, if ((fstflags & ~(__WASI_FILESTAT_SET_ATIM | __WASI_FILESTAT_SET_ATIM_NOW | __WASI_FILESTAT_SET_MTIM | __WASI_FILESTAT_SET_MTIM_NOW)) - != 0) + != 0 + || (fstflags + & (__WASI_FILESTAT_SET_ATIM | __WASI_FILESTAT_SET_ATIM_NOW)) + == (__WASI_FILESTAT_SET_ATIM | __WASI_FILESTAT_SET_ATIM_NOW) + || (fstflags + & (__WASI_FILESTAT_SET_MTIM | __WASI_FILESTAT_SET_MTIM_NOW)) + == (__WASI_FILESTAT_SET_MTIM | __WASI_FILESTAT_SET_MTIM_NOW)) return __WASI_EINVAL; struct fd_object *fo; @@ -2216,11 +2230,10 @@ wasmtime_ssp_poll_oneoff(wasm_exec_env_t exec_env, struct fd_table *curfds, timeout = -1; } - int ret = poll(pfds, nsubscriptions, timeout); - - __wasi_errno_t error = 0; - if (ret == -1) { - error = convert_errno(errno); + int ret; + int error = blocking_op_poll(exec_env, pfds, nsubscriptions, timeout, &ret); + if (error != 0) { + /* got an error */ } else if (ret == 0 && *nevents == 0 && clock_subscription != NULL) { // No events triggered. Trigger the clock event. @@ -2974,7 +2987,9 @@ argv_environ_init(struct argv_environ_values *argv_environ, char *argv_buf, void argv_environ_destroy(struct argv_environ_values *argv_environ) -{} +{ + (void)argv_environ; +} void fd_table_destroy(struct fd_table *ft) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/queue.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/queue.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/queue.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/queue.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/random.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/refcount.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/refcount.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/refcount.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/refcount.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/rights.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/rights.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/rights.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/rights.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/ssp_config.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/ssp_config.h similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/ssp_config.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/ssp_config.h index bcc750c2621..298dea67444 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/ssp_config.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/ssp_config.h @@ -34,14 +34,15 @@ #define CONFIG_HAS_GETRANDOM 0 #endif -#if defined(__CloudABI__) +#if defined(__CloudABI__) || defined(BH_PLATFORM_FREERTOS) #define CONFIG_HAS_CAP_ENTER 1 #else #define CONFIG_HAS_CAP_ENTER 0 #endif #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__EMSCRIPTEN__) \ - && !defined(ESP_PLATFORM) && !defined(DISABLE_CLOCK_NANOSLEEP) + && !defined(ESP_PLATFORM) && !defined(DISABLE_CLOCK_NANOSLEEP) \ + && !defined(BH_PLATFORM_FREERTOS) #define CONFIG_HAS_CLOCK_NANOSLEEP 1 #else #define CONFIG_HAS_CLOCK_NANOSLEEP 0 @@ -54,7 +55,7 @@ #endif #if !defined(__APPLE__) && !defined(BH_PLATFORM_LINUX_SGX) && !defined(_WIN32) \ - && !defined(__COSMOPOLITAN__) + && !defined(__COSMOPOLITAN__) && !defined(BH_PLATFORM_FREERTOS) #define CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK 1 #else #define CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK 0 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/str.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/thread_manager.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/thread_manager.c similarity index 90% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/thread_manager.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/thread_manager.c index dbf002468ba..ebeb1978339 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/thread_manager.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/thread_manager.c @@ -4,6 +4,7 @@ */ #include "thread_manager.h" +#include "../common/wasm_c_api_internal.h" #if WASM_ENABLE_INTERP != 0 #include "../interpreter/wasm_runtime.h" @@ -136,9 +137,10 @@ safe_traverse_exec_env_list(WASMCluster *cluster, list_visitor visitor, return ret; } -/* The caller must lock cluster->lock */ -static bool -allocate_aux_stack(WASMExecEnv *exec_env, uint32 *start, uint32 *size) +/* The caller must not have any locks */ +bool +wasm_cluster_allocate_aux_stack(WASMExecEnv *exec_env, uint32 *p_start, + uint32 *p_size) { WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env); #if WASM_ENABLE_HEAP_AUX_STACK_ALLOCATION != 0 @@ -148,8 +150,8 @@ allocate_aux_stack(WASMExecEnv *exec_env, uint32 *start, uint32 *size) stack_end = wasm_runtime_module_malloc_internal(module_inst, exec_env, cluster->stack_size, NULL); - *start = stack_end + cluster->stack_size; - *size = cluster->stack_size; + *p_start = stack_end + cluster->stack_size; + *p_size = cluster->stack_size; return stack_end != 0; #else @@ -157,27 +159,33 @@ allocate_aux_stack(WASMExecEnv *exec_env, uint32 *start, uint32 *size) /* If the module doesn't have aux stack info, it can't create any threads */ - if (!cluster->stack_segment_occupied) + + os_mutex_lock(&cluster->lock); + if (!cluster->stack_segment_occupied) { + os_mutex_unlock(&cluster->lock); return false; + } for (i = 0; i < cluster_max_thread_num; i++) { if (!cluster->stack_segment_occupied[i]) { - if (start) - *start = cluster->stack_tops[i]; - if (size) - *size = cluster->stack_size; + if (p_start) + *p_start = cluster->stack_tops[i]; + if (p_size) + *p_size = cluster->stack_size; cluster->stack_segment_occupied[i] = true; + os_mutex_unlock(&cluster->lock); return true; } } + os_mutex_unlock(&cluster->lock); return false; #endif } -/* The caller must lock cluster->lock */ -static bool -free_aux_stack(WASMExecEnv *exec_env, uint32 start) +/* The caller must not have any locks */ +bool +wasm_cluster_free_aux_stack(WASMExecEnv *exec_env, uint32 start) { WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env); @@ -198,12 +206,15 @@ free_aux_stack(WASMExecEnv *exec_env, uint32 start) #else uint32 i; + os_mutex_lock(&cluster->lock); for (i = 0; i < cluster_max_thread_num; i++) { if (start == cluster->stack_tops[i]) { cluster->stack_segment_occupied[i] = false; + os_mutex_unlock(&cluster->lock); return true; } } + os_mutex_unlock(&cluster->lock); return false; #endif } @@ -343,6 +354,10 @@ wasm_cluster_destroy(WASMCluster *cluster) wasm_debug_instance_destroy(cluster); #endif +#if WASM_ENABLE_DUMP_CALL_STACK != 0 + bh_vector_destroy(&cluster->exception_frames); +#endif + wasm_runtime_free(cluster); } @@ -488,10 +503,32 @@ wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env) return NULL; } + if (!(new_module_inst = wasm_runtime_instantiate_internal( + module, module_inst, exec_env, stack_size, 0, NULL, 0))) { + return NULL; + } + + /* Set custom_data to new module instance */ + wasm_runtime_set_custom_data_internal( + new_module_inst, wasm_runtime_get_custom_data(module_inst)); + + wasm_native_inherit_contexts(new_module_inst, module_inst); + + if (!(wasm_cluster_dup_c_api_imports(new_module_inst, module_inst))) { + goto fail1; + } + + if (!wasm_cluster_allocate_aux_stack(exec_env, &aux_stack_start, + &aux_stack_size)) { + LOG_ERROR("thread manager error: " + "failed to allocate aux stack space for new thread"); + goto fail1; + } + os_mutex_lock(&cluster->lock); if (cluster->has_exception || cluster->processing) { - goto fail1; + goto fail2; } #if WASM_ENABLE_INTERP != 0 @@ -508,53 +545,39 @@ wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env) } #endif - if (!(new_module_inst = wasm_runtime_instantiate_internal( - module, module_inst, exec_env, stack_size, 0, NULL, 0))) { - goto fail1; - } - - /* Set custom_data to new module instance */ - wasm_runtime_set_custom_data_internal( - new_module_inst, wasm_runtime_get_custom_data(module_inst)); - - wasm_native_inherit_contexts(new_module_inst, module_inst); - new_exec_env = wasm_exec_env_create_internal(new_module_inst, exec_env->wasm_stack_size); - if (!new_exec_env) + if (!new_exec_env) { goto fail2; - - if (!allocate_aux_stack(exec_env, &aux_stack_start, &aux_stack_size)) { - LOG_ERROR("thread manager error: " - "failed to allocate aux stack space for new thread"); - goto fail3; } /* Set aux stack for current thread */ if (!wasm_exec_env_set_aux_stack(new_exec_env, aux_stack_start, aux_stack_size)) { - goto fail4; + goto fail3; } + new_exec_env->is_aux_stack_allocated = true; /* Inherit suspend_flags of parent thread */ - new_exec_env->suspend_flags.flags = exec_env->suspend_flags.flags; + new_exec_env->suspend_flags.flags = + (exec_env->suspend_flags.flags & WASM_SUSPEND_FLAG_INHERIT_MASK); - if (!wasm_cluster_add_exec_env(cluster, new_exec_env)) - goto fail4; + if (!wasm_cluster_add_exec_env(cluster, new_exec_env)) { + goto fail3; + } os_mutex_unlock(&cluster->lock); return new_exec_env; -fail4: - /* free the allocated aux stack space */ - free_aux_stack(exec_env, aux_stack_start); fail3: wasm_exec_env_destroy_internal(new_exec_env); fail2: - wasm_runtime_deinstantiate_internal(new_module_inst, true); -fail1: os_mutex_unlock(&cluster->lock); + /* free the allocated aux stack space */ + wasm_cluster_free_aux_stack(exec_env, aux_stack_start); +fail1: + wasm_runtime_deinstantiate_internal(new_module_inst, true); return NULL; } @@ -565,11 +588,28 @@ wasm_cluster_destroy_spawned_exec_env(WASMExecEnv *exec_env) WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env); wasm_module_inst_t module_inst = wasm_runtime_get_module_inst(exec_env); bh_assert(cluster != NULL); + WASMExecEnv *exec_env_tls = NULL; + +#ifdef OS_ENABLE_HW_BOUND_CHECK + /* Note: free_aux_stack can execute the module's "free" function + * using the specified exec_env. In case of OS_ENABLE_HW_BOUND_CHECK, + * it needs to match the TLS exec_env if available. (Consider a native + * function which calls wasm_cluster_destroy_spawned_exec_env.) + */ + exec_env_tls = wasm_runtime_get_exec_env_tls(); +#endif + if (exec_env_tls == NULL) { + exec_env_tls = exec_env; + } + + /* Free aux stack space which was allocated in + wasm_cluster_spawn_exec_env */ + bh_assert(exec_env_tls->is_aux_stack_allocated); + wasm_cluster_free_aux_stack(exec_env_tls, + exec_env->aux_stack_bottom.bottom); os_mutex_lock(&cluster->lock); - /* Free aux stack space */ - free_aux_stack(exec_env, exec_env->aux_stack_bottom.bottom); /* Remove exec_env */ wasm_cluster_del_exec_env_internal(cluster, exec_env, false); /* Destroy exec_env */ @@ -615,6 +655,11 @@ thread_manager_start_routine(void *arg) wasm_cluster_thread_exited(exec_env); #endif + /* Free aux stack space */ + if (exec_env->is_aux_stack_allocated) + wasm_cluster_free_aux_stack(exec_env, + exec_env->aux_stack_bottom.bottom); + os_mutex_lock(&cluster_list_lock); os_mutex_lock(&cluster->lock); @@ -629,8 +674,12 @@ thread_manager_start_routine(void *arg) since we will exit soon */ } - /* Free aux stack space */ - free_aux_stack(exec_env, exec_env->aux_stack_bottom.bottom); +#if WASM_ENABLE_PERF_PROFILING != 0 + os_printf("============= Spawned thread ===========\n"); + wasm_runtime_dump_perf_profiling(module_inst); + os_printf("========================================\n"); +#endif + /* Remove exec_env */ wasm_cluster_del_exec_env_internal(cluster, exec_env, false); /* Destroy exec_env */ @@ -648,12 +697,13 @@ thread_manager_start_routine(void *arg) int32 wasm_cluster_create_thread(WASMExecEnv *exec_env, - wasm_module_inst_t module_inst, bool alloc_aux_stack, + wasm_module_inst_t module_inst, + bool is_aux_stack_allocated, uint32 aux_stack_start, + uint32 aux_stack_size, void *(*thread_routine)(void *), void *arg) { WASMCluster *cluster; WASMExecEnv *new_exec_env; - uint32 aux_stack_start = 0, aux_stack_size; korp_tid tid; cluster = wasm_exec_env_get_cluster(exec_env); @@ -670,30 +720,27 @@ wasm_cluster_create_thread(WASMExecEnv *exec_env, if (!new_exec_env) goto fail1; - if (alloc_aux_stack) { - if (!allocate_aux_stack(exec_env, &aux_stack_start, &aux_stack_size)) { - LOG_ERROR("thread manager error: " - "failed to allocate aux stack space for new thread"); - goto fail2; - } - + if (is_aux_stack_allocated) { /* Set aux stack for current thread */ if (!wasm_exec_env_set_aux_stack(new_exec_env, aux_stack_start, aux_stack_size)) { - goto fail3; + goto fail2; } + new_exec_env->is_aux_stack_allocated = true; } else { /* Disable aux stack */ new_exec_env->aux_stack_boundary.boundary = 0; new_exec_env->aux_stack_bottom.bottom = UINT32_MAX; + new_exec_env->is_aux_stack_allocated = false; } /* Inherit suspend_flags of parent thread */ - new_exec_env->suspend_flags.flags = exec_env->suspend_flags.flags; + new_exec_env->suspend_flags.flags = + (exec_env->suspend_flags.flags & WASM_SUSPEND_FLAG_INHERIT_MASK); if (!wasm_cluster_add_exec_env(cluster, new_exec_env)) - goto fail3; + goto fail2; new_exec_env->thread_start_routine = thread_routine; new_exec_env->thread_arg = arg; @@ -705,7 +752,7 @@ wasm_cluster_create_thread(WASMExecEnv *exec_env, (void *)new_exec_env, APP_THREAD_STACK_SIZE_DEFAULT)) { os_mutex_unlock(&new_exec_env->wait_lock); - goto fail4; + goto fail3; } /* Wait until the new_exec_env->handle is set to avoid it is @@ -717,12 +764,8 @@ wasm_cluster_create_thread(WASMExecEnv *exec_env, return 0; -fail4: - wasm_cluster_del_exec_env_internal(cluster, new_exec_env, false); fail3: - /* free the allocated aux stack space */ - if (alloc_aux_stack) - free_aux_stack(exec_env, aux_stack_start); + wasm_cluster_del_exec_env_internal(cluster, new_exec_env, false); fail2: wasm_exec_env_destroy_internal(new_exec_env); fail1: @@ -737,7 +780,7 @@ wasm_cluster_dup_c_api_imports(WASMModuleInstanceCommon *module_inst_dst, { /* workaround about passing instantiate-linking information */ CApiFuncImport **new_c_api_func_imports = NULL; - CApiFuncImport *c_api_func_imports; + CApiFuncImport *c_api_func_imports = NULL; uint32 import_func_count = 0; uint32 size_in_bytes = 0; @@ -1013,6 +1056,9 @@ wasm_cluster_exit_thread(WASMExecEnv *exec_env, void *retval) wasm_cluster_thread_exited(exec_env); #endif + /* Free aux stack space */ + wasm_cluster_free_aux_stack(exec_env, exec_env->aux_stack_bottom.bottom); + /* App exit the thread, free the resources before exit native thread */ os_mutex_lock(&cluster_list_lock); @@ -1031,8 +1077,6 @@ wasm_cluster_exit_thread(WASMExecEnv *exec_env, void *retval) module_inst = exec_env->module_inst; - /* Free aux stack space */ - free_aux_stack(exec_env, exec_env->aux_stack_bottom.bottom); /* Remove exec_env */ wasm_cluster_del_exec_env_internal(cluster, exec_env, false); /* Destroy exec_env */ @@ -1297,6 +1341,29 @@ wasm_cluster_set_exception(WASMExecEnv *exec_env, const char *exception) data.exception = exception; os_mutex_lock(&cluster->lock); +#if WASM_ENABLE_DUMP_CALL_STACK != 0 + if (has_exception) { + /* Save the stack frames of the crashed thread into the cluster */ + WASMModuleInstance *module_inst = + (WASMModuleInstance *)get_module_inst(exec_env); + +#if WASM_ENABLE_INTERP != 0 + if (module_inst->module_type == Wasm_Module_Bytecode + && wasm_interp_create_call_stack(exec_env)) { + wasm_frame_vec_clone_internal(module_inst->frames, + &cluster->exception_frames); + } +#endif + +#if WASM_ENABLE_AOT != 0 + if (module_inst->module_type == Wasm_Module_AoT + && aot_create_call_stack(exec_env)) { + wasm_frame_vec_clone_internal(module_inst->frames, + &cluster->exception_frames); + } +#endif + } +#endif /* WASM_ENABLE_DUMP_CALL_STACK != 0 */ cluster->has_exception = has_exception; traverse_list(&cluster->exec_env_list, set_exception_visitor, &data); os_mutex_unlock(&cluster->lock); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/thread_manager.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/thread_manager.h similarity index 90% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/thread_manager.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/thread_manager.h index b95f434ae0d..06d20883648 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/thread_manager.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/thread_manager.h @@ -51,6 +51,13 @@ struct WASMCluster { #if WASM_ENABLE_DEBUG_INTERP != 0 WASMDebugInstance *debug_inst; #endif + +#if WASM_ENABLE_DUMP_CALL_STACK != 0 + /* When an exception occurs in a thread, the stack frames of that thread are + * saved into the cluster + */ + Vector exception_frames; +#endif }; void @@ -81,7 +88,9 @@ wasm_cluster_dup_c_api_imports(WASMModuleInstanceCommon *module_inst_dst, int32 wasm_cluster_create_thread(WASMExecEnv *exec_env, - wasm_module_inst_t module_inst, bool alloc_aux_stack, + wasm_module_inst_t module_inst, + bool is_aux_stack_allocated, uint32 aux_stack_start, + uint32 aux_stack_size, void *(*thread_routine)(void *), void *arg); int32 @@ -221,6 +230,13 @@ wasm_cluster_traverse_lock(WASMExecEnv *exec_env); void wasm_cluster_traverse_unlock(WASMExecEnv *exec_env); +bool +wasm_cluster_allocate_aux_stack(WASMExecEnv *exec_env, uint32 *p_start, + uint32 *p_size); + +bool +wasm_cluster_free_aux_stack(WASMExecEnv *exec_env, uint32 start); + #ifdef __cplusplus } #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/thread_mgr.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/thread_mgr.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/thread-mgr/thread_mgr.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/thread-mgr/thread_mgr.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/cmake/iwasm_helper.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/cmake/iwasm_helper.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/cmake/iwasm_helper.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/cmake/iwasm_helper.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/cmake/wasi_nn.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/external/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/external/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/external/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/external/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/external/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/external/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/external/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/external/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/include/wasi_nn.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/include/wasi_nn.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/include/wasi_nn.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/include/wasi_nn.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/include/wasi_nn_types.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/utils/logger.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/utils/logger.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/utils/logger.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/utils/logger.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/utils/wasi_nn_app_native.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/wasi_nn.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/wasi_nn.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/wasi_nn.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/wasi_nn.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/wasi_nn_private.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.hpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.compile b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.compile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.compile rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.compile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.cpu b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.cpu similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.cpu rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.cpu diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.nvidia-gpu b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.nvidia-gpu similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.nvidia-gpu rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.nvidia-gpu diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.tpu b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.tpu similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.tpu rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.tpu diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.vx-delegate b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.vx-delegate similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/Dockerfile.vx-delegate rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/Dockerfile.vx-delegate diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/average.py b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/average.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/average.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/average.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/max.py b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/max.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/max.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/max.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/mult_dimension.py b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/mult_dimension.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/mult_dimension.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/mult_dimension.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/mult_outputs.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/quantized.py b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/quantized.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/quantized.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/quantized.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/sum.py b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/sum.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/sum.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/sum.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/utils.py b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/utils.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/models/utils.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/models/utils.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/requirements.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/requirements.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/requirements.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/requirements.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/test_tensorflow.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/test_tensorflow.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/test_tensorflow.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/test_tensorflow.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/test_tensorflow_quantized.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/test_tensorflow_quantized.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/test_tensorflow_quantized.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/test_tensorflow_quantized.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/utils.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/utils.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/utils.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/utils.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/utils.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/utils.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/libraries/wasi-nn/test/utils.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/iwasm/libraries/wasi-nn/test/utils.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/coap/er-coap/LICENSE.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/coap/er-coap/LICENSE.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/coap/er-coap/LICENSE.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/coap/er-coap/LICENSE.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/coap/er-coap/coap-constants.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/coap/er-coap/coap-constants.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/coap/er-coap/coap-constants.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/coap/er-coap/coap-constants.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/coap/extension/coap_ext.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/coap/extension/coap_ext.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/coap/extension/coap_ext.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/coap/extension/coap_ext.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/coap/lib_coap.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/coap/lib_coap.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/coap/lib_coap.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/coap/lib_coap.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_alloc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_alloc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_alloc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_alloc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_gc.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_gc.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_gc.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_gc.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_gc_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_gc_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_gc_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_gc_internal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_hmu.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_hmu.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_hmu.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_hmu.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_kfc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_kfc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/ems/ems_kfc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/ems/ems_kfc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/mem_alloc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/mem_alloc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/mem_alloc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/mem_alloc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/mem_alloc.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/mem_alloc.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/mem_alloc.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/mem_alloc.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/mem_alloc.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/mem_alloc.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/mem-alloc/mem_alloc.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/mem-alloc/mem_alloc.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/alios_platform.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/alios_platform.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/alios_platform.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/alios_platform.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/alios_thread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/alios_thread.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/alios_thread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/alios_thread.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/alios_time.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/alios_time.c similarity index 60% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/alios_time.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/alios_time.c index 549252738c1..fb09623a65e 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/alios_time.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/alios_time.c @@ -6,7 +6,14 @@ #include "platform_api_vmcore.h" uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { return (uint64)aos_now_ms() * 1000; } + +uint64 +os_time_thread_cputime_us(void) +{ + /* FIXME if u know the right api */ + return os_time_get_boot_us(); +} \ No newline at end of file diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/platform_internal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/alios/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/alios/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/android/platform_init.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/android/platform_init.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/android/platform_init.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/android/platform_init.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/android/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/android/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/android/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/android/platform_internal.h index 42e4e726c40..4449f21e87d 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/android/platform_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/android/platform_internal.h @@ -80,8 +80,6 @@ typedef jmp_buf korp_jmpbuf; #define os_longjmp longjmp #define os_alloca alloca -#define os_getpagesize getpagesize - typedef void (*os_signal_handler)(void *sig_addr); int @@ -101,6 +99,8 @@ os_sigreturn(); #endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64/RISCV64 */ #endif /* end of WASM_DISABLE_HW_BOUND_CHECK */ +#define os_getpagesize getpagesize + typedef long int __syscall_slong_t; #if __ANDROID_API__ < 19 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/android/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/android/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/android/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/android/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/freertos_malloc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/freertos_malloc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/freertos_malloc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/freertos_malloc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/freertos_thread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/freertos_thread.c similarity index 93% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/freertos_thread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/freertos_thread.c index 9f68bc8f92c..8d57fda531b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/freertos_thread.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/freertos_thread.c @@ -204,8 +204,7 @@ os_thread_wrapper(void *arg) thread_data_list_add(thread_data); thread_data->start_routine(thread_data->arg); - os_thread_cleanup(); - vTaskDelete(NULL); + os_thread_exit(NULL); } int @@ -301,6 +300,22 @@ os_thread_join(korp_tid thread, void **value_ptr) return BHT_OK; } +int +os_thread_detach(korp_tid thread) +{ + /* Do nothing */ + (void)thread; + return BHT_OK; +} + +void +os_thread_exit(void *retval) +{ + (void)retval; + os_thread_cleanup(); + vTaskDelete(NULL); +} + int os_mutex_init(korp_mutex *mutex) { @@ -452,3 +467,33 @@ os_cond_signal(korp_cond *cond) return BHT_OK; } + +int +os_cond_broadcast(korp_cond *cond) +{ + /* Signal all of the wait node of wait list */ + xSemaphoreTake(cond->wait_list_lock, portMAX_DELAY); + if (cond->thread_wait_list) { + os_thread_wait_node *p = cond->thread_wait_list; + while (p) { + xSemaphoreGive(p->sem); + p = p->next; + } + } + xSemaphoreGive(cond->wait_list_lock); + + return BHT_OK; +} + +uint8 * +os_thread_get_stack_boundary() +{ + /* TODO: get freertos stack boundary */ + return NULL; +} + +void +os_thread_jit_write_protect_np(bool enabled) +{ + (void)enabled; +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/freertos_time.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/freertos_time.c similarity index 66% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/freertos_time.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/freertos_time.c index 4497d8c6ce1..e8249fec196 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/freertos_time.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/freertos_time.c @@ -6,8 +6,15 @@ #include "platform_api_vmcore.h" uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { TickType_t ticks = xTaskGetTickCount(); return (uint64)1000 * 1000 / configTICK_RATE_HZ * ticks; } + +uint64 +os_time_thread_cputime_us(void) +{ + /* FIXME if u know the right api */ + return os_time_get_boot_us(); +} \ No newline at end of file diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/platform_api_freertos.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/platform_api_freertos.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/freertos/platform_api_freertos.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/freertos/platform_api_freertos.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/libc-util/libc_errno.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/libc-util/libc_errno.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/libc-util/libc_errno.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/libc-util/libc_errno.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/libc-util/libc_errno.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/libc-util/libc_errno.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/libc-util/libc_errno.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/libc-util/libc_errno.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/libc-util/platform_common_libc_util.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/libc-util/platform_common_libc_util.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/libc-util/platform_common_libc_util.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/libc-util/platform_common_libc_util.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/math/COPYRIGHT b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/math/COPYRIGHT similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/math/COPYRIGHT rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/math/COPYRIGHT diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/math/math.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/math/math.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/math/math.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/math/math.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/math/platform_api_math.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/math/platform_api_math.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/math/platform_api_math.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/math/platform_api_math.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/platform_api_posix.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/platform_api_posix.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/platform_api_posix.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/platform_api_posix.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_blocking_op.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_blocking_op.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_blocking_op.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_blocking_op.c index 560828a06eb..e56f84cf1d7 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_blocking_op.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_blocking_op.c @@ -15,6 +15,7 @@ static void blocking_op_sighandler(int signo) { /* nothing */ + (void)signo; } void diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_clock.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_clock.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_clock.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_clock.c index 280306c422c..41413211cbb 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_clock.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_clock.c @@ -73,6 +73,8 @@ os_clock_time_get(__wasi_clockid_t clock_id, __wasi_timestamp_t precision, clockid_t nclock_id; __wasi_errno_t error = wasi_clockid_to_clockid(clock_id, &nclock_id); + (void)precision; + if (error != __WASI_ESUCCESS) return error; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_file.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_file.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_file.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_file.c index 8c4f7aa9d24..87ce0e2ee1d 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_file.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_file.c @@ -25,12 +25,14 @@ * For NuttX, CONFIG_HAS_ISATTY is provided by its platform header. * (platform_internal.h) */ +#if !defined(CONFIG_HAS_D_INO) #if !defined(__NuttX__) #define CONFIG_HAS_D_INO 1 #define CONFIG_HAS_ISATTY 1 #else #define CONFIG_HAS_D_INO 0 #endif +#endif #if !defined(__APPLE__) && !defined(ESP_PLATFORM) && !defined(__COSMOPOLITAN__) #define CONFIG_HAS_POSIX_FALLOCATE 1 @@ -382,7 +384,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags, // Linux returns ENXIO instead of EOPNOTSUPP when opening a socket. if (openat_errno == ENXIO) { struct stat sb; - int ret = fstatat(fd, path, &sb, + int ret = fstatat(handle, path, &sb, (lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW) ? 0 : AT_SYMLINK_NOFOLLOW); @@ -394,7 +396,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags, if (openat_errno == ENOTDIR && (open_flags & (O_NOFOLLOW | O_DIRECTORY)) != 0) { struct stat sb; - int ret = fstatat(fd, path, &sb, AT_SYMLINK_NOFOLLOW); + int ret = fstatat(handle, path, &sb, AT_SYMLINK_NOFOLLOW); if (S_ISLNK(sb.st_mode)) { return __WASI_ELOOP; } @@ -918,7 +920,12 @@ os_readdir(os_dir_stream dir_stream, __wasi_dirent_t *entry, if (dent == NULL) { *d_name = NULL; - return convert_errno(errno); + if (errno != 0) { + return convert_errno(errno); + } + else { + return 0; + } } long offset = (__wasi_dircookie_t)telldir(dir_stream); @@ -1004,4 +1011,4 @@ char * os_realpath(const char *path, char *resolved_path) { return realpath(path, resolved_path); -} \ No newline at end of file +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_malloc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_malloc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_malloc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_malloc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_memmap.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_memmap.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_memmap.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_memmap.c index 583557bb855..2baf5aeb7ed 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_memmap.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_memmap.c @@ -5,8 +5,9 @@ #include "platform_api_vmcore.h" -#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__) +#if defined(__APPLE__) || defined(__MACH__) #include +#include #endif #ifndef BH_ENABLE_TRACE_MMAP @@ -40,7 +41,8 @@ void * os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) { int map_prot = PROT_NONE; -#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__) +#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__) \ + && defined(TARGET_OS_OSX) && TARGET_OS_OSX != 0 int map_flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_JIT; #else int map_flags = MAP_ANONYMOUS | MAP_PRIVATE; @@ -263,7 +265,10 @@ os_dcache_flush(void) void os_icache_flush(void *start, size_t len) { -#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__) +#if defined(__APPLE__) || defined(__MACH__) sys_icache_invalidate(start, len); +#else + (void)start; + (void)len; #endif } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_sleep.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_sleep.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_sleep.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_sleep.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_socket.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_socket.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_socket.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_socket.c index 7bdcb529e61..0293b08d86d 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_socket.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_socket.c @@ -884,7 +884,7 @@ os_socket_set_ip_ttl(bh_socket_t socket, uint8_t ttl_s) int os_socket_get_ip_ttl(bh_socket_t socket, uint8_t *ttl_s) { - socklen_t opt_len = sizeof(ttl_s); + socklen_t opt_len = sizeof(*ttl_s); if (getsockopt(socket, IPPROTO_IP, IP_TTL, ttl_s, &opt_len) != 0) { return BHT_ERROR; } @@ -906,7 +906,7 @@ os_socket_set_ip_multicast_ttl(bh_socket_t socket, uint8_t ttl_s) int os_socket_get_ip_multicast_ttl(bh_socket_t socket, uint8_t *ttl_s) { - socklen_t opt_len = sizeof(ttl_s); + socklen_t opt_len = sizeof(*ttl_s); if (getsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, ttl_s, &opt_len) != 0) { return BHT_ERROR; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_thread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_thread.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_thread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_thread.c index 616420c948c..1195d80eba4 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_thread.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_thread.c @@ -9,6 +9,10 @@ #include "platform_api_vmcore.h" #include "platform_api_extension.h" +#if defined(__APPLE__) || defined(__MACH__) +#include +#endif + typedef struct { thread_start_routine_t start; void *arg; @@ -476,7 +480,8 @@ os_thread_get_stack_boundary() void os_thread_jit_write_protect_np(bool enabled) { -#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__) +#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__) \ + && defined(TARGET_OS_OSX) && TARGET_OS_OSX != 0 pthread_jit_write_protect_np(enabled); #endif } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_time.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_time.c similarity index 58% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_time.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_time.c index bcf5ca3ce55..8c339aba27c 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/common/posix/posix_time.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/common/posix/posix_time.c @@ -6,7 +6,7 @@ #include "platform_api_vmcore.h" uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { @@ -15,3 +15,14 @@ os_time_get_boot_microsecond() return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000; } + +uint64 +os_time_thread_cputime_us() +{ + struct timespec ts; + if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0) { + return 0; + } + + return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000; +} \ No newline at end of file diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/cosmopolitan/platform_init.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/cosmopolitan/platform_init.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/cosmopolitan/platform_init.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/cosmopolitan/platform_init.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/cosmopolitan/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/cosmopolitan/platform_internal.h similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/cosmopolitan/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/cosmopolitan/platform_internal.h index 02cd78be496..72602116062 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/cosmopolitan/platform_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/cosmopolitan/platform_internal.h @@ -55,6 +55,7 @@ typedef pthread_t korp_tid; typedef pthread_mutex_t korp_mutex; typedef pthread_cond_t korp_cond; typedef pthread_t korp_thread; +typedef pthread_rwlock_t korp_rwlock; typedef sem_t korp_sem; #define OS_THREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER @@ -67,6 +68,12 @@ typedef int os_file_handle; typedef DIR *os_dir_stream; typedef int os_raw_file_handle; +static inline os_file_handle +os_get_invalid_handle() +{ + return -1; +} + #if WASM_DISABLE_WRITE_GS_BASE == 0 #if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) #define os_writegsbase(base_addr) \ @@ -98,8 +105,6 @@ typedef jmp_buf korp_jmpbuf; #define os_longjmp longjmp #define os_alloca alloca -#define os_getpagesize getpagesize - typedef void (*os_signal_handler)(void *sig_addr); int @@ -119,6 +124,8 @@ os_sigreturn(); #endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64/RISCV64 */ #endif /* end of WASM_DISABLE_HW_BOUND_CHECK */ +#define os_getpagesize getpagesize + #ifdef __cplusplus } #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/cosmopolitan/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/cosmopolitan/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/cosmopolitan/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/cosmopolitan/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/darwin/platform_init.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/darwin/platform_init.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/darwin/platform_init.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/darwin/platform_init.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/darwin/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/darwin/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/darwin/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/darwin/platform_internal.h index 30b89624e99..1cbecdc205b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/darwin/platform_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/darwin/platform_internal.h @@ -82,8 +82,6 @@ typedef jmp_buf korp_jmpbuf; #define os_longjmp longjmp #define os_alloca alloca -#define os_getpagesize getpagesize - typedef void (*os_signal_handler)(void *sig_addr); int @@ -103,6 +101,8 @@ os_sigreturn(); #endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64/RISCV64 */ #endif /* end of WASM_DISABLE_HW_BOUND_CHECK */ +#define os_getpagesize getpagesize + #if WASM_DISABLE_WAKEUP_BLOCKING_OP == 0 #define OS_ENABLE_WAKEUP_BLOCKING_OP #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/darwin/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/darwin/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/darwin/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/darwin/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/ego/platform_init.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/ego/platform_init.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/ego/platform_init.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/ego/platform_init.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/ego/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/ego/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/ego/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/ego/platform_internal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/ego/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/ego/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/ego/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/ego/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_clock.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_clock.c new file mode 100644 index 00000000000..41413211cbb --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_clock.c @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2023 Amazon Inc. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include "libc_errno.h" +#include "platform_api_extension.h" + +#define NANOSECONDS_PER_SECOND 1000000000ULL + +static __wasi_errno_t +wasi_clockid_to_clockid(__wasi_clockid_t in, clockid_t *out) +{ + switch (in) { + case __WASI_CLOCK_MONOTONIC: + *out = CLOCK_MONOTONIC; + return __WASI_ESUCCESS; + case __WASI_CLOCK_REALTIME: + *out = CLOCK_REALTIME; + return __WASI_ESUCCESS; + case __WASI_CLOCK_PROCESS_CPUTIME_ID: +#if defined(CLOCK_PROCESS_CPUTIME_ID) + *out = CLOCK_PROCESS_CPUTIME_ID; + return __WASI_ESUCCESS; +#else + return __WASI_ENOTSUP; +#endif + case __WASI_CLOCK_THREAD_CPUTIME_ID: +#if defined(CLOCK_THREAD_CPUTIME_ID) + *out = CLOCK_THREAD_CPUTIME_ID; + return __WASI_ESUCCESS; +#else + return __WASI_ENOTSUP; +#endif + default: + return __WASI_EINVAL; + } +} + +static __wasi_timestamp_t +timespec_to_nanoseconds(const struct timespec *ts) +{ + if (ts->tv_sec < 0) + return 0; + if ((__wasi_timestamp_t)ts->tv_sec >= UINT64_MAX / NANOSECONDS_PER_SECOND) + return UINT64_MAX; + return (__wasi_timestamp_t)ts->tv_sec * NANOSECONDS_PER_SECOND + + (__wasi_timestamp_t)ts->tv_nsec; +} + +__wasi_errno_t +os_clock_res_get(__wasi_clockid_t clock_id, __wasi_timestamp_t *resolution) +{ + clockid_t nclock_id; + __wasi_errno_t error = wasi_clockid_to_clockid(clock_id, &nclock_id); + + if (error != __WASI_ESUCCESS) + return error; + + struct timespec ts; + if (clock_getres(nclock_id, &ts) < 0) + return convert_errno(errno); + + *resolution = timespec_to_nanoseconds(&ts); + + return error; +} + +__wasi_errno_t +os_clock_time_get(__wasi_clockid_t clock_id, __wasi_timestamp_t precision, + __wasi_timestamp_t *time) +{ + clockid_t nclock_id; + __wasi_errno_t error = wasi_clockid_to_clockid(clock_id, &nclock_id); + + (void)precision; + + if (error != __WASI_ESUCCESS) + return error; + + struct timespec ts; + if (clock_gettime(nclock_id, &ts) < 0) + return convert_errno(errno); + + *time = timespec_to_nanoseconds(&ts); + + return error; +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_file.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_file.c new file mode 100644 index 00000000000..8e53da8b62e --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_file.c @@ -0,0 +1,1009 @@ +/* + * Copyright (C) 2023 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include "platform_api_extension.h" +#include "libc_errno.h" +#include + +#if !defined(__APPLE__) && !defined(ESP_PLATFORM) +#define CONFIG_HAS_PWRITEV 1 +#define CONFIG_HAS_PREADV 1 +#else +#define CONFIG_HAS_PWRITEV 0 +#define CONFIG_HAS_PREADV 0 +#endif + +#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(ESP_PLATFORM) +#define CONFIG_HAS_FDATASYNC 1 +#else +#define CONFIG_HAS_FDATASYNC 0 +#endif + +/* + * For NuttX, CONFIG_HAS_ISATTY is provided by its platform header. + * (platform_internal.h) + */ +#if !defined(CONFIG_HAS_D_INO) +#if !defined(__NuttX__) +#define CONFIG_HAS_D_INO 1 +#define CONFIG_HAS_ISATTY 1 +#else +#define CONFIG_HAS_D_INO 0 +#endif +#endif + +#if !defined(__APPLE__) && !defined(ESP_PLATFORM) && !defined(__COSMOPOLITAN__) +#define CONFIG_HAS_POSIX_FALLOCATE 1 +#else +#define CONFIG_HAS_POSIX_FALLOCATE 0 +#endif + +#if defined(O_DSYNC) +#define CONFIG_HAS_O_DSYNC +#endif + +// POSIX requires O_RSYNC to be defined, but Linux explicitly doesn't support +// it. +#if defined(O_RSYNC) && !defined(__linux__) +#define CONFIG_HAS_O_RSYNC +#endif + +#if defined(O_SYNC) +#define CONFIG_HAS_O_SYNC +#endif + +// Converts a POSIX timespec to a WASI timestamp. +static __wasi_timestamp_t +convert_timespec(const struct timespec *ts) +{ + if (ts->tv_sec < 0) + return 0; + if ((__wasi_timestamp_t)ts->tv_sec >= UINT64_MAX / 1000000000) + return UINT64_MAX; + return (__wasi_timestamp_t)ts->tv_sec * 1000000000 + + (__wasi_timestamp_t)ts->tv_nsec; +} + +// Converts a POSIX stat structure to a WASI filestat structure +static void +convert_stat(os_file_handle handle, const struct stat *in, + __wasi_filestat_t *out) +{ + out->st_dev = in->st_dev; + out->st_ino = in->st_ino; + out->st_nlink = (__wasi_linkcount_t)in->st_nlink; + out->st_size = (__wasi_filesize_t)in->st_size; +#ifdef __APPLE__ + out->st_atim = convert_timespec(&in->st_atimespec); + out->st_mtim = convert_timespec(&in->st_mtimespec); + out->st_ctim = convert_timespec(&in->st_ctimespec); +#else + out->st_atim = convert_timespec(&in->st_atim); + out->st_mtim = convert_timespec(&in->st_mtim); + out->st_ctim = convert_timespec(&in->st_ctim); +#endif + + // Convert the file type. In the case of sockets there is no way we + // can easily determine the exact socket type. + if (S_ISBLK(in->st_mode)) { + out->st_filetype = __WASI_FILETYPE_BLOCK_DEVICE; + } + else if (S_ISCHR(in->st_mode)) { + out->st_filetype = __WASI_FILETYPE_CHARACTER_DEVICE; + } + else if (S_ISDIR(in->st_mode)) { + out->st_filetype = __WASI_FILETYPE_DIRECTORY; + } + else if (S_ISFIFO(in->st_mode)) { + out->st_filetype = __WASI_FILETYPE_SOCKET_STREAM; + } + else if (S_ISLNK(in->st_mode)) { + out->st_filetype = __WASI_FILETYPE_SYMBOLIC_LINK; + } + else if (S_ISREG(in->st_mode)) { + out->st_filetype = __WASI_FILETYPE_REGULAR_FILE; + } + else if (S_ISSOCK(in->st_mode)) { + int socktype; + socklen_t socktypelen = sizeof(socktype); + + if (getsockopt(handle, SOL_SOCKET, SO_TYPE, &socktype, &socktypelen) + < 0) { + out->st_filetype = __WASI_FILETYPE_UNKNOWN; + return; + } + + switch (socktype) { + case SOCK_DGRAM: + out->st_filetype = __WASI_FILETYPE_SOCKET_DGRAM; + break; + case SOCK_STREAM: + out->st_filetype = __WASI_FILETYPE_SOCKET_STREAM; + break; + default: + out->st_filetype = __WASI_FILETYPE_UNKNOWN; + return; + } + } + else { + out->st_filetype = __WASI_FILETYPE_UNKNOWN; + } +} + +static void +convert_timestamp(__wasi_timestamp_t in, struct timespec *out) +{ + // Store sub-second remainder. +#if defined(__SYSCALL_SLONG_TYPE) + out->tv_nsec = (__SYSCALL_SLONG_TYPE)(in % 1000000000); +#else + out->tv_nsec = (long)(in % 1000000000); +#endif + in /= 1000000000; + + // Clamp to the maximum in case it would overflow our system's time_t. + out->tv_sec = (time_t)in < BH_TIME_T_MAX ? (time_t)in : BH_TIME_T_MAX; +} + +// Converts the provided timestamps and flags to a set of arguments for +// futimens() and utimensat(). +static void +convert_utimens_arguments(__wasi_timestamp_t st_atim, + __wasi_timestamp_t st_mtim, + __wasi_fstflags_t fstflags, struct timespec *ts) +{ + if ((fstflags & __WASI_FILESTAT_SET_ATIM_NOW) != 0) { + ts[0].tv_nsec = UTIME_NOW; + } + else if ((fstflags & __WASI_FILESTAT_SET_ATIM) != 0) { + convert_timestamp(st_atim, &ts[0]); + } + else { + ts[0].tv_nsec = UTIME_OMIT; + } + + if ((fstflags & __WASI_FILESTAT_SET_MTIM_NOW) != 0) { + ts[1].tv_nsec = UTIME_NOW; + } + else if ((fstflags & __WASI_FILESTAT_SET_MTIM) != 0) { + convert_timestamp(st_mtim, &ts[1]); + } + else { + ts[1].tv_nsec = UTIME_OMIT; + } +} + +__wasi_errno_t +os_fstat(os_file_handle handle, struct __wasi_filestat_t *buf) +{ + struct stat stat_buf; + int ret = fstat(handle, &stat_buf); + + if (ret < 0) + return convert_errno(errno); + + convert_stat(handle, &stat_buf, buf); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_fstatat(os_file_handle handle, const char *path, + struct __wasi_filestat_t *buf, __wasi_lookupflags_t lookup_flags) +{ + struct stat stat_buf; + int ret = fstatat(handle, path, &stat_buf, + (lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW) + ? AT_SYMLINK_FOLLOW + : AT_SYMLINK_NOFOLLOW); + + if (ret < 0) + return convert_errno(errno); + + convert_stat(handle, &stat_buf, buf); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_file_get_fdflags(os_file_handle handle, __wasi_fdflags_t *flags) +{ + int ret = fcntl(handle, F_GETFL); + + if (ret < 0) + return convert_errno(errno); + + *flags = 0; + + if ((ret & O_APPEND) != 0) + *flags |= __WASI_FDFLAG_APPEND; +#ifdef CONFIG_HAS_O_DSYNC + if ((ret & O_DSYNC) != 0) + *flags |= __WASI_FDFLAG_DSYNC; +#endif + if ((ret & O_NONBLOCK) != 0) + *flags |= __WASI_FDFLAG_NONBLOCK; +#ifdef CONFIG_HAS_O_RSYNC + if ((ret & O_RSYNC) != 0) + *flags |= __WASI_FDFLAG_RSYNC; +#endif +#ifdef CONFIG_HAS_O_SYNC + if ((ret & O_SYNC) != 0) + *flags |= __WASI_FDFLAG_SYNC; +#endif + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_file_set_fdflags(os_file_handle handle, __wasi_fdflags_t flags) +{ + int fcntl_flags = 0; + + if ((flags & __WASI_FDFLAG_APPEND) != 0) + fcntl_flags |= O_APPEND; + if ((flags & __WASI_FDFLAG_DSYNC) != 0) +#ifdef CONFIG_HAS_O_DSYNC + fcntl_flags |= O_DSYNC; +#else + return __WASI_ENOTSUP; +#endif + if ((flags & __WASI_FDFLAG_NONBLOCK) != 0) + fcntl_flags |= O_NONBLOCK; + if ((flags & __WASI_FDFLAG_RSYNC) != 0) +#ifdef CONFIG_HAS_O_RSYNC + fcntl_flags |= O_RSYNC; +#else + return __WASI_ENOTSUP; +#endif + if ((flags & __WASI_FDFLAG_SYNC) != 0) +#ifdef CONFIG_HAS_O_SYNC + fcntl_flags |= O_SYNC; +#else + return __WASI_ENOTSUP; +#endif + + int ret = fcntl(handle, F_SETFL, fcntl_flags); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_fdatasync(os_file_handle handle) +{ +#if CONFIG_HAS_FDATASYNC + int ret = fdatasync(handle); +#else + int ret = fsync(handle); +#endif + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_fsync(os_file_handle handle) +{ + int ret = fsync(handle); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_open_preopendir(const char *path, os_file_handle *out) +{ + + int fd = open(path, O_RDONLY | O_DIRECTORY, 0); + + if (fd < 0) + return convert_errno(errno); + + *out = fd; + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags, + __wasi_fdflags_t fs_flags, __wasi_lookupflags_t lookup_flags, + wasi_libc_file_access_mode read_write_mode, os_file_handle *out) +{ + int open_flags = 0; + + // Convert open flags. + if ((oflags & __WASI_O_CREAT) != 0) { + open_flags |= O_CREAT; + } + if ((oflags & __WASI_O_DIRECTORY) != 0) + open_flags |= O_DIRECTORY; + if ((oflags & __WASI_O_EXCL) != 0) + open_flags |= O_EXCL; + if ((oflags & __WASI_O_TRUNC) != 0) { + open_flags |= O_TRUNC; + } + + // Convert file descriptor flags. + if ((fs_flags & __WASI_FDFLAG_APPEND) != 0) + open_flags |= O_APPEND; + if ((fs_flags & __WASI_FDFLAG_DSYNC) != 0) { +#ifdef CONFIG_HAS_O_DSYNC + open_flags |= O_DSYNC; +#else + return __WASI_ENOTSUP; +#endif + } + if ((fs_flags & __WASI_FDFLAG_NONBLOCK) != 0) + open_flags |= O_NONBLOCK; + if ((fs_flags & __WASI_FDFLAG_RSYNC) != 0) { +#ifdef CONFIG_HAS_O_RSYNC + open_flags |= O_RSYNC; +#else + return __WASI_ENOTSUP; +#endif + } + if ((fs_flags & __WASI_FDFLAG_SYNC) != 0) { +#ifdef CONFIG_HAS_O_SYNC + open_flags |= O_SYNC; +#else + return __WASI_ENOTSUP; +#endif + } + + if ((lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW) == 0) { + open_flags |= O_NOFOLLOW; + } + + switch (read_write_mode) { + case WASI_LIBC_ACCESS_MODE_READ_WRITE: + open_flags |= O_RDWR; + break; + case WASI_LIBC_ACCESS_MODE_READ_ONLY: + open_flags |= O_RDONLY; + break; + case WASI_LIBC_ACCESS_MODE_WRITE_ONLY: + open_flags |= O_WRONLY; + break; + default: + return __WASI_EINVAL; + } + + int fd = openat(handle, path, open_flags, 0666); + + if (fd < 0) { + int openat_errno = errno; + // Linux returns ENXIO instead of EOPNOTSUPP when opening a socket. + if (openat_errno == ENXIO) { + struct stat sb; + int ret = fstatat(handle, path, &sb, + (lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW) + ? 0 + : AT_SYMLINK_NOFOLLOW); + return ret == 0 && S_ISSOCK(sb.st_mode) ? __WASI_ENOTSUP + : __WASI_ENXIO; + } + // Linux returns ENOTDIR instead of ELOOP when using + // O_NOFOLLOW|O_DIRECTORY on a symlink. + if (openat_errno == ENOTDIR + && (open_flags & (O_NOFOLLOW | O_DIRECTORY)) != 0) { + struct stat sb; + int ret = fstatat(handle, path, &sb, AT_SYMLINK_NOFOLLOW); + if (S_ISLNK(sb.st_mode)) { + return __WASI_ELOOP; + } + (void)ret; + } + // FreeBSD returns EMLINK instead of ELOOP when using O_NOFOLLOW on + // a symlink. + if ((lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW) == 0 + && openat_errno == EMLINK) + return __WASI_ELOOP; + + return convert_errno(openat_errno); + } + + *out = fd; + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_file_get_access_mode(os_file_handle handle, + wasi_libc_file_access_mode *access_mode) +{ + int ret = fcntl(handle, F_GETFL, 0); + + if (ret < 0) + return convert_errno(errno); + + switch (ret & O_ACCMODE) { + case O_RDONLY: + *access_mode = WASI_LIBC_ACCESS_MODE_READ_ONLY; + break; + case O_WRONLY: + *access_mode = WASI_LIBC_ACCESS_MODE_WRITE_ONLY; + break; + case O_RDWR: + *access_mode = WASI_LIBC_ACCESS_MODE_READ_WRITE; + break; + default: + return __WASI_EINVAL; + } + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_close(os_file_handle handle, bool is_stdio) +{ + if (is_stdio) + return __WASI_ESUCCESS; + + int ret = close(handle); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_preadv(os_file_handle handle, const struct __wasi_iovec_t *iov, int iovcnt, + __wasi_filesize_t offset, size_t *nread) +{ +#if CONFIG_HAS_PREADV + ssize_t len = + preadv(handle, (const struct iovec *)iov, (int)iovcnt, (off_t)offset); + if (len < 0) + return convert_errno(errno); + + *nread = (size_t)len; + return __WASI_ESUCCESS; +#else + if (iovcnt == 1) { + ssize_t len = pread(handle, iov->buf, iov->buf_len, offset); + + if (len < 0) + return convert_errno(errno); + + *nread = len; + return __WASI_ESUCCESS; + } + + // Allocate a single buffer to fit all data. + size_t totalsize = 0; + for (int i = 0; i < iovcnt; ++i) + totalsize += iov[i].buf_len; + + char *buf = BH_MALLOC(totalsize); + + if (buf == NULL) { + return __WASI_ENOMEM; + } + + // Perform a single read operation. + ssize_t len = pread(handle, buf, totalsize, offset); + + if (len < 0) { + BH_FREE(buf); + return convert_errno(errno); + } + + // Copy data back to vectors. + size_t bufoff = 0; + for (int i = 0; i < iovcnt; ++i) { + if (bufoff + iov[i].buf_len < (size_t)len) { + memcpy(iov[i].buf, buf + bufoff, iov[i].buf_len); + bufoff += iov[i].buf_len; + } + else { + memcpy(iov[i].buf, buf + bufoff, len - bufoff); + break; + } + } + BH_FREE(buf); + *nread = len; + + return __WASI_ESUCCESS; +#endif +} + +__wasi_errno_t +os_pwritev(os_file_handle handle, const struct __wasi_ciovec_t *iov, int iovcnt, + __wasi_filesize_t offset, size_t *nwritten) +{ + if (iovcnt == 0) + return __WASI_EINVAL; + + ssize_t len = 0; +#if CONFIG_HAS_PWRITEV + len = + pwritev(handle, (const struct iovec *)iov, (int)iovcnt, (off_t)offset); +#else + if (iovcnt == 1) { + len = pwrite(handle, iov->buf, iov->buf_len, offset); + } + else { + // Allocate a single buffer to fit all data. + size_t totalsize = 0; + for (int i = 0; i < iovcnt; ++i) + totalsize += iov[i].buf_len; + char *buf = BH_MALLOC(totalsize); + if (buf == NULL) { + return __WASI_ENOMEM; + } + size_t bufoff = 0; + for (int i = 0; i < iovcnt; ++i) { + memcpy(buf + bufoff, iov[i].buf, iov[i].buf_len); + bufoff += iov[i].buf_len; + } + + // Perform a single write operation. + len = pwrite(handle, buf, totalsize, offset); + BH_FREE(buf); + } +#endif + if (len < 0) + return convert_errno(errno); + + *nwritten = (size_t)len; + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_readv(os_file_handle handle, const struct __wasi_iovec_t *iov, int iovcnt, + size_t *nread) +{ + ssize_t len = readv(handle, (const struct iovec *)iov, (int)iovcnt); + + if (len < 0) + return convert_errno(errno); + + *nread = (size_t)len; + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_writev(os_file_handle handle, const struct __wasi_ciovec_t *iov, int iovcnt, + size_t *nwritten) +{ + ssize_t len = writev(handle, (const struct iovec *)iov, (int)iovcnt); + + if (len < 0) + return convert_errno(errno); + + *nwritten = (size_t)len; + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_fallocate(os_file_handle handle, __wasi_filesize_t offset, + __wasi_filesize_t length) +{ +#if CONFIG_HAS_POSIX_FALLOCATE + int ret = posix_fallocate(handle, (off_t)offset, (off_t)length); +#else + // At least ensure that the file is grown to the right size. + // TODO(ed): See if this can somehow be implemented without any race + // conditions. We may end up shrinking the file right now. + struct stat sb; + int ret = fstat(handle, &sb); + off_t newsize = (off_t)(offset + length); + + if (ret == 0 && sb.st_size < newsize) + ret = ftruncate(handle, newsize); +#endif + + if (ret != 0) + return convert_errno(ret); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_ftruncate(os_file_handle handle, __wasi_filesize_t size) +{ + int ret = ftruncate(handle, (off_t)size); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_futimens(os_file_handle handle, __wasi_timestamp_t access_time, + __wasi_timestamp_t modification_time, __wasi_fstflags_t fstflags) +{ + struct timespec ts[2]; + convert_utimens_arguments(access_time, modification_time, fstflags, ts); + + int ret = futimens(handle, ts); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_utimensat(os_file_handle handle, const char *path, + __wasi_timestamp_t access_time, + __wasi_timestamp_t modification_time, __wasi_fstflags_t fstflags, + __wasi_lookupflags_t lookup_flags) +{ + struct timespec ts[2]; + convert_utimens_arguments(access_time, modification_time, fstflags, ts); + + int ret = utimensat(handle, path, ts, + (lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW) + ? 0 + : AT_SYMLINK_NOFOLLOW); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_readlinkat(os_file_handle handle, const char *path, char *buf, + size_t bufsize, size_t *nread) +{ + // Linux requires that the buffer size is positive. whereas POSIX does + // not. Use a fake buffer to store the results if the size is zero. + char fakebuf[1]; + ssize_t len = readlinkat(handle, path, bufsize == 0 ? fakebuf : buf, + bufsize == 0 ? sizeof(fakebuf) : bufsize); + + if (len < 0) + return convert_errno(errno); + + *nread = (size_t)len < bufsize ? (size_t)len : bufsize; + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_linkat(os_file_handle from_handle, const char *from_path, + os_file_handle to_handle, const char *to_path, + __wasi_lookupflags_t lookup_flags) +{ + int ret = linkat( + from_handle, from_path, to_handle, to_path, + (lookup_flags & __WASI_LOOKUP_SYMLINK_FOLLOW) ? AT_SYMLINK_FOLLOW : 0); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_symlinkat(const char *old_path, os_file_handle handle, const char *new_path) +{ + int ret = symlinkat(old_path, handle, new_path); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_mkdirat(os_file_handle handle, const char *path) +{ + int ret = mkdirat(handle, path, 0777); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_renameat(os_file_handle old_handle, const char *old_path, + os_file_handle new_handle, const char *new_path) +{ + + int ret = renameat(old_handle, old_path, new_handle, new_path); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_unlinkat(os_file_handle handle, const char *path, bool is_dir) +{ + int ret = unlinkat(handle, path, is_dir ? AT_REMOVEDIR : 0); + +#ifndef __linux__ + if (ret < 0) { + // Non-Linux implementations may return EPERM when attempting to remove + // a directory without REMOVEDIR. While that's what POSIX specifies, + // it's less useful. Adjust this to EISDIR. It doesn't matter that this + // is not atomic with the unlinkat, because if the file is removed and a + // directory is created before fstatat sees it, we're racing with that + // change anyway and unlinkat could have legitimately seen the directory + // if the race had turned out differently. + if (errno == EPERM) { + struct stat statbuf; + if (fstatat(handle, path, &statbuf, AT_SYMLINK_NOFOLLOW) == 0 + && S_ISDIR(statbuf.st_mode)) { + errno = EISDIR; + } + } + // POSIX permits either EEXIST or ENOTEMPTY when the directory is not + // empty. Map it to ENOTEMPTY. + else if (errno == EEXIST) { + errno = ENOTEMPTY; + } + + return convert_errno(errno); + } +#endif + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_lseek(os_file_handle handle, __wasi_filedelta_t offset, + __wasi_whence_t whence, __wasi_filesize_t *new_offset) +{ + int nwhence; + + switch (whence) { + case __WASI_WHENCE_CUR: + nwhence = SEEK_CUR; + break; + case __WASI_WHENCE_END: + nwhence = SEEK_END; + break; + case __WASI_WHENCE_SET: + nwhence = SEEK_SET; + break; + default: + return __WASI_EINVAL; + } + + off_t ret = lseek(handle, offset, nwhence); + + if (ret < 0) + return convert_errno(errno); + + *new_offset = (__wasi_filesize_t)ret; + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_fadvise(os_file_handle handle, __wasi_filesize_t offset, + __wasi_filesize_t length, __wasi_advice_t advice) +{ +#ifdef POSIX_FADV_NORMAL + int nadvice; + switch (advice) { + case __WASI_ADVICE_DONTNEED: + nadvice = POSIX_FADV_DONTNEED; + break; + case __WASI_ADVICE_NOREUSE: + nadvice = POSIX_FADV_NOREUSE; + break; + case __WASI_ADVICE_NORMAL: + nadvice = POSIX_FADV_NORMAL; + break; + case __WASI_ADVICE_RANDOM: + nadvice = POSIX_FADV_RANDOM; + break; + case __WASI_ADVICE_SEQUENTIAL: + nadvice = POSIX_FADV_SEQUENTIAL; + break; + case __WASI_ADVICE_WILLNEED: + nadvice = POSIX_FADV_WILLNEED; + break; + default: + return __WASI_EINVAL; + } + + int ret = posix_fadvise(handle, (off_t)offset, (off_t)length, nadvice); + + if (ret < 0) + return convert_errno(ret); + + return __WASI_ESUCCESS; +#else + // Advisory information can be safely ignored if not supported + switch (advice) { + case __WASI_ADVICE_DONTNEED: + case __WASI_ADVICE_NOREUSE: + case __WASI_ADVICE_NORMAL: + case __WASI_ADVICE_RANDOM: + case __WASI_ADVICE_SEQUENTIAL: + case __WASI_ADVICE_WILLNEED: + return __WASI_ESUCCESS; + default: + return __WASI_EINVAL; + } +#endif +} + +__wasi_errno_t +os_isatty(os_file_handle handle) +{ +#if CONFIG_HAS_ISATTY + int ret = isatty(handle); + + if (ret == 1) + return __WASI_ESUCCESS; + + return __WASI_ENOTTY; +#else + return __WASI_ENOTSUP; +#endif +} + +os_file_handle +os_convert_stdin_handle(os_raw_file_handle raw_stdin) +{ +#ifndef STDIN_FILENO +#define STDIN_FILENO 0 +#endif + return raw_stdin >= 0 ? raw_stdin : STDIN_FILENO; +} + +os_file_handle +os_convert_stdout_handle(os_raw_file_handle raw_stdout) +{ +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + return raw_stdout >= 0 ? raw_stdout : STDOUT_FILENO; +} + +os_file_handle +os_convert_stderr_handle(os_raw_file_handle raw_stderr) +{ +#ifndef STDERR_FILENO +#define STDERR_FILENO 2 +#endif + return raw_stderr >= 0 ? raw_stderr : STDERR_FILENO; +} + +__wasi_errno_t +os_fdopendir(os_file_handle handle, os_dir_stream *dir_stream) +{ + *dir_stream = fdopendir(handle); + + if (*dir_stream == NULL) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_rewinddir(os_dir_stream dir_stream) +{ + rewinddir(dir_stream); + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_seekdir(os_dir_stream dir_stream, __wasi_dircookie_t position) +{ + seekdir(dir_stream, (long)position); + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_readdir(os_dir_stream dir_stream, __wasi_dirent_t *entry, + const char **d_name) +{ + errno = 0; + + struct dirent *dent = readdir(dir_stream); + + if (dent == NULL) { + *d_name = NULL; + return convert_errno(errno); + } + + long offset = (__wasi_dircookie_t)telldir(dir_stream); + + size_t namlen = strlen(dent->d_name); + + *d_name = dent->d_name; + entry->d_next = offset; + entry->d_namlen = (__wasi_dirnamlen_t)namlen; +#if CONFIG_HAS_D_INO + entry->d_ino = dent->d_ino; +#else + entry->d_ino = 0; +#endif + + switch (dent->d_type) { + case DT_BLK: + entry->d_type = __WASI_FILETYPE_BLOCK_DEVICE; + break; + case DT_CHR: + entry->d_type = __WASI_FILETYPE_CHARACTER_DEVICE; + break; + case DT_DIR: + entry->d_type = __WASI_FILETYPE_DIRECTORY; + break; + case DT_FIFO: + entry->d_type = __WASI_FILETYPE_SOCKET_STREAM; + break; + case DT_LNK: + entry->d_type = __WASI_FILETYPE_SYMBOLIC_LINK; + break; + case DT_REG: + entry->d_type = __WASI_FILETYPE_REGULAR_FILE; + break; +#ifdef DT_SOCK + case DT_SOCK: + // Technically not correct, but good enough. + entry->d_type = __WASI_FILETYPE_SOCKET_STREAM; + break; +#endif + default: + entry->d_type = __WASI_FILETYPE_UNKNOWN; + break; + } + + return __WASI_ESUCCESS; +} + +__wasi_errno_t +os_closedir(os_dir_stream dir_stream) +{ + int ret = closedir(dir_stream); + + if (ret < 0) + return convert_errno(errno); + + return __WASI_ESUCCESS; +} + +os_dir_stream +os_get_invalid_dir_stream() +{ + return NULL; +} + +bool +os_is_dir_stream_valid(os_dir_stream *dir_stream) +{ + assert(dir_stream != NULL); + + return *dir_stream != NULL; +} + +bool +os_is_handle_valid(os_file_handle *handle) +{ + assert(handle != NULL); + + return *handle > -1; +} + +char * +os_realpath(const char *path, char *resolved_path) +{ + return realpath(path, resolved_path); +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_malloc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_malloc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_malloc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_malloc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_memmap.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_memmap.c similarity index 74% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_memmap.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_memmap.c index 9f3ec47a6a3..ee155181382 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_memmap.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_memmap.c @@ -9,11 +9,10 @@ #include "soc/mmu.h" #include "rom/cache.h" -#define MEM_DUAL_BUS_OFFSET (IRAM0_CACHE_ADDRESS_LOW - DRAM0_CACHE_ADDRESS_LOW) +#define MEM_DUAL_BUS_OFFSET (SOC_IROM_LOW - SOC_IROM_HIGH) -#define in_ibus_ext(addr) \ - (((uint32)addr >= IRAM0_CACHE_ADDRESS_LOW) \ - && ((uint32)addr < IRAM0_CACHE_ADDRESS_HIGH)) +#define in_ibus_ext(addr) \ + (((uint32)addr >= SOC_IROM_LOW) && ((uint32)addr < SOC_IROM_HIGH)) static portMUX_TYPE s_spinlock = portMUX_INITIALIZER_UNLOCKED; #endif @@ -55,7 +54,24 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) #else uint32_t mem_caps = MALLOC_CAP_8BIT; #endif - return heap_caps_malloc(size, mem_caps); + void *buf_origin = + heap_caps_malloc(size + 4 + sizeof(uintptr_t), mem_caps); + if (!buf_origin) { + return NULL; + } + + // Memory allocation with MALLOC_CAP_SPIRAM or MALLOC_CAP_8BIT will + // return 4-byte aligned Reserve extra 4 byte to fixup alignment and + // size for the pointer to the originally allocated address + void *buf_fixed = buf_origin + sizeof(void *); + if ((uintptr_t)buf_fixed & (uintptr_t)0x7) { + buf_fixed = (void *)((uintptr_t)(buf_fixed + 4) & (~(uintptr_t)7)); + } + + uintptr_t *addr_field = buf_fixed - sizeof(uintptr_t); + *addr_field = (uintptr_t)buf_origin; + + return buf_fixed; } } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_platform.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_platform.c similarity index 76% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_platform.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_platform.c index bbc18f69bf6..670d5bdb243 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_platform.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_platform.c @@ -3,9 +3,25 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +#include "sdkconfig.h" #include "platform_api_vmcore.h" #include "platform_api_extension.h" +#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)) \ + && (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)) +#define UTIMENSAT_TIMESPEC_POINTER 1 +#define FUTIMENS_TIMESPEC_POINTER 1 +#endif + +#if CONFIG_LITTLEFS_OPEN_DIR && CONFIG_LITTLEFS_FCNTL_GET_PATH +#define OPENAT_SUPPORT 1 + +#undef F_GETPATH +#define F_GETPATH CONFIG_LITTLEFS_FCNTL_F_GETPATH_VALUE + +#define DIR_PATH_LEN (CONFIG_LITTLEFS_OBJ_NAME_LEN + 1) +#endif + int bh_platform_init() { @@ -36,11 +52,18 @@ os_vprintf(const char *format, va_list ap) } uint64 -os_time_get_boot_microsecond(void) +os_time_get_boot_us(void) { return (uint64)esp_timer_get_time(); } +uint64 +os_time_thread_cputime_us(void) +{ + /* FIXME if u know the right api */ + return os_time_get_boot_us(); +} + uint8 * os_thread_get_stack_boundary(void) { @@ -162,12 +185,40 @@ writev(int fildes, const struct iovec *iov, int iovcnt) return ntotal; } +#if OPENAT_SUPPORT +int +openat(int fd, const char *pathname, int flags, ...) +{ + int new_fd; + int ret; + char dir_path[DIR_PATH_LEN]; + char *full_path; + + ret = fcntl(fd, F_GETPATH, dir_path); + if (ret != 0) { + errno = -EINVAL; + return -1; + } + + ret = asprintf(&full_path, "%s/%s", dir_path, pathname); + if (ret < 0) { + errno = ENOMEM; + return -1; + } + + new_fd = open(full_path, flags); + free(full_path); + + return new_fd; +} +#else int openat(int fd, const char *path, int oflags, ...) { errno = ENOSYS; return -1; } +#endif int fstatat(int fd, const char *path, struct stat *buf, int flag) @@ -219,7 +270,13 @@ unlinkat(int fd, const char *path, int flag) } int -utimensat(int fd, const char *path, const struct timespec *ts, int flag) +utimensat(int fd, const char *path, +#if UTIMENSAT_TIMESPEC_POINTER + const struct timespec *ts, +#else + const struct timespec ts[2], +#endif + int flag) { errno = ENOSYS; return -1; @@ -242,7 +299,13 @@ ftruncate(int fd, off_t length) #endif int -futimens(int fd, const struct timespec *times) +futimens(int fd, +#if FUTIMENS_TIMESPEC_POINTER + const struct timespec *times +#else + const struct timespec times[2] +#endif +) { errno = ENOSYS; return -1; @@ -253,4 +316,4 @@ nanosleep(const struct timespec *req, struct timespec *rem) { errno = ENOSYS; return -1; -} \ No newline at end of file +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_socket.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_socket.c new file mode 100644 index 00000000000..8c65094647d --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_socket.c @@ -0,0 +1,1027 @@ +/* + * Copyright (C) 2021 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include "platform_api_vmcore.h" +#include "platform_api_extension.h" +#include "libc_errno.h" + +#include +#include +#include +#include + +static bool +textual_addr_to_sockaddr(const char *textual, int port, struct sockaddr *out, + socklen_t *out_len) +{ + struct sockaddr_in *v4; +#ifdef IPPROTO_IPV6 + struct sockaddr_in6 *v6; +#endif + + assert(textual); + + v4 = (struct sockaddr_in *)out; + if (inet_pton(AF_INET, textual, &v4->sin_addr.s_addr) == 1) { + v4->sin_family = AF_INET; + v4->sin_port = htons(port); + *out_len = sizeof(struct sockaddr_in); + return true; + } + +#ifdef IPPROTO_IPV6 + v6 = (struct sockaddr_in6 *)out; + if (inet_pton(AF_INET6, textual, &v6->sin6_addr.s6_addr) == 1) { + v6->sin6_family = AF_INET6; + v6->sin6_port = htons(port); + *out_len = sizeof(struct sockaddr_in6); + return true; + } +#endif + + return false; +} + +static int +sockaddr_to_bh_sockaddr(const struct sockaddr *sockaddr, + bh_sockaddr_t *bh_sockaddr) +{ + switch (sockaddr->sa_family) { + case AF_INET: + { + struct sockaddr_in *addr = (struct sockaddr_in *)sockaddr; + + bh_sockaddr->port = ntohs(addr->sin_port); + bh_sockaddr->addr_buffer.ipv4 = ntohl(addr->sin_addr.s_addr); + bh_sockaddr->is_ipv4 = true; + return BHT_OK; + } +#ifdef IPPROTO_IPV6 + case AF_INET6: + { + struct sockaddr_in6 *addr = (struct sockaddr_in6 *)sockaddr; + size_t i; + + bh_sockaddr->port = ntohs(addr->sin6_port); + + for (i = 0; i < sizeof(bh_sockaddr->addr_buffer.ipv6) + / sizeof(bh_sockaddr->addr_buffer.ipv6[0]); + i++) { + uint16 part_addr = addr->sin6_addr.s6_addr[i * 2] + | (addr->sin6_addr.s6_addr[i * 2 + 1] << 8); + bh_sockaddr->addr_buffer.ipv6[i] = ntohs(part_addr); + } + + bh_sockaddr->is_ipv4 = false; + return BHT_OK; + } +#endif + default: + errno = EAFNOSUPPORT; + return BHT_ERROR; + } +} + +static void +bh_sockaddr_to_sockaddr(const bh_sockaddr_t *bh_sockaddr, + struct sockaddr_storage *sockaddr, socklen_t *socklen) +{ + if (bh_sockaddr->is_ipv4) { + struct sockaddr_in *addr = (struct sockaddr_in *)sockaddr; + addr->sin_port = htons(bh_sockaddr->port); + addr->sin_family = AF_INET; + addr->sin_addr.s_addr = htonl(bh_sockaddr->addr_buffer.ipv4); + *socklen = sizeof(*addr); + } +#ifdef IPPROTO_IPV6 + else { + struct sockaddr_in6 *addr = (struct sockaddr_in6 *)sockaddr; + size_t i; + addr->sin6_port = htons(bh_sockaddr->port); + addr->sin6_family = AF_INET6; + + for (i = 0; i < sizeof(bh_sockaddr->addr_buffer.ipv6) + / sizeof(bh_sockaddr->addr_buffer.ipv6[0]); + i++) { + uint16 part_addr = htons(bh_sockaddr->addr_buffer.ipv6[i]); + addr->sin6_addr.s6_addr[i * 2] = 0xff & part_addr; + addr->sin6_addr.s6_addr[i * 2 + 1] = (0xff00 & part_addr) >> 8; + } + + *socklen = sizeof(*addr); + } +#endif +} + +int +os_socket_create(bh_socket_t *sock, bool is_ipv4, bool is_tcp) +{ + int af = is_ipv4 ? AF_INET : AF_INET6; + + if (!sock) { + return BHT_ERROR; + } + + if (is_tcp) { + *sock = socket(af, SOCK_STREAM, IPPROTO_TCP); + } + else { + *sock = socket(af, SOCK_DGRAM, 0); + } + + return (*sock == -1) ? BHT_ERROR : BHT_OK; +} + +int +os_socket_bind(bh_socket_t socket, const char *host, int *port) +{ + struct sockaddr_storage addr = { 0 }; + struct linger ling; + socklen_t socklen; + int ret; + + assert(host); + assert(port); + + ling.l_onoff = 1; + ling.l_linger = 0; + + if (!textual_addr_to_sockaddr(host, *port, (struct sockaddr *)&addr, + &socklen)) { + goto fail; + } + + ret = setsockopt(socket, SOL_SOCKET, SO_LINGER, &ling, sizeof(ling)); + if (ret < 0) { + goto fail; + } + + ret = bind(socket, (struct sockaddr *)&addr, socklen); + if (ret < 0) { + goto fail; + } + + socklen = sizeof(addr); + if (getsockname(socket, (void *)&addr, &socklen) == -1) { + goto fail; + } + + if (addr.ss_family == AF_INET) { + *port = ntohs(((struct sockaddr_in *)&addr)->sin_port); + } + else { +#ifdef IPPROTO_IPV6 + *port = ntohs(((struct sockaddr_in6 *)&addr)->sin6_port); +#else + goto fail; +#endif + } + + return BHT_OK; + +fail: + return BHT_ERROR; +} + +int +os_socket_settimeout(bh_socket_t socket, uint64 timeout_us) +{ + struct timeval tv; + tv.tv_sec = timeout_us / 1000000UL; + tv.tv_usec = timeout_us % 1000000UL; + + if (setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, + sizeof(tv)) + != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_listen(bh_socket_t socket, int max_client) +{ + if (listen(socket, max_client) != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_accept(bh_socket_t server_sock, bh_socket_t *sock, void *addr, + unsigned int *addrlen) +{ + *sock = accept(server_sock, addr, (socklen_t *)addrlen); + + if (*sock < 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_connect(bh_socket_t socket, const char *addr, int port) +{ + struct sockaddr_storage addr_in = { 0 }; + socklen_t addr_len; + int ret = 0; + + if (!textual_addr_to_sockaddr(addr, port, (struct sockaddr *)&addr_in, + &addr_len)) { + return BHT_ERROR; + } + + ret = connect(socket, (struct sockaddr *)&addr_in, addr_len); + if (ret == -1) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_recv(bh_socket_t socket, void *buf, unsigned int len) +{ + return recv(socket, buf, len, 0); +} + +int +os_socket_recv_from(bh_socket_t socket, void *buf, unsigned int len, int flags, + bh_sockaddr_t *src_addr) +{ + struct sockaddr_storage sock_addr = { 0 }; + socklen_t socklen = sizeof(sock_addr); + int ret; + + ret = recvfrom(socket, buf, len, flags, (struct sockaddr *)&sock_addr, + &socklen); + + if (ret < 0) { + return ret; + } + + if (src_addr && socklen > 0) { + if (sockaddr_to_bh_sockaddr((struct sockaddr *)&sock_addr, src_addr) + == BHT_ERROR) { + return -1; + } + } + else if (src_addr) { + memset(src_addr, 0, sizeof(*src_addr)); + } + + return ret; +} + +int +os_socket_send(bh_socket_t socket, const void *buf, unsigned int len) +{ + return send(socket, buf, len, 0); +} + +int +os_socket_send_to(bh_socket_t socket, const void *buf, unsigned int len, + int flags, const bh_sockaddr_t *dest_addr) +{ + struct sockaddr_storage sock_addr = { 0 }; + socklen_t socklen = 0; + + bh_sockaddr_to_sockaddr(dest_addr, &sock_addr, &socklen); + + return sendto(socket, buf, len, flags, (const struct sockaddr *)&sock_addr, + socklen); +} + +int +os_socket_close(bh_socket_t socket) +{ + close(socket); + return BHT_OK; +} + +__wasi_errno_t +os_socket_shutdown(bh_socket_t socket) +{ + if (shutdown(socket, O_RDWR) != 0) { + return convert_errno(errno); + } + return __WASI_ESUCCESS; +} + +int +os_socket_inet_network(bool is_ipv4, const char *cp, bh_ip_addr_buffer_t *out) +{ + if (!cp) + return BHT_ERROR; + + if (is_ipv4) { + if (inet_pton(AF_INET, cp, &out->ipv4) != 1) { + return BHT_ERROR; + } + /* Note: ntohl(INADDR_NONE) == INADDR_NONE */ + out->ipv4 = ntohl(out->ipv4); + } + else { +#ifdef IPPROTO_IPV6 + if (inet_pton(AF_INET6, cp, out->ipv6) != 1) { + return BHT_ERROR; + } + for (int i = 0; i < 8; i++) { + out->ipv6[i] = ntohs(out->ipv6[i]); + } +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif + } + + return BHT_OK; +} + +static int +getaddrinfo_error_to_errno(int error) +{ + switch (error) { + case EAI_AGAIN: + return EAGAIN; + case EAI_FAIL: + return EFAULT; + case EAI_MEMORY: + return ENOMEM; + default: + return EINVAL; + } +} + +static int +is_addrinfo_supported(struct addrinfo *info) +{ + return + // Allow only IPv4 and IPv6 + (info->ai_family == AF_INET || info->ai_family == AF_INET6) + // Allow only UDP and TCP + && (info->ai_socktype == SOCK_DGRAM || info->ai_socktype == SOCK_STREAM) + && (info->ai_protocol == IPPROTO_TCP + || info->ai_protocol == IPPROTO_UDP); +} + +int +os_socket_addr_resolve(const char *host, const char *service, + uint8_t *hint_is_tcp, uint8_t *hint_is_ipv4, + bh_addr_info_t *addr_info, size_t addr_info_size, + size_t *max_info_size) +{ + struct addrinfo hints = { 0 }, *res, *result; + int hints_enabled = hint_is_tcp || hint_is_ipv4; + int ret; + size_t pos = 0; + + if (hints_enabled) { + if (hint_is_ipv4) { + hints.ai_family = *hint_is_ipv4 ? AF_INET : AF_INET6; + } + if (hint_is_tcp) { + hints.ai_socktype = *hint_is_tcp ? SOCK_STREAM : SOCK_DGRAM; + } + } + + ret = getaddrinfo(host, strlen(service) == 0 ? NULL : service, + hints_enabled ? &hints : NULL, &result); + if (ret != BHT_OK) { + errno = getaddrinfo_error_to_errno(ret); + return BHT_ERROR; + } + + res = result; + while (res) { + if (addr_info_size > pos) { + if (!is_addrinfo_supported(res)) { + res = res->ai_next; + continue; + } + + ret = + sockaddr_to_bh_sockaddr(res->ai_addr, &addr_info[pos].sockaddr); + + if (ret == BHT_ERROR) { + freeaddrinfo(result); + return BHT_ERROR; + } + + addr_info[pos].is_tcp = res->ai_socktype == SOCK_STREAM; + } + + pos++; + res = res->ai_next; + } + + *max_info_size = pos; + freeaddrinfo(result); + + return BHT_OK; +} + +static int +os_socket_setbooloption(bh_socket_t socket, int level, int optname, + bool is_enabled) +{ + int option = (int)is_enabled; + if (setsockopt(socket, level, optname, &option, sizeof(option)) != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +static int +os_socket_getbooloption(bh_socket_t socket, int level, int optname, + bool *is_enabled) +{ + assert(is_enabled); + + int optval; + socklen_t optval_size = sizeof(optval); + if (getsockopt(socket, level, optname, &optval, &optval_size) != 0) { + return BHT_ERROR; + } + *is_enabled = (bool)optval; + return BHT_OK; +} + +int +os_socket_set_send_buf_size(bh_socket_t socket, size_t bufsiz) +{ + int buf_size_int = (int)bufsiz; + if (setsockopt(socket, SOL_SOCKET, SO_SNDBUF, &buf_size_int, + sizeof(buf_size_int)) + != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_get_send_buf_size(bh_socket_t socket, size_t *bufsiz) +{ + assert(bufsiz); + + int buf_size_int; + socklen_t bufsiz_len = sizeof(buf_size_int); + if (getsockopt(socket, SOL_SOCKET, SO_SNDBUF, &buf_size_int, &bufsiz_len) + != 0) { + return BHT_ERROR; + } + *bufsiz = (size_t)buf_size_int; + + return BHT_OK; +} + +int +os_socket_set_recv_buf_size(bh_socket_t socket, size_t bufsiz) +{ + int buf_size_int = (int)bufsiz; + if (setsockopt(socket, SOL_SOCKET, SO_RCVBUF, &buf_size_int, + sizeof(buf_size_int)) + != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_get_recv_buf_size(bh_socket_t socket, size_t *bufsiz) +{ + assert(bufsiz); + + int buf_size_int; + socklen_t bufsiz_len = sizeof(buf_size_int); + if (getsockopt(socket, SOL_SOCKET, SO_RCVBUF, &buf_size_int, &bufsiz_len) + != 0) { + return BHT_ERROR; + } + *bufsiz = (size_t)buf_size_int; + + return BHT_OK; +} + +int +os_socket_set_keep_alive(bh_socket_t socket, bool is_enabled) +{ + return os_socket_setbooloption(socket, SOL_SOCKET, SO_KEEPALIVE, + is_enabled); +} + +int +os_socket_get_keep_alive(bh_socket_t socket, bool *is_enabled) +{ + return os_socket_getbooloption(socket, SOL_SOCKET, SO_KEEPALIVE, + is_enabled); +} + +int +os_socket_set_reuse_addr(bh_socket_t socket, bool is_enabled) +{ + return os_socket_setbooloption(socket, SOL_SOCKET, SO_REUSEADDR, + is_enabled); +} + +int +os_socket_get_reuse_addr(bh_socket_t socket, bool *is_enabled) +{ + return os_socket_getbooloption(socket, SOL_SOCKET, SO_REUSEADDR, + is_enabled); +} + +int +os_socket_set_reuse_port(bh_socket_t socket, bool is_enabled) +{ +#if defined(SO_REUSEPORT) /* NuttX doesn't have SO_REUSEPORT */ + return os_socket_setbooloption(socket, SOL_SOCKET, SO_REUSEPORT, + is_enabled); +#else + errno = ENOTSUP; + return BHT_ERROR; +#endif /* defined(SO_REUSEPORT) */ +} + +int +os_socket_get_reuse_port(bh_socket_t socket, bool *is_enabled) +{ +#if defined(SO_REUSEPORT) /* NuttX doesn't have SO_REUSEPORT */ + return os_socket_getbooloption(socket, SOL_SOCKET, SO_REUSEPORT, + is_enabled); +#else + errno = ENOTSUP; + return BHT_ERROR; +#endif /* defined(SO_REUSEPORT) */ +} + +int +os_socket_set_linger(bh_socket_t socket, bool is_enabled, int linger_s) +{ + struct linger linger_opts = { .l_onoff = (int)is_enabled, + .l_linger = linger_s }; + if (setsockopt(socket, SOL_SOCKET, SO_LINGER, &linger_opts, + sizeof(linger_opts)) + != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_get_linger(bh_socket_t socket, bool *is_enabled, int *linger_s) +{ + assert(is_enabled); + assert(linger_s); + + struct linger linger_opts; + socklen_t linger_opts_len = sizeof(linger_opts); + if (getsockopt(socket, SOL_SOCKET, SO_LINGER, &linger_opts, + &linger_opts_len) + != 0) { + return BHT_ERROR; + } + *linger_s = linger_opts.l_linger; + *is_enabled = (bool)linger_opts.l_onoff; + return BHT_OK; +} + +int +os_socket_set_tcp_no_delay(bh_socket_t socket, bool is_enabled) +{ + return os_socket_setbooloption(socket, IPPROTO_TCP, TCP_NODELAY, + is_enabled); +} + +int +os_socket_get_tcp_no_delay(bh_socket_t socket, bool *is_enabled) +{ + return os_socket_getbooloption(socket, IPPROTO_TCP, TCP_NODELAY, + is_enabled); +} + +int +os_socket_set_tcp_quick_ack(bh_socket_t socket, bool is_enabled) +{ +#ifdef TCP_QUICKACK + return os_socket_setbooloption(socket, IPPROTO_TCP, TCP_QUICKACK, + is_enabled); +#else + errno = ENOSYS; + + return BHT_ERROR; +#endif +} + +int +os_socket_get_tcp_quick_ack(bh_socket_t socket, bool *is_enabled) +{ +#ifdef TCP_QUICKACK + return os_socket_getbooloption(socket, IPPROTO_TCP, TCP_QUICKACK, + is_enabled); +#else + errno = ENOSYS; + + return BHT_ERROR; +#endif +} + +int +os_socket_set_tcp_keep_idle(bh_socket_t socket, uint32 time_s) +{ + int time_s_int = (int)time_s; +#ifdef TCP_KEEPIDLE + if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &time_s_int, + sizeof(time_s_int)) + != 0) { + return BHT_ERROR; + } + return BHT_OK; +#elif defined(TCP_KEEPALIVE) + if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPALIVE, &time_s_int, + sizeof(time_s_int)) + != 0) { + return BHT_ERROR; + } + return BHT_OK; +#else + errno = ENOSYS; + + return BHT_ERROR; +#endif +} + +int +os_socket_get_tcp_keep_idle(bh_socket_t socket, uint32 *time_s) +{ + assert(time_s); + int time_s_int; + socklen_t time_s_len = sizeof(time_s_int); +#ifdef TCP_KEEPIDLE + if (getsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &time_s_int, &time_s_len) + != 0) { + return BHT_ERROR; + } + *time_s = (uint32)time_s_int; + return BHT_OK; +#elif defined(TCP_KEEPALIVE) + if (getsockopt(socket, IPPROTO_TCP, TCP_KEEPALIVE, &time_s_int, &time_s_len) + != 0) { + return BHT_ERROR; + } + *time_s = (uint32)time_s_int; + return BHT_OK; +#else + errno = ENOSYS; + + return BHT_ERROR; +#endif +} + +int +os_socket_set_tcp_keep_intvl(bh_socket_t socket, uint32 time_s) +{ + int time_s_int = (int)time_s; +#ifdef TCP_KEEPINTVL + if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &time_s_int, + sizeof(time_s_int)) + != 0) { + return BHT_ERROR; + } + + return BHT_OK; +#else + errno = ENOSYS; + + return BHT_ERROR; +#endif +} + +int +os_socket_get_tcp_keep_intvl(bh_socket_t socket, uint32 *time_s) +{ +#ifdef TCP_KEEPINTVL + assert(time_s); + int time_s_int; + socklen_t time_s_len = sizeof(time_s_int); + if (getsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &time_s_int, &time_s_len) + != 0) { + return BHT_ERROR; + } + *time_s = (uint32)time_s_int; + return BHT_OK; +#else + errno = ENOSYS; + + return BHT_ERROR; +#endif +} + +int +os_socket_set_tcp_fastopen_connect(bh_socket_t socket, bool is_enabled) +{ +#ifdef TCP_FASTOPEN_CONNECT + return os_socket_setbooloption(socket, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, + is_enabled); +#else + errno = ENOSYS; + + return BHT_ERROR; +#endif +} + +int +os_socket_get_tcp_fastopen_connect(bh_socket_t socket, bool *is_enabled) +{ +#ifdef TCP_FASTOPEN_CONNECT + return os_socket_getbooloption(socket, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, + is_enabled); +#else + errno = ENOSYS; + + return BHT_ERROR; +#endif +} + +int +os_socket_set_ip_multicast_loop(bh_socket_t socket, bool ipv6, bool is_enabled) +{ + if (ipv6) { +#ifdef IPPROTO_IPV6 + return os_socket_setbooloption(socket, IPPROTO_IPV6, + IPV6_MULTICAST_LOOP, is_enabled); +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif + } + else { + return os_socket_setbooloption(socket, IPPROTO_IP, IP_MULTICAST_LOOP, + is_enabled); + } +} + +int +os_socket_get_ip_multicast_loop(bh_socket_t socket, bool ipv6, bool *is_enabled) +{ + if (ipv6) { +#ifdef IPPROTO_IPV6 + return os_socket_getbooloption(socket, IPPROTO_IPV6, + IPV6_MULTICAST_LOOP, is_enabled); +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif + } + else { + return os_socket_getbooloption(socket, IPPROTO_IP, IP_MULTICAST_LOOP, + is_enabled); + } +} + +int +os_socket_set_ip_add_membership(bh_socket_t socket, + bh_ip_addr_buffer_t *imr_multiaddr, + uint32_t imr_interface, bool is_ipv6) +{ + assert(imr_multiaddr); + if (is_ipv6) { +#if defined(IPPROTO_IPV6) && !defined(BH_PLATFORM_COSMOPOLITAN) + struct ipv6_mreq mreq; + for (int i = 0; i < 8; i++) { + ((uint16_t *)mreq.ipv6mr_multiaddr.s6_addr)[i] = + imr_multiaddr->ipv6[i]; + } + mreq.ipv6mr_interface = imr_interface; + if (setsockopt(socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, + sizeof(mreq)) + != 0) { + return BHT_ERROR; + } +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif + } + else { + struct ip_mreq mreq; + mreq.imr_multiaddr.s_addr = imr_multiaddr->ipv4; + mreq.imr_interface.s_addr = imr_interface; + if (setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, + sizeof(mreq)) + != 0) { + return BHT_ERROR; + } + } + + return BHT_OK; +} + +int +os_socket_set_ip_drop_membership(bh_socket_t socket, + bh_ip_addr_buffer_t *imr_multiaddr, + uint32_t imr_interface, bool is_ipv6) +{ + assert(imr_multiaddr); + if (is_ipv6) { +#if defined(IPPROTO_IPV6) && !defined(BH_PLATFORM_COSMOPOLITAN) + struct ipv6_mreq mreq; + for (int i = 0; i < 8; i++) { + ((uint16_t *)mreq.ipv6mr_multiaddr.s6_addr)[i] = + imr_multiaddr->ipv6[i]; + } + mreq.ipv6mr_interface = imr_interface; + if (setsockopt(socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &mreq, + sizeof(mreq)) + != 0) { + return BHT_ERROR; + } +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif + } + else { + struct ip_mreq mreq; + mreq.imr_multiaddr.s_addr = imr_multiaddr->ipv4; + mreq.imr_interface.s_addr = imr_interface; + if (setsockopt(socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, + sizeof(mreq)) + != 0) { + return BHT_ERROR; + } + } + + return BHT_OK; +} + +int +os_socket_set_ip_ttl(bh_socket_t socket, uint8_t ttl_s) +{ + if (setsockopt(socket, IPPROTO_IP, IP_TTL, &ttl_s, sizeof(ttl_s)) != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_get_ip_ttl(bh_socket_t socket, uint8_t *ttl_s) +{ + socklen_t opt_len = sizeof(*ttl_s); + if (getsockopt(socket, IPPROTO_IP, IP_TTL, ttl_s, &opt_len) != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_set_ip_multicast_ttl(bh_socket_t socket, uint8_t ttl_s) +{ + if (setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, &ttl_s, sizeof(ttl_s)) + != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_get_ip_multicast_ttl(bh_socket_t socket, uint8_t *ttl_s) +{ + socklen_t opt_len = sizeof(*ttl_s); + if (getsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, ttl_s, &opt_len) + != 0) { + return BHT_ERROR; + } + + return BHT_OK; +} + +int +os_socket_set_ipv6_only(bh_socket_t socket, bool is_enabled) +{ +#ifdef IPPROTO_IPV6 + return os_socket_setbooloption(socket, IPPROTO_IPV6, IPV6_V6ONLY, + is_enabled); +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif +} + +int +os_socket_get_ipv6_only(bh_socket_t socket, bool *is_enabled) +{ +#ifdef IPPROTO_IPV6 + return os_socket_getbooloption(socket, IPPROTO_IPV6, IPV6_V6ONLY, + is_enabled); +#else + errno = EAFNOSUPPORT; + return BHT_ERROR; +#endif +} + +int +os_socket_set_broadcast(bh_socket_t socket, bool is_enabled) +{ + return os_socket_setbooloption(socket, SOL_SOCKET, SO_BROADCAST, + is_enabled); +} + +int +os_socket_get_broadcast(bh_socket_t socket, bool *is_enabled) +{ + return os_socket_getbooloption(socket, SOL_SOCKET, SO_BROADCAST, + is_enabled); +} + +int +os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us) +{ + struct timeval tv; + tv.tv_sec = timeout_us / 1000000UL; + tv.tv_usec = timeout_us % 1000000UL; + if (setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) != 0) { + return BHT_ERROR; + } + return BHT_OK; +} + +int +os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us) +{ + struct timeval tv; + socklen_t tv_len = sizeof(tv); + if (getsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &tv, &tv_len) != 0) { + return BHT_ERROR; + } + *timeout_us = (tv.tv_sec * 1000000UL) + tv.tv_usec; + return BHT_OK; +} + +int +os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us) +{ + struct timeval tv; + tv.tv_sec = timeout_us / 1000000UL; + tv.tv_usec = timeout_us % 1000000UL; + if (setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) != 0) { + return BHT_ERROR; + } + return BHT_OK; +} + +int +os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us) +{ + struct timeval tv; + socklen_t tv_len = sizeof(tv); + if (getsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &tv, &tv_len) != 0) { + return BHT_ERROR; + } + *timeout_us = (tv.tv_sec * 1000000UL) + tv.tv_usec; + return BHT_OK; +} + +int +os_socket_addr_local(bh_socket_t socket, bh_sockaddr_t *sockaddr) +{ + struct sockaddr_storage addr_storage = { 0 }; + socklen_t addr_len = sizeof(addr_storage); + int ret; + + ret = getsockname(socket, (struct sockaddr *)&addr_storage, &addr_len); + + if (ret != BHT_OK) { + return BHT_ERROR; + } + + return sockaddr_to_bh_sockaddr((struct sockaddr *)&addr_storage, sockaddr); +} + +int +os_socket_addr_remote(bh_socket_t socket, bh_sockaddr_t *sockaddr) +{ + struct sockaddr_storage addr_storage = { 0 }; + socklen_t addr_len = sizeof(addr_storage); + int ret; + + ret = getpeername(socket, (struct sockaddr *)&addr_storage, &addr_len); + + if (ret != BHT_OK) { + return BHT_ERROR; + } + + return sockaddr_to_bh_sockaddr((struct sockaddr *)&addr_storage, sockaddr); +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_thread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_thread.c similarity index 86% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_thread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_thread.c index 637cd4177f5..768d823a8b8 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/espidf_thread.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/espidf_thread.c @@ -230,4 +230,59 @@ int os_cond_broadcast(korp_cond *cond) { return pthread_cond_broadcast(cond); -} \ No newline at end of file +} + +int +os_rwlock_init(korp_rwlock *lock) +{ + assert(lock); + + if (pthread_rwlock_init(lock, NULL) != BHT_OK) + return BHT_ERROR; + + return BHT_OK; +} + +int +os_rwlock_rdlock(korp_rwlock *lock) +{ + assert(lock); + + if (pthread_rwlock_rdlock(lock) != BHT_OK) + return BHT_ERROR; + + return BHT_OK; +} + +int +os_rwlock_wrlock(korp_rwlock *lock) +{ + assert(lock); + + if (pthread_rwlock_wrlock(lock) != BHT_OK) + return BHT_ERROR; + + return BHT_OK; +} + +int +os_rwlock_unlock(korp_rwlock *lock) +{ + assert(lock); + + if (pthread_rwlock_unlock(lock) != BHT_OK) + return BHT_ERROR; + + return BHT_OK; +} + +int +os_rwlock_destroy(korp_rwlock *lock) +{ + assert(lock); + + if (pthread_rwlock_destroy(lock) != BHT_OK) + return BHT_ERROR; + + return BHT_OK; +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/platform_internal.h similarity index 79% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/platform_internal.h index 70c4fe7b1d5..aa81b3d892f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/platform_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/platform_internal.h @@ -56,39 +56,29 @@ typedef unsigned int korp_sem; #define UTIME_OMIT ((1l << 30) - 2l) #endif -#ifdef DT_UNKNOWN -#undef DT_UNKNOWN -#endif - -#ifdef DT_REG -#undef DT_REG -#endif - -#ifdef DT_DIR -#undef DT_DIR -#endif - /* Below parts of d_type define are ported from Nuttx, under Apache License v2.0 */ -/* File type code for the d_type field in dirent structure. - * Note that because of the simplified filesystem organization of the NuttX, - * top-level, pseudo-file system, an inode can be BOTH a file and a directory +/* Following macros are defined in espressif GCC of esp-idf v5.3 */ #define DTYPE_UNKNOWN 0 -#define DTYPE_FIFO 1 -#define DTYPE_CHR 2 -#define DTYPE_SEM 3 -#define DTYPE_DIRECTORY 4 -#define DTYPE_MQ 5 -#define DTYPE_BLK 6 -#define DTYPE_SHM 7 -#define DTYPE_FILE 8 -#define DTYPE_MTD 9 +#define DTYPE_FILE 1 +#define DTYPE_DIRECTORY 2 +#define DTYPE_CHR 4 +#define DTYPE_BLK 5 +#define DTYPE_FIFO 8 #define DTYPE_LINK 10 #define DTYPE_SOCK 12 +/* Following macros are not defined in espressif GCC of esp-idf v5.3 + */ + +#define DTYPE_SEM 100 +#define DTYPE_MQ 101 +#define DTYPE_SHM 102 +#define DTYPE_MTD 103 + /* The d_type field of the dirent structure is not specified by POSIX. It * is a non-standard, 4.5BSD extension that is implemented by most OSs. A * POSIX compliant OS may not implement the d_type field at all. Many OS's @@ -96,18 +86,53 @@ typedef unsigned int korp_sem; * type names: */ +#ifndef DT_UNKNOWN #define DT_UNKNOWN DTYPE_UNKNOWN +#endif + +#ifndef DT_FIFO #define DT_FIFO DTYPE_FIFO +#endif + +#ifndef DT_CHR #define DT_CHR DTYPE_CHR +#endif + +#ifndef DT_SEM #define DT_SEM DTYPE_SEM +#endif + +#ifndef DT_DIR #define DT_DIR DTYPE_DIRECTORY +#endif + +#ifndef DT_MQ #define DT_MQ DTYPE_MQ +#endif + +#ifndef DT_BLK #define DT_BLK DTYPE_BLK +#endif + +#ifndef DT_SHM #define DT_SHM DTYPE_SHM +#endif + +#ifndef DT_REG #define DT_REG DTYPE_FILE +#endif + +#ifndef DT_MTD #define DT_MTD DTYPE_MTD +#endif + +#ifndef DT_LNK #define DT_LNK DTYPE_LINK +#endif + +#ifndef DT_SOCK #define DT_SOCK DTYPE_SOCK +#endif typedef int os_file_handle; typedef DIR *os_dir_stream; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/shared_platform.cmake similarity index 81% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/shared_platform.cmake index 8d7fe5d808a..d254b087b09 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/esp-idf/shared_platform.cmake +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/esp-idf/shared_platform.cmake @@ -10,6 +10,9 @@ include_directories(${PLATFORM_SHARED_DIR}/../include) file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c) +include (${CMAKE_CURRENT_LIST_DIR}/../common/libc-util/platform_common_libc_util.cmake) +set (source_all ${source_all} ${PLATFORM_COMMON_LIBC_UTIL_SOURCE}) + set (PLATFORM_SHARED_SOURCE ${source_all} ${PLATFORM_COMMON_MATH_SOURCE}) # If enable PSRAM of ESP32-S3, it had better to put AOT into PSRAM, so that diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/freebsd/platform_init.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/freebsd/platform_init.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/freebsd/platform_init.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/freebsd/platform_init.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/freebsd/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/freebsd/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/freebsd/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/freebsd/platform_internal.h index 5241c64569c..bfdfe1493ff 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/freebsd/platform_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/freebsd/platform_internal.h @@ -85,8 +85,6 @@ typedef jmp_buf korp_jmpbuf; #define os_longjmp longjmp #define os_alloca alloca -#define os_getpagesize getpagesize - typedef void (*os_signal_handler)(void *sig_addr); int @@ -106,6 +104,8 @@ os_sigreturn(); #endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64/RISCV64 */ #endif /* end of WASM_DISABLE_HW_BOUND_CHECK */ +#define os_getpagesize getpagesize + #if WASM_DISABLE_WAKEUP_BLOCKING_OP == 0 #define OS_ENABLE_WAKEUP_BLOCKING_OP #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/freebsd/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/freebsd/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/freebsd/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/freebsd/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_api_extension.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_api_extension.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_api_extension.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_api_extension.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_api_vmcore.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_api_vmcore.h similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_api_vmcore.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_api_vmcore.h index 559141f75f3..4a9d29cc0ab 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_api_vmcore.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_api_vmcore.h @@ -64,7 +64,13 @@ os_vprintf(const char *format, va_list ap); * Get microseconds after boot. */ uint64 -os_time_get_boot_microsecond(void); +os_time_get_boot_us(void); + +/** + * Get thread-specific CPU-time clock in microseconds + */ +uint64 +os_time_thread_cputime_us(void); /** * Get current thread id. diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_common.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_common.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_common.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_common.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_wasi_types.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_wasi_types.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/include/platform_wasi_types.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/include/platform_wasi_types.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/platform_internal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_file.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_file.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_file.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_file.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_file.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_file.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_file.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_file.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_ipfs.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_ipfs.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_ipfs.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_ipfs.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_ipfs.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_ipfs.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_ipfs.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_ipfs.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_platform.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_platform.c similarity index 91% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_platform.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_platform.c index 32b95682670..d97883a8e48 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_platform.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_platform.c @@ -119,6 +119,18 @@ strcpy(char *dest, const char *src) return dest; } +#if WASM_ENABLE_LIBC_WASI == 0 +bool +os_is_handle_valid(os_file_handle *handle) +{ + assert(handle != NULL); + + return *handle > -1; +} +#else +/* implemented in posix_file.c */ +#endif + void * os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) { @@ -142,8 +154,8 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) ret = sgx_alloc_rsrv_mem(aligned_size); if (ret == NULL) { - os_printf("os_mmap(size=%u, aligned size=%lu, prot=0x%x) failed.", size, - aligned_size, prot); + os_printf("os_mmap(size=%u, aligned size=%lu, prot=0x%x) failed.\n", + size, aligned_size, prot); return NULL; } @@ -156,7 +168,7 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) st = sgx_tprotect_rsrv_mem(ret, aligned_size, mprot); if (st != SGX_SUCCESS) { - os_printf("os_mmap(size=%u, prot=0x%x) failed to set protect.", size, + os_printf("os_mmap(size=%u, prot=0x%x) failed to set protect.\n", size, prot); sgx_free_rsrv_mem(ret, aligned_size); return NULL; @@ -193,7 +205,8 @@ os_mprotect(void *addr, size_t size, int prot) mprot |= SGX_PROT_EXEC; st = sgx_tprotect_rsrv_mem(addr, aligned_size, mprot); if (st != SGX_SUCCESS) - os_printf("os_mprotect(addr=0x%" PRIx64 ", size=%u, prot=0x%x) failed.", + os_printf("os_mprotect(addr=0x%" PRIx64 + ", size=%u, prot=0x%x) failed.\n", (uintptr_t)addr, size, prot); return (st == SGX_SUCCESS ? 0 : -1); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_pthread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_pthread.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_pthread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_pthread.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_pthread.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_pthread.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_pthread.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_pthread.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_rsrv_mem_mngr.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_rsrv_mem_mngr.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_rsrv_mem_mngr.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_rsrv_mem_mngr.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_signal.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_signal.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_signal.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_signal.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_signal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_signal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_signal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_signal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_socket.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_socket.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_socket.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_socket.c index cd1a6ceade8..458bb1e249d 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_socket.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_socket.c @@ -5,10 +5,11 @@ #include "platform_api_vmcore.h" #include "platform_api_extension.h" -#include "libc_errno.h" #ifndef SGX_DISABLE_WASI +#include "libc_errno.h" + #define TRACE_OCALL_FAIL() os_printf("ocall %s failed!\n", __FUNCTION__) /** OCALLs prototypes **/ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_socket.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_socket.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_socket.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_socket.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_thread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_thread.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_thread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_thread.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_time.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_time.c similarity index 90% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_time.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_time.c index d090083ef0d..d39db22fbc2 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_time.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_time.c @@ -26,7 +26,7 @@ ocall_clock_nanosleep(int *p_ret, unsigned clock_id, int flags, const void *rem_buf, unsigned int rem_buf_size); uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { #ifndef SGX_DISABLE_WASI struct timespec ts; @@ -40,6 +40,21 @@ os_time_get_boot_microsecond() #endif } +uint64 +os_time_thread_cputime_us(void) +{ +#ifndef SGX_DISABLE_WASI + struct timespec ts; + if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0) { + return 0; + } + + return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000; +#else + return 0; +#endif +} + #ifndef SGX_DISABLE_WASI int diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_time.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_time.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_time.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_time.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_wamr.edl b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_wamr.edl similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/sgx_wamr.edl rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/sgx_wamr.edl diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/file.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/file.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/file.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/file.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/pthread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/pthread.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/pthread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/pthread.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/signal.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/signal.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/signal.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/signal.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/socket.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/socket.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/socket.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/socket.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/time.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/time.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux-sgx/untrusted/time.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux-sgx/untrusted/time.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux/platform_init.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux/platform_init.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux/platform_init.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux/platform_init.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux/platform_internal.h index 335070bf80f..aeddc4ccf25 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux/platform_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux/platform_internal.h @@ -95,8 +95,6 @@ typedef jmp_buf korp_jmpbuf; #define os_longjmp longjmp #define os_alloca alloca -#define os_getpagesize getpagesize - typedef void (*os_signal_handler)(void *sig_addr); int @@ -116,6 +114,8 @@ os_sigreturn(); #endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64/RISCV64 */ #endif /* end of WASM_DISABLE_HW_BOUND_CHECK */ +#define os_getpagesize getpagesize + #if WASM_DISABLE_WAKEUP_BLOCKING_OP == 0 #define OS_ENABLE_WAKEUP_BLOCKING_OP #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/linux/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/linux/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/nuttx/nuttx_platform.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/nuttx/nuttx_platform.c similarity index 86% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/nuttx/nuttx_platform.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/nuttx/nuttx_platform.c index 38e70076d16..0077c9e0211 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/nuttx/nuttx_platform.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/nuttx/nuttx_platform.c @@ -87,13 +87,18 @@ os_dumps_proc_mem_info(char *out, unsigned int size) void * os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) { + void *p; #if (WASM_MEM_DUAL_BUS_MIRROR != 0) void *i_addr, *d_addr; #endif #if defined(CONFIG_ARCH_USE_TEXT_HEAP) if ((prot & MMAP_PROT_EXEC) != 0) { - return up_textheap_memalign(sizeof(void *), size); + p = up_textheap_memalign(sizeof(void *), size); + if (p) { + memset(p, 0, size); + } + return p; } #endif @@ -107,10 +112,32 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) return NULL; } i_addr = (void *)((uint8 *)d_addr + MEM_DUAL_BUS_OFFSET); - return in_ibus_ext(i_addr) ? i_addr : d_addr; + p = in_ibus_ext(i_addr) ? i_addr : d_addr; + if (p) { + memset(p, 0, size); + } + return p; } #endif - return malloc((uint32)size); + /* Note: aot_loader.c assumes that os_mmap provides large enough + * alignment for any data sections. Some sections like rodata.cst32 + * actually require alignment larger than the natural alignment + * provided by malloc. + * + * Probably it's cleaner to add an explicit alignment argument to + * os_mmap. However, it only makes sense if we change our aot format + * to keep the necessary alignment. + * + * For now, let's assume 32 byte alignment is enough. + */ + if (posix_memalign(&p, 32, size)) { + return NULL; + } + + /* Zero the memory which is required by os_mmap */ + memset(p, 0, size); + + return p; } void diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/nuttx/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/nuttx/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/nuttx/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/nuttx/platform_internal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/nuttx/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/nuttx/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/nuttx/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/nuttx/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/platform_internal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/riot_platform.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/riot_platform.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/riot_platform.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/riot_platform.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/riot_thread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/riot_thread.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/riot_thread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/riot_thread.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/riot_time.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/riot_time.c similarity index 73% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/riot_time.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/riot_time.c index 1503495c1ad..ce73777c921 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/riot_time.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/riot_time.c @@ -10,25 +10,32 @@ #if IS_USED(MODULE_ZTIMER64_USEC) uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { return ztimer64_now(ZTIMER64_USEC); } #elif IS_USED(MODULE_ZTIMER64_MSEC) uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { return ztimer64_now(ZTIMER64_MSEC) * 1000; } #else #ifdef __GNUC__ __attribute__((weak)) uint64 -os_time_get_boot_microsecond(); +os_time_get_boot_us(); #endif uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { static uint64_t times; return ++times; } #endif + +uint64 +os_time_thread_cputime_us(void) +{ + /* FIXME if u know the right api */ + return os_time_get_boot_us(); +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/riot/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/riot/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/platform_internal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/rtt_platform.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/rtt_platform.c similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/rtt_platform.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/rtt_platform.c index 37b247d35fe..31fb316223f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/rtt_platform.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/rtt_platform.c @@ -120,13 +120,20 @@ os_vprintf(const char *format, va_list ap) } uint64 -os_time_get_boot_microsecond(void) +os_time_get_boot_us(void) { uint64 ret = rt_tick_get() * 1000; ret /= RT_TICK_PER_SECOND; return ret; } +uint64 +os_time_thread_cputime_us(void) +{ + /* FIXME if u know the right api */ + return os_time_get_boot_us(); +} + korp_tid os_self_thread(void) { diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/rt-thread/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/rt-thread/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/vxworks/platform_init.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/vxworks/platform_init.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/vxworks/platform_init.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/vxworks/platform_init.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/vxworks/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/vxworks/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/vxworks/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/vxworks/platform_internal.h index 930ff7777bf..1b870c70eb7 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/vxworks/platform_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/vxworks/platform_internal.h @@ -79,8 +79,6 @@ typedef jmp_buf korp_jmpbuf; #define os_longjmp longjmp #define os_alloca alloca -#define os_getpagesize getpagesize - typedef void (*os_signal_handler)(void *sig_addr); int @@ -100,6 +98,8 @@ os_sigreturn(); #endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64 */ #endif /* end of WASM_DISABLE_HW_BOUND_CHECK */ +#define os_getpagesize getpagesize + static inline os_file_handle os_get_invalid_handle() { diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/vxworks/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/vxworks/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/vxworks/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/vxworks/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/platform_init.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/platform_init.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/platform_init.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/platform_init.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/platform_internal.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/platform_internal.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/shared_platform.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/shared_platform.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_atomic.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_atomic.cpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_atomic.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_atomic.cpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_clock.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_clock.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_clock.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_clock.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_file.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_file.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_file.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_file.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_malloc.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_malloc.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_malloc.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_malloc.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_memmap.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_memmap.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_memmap.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_memmap.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_socket.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_socket.c similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_socket.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_socket.c index 91d38fd8b60..b19e5b0976c 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_socket.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_socket.c @@ -32,6 +32,7 @@ static bool is_winsock_inited = false; int init_winsock() { +#if WASM_ENABLE_HOST_SOCKET_INIT == 0 WSADATA wsaData; if (!is_winsock_inited) { @@ -42,6 +43,7 @@ init_winsock() is_winsock_inited = true; } +#endif return BHT_OK; } @@ -49,9 +51,11 @@ init_winsock() void deinit_winsock() { +#if WASM_ENABLE_HOST_SOCKET_INIT == 0 if (is_winsock_inited) { WSACleanup(); } +#endif } int diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_thread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_thread.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_thread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_thread.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_time.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_time.c similarity index 77% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_time.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_time.c index 20e90d5eba9..7b2cd4fffa0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_time.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_time.c @@ -6,7 +6,7 @@ #include "platform_api_vmcore.h" uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { struct timespec ts; #if defined(__MINGW32__) @@ -18,3 +18,10 @@ os_time_get_boot_microsecond() return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000; } + +uint64 +os_time_thread_cputime_us(void) +{ + /* FIXME if u know the right api */ + return os_time_get_boot_us(); +} \ No newline at end of file diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_util.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_util.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_util.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_util.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_util.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_util.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/windows/win_util.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/windows/win_util.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/platform_internal.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/platform_internal.h similarity index 93% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/platform_internal.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/platform_internal.h index a5d563a6c8f..85d4a832d24 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/platform_internal.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/platform_internal.h @@ -50,6 +50,10 @@ #include #endif /* end of KERNEL_VERSION_NUMBER < 0x030200 */ +#if KERNEL_VERSION_NUMBER >= 0x030300 /* version 3.3.0 */ +#include +#endif /* end of KERNEL_VERSION_NUMBER > 0x030300 */ + #ifdef CONFIG_ARM_MPU #if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */ #include @@ -96,7 +100,8 @@ void abort(void); size_t strspn(const char *s, const char *accept); size_t strcspn(const char *s, const char *reject); -/* math functions which are not provided by os */ +/* math functions which are not provided by os with minimal libc */ +#if defined(CONFIG_MINIMAL_LIBC) double atan(double x); double atan2(double y, double x); double sqrt(double x); @@ -123,6 +128,10 @@ double scalbn(double x, int n); unsigned long long int strtoull(const char *nptr, char **endptr, int base); double strtod(const char *nptr, char **endptr); float strtof(const char *nptr, char **endptr); +#else +#include +#endif /* CONFIG_MINIMAL_LIBC */ + /* clang-format on */ #if KERNEL_VERSION_NUMBER >= 0x030100 /* version 3.1.0 */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/shared_platform.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/shared_platform.cmake similarity index 79% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/shared_platform.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/shared_platform.cmake index 9b043b52f3b..dfd45a4064f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/shared_platform.cmake +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/shared_platform.cmake @@ -8,7 +8,9 @@ add_definitions(-DBH_PLATFORM_ZEPHYR) include_directories(${PLATFORM_SHARED_DIR}) include_directories(${PLATFORM_SHARED_DIR}/../include) -include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake) +if(${CONFIG_MINIMAL_LIBC}) + include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake) +endif() file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/zephyr_platform.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/zephyr_platform.c similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/zephyr_platform.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/zephyr_platform.c index 1a5b6621d1f..0fb8e2bd41f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/zephyr_platform.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/zephyr_platform.c @@ -25,9 +25,11 @@ disable_mpu_rasr_xn(void) would most likely be set at index 2. */ for (index = 0U; index < 8; index++) { MPU->RNR = index; +#ifdef MPU_RASR_XN_Msk if (MPU->RASR & MPU_RASR_XN_Msk) { MPU->RASR |= ~MPU_RASR_XN_Msk; } +#endif } } #endif /* end of CONFIG_ARM_MPU */ @@ -72,18 +74,20 @@ bh_platform_destroy() void * os_malloc(unsigned size) { - return NULL; + return malloc(size); } void * os_realloc(void *ptr, unsigned size) { - return NULL; + return realloc(ptr, size); } void os_free(void *ptr) -{} +{ + free(ptr); +} int os_dumps_proc_mem_info(char *out, unsigned int size) @@ -202,10 +206,14 @@ void os_dcache_flush() { #if defined(CONFIG_CPU_CORTEX_M7) && defined(CONFIG_ARM_MPU) +#if KERNEL_VERSION_NUMBER < 0x030300 /* version 3.3.0 */ uint32 key; key = irq_lock(); SCB_CleanDCache(); irq_unlock(key); +#else + sys_cache_data_flush_all(); +#endif #elif defined(CONFIG_SOC_CVF_EM7D) && defined(CONFIG_ARC_MPU) \ && defined(CONFIG_CACHE_FLUSHING) __asm__ __volatile__("sync"); @@ -216,7 +224,11 @@ os_dcache_flush() void os_icache_flush(void *start, size_t len) -{} +{ +#if KERNEL_VERSION_NUMBER >= 0x030300 /* version 3.3.0 */ + sys_cache_instr_flush_range(start, len); +#endif +} void set_exec_mem_alloc_func(exec_mem_alloc_func_t alloc_func, diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/zephyr_thread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/zephyr_thread.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/zephyr_thread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/zephyr_thread.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/zephyr_time.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/zephyr_time.c similarity index 59% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/zephyr_time.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/zephyr_time.c index 99eb3b35467..78bc3e07613 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/platform/zephyr/zephyr_time.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/platform/zephyr/zephyr_time.c @@ -6,7 +6,14 @@ #include "platform_api_vmcore.h" uint64 -os_time_get_boot_microsecond() +os_time_get_boot_us() { return k_uptime_get() * 1000; } + +uint64 +os_time_thread_cputime_us(void) +{ + /* FIXME if u know the right api */ + return os_time_get_boot_us(); +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_assert.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_assert.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_assert.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_assert.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_assert.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_assert.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_assert.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_assert.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_atomic.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_atomic.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_atomic.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_atomic.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_bitmap.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_bitmap.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_bitmap.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_bitmap.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_bitmap.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_bitmap.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_bitmap.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_bitmap.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_common.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_common.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_common.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_common.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_common.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_common.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_common.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_common.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_hashmap.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_hashmap.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_hashmap.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_hashmap.c index 3502239ad87..794b7a746e0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_hashmap.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_hashmap.c @@ -51,7 +51,9 @@ bh_hash_map_create(uint32 size, bool use_lock, HashFunc hash_func, + sizeof(HashMapElem *) * (uint64)size + (use_lock ? sizeof(korp_mutex) : 0); - if (total_size >= UINT32_MAX || !(map = BH_MALLOC((uint32)total_size))) { + /* size <= HASH_MAP_MAX_SIZE, so total_size won't be larger than + UINT32_MAX, no need to check integer overflow */ + if (!(map = BH_MALLOC((uint32)total_size))) { LOG_ERROR("HashMap create failed: alloc memory failed.\n"); return NULL; } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_hashmap.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_hashmap.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_hashmap.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_hashmap.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_list.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_list.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_list.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_list.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_list.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_list.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_list.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_list.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_log.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_log.c similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_log.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_log.c index 78c058065d9..1ffd9b76416 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_log.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_log.c @@ -17,6 +17,7 @@ bh_log_set_verbose_level(uint32 level) log_verbose_level = level; } +#ifndef BH_LOG void bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...) { @@ -31,7 +32,7 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...) self = os_self_thread(); - usec = os_time_get_boot_microsecond(); + usec = os_time_get_boot_us(); t = (uint32)(usec / 1000000) % (24 * 60 * 60); h = t / (60 * 60); t = t % (60 * 60); @@ -43,7 +44,9 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...) "%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ":%03" PRIu32, h, m, s, mills); +#ifndef BH_VPRINTF os_printf("[%s - %" PRIXPTR "]: ", buf, (uintptr_t)self); +#endif if (file) os_printf("%s, line %d, ", file, line); @@ -54,6 +57,7 @@ bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...) os_printf("\n"); } +#endif static uint32 last_time_ms = 0; static uint32 total_time_ms = 0; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_log.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_log.h similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_log.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_log.h index e0bc61da26e..53921b250e0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_log.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_log.h @@ -38,8 +38,14 @@ typedef enum { void bh_log_set_verbose_level(uint32 level); +#ifndef BH_LOG void bh_log(LogLevel log_level, const char *file, int line, const char *fmt, ...); +#else +void +BH_LOG(uint32 log_level, const char *file, int line, const char *fmt, ...); +#define bh_log BH_LOG +#endif #ifdef BH_PLATFORM_NUTTX diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_platform.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_platform.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_platform.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_platform.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_queue.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_queue.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_queue.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_queue.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_queue.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_queue.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_queue.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_queue.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_vector.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_vector.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_vector.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_vector.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_vector.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_vector.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/bh_vector.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/bh_vector.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/gnuc.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/gnuc.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/gnuc.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/gnuc.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/runtime_timer.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/runtime_timer.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/runtime_timer.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/runtime_timer.c index 8fccf4c2f34..9d390c2145b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/runtime_timer.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/runtime_timer.c @@ -38,7 +38,7 @@ struct _timer_ctx { uint64 bh_get_tick_ms() { - return os_time_get_boot_microsecond() / 1000; + return os_time_get_boot_us() / 1000; } uint32 @@ -394,7 +394,7 @@ handle_expired_timers(timer_ctx_t ctx, app_timer_t *expired) operation may change expired->next */ expired = expired->next; if (t->is_periodic) { - /* if it is repeating, then reschedule it; */ + /* if it is repeating, then reschedule it */ reschedule_timer(ctx, t); } else { diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/runtime_timer.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/runtime_timer.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/runtime_timer.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/runtime_timer.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/shared_utils.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/shared_utils.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/shared_utils.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/shared_utils.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/bh_getopt.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/bh_getopt.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/bh_getopt.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/bh_getopt.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/bh_getopt.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/bh_getopt.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/bh_getopt.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/bh_getopt.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/bh_read_file.c b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/bh_read_file.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/bh_read_file.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/bh_read_file.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/bh_read_file.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/bh_read_file.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/bh_read_file.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/bh_read_file.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/shared_uncommon.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/shared_uncommon.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/shared/utils/uncommon/shared_uncommon.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/shared/utils/uncommon/shared_uncommon.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/version.h b/lib/wasm-micro-runtime-WAMR-1.3.3/core/version.h similarity index 89% rename from lib/wasm-micro-runtime-WAMR-1.3.0/core/version.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/core/version.h index 9bb76b2625b..a2231e5ac1b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/version.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/core/version.h @@ -7,5 +7,5 @@ #define _WAMR_VERSION_H_ #define WAMR_VERSION_MAJOR 1 #define WAMR_VERSION_MINOR 3 -#define WAMR_VERSION_PATCH 0 +#define WAMR_VERSION_PATCH 3 #endif diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/build_wamr.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/build_wamr.md similarity index 84% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/build_wamr.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/build_wamr.md index 12cbb41258e..6857478a9cc 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/build_wamr.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/build_wamr.md @@ -1,7 +1,7 @@ # Build WAMR vmcore -WAMR vmcore is a set of runtime libraries for loading and running Wasm modules. This document introduces how to build the WAMR vmcore. +WAMR vmcore is a set of runtime libraries for loading and running Wasm modules. This document introduces how to build the WAMR vmcore. References: - [how to build iwasm](../product-mini/README.md): building different target platforms such as Linux, Windows, Mac etc @@ -62,6 +62,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM #### **Enable Multi-Module feature** - **WAMR_BUILD_MULTI_MODULE**=1/0, default to disable if not set +> Note: See [Multiple Modules as Dependencies](./multi_module.md) for more details. #### **Enable WASM mini loader** @@ -82,6 +83,8 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM - **WAMR_BUILD_LIB_PTHREAD**=1/0, default to disable if not set > Note: The dependent feature of lib pthread such as the `shared memory` and `thread manager` will be enabled automatically. +> See [WAMR pthread library](./pthread_library.md) for more details. + #### **Enable lib-pthread-semaphore** - **WAMR_BUILD_LIB_PTHREAD_SEMAPHORE**=1/0, default to disable if not set > Note: This feature depends on `lib-pthread`, it will be enabled automatically if this feature is enabled. @@ -90,8 +93,11 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM - **WAMR_BUILD_LIB_WASI_THREADS**=1/0, default to disable if not set > Note: The dependent feature of lib wasi-threads such as the `shared memory` and `thread manager` will be enabled automatically. +> See [wasi-threads](./pthread_impls.md#wasi-threads-new) and [Introduction to WAMR WASI threads](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-wasi-threads) for more details. + #### **Enable lib wasi-nn** - **WAMR_BUILD_WASI_NN**=1/0, default to disable if not set +> Note: See [WASI-NN](../core/iwasm/libraries/wasi-nn) for more details. #### **Enable lib wasi-nn GPU mode** - **WAMR_BUILD_WASI_NN_ENABLE_GPU**=1/0, default to disable if not set @@ -130,19 +136,24 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM > Note: if it is enabled, the call stack will be dumped when exception occurs. > - For interpreter mode, the function names are firstly extracted from *custom name section*, if this section doesn't exist or the feature is not enabled, then the name will be extracted from the import/export sections -> - For AOT/JIT mode, the function names are extracted from import/export section, please export as many functions as possible (for `wasi-sdk` you can use `-Wl,--export-all`) when compiling wasm module, and add `--enable-dump-call-stack` option to wamrc during compiling AOT module. +> - For AOT/JIT mode, the function names are extracted from import/export section, please export as many functions as possible (for `wasi-sdk` you can use `-Wl,--export-all`) when compiling wasm module, and add `--enable-dump-call-stack --emit-custom-sections=name` option to wamrc during compiling AOT module. #### **Enable memory profiling (Experiment)** - **WAMR_BUILD_MEMORY_PROFILING**=1/0, default to disable if not set > Note: if it is enabled, developer can use API `void wasm_runtime_dump_mem_consumption(wasm_exec_env_t exec_env)` to dump the memory consumption info. Currently we only profile the memory consumption of module, module_instance and exec_env, the memory consumed by other components such as `wasi-ctx`, `multi-module` and `thread-manager` are not included. +> Also refer to [Memory usage estimation for a module](./memory_usage.md). + #### **Enable performance profiling (Experiment)** - **WAMR_BUILD_PERF_PROFILING**=1/0, default to disable if not set > Note: if it is enabled, developer can use API `void wasm_runtime_dump_perf_profiling(wasm_module_inst_t module_inst)` to dump the performance consumption info. Currently we only profile the performance consumption of each WASM function. > The function name searching sequence is the same with dump call stack feature. +> Also refer to [Tune the performance of running wasm/aot file](./perf_tune.md). + + #### **Enable the global heap** - **WAMR_BUILD_GLOBAL_HEAP_POOL**=1/0, default to disable if not set for all *iwasm* applications, except for the platforms Alios and Zephyr. @@ -179,7 +190,17 @@ Currently we only profile the memory consumption of module, module_instance and > } > ``` > -> and then use `cmake -DWAMR_BH_VPRINTF=my_vprintf ..` to pass the callback function, or add `BH_VPRINTF=my_vprintf` macro for the compiler, e.g. add line `add_defintions(-DBH_VPRINTF=my_vprintf)` in CMakeListst.txt. +> and then use `cmake -DWAMR_BH_VPRINTF=my_vprintf ..` to pass the callback function, or add `BH_VPRINTF=my_vprintf` macro for the compiler, e.g. add line `add_defintions(-DBH_VPRINTF=my_vprintf)` in CMakeListst.txt. See [basic sample](../samples/basic/src/main.c) for a usage example. + +#### **WAMR_BH_LOG**=, default to disable if not set +> Note: if the log_callback function is provided by the developer, WAMR logs are redirected to such callback. For example: +> ```C +> void my_log(uint32 log_level, const char *file, int line, const char *fmt, ...) +> { +> /* Usage of custom logger */ +> } +> ``` +> See [basic sample](../samples/basic/src/main.c) for a usage example. #### **Enable reference types feature** - **WAMR_BUILD_REF_TYPES**=1/0, default to disable if not set @@ -192,7 +213,7 @@ Currently we only profile the memory consumption of module, module_instance and #### **Enable source debugging features** - **WAMR_BUILD_DEBUG_INTERP**=1/0, default to 0 if not set -> Note: There are some other setup required by source debugging, please refer to [source_debugging.md](./source_debugging.md) for more details. +> Note: There are some other setup required by source debugging, please refer to [source_debugging.md](./source_debugging.md) and [WAMR source debugging basic](https://bytecodealliance.github.io/wamr.dev/blog/wamr-source-debugging-basic) for more details. #### **Enable load wasm custom sections** - **WAMR_BUILD_LOAD_CUSTOM_SECTION**=1/0, default to disable if not set @@ -201,18 +222,40 @@ Currently we only profile the memory consumption of module, module_instance and > Note: If `WAMR_BUILD_CUSTOM_NAME_SECTION` is enabled, then the `custom name section` will be treated as a special section and consumed by the runtime, not available to the embedder. -> For AoT file, must use `--emit-custom-sections` to specify which sections need to be emitted into AoT file, otherwise all custom sections (except custom name section) will be ignored. +> For AoT file, must use `--emit-custom-sections` to specify which sections need to be emitted into AoT file, otherwise all custom sections will be ignored. ### **Stack guard size** - **WAMR_BUILD_STACK_GUARD_SIZE**=n, default to N/A if not set. > Note: By default, the stack guard size is 1K (1024) or 24K (if uvwasi enabled). -### **Disable the writing linear memory base address to x86 GS segment register +### **Disable the writing linear memory base address to x86 GS segment register** - **WAMR_DISABLE_WRITE_GS_BASE**=1/0, default to enable if not set and supported by platform > Note: by default only platform [linux x86-64](https://github.com/bytecodealliance/wasm-micro-runtime/blob/5fb5119239220b0803e7045ca49b0a29fe65e70e/core/shared/platform/linux/platform_internal.h#L67) will enable this feature, for 32-bit platforms it's automatically disabled even when the flag is set to 0. In linux x86-64, writing the linear memory base address to x86 GS segment register may be used to speedup the linear memory access for LLVM AOT/JIT, when `--enable-segue=[]` option is added for `wamrc` or `iwasm`. +> See [Enable segue optimization for wamrc when generating the aot file](./perf_tune.md#3-enable-segue-optimization-for-wamrc-when-generating-the-aot-file) for more details. + ### **Enable running PGO(Profile-Guided Optimization) instrumented AOT file** - **WAMR_BUILD_STATIC_PGO**=1/0, default to disable if not set +> Note: See [Use the AOT static PGO method](./perf_tune.md#5-use-the-aot-static-pgo-method) for more details. + +### **Enable linux perf support** +- **WAMR_BUILD_LINUX_PERF**=1/0, enable linux perf support to generate the flamegraph to analyze the performance of a wasm application, default to disable if not set +> Note: See [Use linux-perf](./perf_tune.md#7-use-linux-perf) for more details. + +### **Enable module instance context APIs** +- **WAMR_BUILD_MODULE_INST_CONTEXT**=1/0, enable module instance context APIs which can set one or more contexts created by the embedder for a wasm module instance, default to enable if not set: +```C + wasm_runtime_create_context_key + wasm_runtime_destroy_context_key + wasm_runtime_set_context + wasm_runtime_set_context_spread + wasm_runtime_get_context +``` +> Note: See [wasm_export.h](../core/iwasm/include/wasm_export.h) for more details. + +### **Enable quick AOT/JTI entries** +- **WAMR_BUILD_QUICK_AOT_ENTRY**=1/0, enable registering quick call entries to speedup the aot/jit func call process, default to enable if not set +> Note: See [Refine callings to AOT/JIT functions from host native](./perf_tune.md#83-refine-callings-to-aotjit-functions-from-host-native) for more details. **Combination of configurations:** diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/build_wasm_app.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/build_wasm_app.md similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/build_wasm_app.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/build_wasm_app.md index 4475824dcb7..7747d9ac396 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/build_wasm_app.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/build_wasm_app.md @@ -5,7 +5,7 @@ Prepare WASM building environments For C and C++, WASI-SDK version 19.0+ is the major tool supported by WAMR to build WASM applications. Also, we can use [Emscripten SDK (EMSDK)](https://github.com/emscripten-core/emsdk), but it is not recommended. And there are some other compilers such as the standard clang compiler, which might also work [here](./other_wasm_compilers.md). -To install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. +To install WASI SDK, please download the [wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. The official *wasi-sdk release* doesn't fully support *latest 128-bit SIMD spec* yet. WAMR provides a script in [build-wasi-sdk](../test-tools/build-wasi-sdk/) to generate another wasi-sdk with *llvm-15* from source code and installs it at *../test-tools/wasi-sdk*. If you plan to build WASM applications with *latest 128-bit SIMD*, please use it instead of the official release. @@ -372,6 +372,20 @@ Examples: wamrc -o test.aot test.wasm wamrc --target=i386 --format=object -o test.o test.wasm ``` +## AoT-compiled module compatibility among WAMR versions + +When making major ABI changes for AoT-compiled modules, we bump +`AOT_CURRENT_VERSION` constant in `core/config.h` header. +The runtime rejects to load a module AoT-compiled with wamrc with +a different `AOT_CURRENT_VERSION`. + +We try our best to maintain our runtime ABI for AoT-compiled modules +compatible among WAMR versions with the same `AOT_CURRENT_VERSION` +so that combinations of older wamrc and newer runtime usually work. +However, there might be minor incompatibilities time to time. +For productions, we recommend to use the exactly same version of +wamrc and the runtime. + ## AoT compilation with 3rd-party toolchains `wamrc` uses LLVM to compile wasm bytecode to AoT file, this works for most of the architectures, but there may be circumstances where you want to use 3rd-party toolchains to take over some steps of the compilation pipeline, e.g. diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/devcontainer.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/devcontainer.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/devcontainer.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/devcontainer.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/embed_wamr.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/embed_wamr.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/embed_wamr.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/embed_wamr.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/embed_wamr_spawn_api.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/embed_wamr_spawn_api.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/embed_wamr_spawn_api.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/embed_wamr_spawn_api.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/export_native_api.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/export_native_api.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/export_native_api.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/export_native_api.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/linux_sgx.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/linux_sgx.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/linux_sgx.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/linux_sgx.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/memory_tune.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/memory_tune.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/memory_tune.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/memory_tune.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/memory_usage.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/memory_usage.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/memory_usage.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/memory_usage.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/multi_module.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/multi_module.md similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/multi_module.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/multi_module.md index 1c22863f95b..9ab26673e2d 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/multi_module.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/multi_module.md @@ -6,7 +6,7 @@ WAMR loads all dependencies recursively according to the _import section_ of a m > WAMR only implements the load-time dynamic linking. Please refer to [dynamic linking](https://webassembly.org/docs/dynamic-linking/) for more details. -WAMR follows [WASI Command/Reactor Model](https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md#current-unstable-abi). The WASI model separates modules into commands and reactors. A Command is the main module that requires exports of reactors(submodules). +WAMR follows [WASI Command/Reactor Model](https://github.com/WebAssembly/WASI/blob/main/legacy/application-abi.md#current-unstable-abi). The WASI model separates modules into commands and reactors. A Command is the main module that requires exports of reactors(submodules). if `WASM_ENABLE_LIBC_WASI` is enabled, any module imports a WASI APIs, like `(import "wasi_snapshot_preview1" "XXX")`, should follow restrictions of the _WASI application ABI_: diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/other_wasm_compilers.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/other_wasm_compilers.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/other_wasm_compilers.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/other_wasm_compilers.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/perf_tune.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/perf_tune.md similarity index 57% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/perf_tune.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/perf_tune.md index f57abe068ca..498359f37f5 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/perf_tune.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/perf_tune.md @@ -28,7 +28,7 @@ emcc -msimd128 -O3 -o - Reduce the footprint of JIT/AOT, the JIT/AOT code generated is smaller - Reduce the compilation time of JIT/AOT -Currently it is supported on linux x86-64, developer can use `--enable-segue=[]` for wamrc: +Currently it is only supported on linux x86-64, developer can use `--enable-segue=[]` for wamrc: ```bash wamrc --enable-segue -o aot_file wasm_file @@ -50,6 +50,8 @@ iwasm --enable-segue wasm_file (iwasm is built with llvm-jit enabled) iwasm --enable-segue=[] wasm_file ``` +> Note: Currently it is only supported on linux x86-64. + ## 5. Use the AOT static PGO method LLVM PGO (Profile-Guided Optimization) allows the compiler to better optimize code for how it actually runs. WAMR supports AOT static PGO, currently it is tested on Linux x86-64 and x86-32. The basic steps are: @@ -134,7 +136,7 @@ $ perf report --input=perf.data > > For example, with EMCC, you can add `-g2`. > -> If not able to get the context of the custom name section, WAMR will use `aot_func#N` to represent the function name. `N` is from 0. `aot_func#0` represents the first *not imported wasm function*. +> If not able to get the context of the custom name section, WAMR will use `aot_func#N` to represent the function name. `N` is from 0. `aot_func#0` represents the first _not imported wasm function_. ### 7.1 Flamegraph @@ -177,3 +179,125 @@ $ ./FlameGraph/flamegraph.pl out.folded > perf.foo.wasm.svg > # only jitted functions > $ grep "wasm_runtime_invoke_native" out.folded | ./FlameGraph/flamegraph.pl > perf.foo.wasm.only.svg > ``` + +> [!TIP] +> use [trans_wasm_func_name.py](../test-tools/trans-jitted-func-name/trans_wasm_func_name.py) to translate jitted function +> names to its original wasm function names. It requires _wasm-objdump_ in _wabt_ and _name section_ in the .wasm file +> +> The input file is the output of `./FlameGraph/stackcollapse-perf.pl`. +> +> ```bash +> python trans_wasm_func_name.py --wabt_home --folded out.folded <.wasm> +> ``` +> +> Then you will see a new file named _out.folded.translated_ which contains the translated folded stacks. +> All wasm functions are translated to its original names with a prefix like "[Wasm]" + +## 8. Refine the calling processes between host native and wasm application + +In some scenarios, there may be lots of callings between host native and wasm application, e.g. frequent callings to AOT/JIT functions from host native or frequent callings to host native from AOT/JIT functions. It is important to refine these calling processes to speedup them, WAMR provides several methods: + +### 8.1 Refine callings to native APIs registered by `wasm_runtime_register_natives` from AOT code + +When wamrc compiles the wasm file to AOT code, it may generate LLVM IR to call the native API from an AOT function, and if it doesn't know the native API's signature, the generated LLVM IR has to call the runtime API `aot_invoke_native` to invoke the native API, which is a relatively slow way. If developer registers native APIs during execution by calling `wasm_runtime_register_natives` or by `iwasm --native-lib=`, then developer can also register native APIs with the same signatures to the AOT compiler by `wamrc --native-lib=`, so as to let the AOT compiler pre-know the native API's signature, and generate optimized LLVM IR to quickly call to the native API. + +The below sample registers an API `int test_add(int, int)` to the AOT compiler: + +```C +/* test_add.c */ + +#include "wasm_export.h" + +static int +test_add_wrapper(wasm_exec_env_t exec_env, int x, int y) { + return 0; /* empty function is enough */ +} + +#define REG_NATIVE_FUNC(func_name, signature) \ + { #func_name, func_name##_wrapper, signature, NULL } + +static NativeSymbol native_symbols[] = { + REG_NATIVE_FUNC(test_add, "(ii)i") +}; + +uint32_t +get_native_lib(char **p_module_name, NativeSymbol **p_native_symbols) +{ + *p_module_name = "env"; + *p_native_symbols = native_symbols; + return sizeof(native_symbols) / sizeof(NativeSymbol); +} +``` +```bash +# build native lib +gcc -O3 -fPIC -shared -I /core/iwasm/include -o libtest_add.so test_add.c +# register native lib to aot compiler +wamrc --native-lib=./libtest_add.so -o +``` + +> Note: no need to do anything for LLVM JIT since the native APIs must have been registered before execution and JIT compiler already knows the native APIs' signatures. + +### 8.2 Refine callings to native APIs registered by wasm-c-api `wasm_instance_new` from AOT code + +In wasm-c-api mode, when the native APIs are registered by `wasm_instance_new(..., imports, ...)`, developer can use `wamrc --invoke-c-api-import` option to generate the AOT file, which treats the unknown import function as wasm-c-api import function and generates optimized LLVM IR to speedup the calling process. + +> Note: no need to do anything for LLVM JIT since the similar flag has been set to JIT compiler in wasm-c-api `wasm_engine_new` when LLVM JIT is enabled. + +### 8.3 Refine callings to AOT/JIT functions from host native + +Currently by default WAMR runtime has registered many quick AOT/JIT entries to speedup the calling processes to call AOT/JIT functions from host native, as long as developer doesn't disable it by using `cmake -DWAMR_BUILD_QUICK_AOT_ENTRY=0` or setting the compiler macro `WASM_ENABLE_QUICK_AOT_ENTRY` to 0 in the makefile. These quick AOT/JIT entries include: + +1. wasm function contains 0 to 4 arguments and 0 to 1 results, with the type of each argument is i32 or i64 and the type of result is i32, i64 or void. These functions are like: + +```C +// no argument +i32 foo(), i64 foo(), void foo() +// one argument, each argument is i32 or i64 +i32 foo(i32/i64), i64 foo(i32/i64), void(i32/i64) +// two arguments, each argument is i32 or i64 +i32 foo(i32/i64, i32/i64), i64 foo(i32/i64, i32/i64), void(i32/i64, i32/i64) +// three arguments, each argument is i32 or i64 +i32 foo(i32/i64, i32/i64, i32/i64), i64 foo(i32/i64, i32/i64, i32/i64), void(i32/i64, i32/i64, i32/i64) +// four arguments, each argument is i32 or i64 +i32 foo(i32/i64, i32/i64, i32/i64, i32/i64) +i64 foo(i32/i64, i32/i64, i32/i64, i32/i64) +void(i32/i64, i32/i64, i32/i64, i32/i64) +``` + +2. wasm function contains 5 arguments and 0 to 1 results, with the type of each argument is i32 and the type of result is i32, i64 or void. These functions are like: + +```C +i32 foo(i32, i32, i32, i32, i32) +i64 foo(i32, i32, i32, i32, i32) +void foo(i32, i32, i32, i32, i32) +``` + +To speedup the calling processes, developer had better ensure that the signatures of the wasm functions to expose are like above, or add some conversions to achieve it. For example, if a wasm function to call is `f32 foo(f32)`, developer can define a new function `i32 foo1(i32)` like below and export it: +```C +int32 foo1(int32 arg_i32) +{ + float arg_f32 = *(float *)&arg_i32; + float res_f32 = foo(f32); + int32 res_i32 = *(int32 *)&res_i32; + return res_i32; +} +``` +And in the host embedder: +``` + uint32 argv[2]; + float arg_f32 = ...; /* argument to foo */ + float res_f32; + bool ret; + + argv[0] = *(uint32 *)&arg_f32; + func = wasm_runtime_lookup_function(module_inst, "foo1", NULL); + ret = wasm_runtime_call_wasm(exec_env, func, 1, argv); + if (!ret) { + /* handle exception */ + printf("%s\n", wasm_runtime_get_exception(module_inst)); + } + else { + /* the return value is stored in argv[0] */ + res_f32 = *(float *)&argv[0]; + } +``` diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/app_framework.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/app_framework.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/app_framework.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/app_framework.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/embed.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/embed.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/embed.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/embed.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/extend_library.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/extend_library.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/extend_library.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/extend_library.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/multi_module_pic1.png b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/multi_module_pic1.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/multi_module_pic1.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/multi_module_pic1.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/native_call_wasm.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/native_call_wasm.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/native_call_wasm.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/native_call_wasm.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/request.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/request.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/request.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/request.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/safe.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/safe.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/safe.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/safe.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/sensor_callflow.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/sensor_callflow.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/sensor_callflow.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/sensor_callflow.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/sub.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/sub.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/sub.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/sub.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/vgl_demo.png b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/vgl_demo.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/vgl_demo.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/vgl_demo.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/vgl_demo2.png b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/vgl_demo2.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/vgl_demo2.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/vgl_demo2.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/vgl_demo_linux.png b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/vgl_demo_linux.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/vgl_demo_linux.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/vgl_demo_linux.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/vgl_linux.PNG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/vgl_linux.PNG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/vgl_linux.PNG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/vgl_linux.PNG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/wamr-arch.JPG b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/wamr-arch.JPG similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/wamr-arch.JPG rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/wamr-arch.JPG diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/wamr_memory_model.png b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/wamr_memory_model.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/wamr_memory_model.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/wamr_memory_model.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/wamr_menu_config.png b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/wamr_menu_config.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pics/wamr_menu_config.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pics/wamr_menu_config.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/port_wamr.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/port_wamr.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/port_wamr.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/port_wamr.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pthread_impls.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pthread_impls.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pthread_impls.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pthread_impls.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/pthread_library.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/pthread_library.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/pthread_library.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/pthread_library.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/ref_types.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/ref_types.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/ref_types.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/ref_types.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/release_ack.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/release_ack.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/release_ack.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/release_ack.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/roadmap.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/roadmap.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/roadmap.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/roadmap.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/semantic_version.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/semantic_version.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/semantic_version.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/semantic_version.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/socket_api.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/socket_api.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/socket_api.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/socket_api.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging.md new file mode 100644 index 00000000000..bfa62f6c2d3 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging.md @@ -0,0 +1,20 @@ +# WAMR source debugging + +## Build wasm application with debug information +To debug your application, you need to compile them with debug information. You can use `-g` option when compiling the source code if you are using wasi-sdk (also work for emcc and rustc): +``` bash +/opt/wasi-sdk/bin/clang -g test.c -o test.wasm +``` + +Then you will get `test.wasm` which is a WebAssembly module with embedded DWARF sections. Further, you can use `llvm-dwarfdump` to check if the generated wasm file contains DWARF information: +``` bash +llvm-dwarfdump-12 test.wasm +``` + +## Debugging with interpreter + +See [Debuggging with interpreter](source_debugging_interpreter.md). + +## Debugging with AOT + +See [Debuggging with AOT](source_debugging_aot.md). diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging_aot.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging_aot.md new file mode 100644 index 00000000000..129287bde73 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging_aot.md @@ -0,0 +1,100 @@ +# WAMR source debugging (AOT) + +## Debugging with AOT + +> Note: AOT debugging is experimental and only a few debugging capabilities are supported. + +1. Build lldb (assume you have already built llvm) +``` bash +cd ${WAMR_ROOT}/core/deps/llvm/build +cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLDB_INCLUDE_TESTS=OFF +make -j $(nproc) +``` + +2. Build wamrc with debugging feature +``` bash +cd ${WAMR_ROOT}/wamr-compiler +mkdir build && cd build +cmake .. -DWAMR_BUILD_DEBUG_AOT=1 +make -j $(nproc) +``` + +3. Build iwasm with debugging feature +``` bash +cd ${WAMR_ROOT}/product-mini/platforms/linux +mkdir build && cd build +cmake .. -DWAMR_BUILD_DEBUG_AOT=1 +make +``` + +4. Compile wasm module to AOT module +``` bash +wamrc -o test.aot test.wasm +``` + +5. Execute iwasm using lldb + + Then you can use lldb commands to debug both wamr runtime and your wasm application in ***current terminal***. + + ``` bash + % lldb iwasm -- test.aot + (lldb) target create "iwasm" + Current executable set to 'iwasm' (x86_64). + (lldb) settings set -- target.run-args "test.aot" + (lldb) settings set plugin.jit-loader.gdb.enable on + (lldb) b main + Breakpoint 1: where = iwasm`main + 48 at main.c:294:11, address = 0x0000000100001020 + (lldb) run + Process 27954 launched: '/tmp/bin/iwasm' (x86_64) + Process 27954 stopped + * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 + frame #0: 0x0000000100001020 iwasm`main(argc=2, argv=0x00007ff7bfeff678) at main.c:294:11 + 291 int + 292 main(int argc, char *argv[]) + 293 { + -> 294 int32 ret = -1; + 295 char *wasm_file = NULL; + 296 const char *func_name = NULL; + 297 uint8 *wasm_file_buf = NULL; + Target 0: (iwasm) stopped. + (lldb) c + Process 27954 resuming + 1 location added to breakpoint 1 + error: need to add support for DW_TAG_base_type 'void' encoded with DW_ATE = 0x0, bit_size = 0 + Process 27954 stopped + * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2 + frame #0: 0x00000001002980a0 JIT(0x100298004)`main(exenv=0x0000000301808200) at hello.c:6:9 + 3 int + 4 main(void) + 5 { + -> 6 printf("hello\n"); + 7 + 8 return 0; + 9 } + Target 0: (iwasm) stopped. + (lldb) br l + Current breakpoints: + 1: name = 'main', locations = 2, resolved = 2, hit count = 2 + 1.1: where = iwasm`main + 48 at main.c:294:11, address = 0x0000000100001020, resolved, hit count = 1 + 1.2: where = JIT(0x100298004)`main + 12 at hello.c:6:9, address = 0x00000001002980a0, resolved, hit count = 1 + + (lldb) + ``` + + * In the above example, + + * The first `main` function, which is in `main.c`, is the main + function of the iwasm command. + + * The second `main` function, which is in `hello.c`, is the main + function of the AOT-compiled wasm module. + + * WAMR AOT debugging uses the GDB JIT loader mechanism to load + the debug info of the debugee module. + On some platforms including macOS, you need to enable it explicitly. + (`settings set plugin.jit-loader.gdb.enable on`) + + References: + + * https://github.com/llvm/llvm-project/blob/main/llvm/docs/DebuggingJITedCode.rst + * https://sourceware.org/gdb/current/onlinedocs/gdb/JIT-Interface.html diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/source_debugging.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging_interpreter.md similarity index 55% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/source_debugging.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging_interpreter.md index 513185fe88c..577b9bf4a44 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/source_debugging.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/source_debugging_interpreter.md @@ -1,4 +1,4 @@ -# WAMR source debugging +# WAMR source debugging (interpreter) References: - [Blog: WAMR source debugging basic](https://bytecodealliance.github.io/wamr.dev/blog/wamr-source-debugging-basic/) @@ -8,18 +8,8 @@ WAMR supports source level debugging based on DWARF (normally used in C/C++/Rust **The lldb's ability to debug wasm application is based on the patch [Add class WasmProcess for WebAssembly debugging](https://reviews.llvm.org/D78801). Thanks very much to the author @paolosev for such a great work!** -## Build wasm application with debug information -To debug your application, you need to compile them with debug information. You can use `-g` option when compiling the source code if you are using wasi-sdk (also work for emcc and rustc): -``` bash -/opt/wasi-sdk/bin/clang -g test.c -o test.wasm -``` - -Then you will get `test.wasm` which is a WebAssembly module with embedded DWARF sections. Further, you can use `llvm-dwarfdump` to check if the generated wasm file contains DWARF information: -``` bash -llvm-dwarfdump-12 test.wasm -``` - ## Debugging with interpreter + 1. Install dependent libraries ``` bash apt update && apt install cmake make g++ libxml2-dev -y @@ -70,105 +60,6 @@ lldb ``` Then you can use lldb commands to debug your applications. Please refer to [lldb document](https://lldb.llvm.org/use/tutorial.html) for command usage. -## Debugging with AOT - -> Note: AOT debugging is experimental and only a few debugging capabilities are supported. - -1. Build lldb (assume you have already built llvm) -``` bash -cd ${WAMR_ROOT}/core/deps/llvm/build -cmake ../llvm -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLDB_INCLUDE_TESTS=OFF -make -j $(nproc) -``` - -2. Build wamrc with debugging feature -``` bash -cd ${WAMR_ROOT}/wamr-compiler -mkdir build && cd build -cmake .. -DWAMR_BUILD_DEBUG_AOT=1 -make -j $(nproc) -``` - -3. Build iwasm with debugging feature -``` bash -cd ${WAMR_ROOT}/product-mini/platforms/linux -mkdir build && cd build -cmake .. -DWAMR_BUILD_DEBUG_AOT=1 -make -``` - -4. Compile wasm module to AOT module -``` bash -wamrc -o test.aot test.wasm -``` - -5. Execute iwasm using lldb - - Then you can use lldb commands to debug both wamr runtime and your wasm application in ***current terminal***. - - ``` bash - % lldb iwasm -- test.aot - (lldb) target create "iwasm" - Current executable set to 'iwasm' (x86_64). - (lldb) settings set -- target.run-args "test.aot" - (lldb) settings set plugin.jit-loader.gdb.enable on - (lldb) b main - Breakpoint 1: where = iwasm`main + 48 at main.c:294:11, address = 0x0000000100001020 - (lldb) run - Process 27954 launched: '/tmp/bin/iwasm' (x86_64) - Process 27954 stopped - * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 - frame #0: 0x0000000100001020 iwasm`main(argc=2, argv=0x00007ff7bfeff678) at main.c:294:11 - 291 int - 292 main(int argc, char *argv[]) - 293 { - -> 294 int32 ret = -1; - 295 char *wasm_file = NULL; - 296 const char *func_name = NULL; - 297 uint8 *wasm_file_buf = NULL; - Target 0: (iwasm) stopped. - (lldb) c - Process 27954 resuming - 1 location added to breakpoint 1 - error: need to add support for DW_TAG_base_type 'void' encoded with DW_ATE = 0x0, bit_size = 0 - Process 27954 stopped - * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2 - frame #0: 0x00000001002980a0 JIT(0x100298004)`main(exenv=0x0000000301808200) at hello.c:6:9 - 3 int - 4 main(void) - 5 { - -> 6 printf("hello\n"); - 7 - 8 return 0; - 9 } - Target 0: (iwasm) stopped. - (lldb) br l - Current breakpoints: - 1: name = 'main', locations = 2, resolved = 2, hit count = 2 - 1.1: where = iwasm`main + 48 at main.c:294:11, address = 0x0000000100001020, resolved, hit count = 1 - 1.2: where = JIT(0x100298004)`main + 12 at hello.c:6:9, address = 0x00000001002980a0, resolved, hit count = 1 - - (lldb) - ``` - - * In the above example, - - * The first `main` function, which is in `main.c`, is the main - function of the iwasm command. - - * The second `main` function, which is in `hello.c`, is the main - function of the AOT-compiled wasm module. - - * WAMR AOT debugging uses the GDB JIT loader mechanism to load - the debug info of the debugee module. - On some platforms including macOS, you need to enable it explicitly. - (`settings set plugin.jit-loader.gdb.enable on`) - - References: - - * https://github.com/llvm/llvm-project/blob/main/llvm/docs/DebuggingJITedCode.rst - * https://sourceware.org/gdb/current/onlinedocs/gdb/JIT-Interface.html - ## Enable debugging in embedders (for interpreter) There are three steps to enable debugging in embedders diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/wamr_api.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/wamr_api.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/wamr_api.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/wamr_api.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/wasm_c_api.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/wasm_c_api.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/wasm_c_api.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/wasm_c_api.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/doc/xip.md b/lib/wasm-micro-runtime-WAMR-1.3.3/doc/xip.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/doc/xip.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/doc/xip.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/idf_component.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/idf_component.yml new file mode 100644 index 00000000000..0de47f6b10a --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/idf_component.yml @@ -0,0 +1,14 @@ +version: "1.3.2" +description: WebAssembly Micro Runtime - A lightweight standalone WebAssembly (Wasm) runtime with small footprint, high performance and highly configurable features +url: https://bytecodealliance.org/ +repository: https://github.com/bytecodealliance/wasm-micro-runtime.git +documentation: https://wamr.gitbook.io/ +issues: https://github.com/bytecodealliance/wasm-micro-runtime/issues +dependencies: + idf: ">=4.4" +targets: + - esp32 + - esp32s3 + - esp32c3 +examples: + - path: product-mini/platforms/esp-idf \ No newline at end of file diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/go.mod b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/go.mod similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/go.mod rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/go.mod diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/go.sum b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/go.sum similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/go.sum rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/go.sum diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/test.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/test.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/test.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/test.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/wasm-app/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/wasm-app/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/wasm-app/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/wasm-app/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/wasm-app/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/wasm-app/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/samples/wasm-app/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/samples/wasm-app/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/cgo.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/cgo.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/cgo.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/cgo.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/instance.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/instance.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/instance.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/instance.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/instance_test.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/instance_test.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/instance_test.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/instance_test.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/module.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/module.go similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/module.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/module.go index 13480b221c2..7fd131ea6c3 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/module.go +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/module.go @@ -117,8 +117,8 @@ func (self *Module) SetWasiArgsEx(dirList [][]byte, mapDirList [][]byte, C.wasm_runtime_set_wasi_args_ex(self.module, dirPtr, dirCount, mapDirPtr, mapDirCount, envPtr, envCount, argvPtr, argc, - C.int(stdinfd), C.int(stdoutfd), - C.int(stderrfd)) + C.int64_t(stdinfd), C.int64_t(stdoutfd), + C.int64_t(stderrfd)) } /* Set module's wasi network address pool */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/module_test.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/module_test.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/module_test.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/module_test.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/include/dummy.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/include/dummy.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/include/dummy.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/include/dummy.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/lib/darwin-aarch64/dummy.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/lib/darwin-aarch64/dummy.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/lib/darwin-aarch64/dummy.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/lib/darwin-aarch64/dummy.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/lib/darwin-amd64/dummy.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/lib/darwin-amd64/dummy.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/lib/darwin-amd64/dummy.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/lib/darwin-amd64/dummy.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/lib/dummy.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/lib/dummy.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/lib/dummy.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/lib/dummy.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/lib/linux-amd64/dummy.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/lib/linux-amd64/dummy.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/packaged/lib/linux-amd64/dummy.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/packaged/lib/linux-amd64/dummy.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/runtime.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/runtime.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/runtime.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/runtime.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/runtime_test.go b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/runtime_test.go similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/go/wamr/runtime_test.go rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/go/wamr/runtime_test.go diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/MANIFEST.in b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/MANIFEST.in similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/MANIFEST.in rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/MANIFEST.in diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/pyproject.toml b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/pyproject.toml similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/pyproject.toml rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/pyproject.toml diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/setup.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/setup.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/setup.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/setup.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/libs/.placeholder b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/libs/.placeholder similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/libs/.placeholder rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/libs/.placeholder diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wamrapi/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wamrapi/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wamrapi/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wamrapi/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wamrapi/wamr.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wamrapi/wamr.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wamrapi/wamr.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wamrapi/wamr.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wasmcapi/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wasmcapi/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wasmcapi/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wasmcapi/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wasmcapi/binding.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wasmcapi/binding.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wasmcapi/binding.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wasmcapi/binding.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wasmcapi/ffi.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wasmcapi/ffi.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/src/wamr/wasmcapi/ffi.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/src/wamr/wasmcapi/ffi.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/utils/create_lib.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/utils/create_lib.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/utils/create_lib.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/utils/create_lib.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/requirements.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/requirements.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/requirements.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/requirements.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/basic/compile.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/basic/compile.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/basic/compile.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/basic/compile.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/basic/main.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/basic/main.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/basic/main.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/basic/main.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/basic/sum.c b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/basic/sum.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/basic/sum.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/basic/sum.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/native-symbol/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/native-symbol/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/native-symbol/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/native-symbol/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/native-symbol/compile.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/native-symbol/compile.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/native-symbol/compile.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/native-symbol/compile.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/native-symbol/func.c b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/native-symbol/func.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/native-symbol/func.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/native-symbol/func.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/native-symbol/main.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/native-symbol/main.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wamr-api/samples/native-symbol/main.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wamr-api/samples/native-symbol/main.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/docs/design.md b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/docs/design.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/docs/design.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/docs/design.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/docs/images/python_package_life_cycle.png b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/docs/images/python_package_life_cycle.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/docs/images/python_package_life_cycle.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/docs/images/python_package_life_cycle.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/docs/setup_dev_env.md b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/docs/setup_dev_env.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/docs/setup_dev_env.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/docs/setup_dev_env.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/requirements.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/requirements.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/requirements.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/requirements.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/samples/hello.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/samples/hello.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/samples/hello.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/samples/hello.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/samples/hello_oop.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/samples/hello_oop.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/samples/hello_oop.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/samples/hello_oop.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/samples/hello_procedural.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/samples/hello_procedural.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/samples/hello_procedural.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/samples/hello_procedural.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/context.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/context.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/context.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/context.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/test_advanced.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/test_advanced.py similarity index 93% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/test_advanced.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/test_advanced.py index 2e1c285eabc..706447ab5c7 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/test_advanced.py +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/test_advanced.py @@ -188,18 +188,6 @@ def test_wasm_func_call_native(self): ffi.wasm_func_call(func, params, results) self.assertEqual(params.data[0].of.f32 * 2, results.data[0].of.f64) - def test_wasm_func_call_wrong_params(self): - export_list = ffi.wasm_vec_to_list(self.exports) - func = ffi.wasm_extern_as_func(export_list[0]) - # make a call - params = ffi.wasm_val_vec_t() - ffi.wasm_val_vec_new_empty(params) - results = ffi.wasm_val_vec_t() - ffi.wasm_val_vec_new_empty(results) - trap = ffi.wasm_func_call(func, params, results) - - self.assertIsNotNullPointer(trap) - def test_wasm_func_call_unlinked(self): ft = ffi.wasm_functype_new_0_0() func = ffi.wasm_func_new(self._wasm_store, ft, callback) @@ -453,26 +441,6 @@ def test_wasm_memory_data_size_unlinked(self): ffi.wasm_memory_data_size(mem) ffi.wasm_memory_delete(mem) - def test_wasm_trap(self): - export_list = ffi.wasm_vec_to_list(self.exports) - func = ffi.wasm_extern_as_func(export_list[0]) - # make a call - params = ffi.wasm_val_vec_t() - ffi.wasm_val_vec_new_empty(params) - results = ffi.wasm_val_vec_t() - ffi.wasm_val_vec_new_empty(results) - - trap = ffi.wasm_func_call(func, params, results) - self.assertIsNotNullPointer(trap) - - message = ffi.wasm_message_t() - ffi.wasm_trap_message(trap, message) - self.assertIsNotNullPointer(c.pointer(message)) - - # not a function internal exception - frame = ffi.wasm_trap_origin(trap) - self.assertIsNullPointer(frame) - @unittest.skipUnless( TEST_WITH_WAMR_BUILD_DUMP_CALL_STACK, "need to enable WAMR_BUILD_DUMP_CALL_STACK", diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/test_basic.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/test_basic.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/tests/test_basic.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/tests/test_basic.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/utils/bindgen.py b/lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/utils/bindgen.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/language-bindings/python/wasm-c-api/utils/bindgen.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/language-bindings/python/wasm-c-api/utils/bindgen.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/README.md similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/README.md index 22acfeaf46a..4a827561885 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/README.md @@ -447,12 +447,12 @@ make ## Cosmopolitan Libc Currently, only x86_64 architecture with interpreter modes is supported. -Clone the Cosmopolitan Libc. Setup `cosmocc` as described in [Getting Started](https://github.com/jart/cosmopolitan/#getting-started) being sure to get it into `PATH`. +Setup `cosmocc` as described in [Getting Started](https://github.com/jart/cosmopolitan/#getting-started) being sure to get its `bin` directory into `PATH`. Build iwasm ``` Bash -export CC=cosmocc -export CXX=cosmoc++ +export CC=x86_64-unknown-cosmo-cc +export CXX=x86_64-unknown-cosmo-c++ rm -rf build mkdir build cmake -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 -B build diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world-cmake/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world-cmake/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world-cmake/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world-cmake/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world-cmake/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world-cmake/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world-cmake/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world-cmake/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world-cmake/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world-cmake/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world-cmake/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world-cmake/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world-cmake/print.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world-cmake/print.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world-cmake/print.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world-cmake/print.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/app-samples/hello-world/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/app-samples/hello-world/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/alios-things/aos.mk b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/alios-things/aos.mk similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/alios-things/aos.mk rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/alios-things/aos.mk diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/alios-things/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/alios-things/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/alios-things/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/alios-things/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/alios-things/src/test_wasm.h b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/alios-things/src/test_wasm.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/alios-things/src/test_wasm.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/alios-things/src/test_wasm.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/android/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/android/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/android/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/android/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/android/build_jit.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/android/build_jit.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/android/build_jit.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/android/build_jit.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/android/build_llvm.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/android/build_llvm.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/android/build_llvm.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/android/build_llvm.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/android/wasm-jni.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/android/wasm-jni.cpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/android/wasm-jni.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/android/wasm-jni.cpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/common/libc_wasi.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/common/libc_wasi.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/common/libc_wasi.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/common/libc_wasi.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/cosmopolitan/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/cosmopolitan/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/cosmopolitan/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/cosmopolitan/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/cosmopolitan/build_cosmocc.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/cosmopolitan/build_cosmocc.sh similarity index 76% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/cosmopolitan/build_cosmocc.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/cosmopolitan/build_cosmocc.sh index b2ce15d33a9..8d96027e1d0 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/cosmopolitan/build_cosmocc.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/cosmopolitan/build_cosmocc.sh @@ -2,8 +2,8 @@ # Copyright (C) 2023 Dylibso. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -export CC=cosmocc -export CXX=cosmoc++ +export CC=x86_64-unknown-cosmo-cc +export CXX=x86_64-unknown-cosmo-c++ rm -rf build mkdir build cmake -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 -B build diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/cosmopolitan/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/cosmopolitan/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/cosmopolitan/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/cosmopolitan/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/darwin/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/darwin/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/darwin/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/darwin/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/darwin/build_jit.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/darwin/build_jit.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/darwin/build_jit.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/darwin/build_jit.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/darwin/build_llvm.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/darwin/build_llvm.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/darwin/build_llvm.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/darwin/build_llvm.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/darwin/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/darwin/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/darwin/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/darwin/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/CMakeLists.txt similarity index 68% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/CMakeLists.txt index d8a3d2f96cf..8472df8dd8f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/CMakeLists.txt @@ -6,7 +6,4 @@ cmake_minimum_required(VERSION 3.5) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set (COMPONENTS ${IDF_TARGET} main freertos esptool_py wamr) -list(APPEND EXTRA_COMPONENT_DIRS "$ENV{WAMR_PATH}/build-scripts/esp-idf") - project(wamr-simple) \ No newline at end of file diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/build_and_run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/build_and_run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/build_and_run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/build_and_run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/main/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/CMakeLists.txt similarity index 70% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/main/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/CMakeLists.txt index 55e72567049..1bb61bad945 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/main/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/CMakeLists.txt @@ -2,5 +2,4 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception idf_component_register(SRCS "main.c" - INCLUDE_DIRS "." - REQUIRES wamr) + INCLUDE_DIRS ".") diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/idf_component.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/idf_component.yml new file mode 100644 index 00000000000..83aac8567b6 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/idf_component.yml @@ -0,0 +1,7 @@ +## IDF Component Manager Manifest File +dependencies: + wasm-micro-runtime: + version: "^1" + override_path: "../../../.." + idf: + version: ">=4.4" \ No newline at end of file diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/main/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/main.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/main/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/main.c index fbfb04c2164..1a34096d7a0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/main/main.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/main.c @@ -12,11 +12,7 @@ #include "esp_log.h" -#ifdef CONFIG_IDF_TARGET_ESP32S3 #define IWASM_MAIN_STACK_SIZE 5120 -#else -#define IWASM_MAIN_STACK_SIZE 4096 -#endif #define LOG_TAG "wamr" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/main/test_wasm.h b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/test_wasm.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/main/test_wasm.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/main/test_wasm.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/sdkconfig.defaults b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/sdkconfig.defaults similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/sdkconfig.defaults rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/sdkconfig.defaults diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/sdkconfig.defaults.esp32 b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/sdkconfig.defaults.esp32 similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/sdkconfig.defaults.esp32 rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/sdkconfig.defaults.esp32 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/sdkconfig.defaults.esp32c3 b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/sdkconfig.defaults.esp32c3 similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/esp-idf/sdkconfig.defaults.esp32c3 rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/esp-idf/sdkconfig.defaults.esp32c3 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/freebsd/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/freebsd/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/freebsd/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/freebsd/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/freebsd/build_jit.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/freebsd/build_jit.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/freebsd/build_jit.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/freebsd/build_jit.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/freebsd/build_llvm.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/freebsd/build_llvm.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/freebsd/build_llvm.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/freebsd/build_llvm.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/freebsd/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/freebsd/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/freebsd/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/freebsd/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/ios/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/ios/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/ios/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/ios/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/ios/generate_xcodeproj.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/ios/generate_xcodeproj.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/ios/generate_xcodeproj.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/ios/generate_xcodeproj.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/CMakeLists.txt similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/CMakeLists.txt index a9aef355c49..0b2b4afeca7 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/CMakeLists.txt @@ -164,3 +164,15 @@ else() OUTPUT_VARIABLE cmdOutput ) endif() + +if (WAMR_BUILD_LIBC_WASI EQUAL 1) + execute_process( + COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_LIBC_WASI = 0/WAMR_BUILD_LIBC_WASI = 1/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile" + OUTPUT_VARIABLE cmdOutput + ) +else() + execute_process( + COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_LIBC_WASI = 1/WAMR_BUILD_LIBC_WASI = 0/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile" + OUTPUT_VARIABLE cmdOutput + ) +endif() diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/CMakeLists_minimal.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/enclave-sample/Makefile b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/enclave-sample/Makefile similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/enclave-sample/Makefile rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/enclave-sample/Makefile index dae97a06998..8fd053a5fbe 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/enclave-sample/Makefile +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/enclave-sample/Makefile @@ -16,6 +16,7 @@ WAMR_BUILD_LIB_RATS = 0 WAMR_BUILD_GLOBAL_HEAP_POOL = 0 WAMR_BUILD_GLOBAL_HEAP_SIZE = 10485760 WAMR_BUILD_STATIC_PGO = 0 +WAMR_BUILD_LIBC_WASI = 1 VMLIB_BUILD_DIR ?= $(CURDIR)/../build LIB_RATS_SRC ?= $(VMLIB_BUILD_DIR)/_deps/librats-build @@ -66,7 +67,9 @@ ifeq ($(WAMR_BUILD_LIB_RATS), 1) App_Include_Paths += -I$(LIB_RATS_INCLUDE_DIR) endif -App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) -DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO) +App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) \ + -DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO) \ + -DWASM_ENABLE_LIBC_WASI=$(WAMR_BUILD_LIBC_WASI) # Three configuration modes - Debug, prerelease, release # Debug - Macro DEBUG enabled. @@ -135,7 +138,13 @@ ifeq ($(WAMR_BUILD_LIB_RATS), 1) Enclave_Include_Paths += -I$(LIB_RATS_INCLUDE_DIR) -I$(SGX_SSL)/include endif -Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths) -DWASM_GLOBAL_HEAP_SIZE=$(WAMR_BUILD_GLOBAL_HEAP_SIZE) -DWASM_ENABLE_GLOBAL_HEAP_POOL=$(WAMR_BUILD_GLOBAL_HEAP_POOL) -DWASM_ENABLE_LIB_RATS=$(WAMR_BUILD_LIB_RATS) -DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO) +Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden \ + -fpie -fstack-protector $(Enclave_Include_Paths) \ + -DWASM_GLOBAL_HEAP_SIZE=$(WAMR_BUILD_GLOBAL_HEAP_SIZE) \ + -DWASM_ENABLE_GLOBAL_HEAP_POOL=$(WAMR_BUILD_GLOBAL_HEAP_POOL) \ + -DWASM_ENABLE_LIB_RATS=$(WAMR_BUILD_LIB_RATS) \ + -DWASM_ENABLE_STATIC_PGO=$(WAMR_BUILD_STATIC_PGO) \ + -DWASM_ENABLE_LIBC_WASI=$(WAMR_BUILD_LIBC_WASI) ifeq ($(SPEC_TEST), 1) Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=1 else diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/enclave-sample/Makefile_minimal b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/enclave-sample/Makefile_minimal similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/enclave-sample/Makefile_minimal rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/enclave-sample/Makefile_minimal index a64d5774486..07b640da2c4 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux-sgx/enclave-sample/Makefile_minimal +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux-sgx/enclave-sample/Makefile_minimal @@ -102,7 +102,7 @@ Enclave_Include_Paths := -IEnclave -I$(WAMR_ROOT)/core/iwasm/include \ Enclave_C_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Enclave_Include_Paths) # disable wasi -Enclave_C_Flags += -DSGX_DISABLE_WASI +Enclave_C_Flags += -DWASM_ENABLE_LIBC_WASI=0 ifeq ($(SPEC_TEST), 1) Enclave_C_Flags += -DWASM_ENABLE_SPEC_TEST=1 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux/build_jit.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux/build_jit.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux/build_jit.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux/build_jit.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux/build_llvm.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux/build_llvm.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux/build_llvm.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux/build_llvm.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/linux/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/linux/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/nuttx/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/nuttx/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/nuttx/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/nuttx/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/nuttx/wamr.mk b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/nuttx/wamr.mk similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/nuttx/wamr.mk rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/nuttx/wamr.mk index b91fac9a86c..748fb6a87bd 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/nuttx/wamr.mk +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/nuttx/wamr.mk @@ -133,10 +133,21 @@ CSRCS += aot_loader.c \ $(AOT_RELOC) \ aot_intrinsic.c \ aot_runtime.c +ifeq ($(CONFIG_INTERPRETERS_WAMR_DEBUG_AOT),y) +CFLAGS += -DWASM_ENABLE_DEBUG_AOT=1 +CSRCS += elf_parser.c \ + jit_debug.c +endif else CFLAGS += -DWASM_ENABLE_AOT=0 endif +ifeq ($(CONFIG_INTERPRETERS_WAMR_AOT_QUICK_ENTRY),y) +CFLAGS += -DWASM_ENABLE_QUICK_AOT_ENTRY=1 +else +CFLAGS += -DWASM_ENABLE_QUICK_AOT_ENTRY=0 +endif + ifeq ($(CONFIG_INTERPRETERS_WAMR_AOT_WORD_ALIGN_READ),y) CFLAGS += -DWASM_ENABLE_WORD_ALIGN_READ=1 else @@ -187,9 +198,7 @@ CSRCS += utils.c VPATH += $(IWASM_ROOT)/libraries/debug-engine endif -ifeq ($(CONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE),) -CFLAGS += -DWASM_STACK_GUARD_SIZE=0 -else +ifneq ($(CONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE),) CFLAGS += -DWASM_STACK_GUARD_SIZE=CONFIG_INTERPRETERS_WAMR_STACK_GUARD_SIZE endif @@ -350,6 +359,14 @@ else CFLAGS += -DWASM_ENABLE_REF_TYPES=0 endif +ifeq ($(CONFIG_INTERPRETERS_WAMR_ENABLE_EXCE_HANDLING),y) +CFLAGS += -DWASM_ENABLE_EXCE_HANDLING=1 +CFLAGS += -DWASM_ENABLE_TAGS=1 +else +CFLAGS += -DWASM_ENABLE_EXCE_HANDLING=0 +CFLAGS += -DWASM_ENABLE_TAGS=0 +endif + CFLAGS += -Wno-strict-prototypes -Wno-shadow -Wno-unused-variable CFLAGS += -Wno-int-conversion -Wno-implicit-function-declaration @@ -412,3 +429,4 @@ VPATH += $(IWASM_ROOT)/libraries/lib-pthread VPATH += $(IWASM_ROOT)/common/arch VPATH += $(IWASM_ROOT)/aot VPATH += $(IWASM_ROOT)/aot/arch +VPATH += $(IWASM_ROOT)/aot/debug diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/posix/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/posix/main.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/posix/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/posix/main.c index 85185549791..09d32c62092 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/posix/main.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/posix/main.c @@ -58,7 +58,6 @@ print_help() #if WASM_ENABLE_JIT != 0 printf(" --llvm-jit-size-level=n Set LLVM JIT size level, default is 3\n"); printf(" --llvm-jit-opt-level=n Set LLVM JIT optimization level, default is 3\n"); - printf(" --perf-profile Enable linux perf support. For now, it only works in llvm-jit.\n"); #if defined(os_writegsbase) printf(" --enable-segue[=] Enable using segment register GS as the base address of\n"); printf(" linear memory, which may improve performance, flags can be:\n"); @@ -67,6 +66,9 @@ print_help() printf(" Use comma to separate, e.g. --enable-segue=i32.load,i64.store\n"); printf(" and --enable-segue means all flags are added.\n"); #endif +#endif /* WASM_ENABLE_JIT != 0*/ +#if WASM_ENABLE_LINUX_PERF != 0 + printf(" --enable-linux-perf Enable linux perf support. It works in aot and llvm-jit.\n"); #endif printf(" --repl Start a very simple REPL (read-eval-print-loop) mode\n" " that runs commands in the form of \"FUNC ARG...\"\n"); @@ -561,7 +563,9 @@ main(int argc, char *argv[]) uint32 llvm_jit_size_level = 3; uint32 llvm_jit_opt_level = 3; uint32 segue_flags = 0; - bool enable_linux_perf_support = false; +#endif +#if WASM_ENABLE_LINUX_PERF != 0 + bool enable_linux_perf = false; #endif wasm_module_t wasm_module = NULL; wasm_module_inst_t wasm_module_inst = NULL; @@ -702,9 +706,6 @@ main(int argc, char *argv[]) if (segue_flags == (uint32)-1) return print_help(); } - else if (!strncmp(argv[0], "--perf-profile", 14)) { - enable_linux_perf_support = true; - } #endif /* end of WASM_ENABLE_JIT != 0 */ #if BH_HAS_DLFCN else if (!strncmp(argv[0], "--native-lib=", 13)) { @@ -718,6 +719,11 @@ main(int argc, char *argv[]) native_lib_list[native_lib_count++] = argv[0] + 13; } #endif +#if WASM_ENABLE_LINUX_PERF != 0 + else if (!strncmp(argv[0], "--enable-linux-perf", 19)) { + enable_linux_perf = true; + } +#endif #if WASM_ENABLE_MULTI_MODULE != 0 else if (!strncmp(argv[0], "--module-path=", strlen("--module-path="))) { @@ -761,7 +767,7 @@ main(int argc, char *argv[]) gen_prof_file = argv[0] + 16; } #endif - else if (!strncmp(argv[0], "--version", 9)) { + else if (!strcmp(argv[0], "--version")) { uint32 major, minor, patch; wasm_runtime_get_version(&major, &minor, &patch); printf("iwasm %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", major, minor, @@ -819,13 +825,16 @@ main(int argc, char *argv[]) init_args.llvm_jit_size_level = llvm_jit_size_level; init_args.llvm_jit_opt_level = llvm_jit_opt_level; init_args.segue_flags = segue_flags; - init_args.linux_perf_support = enable_linux_perf_support; +#endif +#if WASM_ENABLE_LINUX_PERF != 0 + init_args.enable_linux_perf = enable_linux_perf; #endif #if WASM_ENABLE_DEBUG_INTERP != 0 init_args.instance_port = instance_port; if (ip_addr) - strcpy(init_args.ip_addr, ip_addr); + /* ensure that init_args.ip_addr is null terminated */ + strncpy(init_args.ip_addr, ip_addr, sizeof(init_args.ip_addr) - 1); #endif /* initialize runtime environment */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/riot/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/riot/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/riot/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/riot/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/riot/Makefile b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/riot/Makefile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/riot/Makefile rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/riot/Makefile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/riot/iwasmt.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/riot/iwasmt.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/riot/iwasmt.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/riot/iwasmt.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/riot/test_wasm.h b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/riot/test_wasm.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/riot/test_wasm.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/riot/test_wasm.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/rt-thread/SConscript b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/rt-thread/SConscript similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/rt-thread/SConscript rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/rt-thread/SConscript diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/rt-thread/iwasm.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/rt-thread/iwasm.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/rt-thread/iwasm.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/rt-thread/iwasm.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/rt-thread/iwasm.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/rt-thread/iwasm.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/rt-thread/iwasm.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/rt-thread/iwasm.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/vxworks/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/vxworks/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/vxworks/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/vxworks/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/vxworks/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/vxworks/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/vxworks/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/vxworks/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/build_llvm.py b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/build_llvm.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/build_llvm.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/build_llvm.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/main.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/main.c index 921b7726541..35a4897217e 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/main.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/main.c @@ -406,7 +406,7 @@ main(int argc, char *argv[]) ip_addr = argv[0] + 3; } #endif - else if (!strncmp(argv[0], "--version", 9)) { + else if (!strcmp(argv[0], "--version")) { uint32 major, minor, patch; wasm_runtime_get_version(&major, &minor, &patch); printf("iwasm %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", major, minor, @@ -464,7 +464,9 @@ main(int argc, char *argv[]) #if WASM_ENABLE_DEBUG_INTERP != 0 init_args.instance_port = instance_port; if (ip_addr) - strcpy(init_args.ip_addr, ip_addr); + /* ensure that init_args.ip_addr is null terminated */ + strncpy_s(init_args.ip_addr, sizeof(init_args.ip_addr) - 1, ip_addr, + strlen(ip_addr)); #endif /* initialize runtime environment */ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/wasi_filtered_tests.json b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/wasi_filtered_tests.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/windows/wasi_filtered_tests.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/windows/wasi_filtered_tests.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/Dockerfile b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/Dockerfile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/Dockerfile rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/Dockerfile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/boards/nucleo_f767zi.conf b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/boards/nucleo_f767zi.conf similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/boards/nucleo_f767zi.conf rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/boards/nucleo_f767zi.conf diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/boards/qemu_cortex_a53.conf b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/boards/qemu_cortex_a53.conf similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/boards/qemu_cortex_a53.conf rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/boards/qemu_cortex_a53.conf diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/build_and_run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/build_and_run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/build_and_run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/build_and_run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/prj.conf b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/prj.conf similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/prj.conf rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/prj.conf diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/test_wasm.h b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/test_wasm.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/test_wasm.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/test_wasm.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/test_wasm_riscv64.h b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/test_wasm_riscv64.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/test_wasm_riscv64.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/test_wasm_riscv64.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/wasm-app-riscv64/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/wasm-app-riscv64/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/wasm-app-riscv64/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/wasm-app-riscv64/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/wasm-app-riscv64/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/wasm-app-riscv64/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/product-mini/platforms/zephyr/simple/src/wasm-app-riscv64/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/product-mini/platforms/zephyr/simple/src/wasm-app-riscv64/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/build.sh similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/build.sh index a0be7e1c7be..c1d598a8c93 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/build.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/build.sh @@ -21,7 +21,7 @@ echo "#####################build basic project" cd ${CURR_DIR} mkdir -p cmake_build cd cmake_build -cmake .. +cmake .. -DCMAKE_BUILD_TYPE=Debug -DWAMR_BH_VPRINTF=my_vprintf -DWAMR_BH_LOG=my_log make -j ${nproc} if [ $? != 0 ];then echo "BUILD_FAIL basic exit as $?\n" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/src/main.c similarity index 90% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/src/main.c index c35da317933..ca580af3309 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/src/main.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/src/main.c @@ -15,6 +15,30 @@ get_pow(int x, int y); int32_t calculate_native(int32_t n, int32_t func1, int32_t func2); +void +my_log(uint32 log_level, const char *file, int line, const char *fmt, ...) +{ + char buf[200]; + snprintf(buf, 200, + log_level == WASM_LOG_LEVEL_VERBOSE ? "[WamrLogger - VERBOSE] %s" + : "[WamrLogger] %s", + fmt); + + va_list ap; + va_start(ap, fmt); + vprintf(buf, ap); + va_end(ap); +} + +int +my_vprintf(const char *format, va_list ap) +{ + /* Print in blue */ + char buf[200]; + snprintf(buf, 200, "\x1b[34m%s\x1b[0m", format); + return vprintf(buf, ap); +} + void print_usage(void) { @@ -95,6 +119,7 @@ main(int argc, char *argv_main[]) printf("Init runtime environment failed.\n"); return -1; } + wasm_runtime_set_log_level(WASM_LOG_LEVEL_VERBOSE); buffer = bh_read_file_to_buffer(wasm_path, &buf_size); @@ -103,7 +128,8 @@ main(int argc, char *argv_main[]) goto fail; } - module = wasm_runtime_load(buffer, buf_size, error_buf, sizeof(error_buf)); + module = wasm_runtime_load((uint8 *)buffer, buf_size, error_buf, + sizeof(error_buf)); if (!module) { printf("Load wasm module failed. error: %s\n", error_buf); goto fail; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/src/native_impl.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/src/native_impl.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/src/native_impl.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/src/native_impl.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/wasm-apps/testapp.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/wasm-apps/testapp.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/basic/wasm-apps/testapp.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/basic/wasm-apps/testapp.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/bh-atomic/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/bh-atomic/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/bh-atomic/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/bh-atomic/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/bh-atomic/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/bh-atomic/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/bh-atomic/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/bh-atomic/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/README.md similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/README.md index 8b34719ef16..98f0cc3a71b 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/README.md @@ -5,7 +5,7 @@ This sample can also demonstrate the SGX IPFS (Intel Protected File System), ena ## Preparation -Please install WASI SDK, download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. +Please install WASI SDK, download the [wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. For testing with SGX IPFS, follow the instructions in [the documentation of SGX for WAMR](../../doc/linux_sgx.md#sgx-intel-protected-file-system). ## Build the sample diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/src/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/src/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/src/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/src/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/wasm-app/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/wasm-app/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/wasm-app/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/wasm-app/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/wasm-app/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/wasm-app/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/file/wasm-app/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/file/wasm-app/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/lv_config/lv_conf.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/lv_config/lv_conf.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/lv_config/lv_conf.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/lv_config/lv_conf.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/lv_config/lv_drv_conf.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/lv_config/lv_drv_conf.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/lv_config/lv_drv_conf.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/lv_config/lv_drv_conf.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/lv_config/system_header.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/lv_config/system_header.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/lv_config/system_header.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/lv_config/system_header.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wamr_config_gui.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wamr_config_gui.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wamr_config_gui.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wamr_config_gui.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/build_apps.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/build_apps.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/build_apps.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/build_apps.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/decrease/Makefile b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/decrease/Makefile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/decrease/Makefile rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/decrease/Makefile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/decrease/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/decrease/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/decrease/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/decrease/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/increase/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/increase/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/increase/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/increase/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/increase/Makefile b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/increase/Makefile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/increase/Makefile rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/increase/Makefile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/increase/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/increase/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-apps/increase/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-apps/increase/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/linux/iwasm_main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/linux/iwasm_main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/linux/iwasm_main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/linux/iwasm_main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/linux/lv_drv_conf.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/linux/lv_drv_conf.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/linux/lv_drv_conf.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/linux/lv_drv_conf.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/linux/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/linux/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/linux/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/linux/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.c index cdad9dac205..5502cfd89d5 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.c @@ -10,8 +10,12 @@ #include #include "drivers/spi.h" -#include "zephyr.h" -#include "kernel.h" +#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */ +#include +#include +#else +#include +#endif #if USE_XPT2046 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/XPT2046.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/board_config.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/board_config.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/board_config.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/board_config.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.h similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.h index f72279d69fc..ddc396e1d7f 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340.h @@ -7,7 +7,12 @@ #define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ #include "board_config.h" #include + +#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */ #include +#else +#include +#endif #define ILI9340_CMD_ENTER_SLEEP 0x10 #define ILI9340_CMD_EXIT_SLEEP 0x11 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340_adafruit_1480.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340_adafruit_1480.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340_adafruit_1480.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/display_ili9340_adafruit_1480.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/iwasm_main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/iwasm_main.c similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/iwasm_main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/iwasm_main.c index 6a88f8007b4..9ce0c11cd05 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/iwasm_main.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/iwasm_main.c @@ -31,7 +31,12 @@ xpt2046_init(void); extern void wgl_init(); +#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */ #include +#else +#include +#endif + #include #include diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/pin_config_jlf.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/pin_config_jlf.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/pin_config_jlf.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/pin_config_jlf.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/pin_config_stm32.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/pin_config_stm32.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/gui/wasm-runtime-wgl/src/platform/zephyr/pin_config_stm32.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/gui/wasm-runtime-wgl/src/platform/zephyr/pin_config_stm32.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/src/my_context.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/src/my_context.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/src/my_context.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/src/my_context.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/src/native_impl.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/src/native_impl.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/src/native_impl.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/src/native_impl.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/wasm-apps/testapp.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/wasm-apps/testapp.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context-threads/wasm-apps/testapp.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context-threads/wasm-apps/testapp.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/src/my_context.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/src/my_context.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/src/my_context.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/src/my_context.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/src/native_impl.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/src/native_impl.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/src/native_impl.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/src/native_impl.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/wasm-apps/testapp.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/wasm-apps/testapp.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/inst-context/wasm-apps/testapp.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/inst-context/wasm-apps/testapp.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/LICENCE.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/LICENCE.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/LICENCE.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/LICENCE.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/lv_config/lv_conf.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/lv_config/lv_conf.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/lv_config/lv_conf.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/lv_config/lv_conf.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/lv_config/lv_drv_conf.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/lv_config/lv_drv_conf.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/lv_config/lv_drv_conf.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/lv_config/lv_drv_conf.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/CMakeLists.txt.in b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/CMakeLists.txt.in similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/CMakeLists.txt.in rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/CMakeLists.txt.in diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/display_indev.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/display_indev.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/display_indev.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/display_indev.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/indev/mouse.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/linux_display_indev.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/linux_display_indev.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/linux_display_indev.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/linux_display_indev.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/system_header.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/system_header.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/lv-drivers/system_header.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/lv-drivers/system_header.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-native-ui-app/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-native-ui-app/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/display_indev.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/display_indev.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/display_indev.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/display_indev.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/display_indev.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/display_indev.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/display_indev.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/display_indev.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/iwasm_main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/iwasm_main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/iwasm_main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/iwasm_main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/mouse.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/mouse.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/mouse.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/linux/mouse.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c index d59b6c9b7bf..e3948e2f208 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.c @@ -10,8 +10,12 @@ #include #include "drivers/spi.h" -#include "zephyr.h" -#include "kernel.h" +#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */ +#include +#include +#else +#include +#endif #if USE_XPT2046 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/XPT2046.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/board_config.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/board_config.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/board_config.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/board_config.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h index 4eb11e2d143..39257a29a62 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340.h @@ -7,7 +7,12 @@ #define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9340_H_ #include "board_config.h" #include + +#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */ #include +#else +#include +#endif #define ILI9340_CMD_ENTER_SLEEP 0x10 #define ILI9340_CMD_EXIT_SLEEP 0x11 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340_adafruit_1480.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340_adafruit_1480.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340_adafruit_1480.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_ili9340_adafruit_1480.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_indev.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_indev.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_indev.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/display_indev.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c index dceb5786b49..10f4980268c 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/iwasm_main.c @@ -16,7 +16,12 @@ #include "connection_native_api.h" #include "display_indev.h" +#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */ #include +#else +#include +#endif + #include #include diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_jlf.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_jlf.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_jlf.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_jlf.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_stm32.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_stm32.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_stm32.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/vgl-wasm-runtime/src/platform/zephyr/pin_config_stm32.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wamr_config_littlevgl.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wamr_config_littlevgl.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wamr_config_littlevgl.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wamr_config_littlevgl.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/Makefile_wasm_app b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/Makefile_wasm_app similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/Makefile_wasm_app rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/Makefile_wasm_app diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/Makefile_wasm_app_no_wasi b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/Makefile_wasm_app_no_wasi similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/Makefile_wasm_app_no_wasi rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/Makefile_wasm_app_no_wasi diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/build_wasm_app.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/build_wasm_app.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/build_wasm_app.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/build_wasm_app.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/src/display_indev.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/src/display_indev.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/src/display_indev.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/src/display_indev.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/src/system_header.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/src/system_header.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/littlevgl/wasm-apps/src/system_header.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/littlevgl/wasm-apps/src/system_header.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/mem-allocator/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/mem-allocator/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/mem-allocator/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/mem-allocator/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/mem-allocator/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/mem-allocator/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/mem-allocator/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/mem-allocator/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/CMakeLists.txt similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/CMakeLists.txt index ee6c98df469..17f4e1bcc27 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/CMakeLists.txt @@ -132,6 +132,7 @@ endif() # .c -> .wasm ExternalProject_Add(WASM_MODULE SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wasm-apps + BUILD_ALWAYS TRUE UPDATE_COMMAND "" PATCH_COMMAND "" CONFIGURE_COMMAND ${CMAKE_COMMAND} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mA.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mA.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mA.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mA.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mB.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mB.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mB.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mB.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mC.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mC.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mC.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mC.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mD.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mD.cpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mD.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mD.cpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mE.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mE.cpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-module/wasm-apps/mE.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-module/wasm-apps/mE.cpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/wasm-apps/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/wasm-apps/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/wasm-apps/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/wasm-apps/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/wasm-apps/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/wasm-apps/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/wasm-apps/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/wasm-apps/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/wasm-apps/main_global_atomic.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/wasm-apps/main_global_atomic.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/wasm-apps/main_global_atomic.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/wasm-apps/main_global_atomic.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/wasm-apps/main_thread_exception.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/wasm-apps/main_thread_exception.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/multi-thread/wasm-apps/main_thread_exception.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/multi-thread/wasm-apps/main_thread_exception.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/README.md similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/README.md index 80500ade0fd..be1cc6e74c1 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/README.md @@ -29,7 +29,7 @@ get_native_lib(char **p_module_name, NativeSymbol **p_native_symbols) ## Preparation -Please install WASI SDK, download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. +Please install WASI SDK, download the [wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. ## Build the sample diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/test_add.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/test_add.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/test_add.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/test_add.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/test_hello.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/test_hello.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/test_hello.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/test_hello.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/test_hello2.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/test_hello2.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/test_hello2.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/test_hello2.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/test_sqrt.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/test_sqrt.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/test_sqrt.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/test_sqrt.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/wasm-app/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/wasm-app/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/wasm-app/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/wasm-app/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/wasm-app/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/wasm-app/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/native-lib/wasm-app/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/native-lib/wasm-app/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/ref-types/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/ref-types/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/ref-types/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/ref-types/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/ref-types/src/hello.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/ref-types/src/hello.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/ref-types/src/hello.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/ref-types/src/hello.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/ref-types/src/hello.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/ref-types/src/hello.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/ref-types/src/hello.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/ref-types/src/hello.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/CMakeLists.txt similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/CMakeLists.txt index 7ab5522489f..3f5f23e97c2 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/CMakeLists.txt @@ -69,6 +69,7 @@ execute_process ( add_custom_target ( iwasm ALL DEPENDS vmlib_untrusted vmlib_untrusted vmlib + COMMAND make -C ${SGX_PLATFORM_DIR}/enclave-sample clean COMMAND make -C ${SGX_PLATFORM_DIR}/enclave-sample SGX_MODE=HW SGX_DEBUG=1 VMLIB_BUILD_DIR=${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E copy ${SGX_PLATFORM_DIR}/enclave-sample/enclave.signed.so ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} -E copy ${SGX_PLATFORM_DIR}/enclave-sample/iwasm ${CMAKE_BINARY_DIR} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/wasm-app/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/wasm-app/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/wasm-app/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/wasm-app/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/wasm-app/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/wasm-app/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/sgx-ra/wasm-app/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/sgx-ra/wasm-app/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/build.sh similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/build.sh index 9af5b3edd73..e6c10474533 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/build.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/build.sh @@ -21,7 +21,7 @@ echo "##################### build shared-module project" cd ${CURR_DIR} mkdir -p cmake_build cd cmake_build -cmake .. +cmake .. -DCMAKE_BUILD_TYPE=Debug make -j ${nproc} if [ $? != 0 ];then echo "BUILD_FAIL shared-module exit as $?\n" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/wasm-apps/testapp.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/wasm-apps/testapp.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/shared-module/wasm-apps/testapp.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/shared-module/wasm-apps/testapp.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/build.sh similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/build.sh index 4e8155156a3..9d9d1874d12 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/build.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/build.sh @@ -17,7 +17,7 @@ APP_LIB_SRC="${APP_FRAMEWORK_DIR}/base/app/*.c ${APP_FRAMEWORK_DIR}/sensor/app/* ${APP_FRAMEWORK_DIR}/connection/app/*.c ${NATIVE_LIBS}/*.c" WASM_APPS=${PWD}/wasm-apps CLEAN= -CM_BUILD_TYPE="-DCMAKE_BUILD_TYPE=Release" +CM_BUILD_TYPE="-DCMAKE_BUILD_TYPE=Debug" CM_TOOLCHAIN="" usage () diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm-interp/toolchain.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm-interp/toolchain.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm-interp/toolchain.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm-interp/toolchain.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm-interp/wamr_config_simple.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm-interp/wamr_config_simple.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm-interp/wamr_config_simple.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm-interp/wamr_config_simple.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm64-aot/toolchain.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm64-aot/toolchain.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm64-aot/toolchain.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm64-aot/toolchain.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm64-aot/wamr_config_simple.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm64-aot/wamr_config_simple.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm64-aot/wamr_config_simple.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm64-aot/wamr_config_simple.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm64-interp/toolchain.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm64-interp/toolchain.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm64-interp/toolchain.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm64-interp/toolchain.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm64-interp/wamr_config_simple.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm64-interp/wamr_config_simple.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/arm64-interp/wamr_config_simple.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/arm64-interp/wamr_config_simple.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/host-aot/wamr_config_simple.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/host-aot/wamr_config_simple.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/host-aot/wamr_config_simple.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/host-aot/wamr_config_simple.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/host-interp/wamr_config_simple.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/host-interp/wamr_config_simple.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/host-interp/wamr_config_simple.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/host-interp/wamr_config_simple.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/macos-interp/wamr_config_simple.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/macos-interp/wamr_config_simple.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/profiles/macos-interp/wamr_config_simple.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/profiles/macos-interp/wamr_config_simple.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/sample_test_run.py b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/sample_test_run.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/sample_test_run.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/sample_test_run.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/src/iwasm_main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/src/iwasm_main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/src/iwasm_main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/src/iwasm_main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/connection.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/connection.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/connection.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/connection.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/event_publisher.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/event_publisher.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/event_publisher.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/event_publisher.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/event_subscriber.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/event_subscriber.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/event_subscriber.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/event_subscriber.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/request_handler.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/request_handler.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/request_handler.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/request_handler.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/request_sender.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/request_sender.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/request_sender.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/request_sender.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/sensor.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/sensor.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/sensor.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/sensor.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/timer.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/timer.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/simple/wasm-apps/timer.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/simple/wasm-apps/timer.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/README.md similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/README.md index a3bc5ac1523..911dfb7ab3c 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/README.md @@ -6,7 +6,7 @@ how they communicate with each other. ## Preparation -Please install WASI SDK, download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. +Please install WASI SDK, download the [wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. And install wabt, download the [wabt release](https://github.com/WebAssembly/wabt/releases) and extract the archive to default path `/opt/wabt` ## Build the sample diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/sample_test_run.py b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/sample_test_run.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/sample_test_run.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/sample_test_run.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/addr_resolve.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/addr_resolve.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/addr_resolve.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/addr_resolve.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/inc/.gitkeep b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/inc/.gitkeep similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/inc/.gitkeep rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/inc/.gitkeep diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/multicast_client.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/multicast_client.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/multicast_client.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/multicast_client.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/multicast_server.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/multicast_server.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/multicast_server.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/multicast_server.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/send_recv.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/send_recv.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/send_recv.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/send_recv.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/socket_opts.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/socket_opts.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/socket_opts.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/socket_opts.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/socket_utils.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/socket_utils.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/socket_utils.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/socket_utils.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/tcp_client.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/tcp_client.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/tcp_client.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/tcp_client.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/tcp_server.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/tcp_server.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/tcp_server.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/tcp_server.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/timeout_client.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/timeout_client.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/timeout_client.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/timeout_client.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/timeout_server.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/timeout_server.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/timeout_server.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/timeout_server.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/udp_client.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/udp_client.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/udp_client.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/udp_client.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/udp_server.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/udp_server.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/socket-api/wasm-src/udp_server.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/socket-api/wasm-src/udp_server.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/CMakeLists.txt similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/CMakeLists.txt index 7b76311d767..29c4dc429c3 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/CMakeLists.txt @@ -45,9 +45,9 @@ endif () set(WAMR_BUILD_INTERP 1) set(WAMR_BUILD_AOT 1) set(WAMR_BUILD_JIT 0) -set(WAMR_BUILD_LIBC_BUILTIN 1) set(WAMR_BUILD_FAST_INTERP 1) -set(WAMR_BUILD_LIB_PTHREAD 1) +set(WAMR_BUILD_THREAD_MGR 1) +set(WAMR_BUILD_SHARED_MEMORY 1) # compiling and linking flags if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/wasm-apps/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/wasm-apps/CMakeLists.txt similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/wasm-apps/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/wasm-apps/CMakeLists.txt index 52ee7d7520a..0996d5841d7 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/wasm-apps/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/wasm-apps/CMakeLists.txt @@ -29,6 +29,7 @@ set (DEFINED_SYMBOLS set (CMAKE_EXE_LINKER_FLAGS "-Wl,--shared-memory,--max-memory=131072, \ -Wl,--no-entry,--strip-all,--export=sum, \ + -Wl,--export=return_bss, \ -Wl,--export=__heap_base,--export=__data_end \ -Wl,--export=__wasm_call_ctors \ -Wl,--allow-undefined-file=${DEFINED_SYMBOLS}" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/wasm-apps/sum.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/wasm-apps/sum.c similarity index 61% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/wasm-apps/sum.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/wasm-apps/sum.c index 0bcb8918d7b..6f8b8f2189c 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/spawn-thread/wasm-apps/sum.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/spawn-thread/wasm-apps/sum.c @@ -3,6 +3,17 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ +/* + * have something in bss so that llvm synthesizes + * wasm start function for this module. + */ +char * +return_bss() +{ + static char bss[4096]; + return bss; +} + int sum(int start, int length) { @@ -13,4 +24,4 @@ sum(int start, int length) } return sum; -} \ No newline at end of file +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/.gitignore new file mode 100644 index 00000000000..0fa8a76bdaf --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/.gitignore @@ -0,0 +1 @@ +/out/ \ No newline at end of file diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/CMakeLists.txt new file mode 100644 index 00000000000..246b835ddc6 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/CMakeLists.txt @@ -0,0 +1,98 @@ +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +cmake_minimum_required (VERSION 3.14) + +include(CheckPIESupported) + +project (terminate) + +set (CMAKE_CXX_STANDARD 17) + +################ runtime settings ################ +string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM) +if (APPLE) + add_definitions(-DBH_PLATFORM_DARWIN) +endif () + +# Reset default linker flags +set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +# WAMR features switch + +# Set WAMR_BUILD_TARGET, currently values supported: +# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]", +# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]" +if (NOT DEFINED WAMR_BUILD_TARGET) + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)") + set (WAMR_BUILD_TARGET "AARCH64") + elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64") + set (WAMR_BUILD_TARGET "RISCV64") + elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) + # Build as X86_64 by default in 64-bit platform + set (WAMR_BUILD_TARGET "X86_64") + elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) + # Build as X86_32 by default in 32-bit platform + set (WAMR_BUILD_TARGET "X86_32") + else () + message(SEND_ERROR "Unsupported build target platform!") + endif () +endif () + +if (NOT CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE Debug) +endif () + +set (WAMR_BUILD_LIBC_WASI 1) +set (WAMR_BUILD_LIB_WASI_THREADS 1) +set (WAMR_BUILD_THREAD_MGR 1) +set (WAMR_BUILD_INTERP 1) +set (WAMR_BUILD_AOT 1) +set (WAMR_BUILD_JIT 0) + +# fast interpreter +# set (WAMR_BUILD_FAST_INTERP 1) + +# fast-jit +# set (WAMR_BUILD_FAST_JIT 1) + +# llvm jit +# set (WAMR_BUILD_JIT 1) +# set (LLVM_DIR /usr/local/opt/llvm@14/lib/cmake/llvm) + +set (WAMR_BUILD_REF_TYPES 1) + +if (NOT MSVC) + # linker flags + if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") + endif () + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security") + if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") + if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register") + endif () + endif () +endif () + +# build out vmlib +set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..) +include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) + +add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) + +################ application related ################ +include_directories(${CMAKE_CURRENT_LIST_DIR}/src) +include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) + +add_executable (terminate src/main.c ${UNCOMMON_SHARED_SOURCE}) + +check_pie_supported() +set_target_properties (terminate PROPERTIES POSITION_INDEPENDENT_CODE ON) + +if (APPLE) + target_link_libraries (terminate vmlib -lm -ldl -lpthread ${LLVM_AVAILABLE_LIBS}) +else () + target_link_libraries (terminate vmlib -lm -ldl -lpthread -lrt ${LLVM_AVAILABLE_LIBS}) +endif () diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/README.md new file mode 100644 index 00000000000..89a9c16bc3c --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/README.md @@ -0,0 +1,4 @@ +The "terminate" sample project +============================== + +This sample demonstrates wasm_runtime_terminate API. diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/build.sh new file mode 100755 index 00000000000..4c882e981b0 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/build.sh @@ -0,0 +1,63 @@ +# +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# + +#!/bin/bash + +CURR_DIR=$PWD +WAMR_DIR=${PWD}/../.. +OUT_DIR=${PWD}/out + +WASM_APPS=${PWD}/wasm-apps + + +rm -rf ${OUT_DIR} +mkdir ${OUT_DIR} +mkdir ${OUT_DIR}/wasm-apps + + +echo "##################### build terminate project" +cd ${CURR_DIR} +mkdir -p cmake_build +cd cmake_build +cmake .. -DCMAKE_BUILD_TYPE=Debug +make -j ${nproc} +if [ $? != 0 ];then + echo "BUILD_FAIL terminate exit as $?\n" + exit 2 +fi + +cp -a terminate ${OUT_DIR} + +printf "\n" + +echo "##################### build wasm apps" + +cd ${WASM_APPS} + +for i in `ls *.wat` +do +APP_SRC="$i" +OUT_FILE=${i%.*}.wasm + +# Note: the CI installs wabt in /opt/wabt +if type wat2wasm; then + WAT2WASM=${WAT2WASM:-wat2wasm} +elif [ -x /opt/wabt/bin/wat2wasm ]; then + WAT2WASM=${WAT2WASM:-/opt/wabt/bin/wat2wasm} +fi + +${WAT2WASM} -o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC} + +# aot +# wamrc -o ${OUT_DIR}/wasm-apps/${OUT_FILE}.aot ${OUT_DIR}/wasm-apps/${OUT_FILE} +# mv ${OUT_DIR}/wasm-apps/${OUT_FILE}.aot ${OUT_DIR}/wasm-apps/${OUT_FILE} + +if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then + echo "build ${OUT_FILE} success" +else + echo "build ${OUT_FILE} fail" +fi +done +echo "##################### build wasm apps done" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/run.sh new file mode 100755 index 00000000000..0a75fea2a19 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +out/terminate -f out/wasm-apps/testapp.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/src/main.c new file mode 100644 index 00000000000..4885b0b11bb --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/src/main.c @@ -0,0 +1,219 @@ + +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include +#include +#include +#include + +#include "wasm_export.h" +#include "bh_read_file.h" +#include "bh_getopt.h" + +void +print_usage(void) +{ + fprintf(stdout, "Options:\r\n"); + fprintf(stdout, " -f [path of wasm file] \n"); +} + +static void * +runner_with_sigleton_exec_env(void *vp) +{ + wasm_module_inst_t inst = vp; + bool ok = wasm_runtime_init_thread_env(); + assert(ok); + wasm_application_execute_main(inst, 0, NULL); + wasm_runtime_destroy_thread_env(); + return inst; +} + +static void * +runner_with_spawn_exec_env(void *vp) +{ + wasm_exec_env_t env = vp; + wasm_module_inst_t inst = wasm_runtime_get_module_inst(env); + wasm_function_inst_t func; + bool ok = wasm_runtime_init_thread_env(); + assert(ok); + func = wasm_runtime_lookup_function(inst, "block_forever", NULL); + assert(func != NULL); + wasm_runtime_call_wasm(env, func, 0, NULL); + wasm_runtime_destroy_spawned_exec_env(env); + wasm_runtime_destroy_thread_env(); + return inst; +} + +int +main(int argc, char *argv_main[]) +{ + int exit_code = 1; + static char global_heap_buf[512 * 1024]; + char *buffer; + char error_buf[128]; + int opt; + char *wasm_path = NULL; + int ret; + int pipe_fds[2]; + + const unsigned int N = 4; + wasm_module_t module = NULL; + wasm_module_inst_t module_inst[N]; + pthread_t th[N]; + unsigned int i; + uint32 buf_size, stack_size = 8092, heap_size = 8092; + + for (i = 0; i < N; i++) { + module_inst[i] = NULL; + } + + RuntimeInitArgs init_args; + memset(&init_args, 0, sizeof(RuntimeInitArgs)); + + while ((opt = getopt(argc, argv_main, "hf:")) != -1) { + switch (opt) { + case 'f': + wasm_path = optarg; + break; + case 'h': + print_usage(); + return 0; + case '?': + print_usage(); + return 0; + } + } + if (optind == 1) { + print_usage(); + return 0; + } + + memset(&init_args, 0, sizeof(init_args)); + init_args.mem_alloc_type = Alloc_With_Pool; + init_args.mem_alloc_option.pool.heap_buf = global_heap_buf; + init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf); + + if (!wasm_runtime_full_init(&init_args)) { + printf("Init runtime environment failed.\n"); + return -1; + } + + buffer = bh_read_file_to_buffer(wasm_path, &buf_size); + + if (!buffer) { + printf("Open wasm app file [%s] failed.\n", wasm_path); + goto fail; + } + + module = wasm_runtime_load((uint8 *)buffer, buf_size, error_buf, + sizeof(error_buf)); + if (!module) { + printf("Load wasm module failed. error: %s\n", error_buf); + goto fail; + } + + /* Ensure that fd_read on FD 0 blocks. */ + ret = pipe(pipe_fds); + if (ret != 0) { + goto fail; + } + wasm_runtime_set_wasi_args_ex(module, NULL, 0, NULL, 0, NULL, 0, NULL, 0, + pipe_fds[0], -1, -1); + + for (i = 0; i < N; i++) { + bool use_wasm_runtime_spawn_exec_env = i / 2 == 0; + wasm_exec_env_t env; + + module_inst[i] = wasm_runtime_instantiate(module, stack_size, heap_size, + error_buf, sizeof(error_buf)); + + if (!module_inst[i]) { + printf("Instantiate wasm module failed. error: %s\n", error_buf); + goto fail; + } + + /* Note: ensure that module inst has an exec env so that + * it can receive the termination request. + */ + env = wasm_runtime_get_exec_env_singleton(module_inst[i]); + assert(env != NULL); + if (use_wasm_runtime_spawn_exec_env) { + env = wasm_runtime_spawn_exec_env(env); + assert(env != NULL); + } + + if ((i % 2) == 0) { + printf("terminating thread %u before starting\n", i); + wasm_runtime_terminate(module_inst[i]); + } + + if (use_wasm_runtime_spawn_exec_env) { + printf("starting thread %u (spawn_exec_env)\n", i); + ret = pthread_create(&th[i], NULL, runner_with_spawn_exec_env, env); + if (ret != 0) { + wasm_runtime_destroy_spawned_exec_env(env); + goto fail; + } + } + else { + printf("starting thread %u (singleton exec_env)\n", i); + ret = pthread_create(&th[i], NULL, runner_with_sigleton_exec_env, + module_inst[i]); + if (ret != 0) { + goto fail; + } + } + } + + printf("sleeping a bit to ensure that the threads actually started\n"); + sleep(1); + + for (i = 0; i < N; i++) { + if ((i % 2) != 0) { + printf("terminating thread %u\n", i); + wasm_runtime_terminate(module_inst[i]); + } + } + + for (i = 0; i < N; i++) { + printf("joining thread %u\n", i); + void *status; + ret = pthread_join(th[i], &status); + if (ret != 0) { + printf("pthread_join failed for thread %u\n", i); + goto fail; + } + } + + for (i = 0; i < N; i++) { + const char *exception = wasm_runtime_get_exception(module_inst[i]); + if (exception != NULL) { + if (!strstr(exception, "terminated by user")) { + printf("thread %u got an exception: %s (unexpected)\n", i, + exception); + goto fail; + } + printf("thread %u got an exception: %s (expected)\n", i, exception); + } + else { + printf("thread %u got no exception (unexpected)\n", i); + goto fail; + } + } + + exit_code = 0; +fail: + for (i = 0; i < N; i++) { + if (module_inst[i]) + wasm_runtime_deinstantiate(module_inst[i]); + } + if (module) + wasm_runtime_unload(module); + if (buffer) + BH_FREE(buffer); + wasm_runtime_destroy(); + return exit_code; +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/wasm-apps/testapp.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/wasm-apps/testapp.wat new file mode 100644 index 00000000000..349535da737 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/terminate/wasm-apps/testapp.wat @@ -0,0 +1,53 @@ +;; Copyright (C) 2024 YAMAMOTO Takashi +;; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +(module + (func $fd_read (import "wasi_snapshot_preview1" "fd_read") (param i32 i32 i32 i32) (result i32)) + (func $block_forever (export "block_forever") + ;; read from FD 0 + i32.const 100 ;; iov_base + i32.const 200 ;; buffer + i32.store + i32.const 104 ;; iov_len + i32.const 1 + i32.store + i32.const 0 ;; fd 0 + i32.const 100 ;; iov_base + i32.const 1 ;; iov count + i32.const 300 ;; retp (out) + call $fd_read + unreachable + ) + (func (export "_start") + call $block_forever + ) + + ;; a dumb malloc/free implementation + (func (export "malloc") (param i32) (result i32) + local.get 0 + i32.const 65535 + i32.add + i32.const 65536 + i32.div_u + memory.grow + local.set 0 + local.get 0 + i32.const -1 + i32.eq + if + i32.const 0 + return + end + local.get 0 + i32.const 65536 + i32.mul + ) + (func (export "free") (param i32)) + + (memory (export "memory") 1) + + ;; fake globals to make wasm_set_aux_stack happy + (global (export "__heap_base") i32 (i32.const 0x10000)) + (global (export "__data_end") i32 (i32.const 0x10000)) + (global (mut i32) (i32.const 0x10000)) +) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/no_pthread.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/no_pthread.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/no_pthread.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/no_pthread.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/wasi_thread_start.S b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/wasi_thread_start.S similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/wasi_thread_start.S rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/wasi_thread_start.S diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/wasi_thread_start.h b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/wasi_thread_start.h similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/wasi_thread_start.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/wasi_thread_start.h index 2427fd2b9bc..5eae2938d56 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasi-threads/wasm-apps/wasi_thread_start.h +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasi-threads/wasm-apps/wasi_thread_start.h @@ -9,6 +9,7 @@ /* See https://github.com/WebAssembly/wasi-threads#design-choice-thread-ids */ #define ASSERT_VALID_TID(TID) \ + (void)TID; \ assert(TID >= 1 && TID <= 0x1FFFFFFF && "Invalid thread ID") typedef struct { diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/host/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/host/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/host/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/host/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/host/example1.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/host/example1.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/host/example1.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/host/example1.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/wasm/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/wasm/CMakeLists.txt similarity index 91% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/wasm/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/wasm/CMakeLists.txt index 6b2743cb5b4..bf2358444c8 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/wasm/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/wasm/CMakeLists.txt @@ -31,7 +31,7 @@ target_link_options(send_recv PRIVATE if(WASM_TO_AOT) # wasm -> aot add_custom_target(send_recv_aot ALL - COMMAND pwd && ${WAMRC_PATH} --enable-multi-thread -o ./send_recv.aot ./send_recv.wasm + COMMAND pwd && ${WAMRC_PATH} --invoke-c-api-import --enable-multi-thread -o ./send_recv.aot ./send_recv.wasm DEPENDS send_recv WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/wasm/inc/.gitkeep b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/wasm/inc/.gitkeep similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/wasm/inc/.gitkeep rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/wasm/inc/.gitkeep diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/wasm/send_recv.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/wasm/send_recv.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api-imports/wasm/send_recv.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api-imports/wasm/send_recv.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/callback.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/callback.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/callback.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/callback.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/callback.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/callback.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/callback.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/callback.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/callback_chain.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/callback_chain.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/callback_chain.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/callback_chain.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/callback_chain.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/callback_chain.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/callback_chain.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/callback_chain.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/clone.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/clone.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/clone.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/clone.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/clone.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/clone.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/clone.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/clone.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/empty_imports.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/empty_imports.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/empty_imports.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/empty_imports.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/empty_imports.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/empty_imports.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/empty_imports.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/empty_imports.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/global.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/global.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/global.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/global.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/global.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/global.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/global.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/global.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/globalexportimport-0.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/globalexportimport-0.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/globalexportimport-0.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/globalexportimport-0.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/globalexportimport-1.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/globalexportimport-1.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/globalexportimport-1.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/globalexportimport-1.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/globalexportimport.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/globalexportimport.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/globalexportimport.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/globalexportimport.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/hello.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/hello.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/hello.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/hello.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/hello.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/hello.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/hello.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/hello.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/hostref.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/hostref.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/hostref.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/hostref.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/hostref.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/hostref.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/hostref.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/hostref.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/memory.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/memory.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/memory.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/memory.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/memory.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/memory.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/memory.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/memory.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/multi.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/multi.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/multi.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/multi.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/multi.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/multi.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/multi.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/multi.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/reflect.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/reflect.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/reflect.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/reflect.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/reflect.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/reflect.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/reflect.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/reflect.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/serialize.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/serialize.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/serialize.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/serialize.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/serialize.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/serialize.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/serialize.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/serialize.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/table.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/table.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/table.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/table.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/table.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/table.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/table.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/table.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/threads.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/threads.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/threads.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/threads.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/threads.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/threads.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/threads.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/threads.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/trap.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/trap.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/trap.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/trap.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/trap.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/trap.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/trap.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/trap.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/utils/multi_module_utils.c b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/utils/multi_module_utils.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/wasm-c-api/src/utils/multi_module_utils.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/wasm-c-api/src/utils/multi_module_utils.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/benchmark.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/benchmark.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/benchmark.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/benchmark.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/xnnpack.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/xnnpack.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/XNNPACK/xnnpack.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/XNNPACK/xnnpack.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/CMakeLists.bwa_wasm.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/CMakeLists.bwa_wasm.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/CMakeLists.bwa_wasm.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/CMakeLists.bwa_wasm.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/bwa.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/bwa.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/bwa/bwa.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/bwa/bwa.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/cmake/FindBinaryen.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/cmake/FindBinaryen.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/cmake/FindBinaryen.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/cmake/FindBinaryen.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/cmake/FindWASISDK.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/cmake/FindWASISDK.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/cmake/FindWASISDK.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/cmake/FindWASISDK.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/include/.gitkeep b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/include/.gitkeep similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/include/.gitkeep rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/include/.gitkeep diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/meshoptimizer/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/meshoptimizer/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/meshoptimizer/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/meshoptimizer/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/meshoptimizer/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/meshoptimizer/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/meshoptimizer/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/meshoptimizer/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/meshoptimizer/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/meshoptimizer/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/meshoptimizer/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/meshoptimizer/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/meshoptimizer/codecbench.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/meshoptimizer/codecbench.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/meshoptimizer/codecbench.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/meshoptimizer/codecbench.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/preparation.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/preparation.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/preparation.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/preparation.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/tensorflow/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/tensorflow/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/tensorflow/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/tensorflow/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/tensorflow/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/tensorflow/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/tensorflow/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/tensorflow/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/tensorflow/tf_lite.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/tensorflow/tf_lite.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/tensorflow/tf_lite.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/tensorflow/tf_lite.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/CMakeLists.avx_wasm.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/CMakeLists.avx_wasm.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/CMakeLists.avx_wasm.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/CMakeLists.avx_wasm.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/av1-clang.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/av1-clang.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/av1-clang.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/av1-clang.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/wasm-av1.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/wasm-av1.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/samples/workload/wasm-av1/wasm-av1.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/samples/workload/wasm-av1/wasm-av1.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/docker-compose.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/docker-compose.yml similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/docker-compose.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/docker-compose.yml diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/Dockerfile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3 b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3 similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3 rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/db.sqlite3 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/admin.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/apps.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/migrations/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/models.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/application.html diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/appstore.html diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/empty.html diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/help.html diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/templates/mysite.html diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/tests.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/devices/views.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/manage.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/manage.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/manage.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/manage.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/settings.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/urls.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/mysite/wsgi.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/server/Dockerfile b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/server/Dockerfile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/server/Dockerfile rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/server/Dockerfile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/server/wasm_server.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/application.css diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/appstore.css b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/appstore.css similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/appstore.css rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/appstore.css diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/index.css b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/index.css similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/index.css rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/css/index.css diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/application.js diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/appstore.js diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/index.js b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/index.js similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/index.js rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/js/index.js diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/app(1).png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/app(1).png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/app(1).png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/app(1).png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/application.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/application.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/application.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/application.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/delete.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/delete.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/delete.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/delete.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/download(1).png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/download(1).png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/download(1).png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/download(1).png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/menu.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/menu.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/menu.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/menu.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/milky-way-2695569_1280.jpg b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/milky-way-2695569_1280.jpg similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/milky-way-2695569_1280.jpg rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/milky-way-2695569_1280.jpg diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/net_device.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/net_device.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/net_device.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/net_device.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/software-icon-32081.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/software-icon-32081.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/software-icon-32081.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/software-icon-32081.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/totalblack.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/totalblack.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/totalblack.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/photo/totalblack.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/connection.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/connection.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/connection.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/connection.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_publisher.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_publisher.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_publisher.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_publisher.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_subscriber.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_subscriber.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_subscriber.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/event_subscriber.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_handler.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_handler.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_handler.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_handler.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_sender.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_sender.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_sender.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/request_sender.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sensor.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sensor.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sensor.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sensor.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/simple b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/simple similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/simple rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/simple diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/connection.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/connection.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/connection.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/connection.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_publisher.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_publisher.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_publisher.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_publisher.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_subscriber.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_subscriber.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_subscriber.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/event_subscriber.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_handler.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_handler.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_handler.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_handler.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_sender.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_sender.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_sender.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/request_sender.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/timer.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/timer.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/timer.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/sys/timer.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/timer.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/timer.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/timer.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/timer.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/ui_app.wasm b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/ui_app.wasm similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/ui_app.wasm rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/ui_app.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/wasm_runtime_wgl b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/wasm_runtime_wgl similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/wasm_runtime_wgl rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/IoT-APP-Store-Demo/wasm_django/static/upload/wasm_runtime_wgl diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/append-aot-to-wasm/append_aot_to_wasm.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/append-aot-to-wasm/append_aot_to_wasm.py new file mode 100644 index 00000000000..4829fbb194a --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/append-aot-to-wasm/append_aot_to_wasm.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +""" +It is used to append a .aot to a .wasm as a custom section. +The custom section name is "aot". + +e.g. +$ python3 append_aot_to_wasm.py --wasm quicksort.wasm --aot quicksort.aot --output quicksort.aot.wasm +""" + +import argparse +from pathlib import Path + + +def leb128_encode_uint(value: int) -> bytes: + """ + encode unsigned int into a leb128 bytes + """ + binary = [] + while value != 0: + lower_7_bits = value & 0x7F + value >>= 7 + + if value != 0: + current_byte = 0x80 | lower_7_bits + else: + current_byte = 0x00 | lower_7_bits + + binary.append(current_byte) + + return bytes(binary) + + +def leb128_decode_uint(binary: bytes) -> (int, int): + """ + decode binary unsigned from a leb128 bytes + """ + + result = 0 + shift = 0 + for i, b in enumerate(binary): + lower_7_bits = b & 0x7F + result |= lower_7_bits << shift + + highest_bit = b & 0x80 + if not highest_bit: + break + + shift += 7 + + return i + 1, result + + +def is_aligned(n: int, alignment: int): + return (n & (alignment - 1)) == 0 + + +def align_up(n: int, alignment: int): + return n + (alignment - 1) & ~(alignment - 1) + + +def present_as_vector(content: bytes) -> bytes: + v_l = len(content) + v_bin = leb128_encode_uint(v_l) if v_l else b"\x00" + return v_bin + content + + +def calc_padding( + alignment: int, name_bin_len: int, content_len: int, start_pos: int +) -> bytes: + for padding in range(alignment * 2): + padding_bin = present_as_vector(b"\x00" * padding) + section_length = name_bin_len + len(padding_bin) + content_len + section_length_bin = leb128_encode_uint(section_length) + + pos = start_pos + 1 + len(section_length_bin) + name_bin_len + len(padding_bin) + if is_aligned(pos, alignment): + return padding_bin + + +def build_content(content: bytes, pos: int, adding: bytes) -> (int, bytes): + return pos + len(adding), content + adding + + +def create_custom_section_aligned( + start_pos: int, name: str, content: bytes, alignment: int = 4 +) -> bytes: + """ + be sure the section_content starts at a X alignment position + + 1B + | \x00 | length | name vec | padding vec | content | + ^ ^ + | | + start address aligned address + """ + + name_bin = present_as_vector(name.encode("ascii")) + padding_bin = calc_padding(alignment, len(name_bin), len(content), start_pos) + + full_content_bin = b"" + pos = start_pos + + # custome section id 0 + pos, full_content_bin = build_content(full_content_bin, pos, b"\x00") + + # custom section length + section_length = len(name_bin) + len(padding_bin) + len(content) + section_length_bin = leb128_encode_uint(section_length) + pos, full_content_bin = build_content(full_content_bin, pos, section_length_bin) + + # custom section name + pos, full_content_bin = build_content(full_content_bin, pos, name_bin) + + # padding + pos, full_content_bin = build_content(full_content_bin, pos, padding_bin) + assert is_aligned(pos, alignment), f"{pos} is not aligned to {alignment}" + + print(f"append .aot @ offset {pos}(0x{pos:X})") + _, full_content_bin = build_content(full_content_bin, pos, content) + + return full_content_bin + + +def main(wasm_file: str, aot_file: str, output: str) -> None: + cwd = Path.cwd() + wasm_file = cwd.joinpath(wasm_file).resolve() + aot_file = cwd.joinpath(aot_file).resolve() + output = cwd.joinpath(output).resolve() + + assert wasm_file.exists() + assert aot_file.exists() + output.unlink(missing_ok=True) + + # read aot content + with open(aot_file, "rb") as f: + aot_content = f.read() + + # append to .wasm + with open(wasm_file, "rb") as f_in, open(output, "wb") as f_out: + wasm_content = f_in.read(1024) + while wasm_content: + f_out.write(wasm_content) + wasm_content = f_in.read(1024) + + f_out.write(create_custom_section_aligned(f_out.tell(), "aot", aot_content, 4)) + + print(f"{wasm_file.name} + {aot_file.name} ==> {output}") + + +if __name__ == "__main__": + argparse = argparse.ArgumentParser() + argparse.add_argument("--wasm", help="a .wasm") + argparse.add_argument("--aot", help="a .aot") + argparse.add_argument("-o", "--output", help="the output, still be a .wasm") + + args = argparse.parse_args() + main(args.wasm, args.aot, args.output) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/binarydump-tool/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/binarydump-tool/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/binarydump-tool/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/binarydump-tool/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/binarydump-tool/binarydump.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/binarydump-tool/binarydump.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/binarydump-tool/binarydump.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/binarydump-tool/binarydump.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/case_base.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/case_base.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/case_base.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/case_base.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/engine.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/engine.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/engine.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/engine.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/framework.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/framework.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/framework.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/framework.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/suite.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/suite.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/suite.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/suite.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/test_api.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/test_api.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/test_api.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/test_api.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/test_utils.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/test_utils.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/framework/test_utils.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/framework/test_utils.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/harness/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/harness/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/harness/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/harness/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/harness/harness_api.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/harness/harness_api.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/harness/harness_api.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/harness/harness_api.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/host-clients/src/host_app_sample.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/host-clients/src/host_app_sample.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/host-clients/src/host_app_sample.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/host-clients/src/host_app_sample.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/host-clients/src/makefile b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/host-clients/src/makefile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/host-clients/src/makefile rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/host-clients/src/makefile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/set_dev_env.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/set_dev_env.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/set_dev_env.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/set_dev_env.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/start.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/start.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/start.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/start.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/01-install/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/01-install/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/01-install/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/01-install/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/01-install/case.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/01-install/case.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/01-install/case.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/01-install/case.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/02-request/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/02-request/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/02-request/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/02-request/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/02-request/case.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/02-request/case.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/02-request/case.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/02-request/case.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/03-event/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/03-event/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/03-event/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/03-event/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/03-event/case.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/03-event/case.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/03-event/case.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/03-event/case.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/case.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/case.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/case.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/04-request-internal/case.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/case.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/case.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/case.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/05-event-internal/case.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/06-timer/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/06-timer/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/06-timer/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/06-timer/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/06-timer/case.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/06-timer/case.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/06-timer/case.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/06-timer/case.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/case.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/case.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/case.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/07-sensor/case.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/case.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/case.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/case.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/08-on-destroy/case.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/cases/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/cases/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/suite_setup.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/suite_setup.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/suite_setup.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/suite_setup.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/01_install.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/01_install.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/01_install.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/01_install.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/02_request.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/02_request.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/02_request.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/02_request.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/03_event.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/03_event.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/03_event.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/03_event.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_req.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_req.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_req.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_req.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_resp.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_resp.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_resp.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/04_request_internal_resp.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_provider.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_provider.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_provider.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_provider.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_subscriber.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_subscriber.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_subscriber.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/05_event_internal_subscriber.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/06_timer.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/06_timer.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/06_timer.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/06_timer.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/07_sensor.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/07_sensor.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/07_sensor.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/07_sensor.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/08_on_destroy.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/08_on_destroy.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/08_on_destroy.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/08_on_destroy.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/test-app/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/test-app/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/tools/product/start.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/tools/product/start.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/tools/product/start.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/tools/product/start.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/tools/product/stop.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/tools/product/stop.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/01-life-cycle/tools/product/stop.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/01-life-cycle/tools/product/stop.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/__init__.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/__init__.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/__init__.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/__init__.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/readme.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/readme.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/component-test/suites/readme.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/component-test/suites/readme.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/external/cJSON/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/external/cJSON/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/external/cJSON/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/external/cJSON/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/external/cJSON/cJSON.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/external/cJSON/cJSON.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/external/cJSON/cJSON.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/external/cJSON/cJSON.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/external/cJSON/cJSON.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/external/cJSON/cJSON.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/external/cJSON/cJSON.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/external/cJSON/cJSON.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/external/cJSON/cjson.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/external/cJSON/cjson.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/external/cJSON/cjson.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/external/cJSON/cjson.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/host_tool_utils.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/host_tool_utils.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/host_tool_utils.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/host_tool_utils.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/host_tool_utils.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/host_tool_utils.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/host_tool_utils.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/host_tool_utils.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/main.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/main.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/transport.c b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/transport.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/transport.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/transport.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/transport.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/transport.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/host-tool/src/transport.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/host-tool/src/transport.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/pick-up-emscripten-headers/collect_files.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/pick-up-emscripten-headers/collect_files.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/pick-up-emscripten-headers/collect_files.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/pick-up-emscripten-headers/collect_files.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/trans-jitted-func-name/trans_wasm_func_name.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/trans-jitted-func-name/trans_wasm_func_name.py new file mode 100644 index 00000000000..1380cd52a89 --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/trans-jitted-func-name/trans_wasm_func_name.py @@ -0,0 +1,210 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2019 Intel Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +""" +It is used to translate jitted functions' names(in out.folded) to coorespond name in name section in .wasm + +Usage: + +After +``` +$ perf script -i perf.data > out.perf + +# fold call stacks +$ ./FlameGraph/stackcollapse-perf.pl out.perf > out.folded +``` + +Add a step: +``` +# translate jitted functions' names +$ python translate_wasm_function_name.py --wabt_home --folded out.folded <.wasm> +# out.folded -> out.folded.translated +$ ls out.folded.translated +``` + +Then +``` +# generate flamegraph +$ ./FlameGraph/flamegraph.pl out.folded.translated > perf.wasm.svg +``` + +""" + +import argparse +import os +from pathlib import Path +import re +import shlex +import subprocess + + +def preflight_check(wabt_home: Path) -> Path: + """ + if wasm-objdump exists in wabt_home + """ + wasm_objdump_bin = wabt_home.joinpath("bin", "wasm-objdump") + if not wasm_objdump_bin.exists(): + raise RuntimeError(f"wasm-objdump not found in {wabt_home}") + + return wasm_objdump_bin + + +def collect_import_section_content(wasm_objdump_bin: Path, wasm_file: Path) -> dict: + """ + execute "wasm_objdump_bin -j Import -x " and return a dict like {function: X, global: Y, memory: Z, table: N} + """ + assert wasm_objdump_bin.exists() + assert wasm_file.exists() + + command = f"{wasm_objdump_bin} -j Import -x {wasm_file}" + p = subprocess.run( + shlex.split(command), + capture_output=True, + check=False, + text=True, + universal_newlines=True, + ) + + if p.stderr: + return {} + + import_section = {} + for line in p.stdout.split(os.linesep): + line = line.strip() + + if not line: + continue + + if line.startswith(" - func"): + import_section.update("function", import_section.get("function", 0) + 1) + else: + pass + + return import_section + + +def collect_name_section_content(wasm_objdump_bin: Path, wasm_file: Path) -> dict: + """ + execute "wasm_objdump_bin -j name -x wasm_file" and store the output in a list + """ + assert wasm_objdump_bin.exists() + assert wasm_file.exists() + + command = f"{wasm_objdump_bin} -j name -x {wasm_file}" + p = subprocess.run( + shlex.split(command), + capture_output=True, + check=False, + text=True, + universal_newlines=True, + ) + + if p.stderr: + raise RuntimeError(f"not found name section in {wasm_file}") + + name_section = {} + for line in p.stdout.split(os.linesep): + line = line.strip() + + if not line: + continue + + # - func[0] <__imported_wasi_snapshot_preview1_fd_close> + if line.startswith("- func"): + m = re.match(r"- func\[(\d+)\] <(.+)>", line) + assert m + + func_index, func_name = m.groups() + name_section.update({func_index: func_name}) + + assert name_section + return name_section + + +def replace_function_name( + import_section: dict, name_section: dict, folded_in: str, folded_out: str +) -> None: + """ + read content in . each line will be like: + + quiche::BalsaFrame::ProcessHeaders;non-virtual thunk to Envoy::Http::Http1::BalsaParser::MessageDone;Envoy::Http::Http1::ConnectionImpl::onMessageComplete;Envoy::Http::Http1::ConnectionImpl::onMessageCompleteImpl;Envoy::Http::Http1::ServerConnectionImpl::onMessageCompleteBase;Envoy::Http::ConnectionManagerImpl::ActiveStream::decodeHeaders;Envoy::Http::FilterManager::decodeHeaders;virtual thunk to Envoy::Extensions::Common::Wasm::Context::decodeHeaders;proxy_wasm::ContextBase::onRequestHeaders;proxy_wasm::wamr::Wamr::getModuleFunctionImpl;wasm_func_call;wasm_runtime_call_wasm;wasm_call_function;call_wasm_with_hw_bound_check;wasm_interp_call_wasm;llvm_jit_call_func_bytecode;wasm_runtime_invoke_native;push_args_end;aot_func_internal#3302;aot_func_internal#3308;asm_sysvec_apic_timer_interrupt;sysvec_apic_timer_interrupt;__sysvec_apic_timer_interrupt;hrtimer_interrupt;__hrtimer_run_queues;__remove_hrtimer;rb_next 1110899 + + symbol names are spearated by ";" + + if there is a symbol named like "aot_func#XXX" or "aot_func_internal#XXX", it will be replaced with the function name in name section by index + """ + folded_in = Path(folded_in) + assert folded_in.exists() + folded_out = Path(folded_out) + + import_function_count = import_section.get("function", 0) + with folded_in.open("rt", encoding="utf-8") as f_in, folded_out.open( + "wt", encoding="utf-8" + ) as f_out: + precheck_mode = False + for line in f_in: + line = line.strip() + if "aot_func_internal" in line: + precheck_mode = True + + f_in.seek(0) + for line in f_in: + new_line = [] + line = line.strip() + + m = re.match(r"(.*) (\d+)", line) + syms, samples = m.groups() + for sym in syms.split(";"): + m = re.match(r"aot_func(_internal)?#(\d+)", sym) + if not m: + new_line.append(sym) + continue + + func_idx = m.groups()[-1] + if func_idx in name_section: + wasm_func_name = f"[Wasm] {name_section[func_idx]}" + else: + wasm_func_name = ( + f"[Wasm] function[{func_idx + import_function_count}]" + ) + + if precheck_mode: + # aot_func_internal -> xxx + # aot_func --> xxx_precheck + wasm_func_name += "_precheck" if not m.groups()[0] else "" + else: + # aot_func --> xxx + pass + + new_line.append(wasm_func_name) + + line = ";".join(new_line) + line += f" {samples}" + f_out.write(line + os.linesep) + + print(f"⚙️ {folded_in} -> {folded_out}") + + +def main(wabt_home: str, wasm_file: str, folded: str) -> None: + wabt_home = Path(wabt_home) + wasm_file = Path(wasm_file) + + wasm_objdump_bin = preflight_check(wabt_home) + import_section = collect_import_section_content(wasm_objdump_bin, wasm_file) + name_section = collect_name_section_content(wasm_objdump_bin, wasm_file) + + replace_function_name(import_section, name_section, folded, folded + ".translated") + + +if __name__ == "__main__": + argparse = argparse.ArgumentParser() + argparse.add_argument( + "--folded", help="stackcollapse-perf.pl generated, like out.folded" + ) + argparse.add_argument("wasm_file", help="wasm file") + argparse.add_argument("--wabt_home", help="wabt home, like /opt/wabt-1.0.33") + + args = argparse.parse_args() + main(args.wabt_home, args.wasm_file, args.folded) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/.gitattributes b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/.gitattributes similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/.gitattributes rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/.gitattributes diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/Config_building_target.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/Config_building_target.png new file mode 100644 index 00000000000..18db0c83626 Binary files /dev/null and b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/Config_building_target.png differ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/build_folder.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/build_folder.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/build_folder.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/build_folder.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/build_terminal.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/build_terminal.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/build_terminal.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/build_terminal.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/change_workspace_dialog.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/change_workspace_dialog.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/change_workspace_dialog.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/change_workspace_dialog.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/compilation_config.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/compilation_config.png new file mode 100644 index 00000000000..346244d6cd4 Binary files /dev/null and b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/compilation_config.png differ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/compilation_config_2.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/compilation_config_2.png new file mode 100644 index 00000000000..7bf46b2aa64 Binary files /dev/null and b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/compilation_config_2.png differ diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/debug.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/debug.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/debug.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/debug.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/decoration_for_files.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/decoration_for_files.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/decoration_for_files.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/decoration_for_files.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/docker_config.jpg b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/docker_config.jpg similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/docker_config.jpg rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/docker_config.jpg diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/docker_engine_config.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/docker_engine_config.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/docker_engine_config.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/docker_engine_config.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/docker_images.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/docker_images.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/docker_images.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/docker_images.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/install_from_vsix.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/install_from_vsix.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/install_from_vsix.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/install_from_vsix.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/new_project_page.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/new_project_page.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/new_project_page.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/new_project_page.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/open_project_page.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/open_project_page.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/open_project_page.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/open_project_page.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/project_template.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/project_template.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/project_template.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/project_template.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/right_click_menus_1.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/right_click_menus_1.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/right_click_menus_1.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/right_click_menus_1.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/right_click_menus_2.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/right_click_menus_2.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/right_click_menus_2.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/right_click_menus_2.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/run.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/run.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/run.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/run.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/save_configuration.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/save_configuration.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/save_configuration.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/save_configuration.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/set_up_workspace_message.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/set_up_workspace_message.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/set_up_workspace_message.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/set_up_workspace_message.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/wamr_ide_main_menu.png b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/wamr_ide_main_menu.png similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Media/wamr_ide_main_menu.png rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Media/wamr_ide_main_menu.png diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/README.md similarity index 87% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/README.md index 8a6e1509f59..77889222094 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/README.md @@ -14,7 +14,11 @@ The WAMR-IDE is an Integrated Development Environment to develop WebAssembly app ## How to setup WAMR IDE -Now, we have same version tagged docker images, lldb binaries and VS Code installation file(.vsix file) packed for each GitHub release. So if you simply want to use WAMR debugging features in VS Code, the ideal(and effortless) way is following the tutorial in [this section](#21-download-wamr-vs-code-extension-from-the-github-releaserecommended-approach). +Now, the most straightforward way to install the WAMR IDE extension is by searching for WAMR-IDE in the VS Code extension marketplace and installing it directly. So, if you simply want to use WAMR debugging features in VS Code, this is the ideal (and effortless) way. And you are ready to [use WAMR IDE](#how-to-use-wamr-ide). + +> It is only recommended to download versions after 1.3.2 from the marketplace. + +Also, we have same version tagged docker images, lldb binaries and VS Code installation file(.vsix file) packed for each GitHub release. You can following the tutorial in [this section](#21-download-wamr-vs-code-extension-from-the-github-releaserecommended-approach). Alternatively, if you want to build lldb, docker images, or .vsix file locally so that you can try the effect of your modification, you could refer to the tutorial in [this section](#22-build-wamr-vs-code-extension-locallyalternative-approach). @@ -93,19 +97,19 @@ We have 2 docker images which should be built or loaded on your host, `wasm-tool Windows (powershell): ```batch -$ cd .\WASM-Toolchain\Docker -$ .\build_docker_image.bat -$ cd .\WASM-Debug-Server\Docker -$ .\build_docker_image.bat +cd .\WASM-Toolchain\Docker +.\build_docker_image.bat +cd .\WASM-Debug-Server\Docker +.\build_docker_image.bat ``` Linux: ```shell -$ cd ./WASM-Toolchain/Docker -$ ./build_docker_image.sh -$ cd ./WASM-Debug-Server/Docker -$ ./build_docker_image.sh +cd ./WASM-Toolchain/Docker +./build_docker_image.sh +cd ./WASM-Debug-Server/Docker +./build_docker_image.sh ``` ##### 2.2.2 After building, you can find `wasm-toolchain` and `wasm-debug-server` docker images on your local @@ -145,11 +149,11 @@ $ docker build --no-cache --build-arg http_proxy=http://proxy.example.com:1234 `wamride-1.0.0.vsix` can be packaged by [`npm vsce`](https://code.visualstudio.com/api/working-with-extensions/publishing-extension). ```shell -$ npm install -g vsce -$ cd VSCode-Extension -$ rm -rf node_modules -$ npm install -$ vsce package +npm install -g vsce +cd VSCode-Extension +rm -rf node_modules +npm install +vsce package ``` ##### 2.2.7 Enable VS Code debugging feature @@ -171,7 +175,6 @@ $ cp inst/* /home/{usrname}/.vscode-server/extensions/wamr.wamride-1.0.0/resourc If you want to use your own patched `lldb`, you could follow this [instruction](../../doc/source_debugging.md#debugging-with-interpreter) to build `lldb`. And follow this [instruction](./VSCode-Extension/resource/debug/README.md) to copy the binaries to replace the existing ones. - > **You can also debug the extension directly follow this [instruction](./VSCode-Extension/README.md) without packing the extension.** ##### 2.2.7 Install extension from vsix @@ -184,7 +187,7 @@ select `wamride-1.0.0.vsix` which you have packed on your host. ## How to use `wamr-ide` -#### `WAMR-IDE` extension contains 2 components as following picture showing. `WAMR IDE` for workspace and project management and `Current Project` for project's execution. +#### `WAMR-IDE` extension contains 2 components as following picture showing. `WAMR IDE` for workspace and project management and `Current Project` for project's execution ![wamr_ide_main_menu](./Media/wamr_ide_main_menu.png "wamr-ide main menu") @@ -254,7 +257,7 @@ Click `Change workspace` button, a dialog will show as following. You can select At the same time, all added `include path` and `exclude files` will be saved in `.wamr/compilation_config.json` as json array. - ![compilation config](./Media/compilation_config_2.png "compilation config") + ![compilation config](./Media/compilation_config.png "compilation config") > `Toggle state of path including` just shows when selecting `folder` and hides with other resources. > @@ -268,13 +271,22 @@ Click `Configuration` button, a new page will be shown as following. You can con ![config building target](./Media/Config_building_target.png "config building target") +Short Explanation of the Fields Above: + +- Output file name: The compiled wasm file name of your program. +- Initial linear memory size, Max linear memory size, Stack size: The wasi-sdk clang compile options. +- Exported symbols: The symbols your wasm program wants to export. **Multiple symbols are separated by commas without spaces**. +- Host managed heap size: The running configuration for the host managed heap size of iwasm. In most cases, the default size would be fine, but in some scenarios, let's say you want to allocate more memory using `malloc`, you should increase it here accordingly. + +> Note that due to the current implementation limitation, after changing the `Output file name` or `Host managed heap size`, you need to close and reopen VSCode (to reactivate the extension) so that the running config will be correctly updated. + Then click `Modify` button to confirm, if configurations are modified successfully and following message will pop. Click `OK`, the page will be auto closed. ![save configuration](./Media/save_configuration.png "save configuration") And all configuration will be saved in `.wamr/compilation_config.json`. -![configuration file](./Media/compilation_config.png "configuration file") +![configuration file](./Media/compilation_config_2.png "configuration file") #### 2. `Build` diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Script/build.bat b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Script/build.bat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Script/build.bat rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Script/build.bat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Script/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Script/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/Script/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/Script/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.eslintrc.json b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.eslintrc.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.eslintrc.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.eslintrc.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.npmrc b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.npmrc similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.npmrc rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.npmrc diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.prettierrc.json b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.prettierrc.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.prettierrc.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.prettierrc.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.vscodeignore b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.vscodeignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/.vscodeignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/.vscodeignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/CONTRIBUTING.md b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/CONTRIBUTING.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/CONTRIBUTING.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/CONTRIBUTING.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/formatters/rust.py b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/formatters/rust.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/formatters/rust.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/formatters/rust.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/package.json b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/package.json similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/package.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/package.json index d7cc20595f4..77f96537cc0 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/package.json +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/package.json @@ -6,7 +6,7 @@ }, "displayName": "WAMR-IDE", "description": "An Integrated Development Environment for WASM", - "version": "1.2.2", + "version": "1.3.2", "engines": { "vscode": "^1.59.0", "node": ">=16.0.0" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.bat b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.bat similarity index 86% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.bat rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.bat index 7fd1f024aad..4d3a2c3ec23 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.bat +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.bat @@ -7,4 +7,4 @@ docker run --rm -it --name=wasm-debug-server-ctr ^ -v "%cd%":/mnt ^ -p 1234:1234 ^ wasm-debug-server:%2 ^ - /bin/bash -c "./debug.sh %1" + /bin/bash -c "./debug.sh %1 %3" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.sh similarity index 86% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.sh index 169fb7e5f43..e0658659356 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/boot_debugger_server.sh @@ -9,4 +9,4 @@ docker run --rm -it --name=wasm-debug-server-ctr \ -v "$(pwd)":/mnt \ -p 1234:1234 \ wasm-debug-server:$2 \ - /bin/bash -c "./debug.sh $1" + /bin/bash -c "./debug.sh $1 $3" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/build.bat b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/build.bat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/build.bat rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/build.bat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.bat b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.bat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.bat rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.bat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/destroy.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/project.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/project.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/project.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/project.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.bat b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.bat similarity index 85% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.bat rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.bat index af47f35baeb..387a8e629c8 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.bat +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.bat @@ -6,4 +6,4 @@ docker run --rm -it --name=wasm-debug-server-ctr ^ -v "%cd%":/mnt ^ wasm-debug-server:%2 ^ - /bin/bash -c "./run.sh %1" + /bin/bash -c "./run.sh %1 %3" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.sh similarity index 86% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.sh index 670e57c1e78..2526b95462c 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/scripts/run.sh @@ -8,4 +8,4 @@ set -e docker run --rm -it --name=wasm-debug-server-ctr \ -v "$(pwd)":/mnt \ wasm-debug-server:$2 \ - /bin/bash -c "./run.sh $1" + /bin/bash -c "./run.sh $1 $3" diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/test/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/test/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/test/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/test/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/test/test.rs b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/test/test.rs similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/test/test.rs rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/test/test.rs diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/assert.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/assert.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/assert.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/assert.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/ctype.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/ctype.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/ctype.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/ctype.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/errno.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/errno.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/errno.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/errno.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/fcntl.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/fcntl.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/fcntl.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/fcntl.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/inttypes.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/inttypes.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/inttypes.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/inttypes.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/limits.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/limits.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/limits.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/limits.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/pthread.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/pthread.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/pthread.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/pthread.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdarg.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdarg.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdarg.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdarg.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdbool.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdbool.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdbool.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdbool.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdint.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdint.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdint.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdint.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdio.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdio.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdio.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdio.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdlib.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdlib.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdlib.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/stdlib.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/string.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/string.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/string.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/string.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/strings.h b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/strings.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/strings.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/wamr-sdk/libc-builtin-sysroot/include/strings.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/css/style.css b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/css/style.css similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/css/style.css rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/css/style.css diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/configbuildtarget.js b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/configbuildtarget.js similarity index 86% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/configbuildtarget.js rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/configbuildtarget.js index 837f384bcd5..1c146d93364 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/configbuildtarget.js +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/configbuildtarget.js @@ -15,6 +15,7 @@ function submitFunc() { let maxMemSize = document.getElementById('max_mem_size').value; let stackSize = document.getElementById('stack_size').value; let exportedSymbols = document.getElementById('exported_symbols').value; + let hostManagedHeapSize = document.getElementById('host_managed_heap_size').value; vscode.postMessage({ command: 'config_build_target', @@ -23,5 +24,6 @@ function submitFunc() { maxMemSize: maxMemSize, stackSize: stackSize, exportedSymbols: exportedSymbols, + hostManagedHeapSize: hostManagedHeapSize, }); } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/newproj.js b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/newproj.js similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/newproj.js rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/js/newproj.js diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/configBuildTarget.html b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/configBuildTarget.html similarity index 77% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/configBuildTarget.html rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/configBuildTarget.html index b4c43151129..877356a4215 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/configBuildTarget.html +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/configBuildTarget.html @@ -41,12 +41,30 @@

Config building target

- +
+
+
+

Config iwasm running option

+ +
+
+ +
+
+
+ + +
+
+
+
diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/newProject.html b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/newProject.html similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/newProject.html rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/resource/webview/page/newProject.html diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/constants.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/constants.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/constants.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/constants.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/debugConfigurationProvider.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/debugConfigurationProvider.ts similarity index 69% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/debugConfigurationProvider.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/debugConfigurationProvider.ts index 657cf59c766..d24abe6a288 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/debugConfigurationProvider.ts +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/debugConfigurationProvider.ts @@ -8,23 +8,24 @@ import * as os from 'os'; /* see https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-vscode#attaching-settings */ export interface WasmDebugConfig { - type: string, - name: string, - request: string, - program? : string, - pid?: string, - stopOnEntry?: boolean, - waitFor?: boolean, - initCommands?: string[], - preRunCommands?: string[], - stopCommands?: string[], - exitCommands?: string[], - terminateCommands?: string[], - attachCommands?: string[] + type: string; + name: string; + request: string; + program?: string; + pid?: string; + stopOnEntry?: boolean; + waitFor?: boolean; + initCommands?: string[]; + preRunCommands?: string[]; + stopCommands?: string[]; + exitCommands?: string[]; + terminateCommands?: string[]; + attachCommands?: string[]; } export class WasmDebugConfigurationProvider - implements vscode.DebugConfigurationProvider { + implements vscode.DebugConfigurationProvider +{ private wasmDebugConfig: WasmDebugConfig = { type: 'wamr-debug', name: 'Attach', @@ -33,28 +34,29 @@ export class WasmDebugConfigurationProvider attachCommands: [ /* default port 1234 */ 'process connect -p wasm connect://127.0.0.1:1234', - ] + ], }; constructor(extensionPath: string) { this.wasmDebugConfig.initCommands = [ /* Add rust formatters -> https://lldb.llvm.org/use/variable.html */ - `command script import ${extensionPath}/formatters/rust.py` + `command script import ${extensionPath}/formatters/rust.py`, ]; if (os.platform() === 'win32' || os.platform() === 'darwin') { - this.wasmDebugConfig.initCommands.push('platform select remote-linux'); + this.wasmDebugConfig.initCommands.push( + 'platform select remote-linux' + ); } } public resolveDebugConfiguration( _: vscode.WorkspaceFolder | undefined, - debugConfiguration: vscode.DebugConfiguration, + debugConfiguration: vscode.DebugConfiguration ): vscode.ProviderResult { - this.wasmDebugConfig = { ...this.wasmDebugConfig, - ...debugConfiguration + ...debugConfiguration, }; return this.wasmDebugConfig; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/decorationProvider.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/decorationProvider.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/decorationProvider.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/decorationProvider.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/extension.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/extension.ts similarity index 99% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/extension.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/extension.ts index 419f730c884..ab549fc2d22 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/extension.ts +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/extension.ts @@ -170,7 +170,9 @@ export async function activate(context: vscode.ExtensionContext) { } /* register debug configuration */ - wasmDebugConfigProvider = new WasmDebugConfigurationProvider(context.extensionPath); + wasmDebugConfigProvider = new WasmDebugConfigurationProvider( + context.extensionPath + ); vscode.debug.registerDebugConfigurationProvider( 'wamr-debug', @@ -811,6 +813,7 @@ interface BuildArgs { maxMemorySize: string; stackSize: string; exportedSymbols: string; + hostManagedHeapSize: string; } /** diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/taskProvider.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/taskProvider.ts similarity index 98% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/taskProvider.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/taskProvider.ts index 9b9b75f9a02..ee8ba5d1dfc 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/taskProvider.ts +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/taskProvider.ts @@ -31,6 +31,7 @@ export class WasmTaskProvider implements vscode.TaskProvider { /* target name is used for generated aot target */ const targetName = TargetConfigPanel.buildArgs.outputFileName.split('.')[0]; + const heapSize = TargetConfigPanel.buildArgs.hostManagedHeapSize; if ( os.platform() === 'linux' || @@ -57,7 +58,7 @@ export class WasmTaskProvider implements vscode.TaskProvider { : (this._script.get('debugScript') as string), options: { executable: this._script.get('debugScript'), - shellArgs: [targetName, this._wamrVersion], + shellArgs: [targetName, this._wamrVersion, heapSize], }, }; @@ -69,7 +70,7 @@ export class WasmTaskProvider implements vscode.TaskProvider { : (this._script.get('runScript') as string), options: { executable: this._script.get('runScript'), - shellArgs: [targetName, this._wamrVersion], + shellArgs: [targetName, this._wamrVersion, heapSize], }, }; diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/runTest.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/runTest.ts new file mode 100644 index 00000000000..635e02ede8f --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/runTest.ts @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +import * as path from 'path'; +import * as os from 'os'; + +import { runTests } from '@vscode/test-electron'; + +async function main() { + try { + // The folder containing the Extension Manifest package.json + // Passed to `--extensionDevelopmentPath` + const extensionDevelopmentPath = path.resolve(__dirname, '../../'); + + // The path to the extension test script + // Passed to --extensionTestsPath + const extensionTestsPath = path.resolve(__dirname, './suite/index'); + + // Download VS Code, unzip it and run the integration test + await runTests({ + extensionDevelopmentPath, + extensionTestsPath, + launchArgs: ['--user-data-dir', `${os.tmpdir()}`], + }); + } catch (err) { + console.error('Failed to run tests'); + process.exit(1); + } +} + +main(); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts new file mode 100644 index 00000000000..d1420dfa5eb --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/extension.test.ts @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +import { DebugProtocol } from '@vscode/debugprotocol'; +import { after, before, test, suite } from 'mocha'; +import { assert } from 'chai'; +import * as vscode from 'vscode'; +import * as cp from 'child_process'; +import * as path from 'path'; +import * as os from 'os'; +import { + WasmDebugConfig, + WasmDebugConfigurationProvider, +} from '../../debugConfigurationProvider'; +import { + EXTENSION_PATH, + clearAllBp, + setBpAtMarker, + compileRustToWasm, +} from './utils'; +import { downloadLldb, isLLDBInstalled } from '../../utilities/lldbUtilities'; + +suite('Unit Tests', function () { + test('DebugConfigurationProvider init commands', function () { + const testExtensionPath = '/test/path/'; + const provider = new WasmDebugConfigurationProvider(testExtensionPath); + + assert.includeMembers( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + provider.getDebugConfig().initCommands!, + [`command script import ${testExtensionPath}/formatters/rust.py`], + 'Debugger init commands did not contain ' + ); + }); + + test('DebugConfigurationProvider resolve configuration', function () { + const testExtensionPath = '/test/path/'; + const provider = new WasmDebugConfigurationProvider(testExtensionPath); + + const actual = provider.resolveDebugConfiguration(undefined, { + type: 'wamr-debug', + name: 'Attach', + request: 'attach', + initCommands: [], + attachCommands: [ + 'process connect -p wasm connect://123.456.789.1:1237', + ], + }); + + assert.deepEqual( + actual, + { + type: 'wamr-debug', + name: 'Attach', + request: 'attach', + stopOnEntry: true, + initCommands: [], + attachCommands: [ + 'process connect -p wasm connect://123.456.789.1:1237', + ], + }, + 'Configuration did not match the expected configuration after calling resolveDebugConfiguration()' + ); + }); +}); + +suite('Inegration Tests', function () { + let debuggerProcess: cp.ChildProcessWithoutNullStreams; + const port = 1239; + const downloadTimeout = 60 * 1000; + + before(async function () { + // timeout of 20 seconds + this.timeout(20 * 1000); + // Download LLDB if necessary. Should be available in the CI. Only for local execution. + if (!isLLDBInstalled(EXTENSION_PATH)) { + this.timeout(downloadTimeout); + console.log('Downloading LLDB. This might take a moment...'); + await downloadLldb(EXTENSION_PATH); + assert.isTrue( + isLLDBInstalled(EXTENSION_PATH), + 'LLDB was not installed correctly' + ); + } + + compileRustToWasm(); + + const platform = os.platform(); + assert.isTrue( + platform === 'darwin' || platform === 'linux', + `Tests do not support your platform: ${platform}` + ); + const iWasmPath = path.resolve( + `${EXTENSION_PATH}/../../../product-mini/platforms/${platform}/build/iwasm` + ); + const testWasmFilePath = `${EXTENSION_PATH}/resource/test/test.wasm`; + + debuggerProcess = cp.spawn( + iWasmPath, + [`-g=127.0.0.1:${port}`, testWasmFilePath], + {} + ); + + debuggerProcess.stderr.on('data', data => { + console.log(`Error from debugger process: ${data}`); + }); + }); + + after(async function () { + await vscode.debug.stopDebugging(); + debuggerProcess.kill(); + }); + + test('Rust formatters', async function () { + // timeout of 1 minutes + this.timeout(60 * 1000); + clearAllBp(); + setBpAtMarker(`${EXTENSION_PATH}/resource/test/test.rs`, 'BP_MARKER_1'); + + const getVariables = new Promise( + (resolve, reject) => { + vscode.debug.registerDebugAdapterTrackerFactory('wamr-debug', { + createDebugAdapterTracker: function () { + return { + // The debug adapter has sent a Debug Adapter Protocol message to the editor. + onDidSendMessage: ( + message: DebugProtocol.ProtocolMessage + ) => { + if (message.type === 'response') { + const m = message as DebugProtocol.Response; + if (m.command === 'variables') { + const res = + m as DebugProtocol.VariablesResponse; + resolve(res.body.variables); + } + } + }, + onError: (error: Error) => { + reject( + 'An error occurred before vscode reached the breakpoint: ' + + error + ); + }, + onExit: (code: number | undefined) => { + reject( + `Debugger exited before vscode reached the breakpoint with code: ${code}` + ); + }, + }; + }, + }); + } + ); + + const config: WasmDebugConfig = { + type: 'wamr-debug', + request: 'attach', + name: 'Attach Debugger', + stopOnEntry: false, + initCommands: [ + `command script import ${EXTENSION_PATH}/formatters/rust.py`, + ], + attachCommands: [ + `process connect -p wasm connect://127.0.0.1:${port}`, + ], + }; + + if (os.platform() === 'win32' || os.platform() === 'darwin') { + config.initCommands?.push('platform select remote-linux'); + } + + try { + await vscode.debug.startDebugging(undefined, config); + } catch (e) { + assert.fail('Could not connect to debug adapter'); + } + + // wait until vs code has reached breakpoint and has requested the variables. + const variables = await getVariables; + const namesToVariables = variables.reduce( + (acc: { [name: string]: DebugProtocol.Variable }, c) => { + if (c.evaluateName) { + acc[c.evaluateName] = c; + } + return acc; + }, + {} + ); + + assert.includeMembers( + Object.keys(namesToVariables), + ['vector', 'map', 'string', 'slice', 'deque', 'ref_cell'], + 'The Debugger did not return all expected debugger variables.' + ); + + // Vector + assert.equal( + namesToVariables['vector'].value, + ' (5) vec![1, 2, 3, 4, 12]', + 'The Vector summary string looks different than expected' + ); + + // Map + assert.equal( + namesToVariables['map'].value, + ' size=5, capacity=8', + 'The Map summary string looks different than expected' + ); + + // String + assert.equal( + namesToVariables['string'].value, + ' "this is a string"', + 'The String summary string looks different than expected' + ); + + // Slice + assert.equal( + namesToVariables['slice'].value, + ' "ello"', + 'The Slice summary string looks different than expected' + ); + + // Deque + // TODO: The deque format conversion have some problem now + // -alloc::collections::vec_deque::VecDeque @ 0xfff1c + // + (5) VecDeque[1, 2, 3, 4, 5] + // assert.equal( + // namesToVariables['deque'].value, + // ' (5) VecDeque[1, 2, 3, 4, 5]', + // 'The Deque summary string looks different than expected' + // ); + + // RefCell + assert.equal( + namesToVariables['ref_cell'].value, + ' 5', + 'The RefCell summary string looks different than expected' + ); + }); +}); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/index.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/index.ts new file mode 100644 index 00000000000..3b7d271b14c --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/index.ts @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 Intel Corporation. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +import * as path from 'path'; +import * as Mocha from 'mocha'; +import * as glob from 'glob'; + +export function run(): Promise { + // Create the mocha test + const mocha = new Mocha({ + ui: 'tdd', + }); + + const testsRoot = path.resolve(__dirname, '..'); + + return new Promise((c, e) => { + glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { + if (err) { + return e(err); + } + + // Add files to the test suite + files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); + + try { + // Run the mocha test + mocha.run(failures => { + if (failures > 0) { + e(new Error(`${failures} tests failed.`)); + } else { + c(); + } + }); + } catch (err) { + console.error(err); + e(err); + } + }); + }); +} diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts similarity index 63% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts index 87cb04b3b1c..3f40596c3d1 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/test/suite/utils.ts @@ -3,10 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ -import {assert} from 'chai'; +import { assert } from 'chai'; import * as vscode from 'vscode'; -import {Range, SourceBreakpoint} from "vscode"; -import * as fs from "fs"; +import { Range, SourceBreakpoint } from 'vscode'; +import * as fs from 'fs'; import path = require('path'); import * as cp from 'child_process'; @@ -20,11 +20,18 @@ export function clearAllBp(): void { // Inserts a breakpoint in a file at the first occurrence of bpMarker export function setBpAtMarker(file: string, bpMarker: string): void { const uri = vscode.Uri.file(file); - const data = fs.readFileSync(uri.path, "utf8"); - const line = data.split("\n").findIndex(line => line.includes(bpMarker)); - assert.notStrictEqual(line, -1, "Could not find breakpoint marker in source file"); + const data = fs.readFileSync(uri.path, 'utf8'); + const line = data.split('\n').findIndex(line => line.includes(bpMarker)); + assert.notStrictEqual( + line, + -1, + 'Could not find breakpoint marker in source file' + ); const position = new vscode.Position(line, 0); - const bp = new SourceBreakpoint(new vscode.Location(uri, new Range(position, position)), true); + const bp = new SourceBreakpoint( + new vscode.Location(uri, new Range(position, position)), + true + ); vscode.debug.addBreakpoints([bp]); } @@ -35,9 +42,12 @@ export function compileRustToWasm(): void { const cmd = `rustc --target wasm32-wasi ${testResourceFolder}/test.rs -g -C opt-level=0 -o ${testResourceFolder}/test.wasm`; try { - cp.execSync(cmd, {stdio: [null, null, process.stderr]}); + cp.execSync(cmd, { stdio: [null, null, process.stderr] }); } catch (e) { assert.fail(`Compilation of example rust file failed with error: ${e}`); } - assert.isTrue(fs.existsSync(`${testResourceFolder}/test.wasm`), "Could not find wasm file WASM file to run debugger on."); + assert.isTrue( + fs.existsSync(`${testResourceFolder}/test.wasm`), + 'Could not find wasm file WASM file to run debugger on.' + ); } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/directoryUtilities.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/directoryUtilities.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/directoryUtilities.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/directoryUtilities.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/dockerUtilities.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/dockerUtilities.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/dockerUtilities.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/dockerUtilities.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/getUri.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/getUri.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/getUri.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/getUri.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/lldbUtilities.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/lldbUtilities.ts similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/lldbUtilities.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/lldbUtilities.ts index b6553acbc7e..95447666679 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/utilities/lldbUtilities.ts +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/utilities/lldbUtilities.ts @@ -35,9 +35,7 @@ function getLLDBUnzipFilePath(destinationFolder: string, filename: string) { return path.join(destinationFolder, ...dirs); } -export function getWAMRExtensionVersion( - extensionPath: string -): string { +export function getWAMRExtensionVersion(extensionPath: string): string { // eslint-disable-next-line @typescript-eslint/no-var-requires return require(path.join(extensionPath, 'package.json')).version; } @@ -68,7 +66,6 @@ export function isLLDBInstalled(extensionPath: string): boolean { export async function promptInstallLLDB( extensionPath: string ): Promise { - const response = await vscode.window.showWarningMessage( 'No LLDB instance found. Setup now?', SelectionOfPrompt.setUp, @@ -84,9 +81,7 @@ export async function promptInstallLLDB( return SelectionOfPrompt.setUp; } -export async function downloadLldb( - extensionPath: string -): Promise { +export async function downloadLldb(extensionPath: string): Promise { const downloadUrl = getLLDBDownloadUrl(extensionPath); const destinationDir = os.platform(); diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/view/NewProjectPanel.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/view/NewProjectPanel.ts similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/view/NewProjectPanel.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/view/NewProjectPanel.ts diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/view/TargetConfigPanel.ts b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/view/TargetConfigPanel.ts similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/view/TargetConfigPanel.ts rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/view/TargetConfigPanel.ts index f2e1343a590..8efa2455cdb 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/src/view/TargetConfigPanel.ts +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/src/view/TargetConfigPanel.ts @@ -20,6 +20,7 @@ export class TargetConfigPanel { maxMemorySize: '131072', stackSize: '4096', exportedSymbols: 'main', + hostManagedHeapSize: '4096', }; private static readonly userInputError: number = -2; @@ -74,14 +75,16 @@ export class TargetConfigPanel { initMemSize: string, maxMemSize: string, stackSize: string, - exportedSymbols: string + exportedSymbols: string, + hostManagedHeapSize: string ): number { if ( outputFileName === '' || initMemSize === '' || maxMemSize === '' || stackSize === '' || - exportedSymbols === '' + exportedSymbols === '' || + hostManagedHeapSize === '' ) { return TargetConfigPanel.userInputError; } @@ -95,6 +98,7 @@ export class TargetConfigPanel { maxMemorySize: maxMemSize, stackSize: stackSize, exportedSymbols: exportedSymbols, + hostManagedHeapSize: hostManagedHeapSize, }; const configStr = readFromConfigFile(); @@ -174,6 +178,10 @@ export class TargetConfigPanel { .replace( /(\${exported_symbols_val})/, TargetConfigPanel.buildArgs.exportedSymbols + ) + .replace( + /(\${host_managed_heap_size_val})/, + TargetConfigPanel.buildArgs.hostManagedHeapSize ); return html; @@ -189,7 +197,8 @@ export class TargetConfigPanel { message.initMemSize === '' || message.maxMemSize === '' || message.stackSize === '' || - message.exportedSymbols === '' + message.exportedSymbols === '' || + message.hostManagedHeapSize === '' ) { vscode.window.showErrorMessage( 'Please fill chart before your submit!' @@ -201,7 +210,8 @@ export class TargetConfigPanel { message.initMemSize, message.maxMemSize, message.stackSize, - message.exportedSymbols + message.exportedSymbols, + message.hostManagedHeapSize ) === TargetConfigPanel.executionSuccess ) { vscode.window diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/tsconfig.json b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/tsconfig.json similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/VSCode-Extension/tsconfig.json rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/VSCode-Extension/tsconfig.json diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/Dockerfile b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/Dockerfile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/Dockerfile rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/Dockerfile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/build_docker_image.bat b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/build_docker_image.bat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/build_docker_image.bat rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/build_docker_image.bat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/build_docker_image.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/build_docker_image.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/build_docker_image.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/build_docker_image.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/debug.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/debug.sh similarity index 61% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/debug.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/debug.sh index 48458870f33..33cdb58447c 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/debug.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/debug.sh @@ -3,4 +3,5 @@ #!/bin/bash TARGET=$1 -./iwasm -g=0.0.0.0:1234 /mnt/build/${TARGET}.wasm \ No newline at end of file +HEAP_SIZE=$2 +./iwasm -g=0.0.0.0:1234 --heap-size=${HEAP_SIZE} /mnt/build/${TARGET}.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/run.sh similarity index 66% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/run.sh index 4e3acecbaa3..f652cfc2eab 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/run.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Debug-Server/Docker/resource/run.sh @@ -3,4 +3,5 @@ #!/bin/bash TARGET=$1 -./iwasm /mnt/build/${TARGET}.wasm \ No newline at end of file +HEAP_SIZE=$2 +./iwasm --heap-size=${HEAP_SIZE} /mnt/build/${TARGET}.wasm diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/.dockerignore b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/.dockerignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/.dockerignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/.dockerignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/Dockerfile b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/Dockerfile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/Dockerfile rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/Dockerfile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.bat b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.bat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.bat rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.bat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/build_docker_image.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/resource/build_wasm.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/resource/build_wasm.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/resource/build_wasm.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/resource/build_wasm.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/resource/wamr_toolchain.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/resource/wamr_toolchain.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/test-tools/wamr-ide/WASM-Toolchain/Docker/resource/wamr_toolchain.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/test-tools/wamr-ide/WASM-Toolchain/Docker/resource/wamr_toolchain.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/README.md similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/README.md index 4e88069f851..5b874e9889a 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/README.md @@ -10,7 +10,7 @@ Please build iwasm and wamrc, refer to: - [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos) - [Build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler) -And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. +And install WASI SDK, please download the [wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. And then run `./build.sh` to build the source code, file `coremark.exe`, `coremark.wasm` and `coremark.aot` will be generated. diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/test_pgo.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/test_pgo.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/coremark/test_pgo.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/coremark/test_pgo.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/LICENSE b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/LICENSE similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/LICENSE rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/LICENSE diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/include/dhry.h b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/include/dhry.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/include/dhry.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/include/dhry.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/run.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/run.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/run.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/run.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/src/dhry_1.c b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/src/dhry_1.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/src/dhry_1.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/src/dhry_1.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/src/dhry_2.c b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/src/dhry_2.c similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/src/dhry_2.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/src/dhry_2.c diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/test_pgo.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/test_pgo.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/dhrystone/test_pgo.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/dhrystone/test_pgo.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/jetstream.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/jetstream.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/jetstream.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/jetstream.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/run_aot.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/run_aot.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/run_aot.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/run_aot.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/test_pgo.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/test_pgo.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/test_pgo.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/test_pgo.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/tsf.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/tsf.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/jetstream/tsf.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/jetstream/tsf.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/libsodium/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/libsodium/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/libsodium/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/libsodium/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/libsodium/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/libsodium/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/libsodium/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/libsodium/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/libsodium/run_aot.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/libsodium/run_aot.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/libsodium/run_aot.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/libsodium/run_aot.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/libsodium/test_pgo.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/libsodium/test_pgo.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/libsodium/test_pgo.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/libsodium/test_pgo.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/README.md similarity index 94% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/README.md index d8b3db96197..7b6623f2215 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/README.md @@ -10,7 +10,7 @@ Please build iwasm and wamrc, refer to: - [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos) - [Build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler) -And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. +And install WASI SDK, please download the [wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it. diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/run_aot.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/run_aot.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/run_aot.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/run_aot.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/run_interp.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/run_interp.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/run_interp.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/run_interp.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/test_pgo.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/test_pgo.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/polybench/test_pgo.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/polybench/test_pgo.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/README.md similarity index 93% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/README.md index ff34c7d700b..3f54fda1bcd 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/README.md @@ -10,7 +10,7 @@ Please build iwasm and wamrc, refer to: - [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos) - [Build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler) -And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. +And install WASI SDK, please download the [wasi-sdk release](https://github.com/WebAssembly/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it. diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/build.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/build.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/build.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/build.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/run_aot.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/run_aot.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/run_aot.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/run_aot.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/run_interp.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/run_interp.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/run_interp.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/run_interp.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/test_pgo.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/test_pgo.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/benchmarks/sightglass/test_pgo.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/benchmarks/sightglass/test_pgo.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/unit/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/unit/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/unit/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/unit/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/unit/main.cpp b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/unit/main.cpp similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/unit/main.cpp rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/unit/main.cpp diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-compiler/.gitignore b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-compiler/.gitignore similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-compiler/.gitignore rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-compiler/.gitignore diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-compiler/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-compiler/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-compiler/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-compiler/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-compiler/test_shift_negative_constants.wat b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-compiler/test_shift_negative_constants.wat similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-compiler/test_shift_negative_constants.wat rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-compiler/test_shift_negative_constants.wat diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/CHANGES b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/CHANGES similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/CHANGES rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/CHANGES diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/all.py b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/all.py similarity index 92% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/all.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/all.py index 551a3176c61..7aa47cf413c 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/all.py +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/all.py @@ -47,6 +47,7 @@ def get_iwasm_cmd(platform: str) -> str: IWASM_SGX_CMD = "../../../product-mini/platforms/linux-sgx/enclave-sample/iwasm" IWASM_QEMU_CMD = "iwasm" SPEC_TEST_DIR = "spec/test/core" +EXCE_HANDLING_DIR = "exception-handling/test/core" WAST2WASM_CMD = exe_file_path("./wabt/out/gcc/Release/wat2wasm") SPEC_INTERPRETER_CMD = "spec/interpreter/wasm" WAMRC_CMD = "../../../wamr-compiler/build/wamrc" @@ -78,8 +79,10 @@ def ignore_the_case( simd_flag=False, gc_flag=False, xip_flag=False, + eh_flag=False, qemu_flag=False, ): + if case_name in ["comments", "inline-module", "names"]: return True @@ -126,7 +129,7 @@ def ignore_the_case( return False -def preflight_check(aot_flag): +def preflight_check(aot_flag, eh_flag): if not pathlib.Path(SPEC_TEST_DIR).resolve().exists(): print(f"Can not find {SPEC_TEST_DIR}") return False @@ -139,6 +142,10 @@ def preflight_check(aot_flag): print(f"Can not find {WAMRC_CMD}") return False + if eh_flag and not pathlib.Path(EXCE_HANDLING_DIR).resolve().exists(): + print(f"Can not find {EXCE_HANDLING_DIR}") + return False + return True @@ -151,6 +158,7 @@ def test_case( multi_thread_flag=False, simd_flag=False, xip_flag=False, + eh_flag=False, clean_up_flag=True, verbose_flag=True, gc_flag=False, @@ -195,6 +203,9 @@ def test_case( if xip_flag: CMD.append("--xip") + if eh_flag: + CMD.append("--eh") + if qemu_flag: CMD.append("--qemu") CMD.append("--qemu-firmware") @@ -268,6 +279,7 @@ def test_suite( multi_thread_flag=False, simd_flag=False, xip_flag=False, + eh_flag=False, clean_up_flag=True, verbose_flag=True, gc_flag=False, @@ -291,6 +303,15 @@ def test_suite( gc_case_list = sorted(suite_path.glob("gc/*.wast")) case_list.extend(gc_case_list) + if eh_flag: + eh_path = pathlib.Path(EXCE_HANDLING_DIR).resolve() + if not eh_path.exists(): + print(f"can not find spec test cases at {eh_path}") + return False + eh_case_list = sorted(eh_path.glob("*.wast")) + eh_case_list_include = [test for test in eh_case_list if test.stem in ["throw", "tag", "try_catch", "rethrow", "try_delegate"]] + case_list.extend(eh_case_list_include) + # ignore based on command line options filtered_case_list = [] for case_path in case_list: @@ -305,6 +326,7 @@ def test_suite( simd_flag, gc_flag, xip_flag, + eh_flag, qemu_flag, ): filtered_case_list.append(case_path) @@ -331,6 +353,7 @@ def test_suite( multi_thread_flag, simd_flag, xip_flag, + eh_flag, clean_up_flag, verbose_flag, gc_flag, @@ -369,6 +392,7 @@ def test_suite( multi_thread_flag, simd_flag, xip_flag, + eh_flag, clean_up_flag, verbose_flag, gc_flag, @@ -428,6 +452,14 @@ def main(): dest="xip_flag", help="Running with the XIP feature", ) + # added to support WASM_ENABLE_EXCE_HANDLING + parser.add_argument( + "-e", + action="store_true", + default=False, + dest="eh_flag", + help="Running with the exception-handling feature", + ) parser.add_argument( "-t", action="store_true", @@ -508,7 +540,7 @@ def main(): if options.target == "x86_32": options.target = "i386" - if not preflight_check(options.aot_flag): + if not preflight_check(options.aot_flag, options.eh_flag): return False if not options.cases: @@ -527,6 +559,7 @@ def main(): options.multi_thread_flag, options.simd_flag, options.xip_flag, + options.eh_flag, options.clean_up_flag, options.verbose_flag, options.gc_flag, @@ -552,6 +585,7 @@ def main(): options.multi_thread_flag, options.simd_flag, options.xip_flag, + options.eh_flag, options.clean_up_flag, options.verbose_flag, options.gc_flag, diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/all.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/all.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/all.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/all.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/collect_coverage.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/collect_coverage.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/collect_coverage.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/collect_coverage.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/exception_handling.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/exception_handling.patch new file mode 100644 index 00000000000..0c9e8d40f5c --- /dev/null +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/exception_handling.patch @@ -0,0 +1,20 @@ +diff --git a/test/core/try_catch.wast b/test/core/try_catch.wast +index 2a0e9ff6..f243489d 100644 +--- a/test/core/try_catch.wast ++++ b/test/core/try_catch.wast +@@ -203,7 +203,6 @@ + + (assert_return (invoke "catch-param-i32" (i32.const 5)) (i32.const 5)) + +-(assert_return (invoke "catch-imported") (i32.const 2)) + + (assert_return (invoke "catchless-try" (i32.const 0)) (i32.const 0)) + (assert_return (invoke "catchless-try" (i32.const 1)) (i32.const 1)) +@@ -231,7 +230,6 @@ + ) + ) + +-(assert_return (invoke "imported-mismatch") (i32.const 3)) + + (assert_malformed + (module quote "(module (func (catch_all)))") diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/ignore_cases.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/ignore_cases.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/ignore_cases.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/ignore_cases.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/multi_module_aot_ignore_cases.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/multi_module_aot_ignore_cases.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/multi_module_aot_ignore_cases.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/multi_module_aot_ignore_cases.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/runtest.py b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/runtest.py similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/runtest.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/runtest.py index dcc0c3361db..60d4607e9b5 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/runtest.py +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/runtest.py @@ -301,6 +301,9 @@ def assert_prompt(runner, prompts, timeout, is_need_execute_result): parser.add_argument('--xip', default=False, action='store_true', help="Enable XIP") +parser.add_argument('--eh', default=False, action='store_true', + help="Enable Exception Handling") + parser.add_argument('--multi-module', default=False, action='store_true', help="Enable Multi-thread") @@ -762,6 +765,13 @@ def test_assert(r, opts, mode, cmd, expected): if o.find(e) >= 0 or e.find(o) >= 0: return True + # wasm-exception thrown out of function call, not a trap + if mode=='wasmexception': + o = re.sub('^Exception: ', '', out) + e = re.sub('^Exception: ', '', expected) + if o.find(e) >= 0 or e.find(o) >= 0: + return True + ## 0x9:i32,-0x1:i32 -> ['0x9:i32', '-0x1:i32'] expected_list = re.split(',', expected) out_list = re.split(',', out) @@ -987,6 +997,42 @@ def test_assert_exhaustion(r,opts,form): expected = "Exception: %s\n" % m.group(3) test_assert(r, opts, "exhaustion", "%s %s" % (func, " ".join(args)), expected) + +# added to support WASM_ENABLE_EXCE_HANDLING +def test_assert_wasmexception(r,opts,form): + # params + + # ^ + # \(assert_exception\s+ + # \(invoke\s+"([^"]+)"\s+ + # (\(.*\))\s* + # () + # \)\s* + # \)\s* + # $ + m = re.search('^\(assert_exception\s+\(invoke\s+"([^"]+)"\s+(\(.*\))\s*\)\s*\)\s*$', form) + if not m: + # no params + + # ^ + # \(assert_exception\s+ + # \(invoke\s+"([^"]+)"\s* + # () + # \)\s* + # \)\s* + # $ + m = re.search('^\(assert_exception\s+\(invoke\s+"([^"]+)"\s*()\)\s*\)\s*$', form) + if not m: + raise Exception("unparsed assert_exception: '%s'" % form) + func = m.group(1) # function name + if m.group(2) == '': # arguments + args = [] + else: + args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", m.group(2)[1:-1])] + + expected = "Exception: uncaught wasm exception\n" + test_assert(r, opts, "wasmexception", "%s %s" % (func, " ".join(args)), expected) + def do_invoke(r, opts, form): # params m = re.search('^\(invoke\s+"([^"]+)"\s+(\(.*\))\s*\)\s*$', form) @@ -1025,6 +1071,8 @@ def compile_wast_to_wasm(form, wast_tempfile, wasm_tempfile, opts): # default arguments if opts.gc: cmd = [opts.wast2wasm, "-u", "-d", wast_tempfile, "-o", wasm_tempfile] + elif opts.eh: + cmd = [opts.wast2wasm, "--enable-thread", "--no-check", "--enable-exceptions", "--enable-tail-call", wast_tempfile, "-o", wasm_tempfile ] else: cmd = [opts.wast2wasm, "--enable-thread", "--no-check", wast_tempfile, "-o", wasm_tempfile ] @@ -1236,6 +1284,8 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r) elif re.match("^\(assert_exhaustion\\b.*", form): test_assert_exhaustion(r, opts, form) + elif re.match("^\(assert_exception\\b.*", form): + test_assert_wasmexception(r, opts, form) elif re.match("^\(assert_unlinkable\\b.*", form): test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r, False) elif re.match("^\(assert_malformed\\b.*", form): diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/simd_ignore_cases.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/simd_ignore_cases.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/simd_ignore_cases.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/simd_ignore_cases.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/tail-call/return_call.wast b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/tail-call/return_call.wast similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/tail-call/return_call.wast rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/tail-call/return_call.wast diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/tail-call/return_call_indirect.wast b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/tail-call/return_call_indirect.wast similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/tail-call/return_call_indirect.wast rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/tail-call/return_call_indirect.wast diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/thread_proposal_fix_atomic_case.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/thread_proposal_fix_atomic_case.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/thread_proposal_fix_atomic_case.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/thread_proposal_fix_atomic_case.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/thread_proposal_ignore_cases.patch b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/thread_proposal_ignore_cases.patch similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/spec-test-script/thread_proposal_ignore_cases.patch rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/spec-test-script/thread_proposal_ignore_cases.patch diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/test_wamr.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/test_wamr.sh similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/test_wamr.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/test_wamr.sh index 76b235d499e..7f41fc43dfd 100755 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/test_wamr.sh +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/test_wamr.sh @@ -24,6 +24,7 @@ function help() echo "-S enable SIMD feature" echo "-G enable GC feature" echo "-X enable XIP feature" + echo "-e enable exception handling" echo "-x test SGX" echo "-w enable WASI threads" echo "-b use the wabt binary release package instead of compiling from the source code" @@ -50,6 +51,7 @@ COLLECT_CODE_COVERAGE=0 ENABLE_SIMD=0 ENABLE_GC=0 ENABLE_XIP=0 +ENABLE_EH=0 ENABLE_DEBUG_VERSION=0 ENABLE_GC_HEAP_VERIFY=0 #unit test case arrary @@ -70,7 +72,7 @@ WASI_TESTSUITE_COMMIT="ee807fc551978490bf1c277059aabfa1e589a6c2" TARGET_LIST=("AARCH64" "AARCH64_VFP" "ARMV7" "ARMV7_VFP" "THUMBV7" "THUMBV7_VFP" \ "RISCV32" "RISCV32_ILP32F" "RISCV32_ILP32D" "RISCV64" "RISCV64_LP64F" "RISCV64_LP64D") -while getopts ":s:cabgvt:m:MCpSXxwPGQF:j:T:" opt +while getopts ":s:cabgvt:m:MCpSXexwPGQF:j:T:" opt do OPT_PARSED="TRUE" case $opt in @@ -119,7 +121,7 @@ do ;; m) echo "set compile target of wamr" ${OPTARG} - TARGET=${OPTARG^^} # set target to uppercase if input x86_32 or x86_64 --> X86_32 and X86_64 + TARGET=$(echo "$OPTARG" | tr '[a-z]' '[A-Z]') # set target to uppercase if input x86_32 or x86_64 --> X86_32 and X86_64 ;; w) echo "enable WASI threads" @@ -145,6 +147,10 @@ do echo "enable XIP feature" ENABLE_XIP=1 ;; + e) + echo "enable exception handling feature" + ENABLE_EH=1 + ;; x) echo "test SGX" SGX_OPT="--sgx" @@ -425,6 +431,26 @@ function spec_test() git apply ../../spec-test-script/thread_proposal_fix_atomic_case.patch fi + if [ ${ENABLE_EH} == 1 ]; then + echo "checkout exception-handling test cases" + popd + if [ ! -d "exception-handling" ];then + echo "exception-handling not exist, clone it from github" + git clone -b master --single-branch https://github.com/WebAssembly/exception-handling + fi + pushd exception-handling + + # restore and clean everything + git reset --hard 51c721661b671bb7dc4b3a3acb9e079b49778d36 + + if [[ ${ENABLE_MULTI_MODULE} == 0 ]]; then + git apply ../../spec-test-script/exception_handling.patch + fi + + popd + echo $(pwd) + fi + # update GC cases if [[ ${ENABLE_GC} == 1 ]]; then echo "checkout spec for GC proposal" @@ -463,6 +489,10 @@ function spec_test() fi fi + if [[ 1 == ${ENABLE_EH} ]]; then + ARGS_FOR_SPEC_TEST+="-e " + fi + # sgx only enable in interp mode and aot mode if [[ ${SGX_OPT} == "--sgx" ]];then if [[ $1 == 'classic-interp' || $1 == 'fast-interp' || $1 == 'aot' || $1 == 'fast-jit' ]]; then @@ -827,6 +857,10 @@ function trigger() EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_WASI_THREADS=1" fi + if [[ ${ENABLE_EH} == 1 ]]; then + EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_EXCE_HANDLING=1" + EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_TAIL_CALL=1" + fi echo "SANITIZER IS" $WAMR_BUILD_SANITIZER if [[ "$WAMR_BUILD_SANITIZER" == "ubsan" ]]; then diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/tsan_suppressions.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/tsan_suppressions.txt similarity index 96% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/tsan_suppressions.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/tsan_suppressions.txt index d79eafddc56..dd903a60577 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/tsan_suppressions.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/tsan_suppressions.txt @@ -1,6 +1,7 @@ # Proposing to accept this risk for now. It might be wasi-libc related. # https://github.com/bytecodealliance/wasm-micro-runtime/pull/1963#issuecomment-1455342931 race:STORE_U32 +race:STORE_U8 # Suppressing signal-unsafe inside of a signal for AOT mode # see https://github.com/bytecodealliance/wasm-micro-runtime/issues/2248#issuecomment-1630189656 diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/wamr-compiler-test-script/run_wamr_compiler_tests.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/wamr-compiler-test-script/run_wamr_compiler_tests.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/wamr-compiler-test-script/run_wamr_compiler_tests.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/wamr-compiler-test-script/run_wamr_compiler_tests.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/wasi-test-script/pipe.py b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/wasi-test-script/pipe.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/wasi-test-script/pipe.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/wasi-test-script/pipe.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/CMakeLists.txt similarity index 75% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/CMakeLists.txt index 5fe8fae16f2..84e8b524c59 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/CMakeLists.txt +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/CMakeLists.txt @@ -44,36 +44,53 @@ add_definitions(-DWASM_ENABLE_CUSTOM_NAME_SECTION=1) add_definitions(-DWASM_ENABLE_DUMP_CALL_STACK=1) add_definitions(-DWASM_ENABLE_PERF_PROFILING=1) add_definitions(-DWASM_ENABLE_LOAD_CUSTOM_SECTION=1) -add_definitions(-DWASM_ENABLE_LIB_WASI_THREADS=1) add_definitions(-DWASM_ENABLE_MODULE_INST_CONTEXT=1) if (WAMR_BUILD_LLVM_LEGACY_PM EQUAL 1) add_definitions(-DWASM_ENABLE_LLVM_LEGACY_PM=1) -endif() +endif () + +if (LINUX) + add_definitions(-DWASM_ENABLE_LINUX_PERF=1) +endif () if (DEFINED WAMR_BUILD_AOT_FUNC_PREFIX) add_definitions(-DAOT_FUNC_PREFIX="${WAMR_BUILD_AOT_FUNC_PREFIX}") endif () -# Set WAMR_BUILD_TARGET, currently values supported: -# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32" if (NOT WAMR_BUILD_TARGET) - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - # Build as X86_64 by default in 64-bit platform + string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" HOST_SYSTEM_PROCESSOR) + if (${HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") set (WAMR_BUILD_TARGET "X86_64") - else () - # Build as X86_32 by default in 32-bit platform + elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "i686") set (WAMR_BUILD_TARGET "X86_32") - endif () + elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "amd64") + set (WAMR_BUILD_TARGET "AMD_64") + elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "aarch64" + OR ${HOST_SYSTEM_PROCESSOR} STREQUAL "arm64") + set (WAMR_BUILD_TARGET "AARCH64") + elseif (${HOST_SYSTEM_PROCESSOR} MATCHES "arm.*") + message(STATUS "Assuming ${CMAKE_HOST_SYSTEM_PROCESSOR} as ARM_32") + set (WAMR_BUILD_TARGET "ARM_32") + elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "mips") + set (WAMR_BUILD_TARGET "MIPS_32") + elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "xtensa") + set (WAMR_BUILD_TARGET "XTENSA_32") + elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "riscv64") + set (WAMR_BUILD_TARGET "RISCV64") + elseif (${HOST_SYSTEM_PROCESSOR} STREQUAL "riscv") + message(STATUS "Assuming ${CMAKE_HOST_SYSTEM_PROCESSOR} as RISCV32") + set (WAMR_BUILD_TARGET "RISCV32") + else () + message (FATAL_ERROR "Unsupported CMAKE_HOST_SYSTEM_PROCESSOR " + "${CMAKE_HOST_SYSTEM_PROCESSOR}") + endif() + if (WAMR_BUILD_PLATFORM STREQUAL "windows") if (("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")) set (WAMR_BUILD_TARGET "X86_32") endif() - elseif (WAMR_BUILD_PLATFORM STREQUAL "darwin") - if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64") - set (WAMR_BUILD_TARGET "AARCH64") - endif () - endif() + endif () endif () string(TOUPPER ${WAMR_BUILD_TARGET} WAMR_BUILD_TARGET) @@ -199,31 +216,97 @@ include_directories (${SHARED_DIR}/include enable_language (ASM) if (NOT MINGW AND NOT MSVC) - set(WAMR_BUILD_LIBC_WASI 1) -else() - set(WAMR_BUILD_LIBC_UVWASI 1) -endif() + if ((NOT DEFINED WAMR_BUILD_LIBC_WASI) AND (NOT DEFINED WAMR_BUILD_LIBC_UVWASI)) + set (WAMR_BUILD_LIBC_WASI 1) + endif () + + if ((WAMR_BUILD_LIBC_WASI EQUAL 1) AND (WAMR_BUILD_LIBC_UVWASI EQUAL 1)) + message (WARNING "-- pick WAMR_BULID_LIBC_UVWASI when both are enabled") + set (WAMR_BUILD_LIBC_WASI 0) + endif () +else () + if (NOT DEFINED WAMR_BUILD_LIBC_UVWASI) + set (WAMR_BUILD_LIBC_UVWASI 1) + endif () + + if (WAMR_BUILD_LIBC_WASI EQUAL 1) + message (WARNING "-- don't accept WAMR_BUILD_LIBC_WASI=1 on MINGW or MSVC") + set (WAMR_BUILD_LIBC_WASI 0) + endif () +endif () + +if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN) + set (WAMR_BUILD_LIBC_BUILTIN 1) +endif () + +if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD) + set (WAMR_BUILD_LIB_PTHREAD 1) +endif () + +if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS) + set (WAMR_BUILD_LIB_WASI_THREADS 1) +endif () + +if (WAMR_BUILD_LIBC_UVWASI EQUAL 1) + message ("-- Libc WASI enabled with uvwasi implementation") +endif () + +if (WAMR_BUILD_LIBC_WASI EQUAL 1) + message ("-- Libc WASI enabled") +endif () + +if ((NOT WAMR_BUILD_LIBC_WASI) AND (NOT WAMR_BUILD_LIBC_UVWASI)) + message ("-- Libc WASI disabled") +endif () + +if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1) + message ("-- Libc builtin enabled") +else () + message ("-- Libc builtin disabled") +endif () + +if (WAMR_BUILD_LIB_PTHREAD EQUAL 1) + message ("-- Lib pthread enabled") +else () + message ("-- Lib pthread disabled") +endif () + +if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1) + message ("-- Lib wasi-threads enabled") +else () + message ("-- Lib wasi-threads disabled") +endif () include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake) include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake) include (${SHARED_DIR}/utils/shared_utils.cmake) include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake) -include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake) -if (NOT MINGW) - if (NOT MSVC) - include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake) - else() - include (${IWASM_DIR}/libraries/libc-uvwasi/libc_uvwasi.cmake) - endif() -endif() -include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake) -include (${IWASM_DIR}/libraries/lib-wasi-threads/lib_wasi_threads.cmake) include (${IWASM_DIR}/common/iwasm_common.cmake) include (${IWASM_DIR}/interpreter/iwasm_interp.cmake) include (${IWASM_DIR}/aot/iwasm_aot.cmake) include (${IWASM_DIR}/compilation/iwasm_compl.cmake) +if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1) + include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake) +endif () + +if (WAMR_BUILD_LIBC_UVWASI EQUAL 1) + include (${IWASM_DIR}/libraries/libc-uvwasi/libc_uvwasi.cmake) +endif () + +if (WAMR_BUILD_LIBC_WASI EQUAL 1) + include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake) +endif () + +if (WAMR_BUILD_LIB_PTHREAD EQUAL 1) + include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake) +endif () + +if (WAMR_BUILD_LIB_WASI_THREADS EQUAL 1) + include (${IWASM_DIR}/libraries/lib-wasi-threads/lib_wasi_threads.cmake) +endif () + # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion") if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" OR MSVC)) diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/README.md similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/README.md diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/build_llvm.py b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/build_llvm.py similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/build_llvm.py rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/build_llvm.py diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/build_llvm.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/build_llvm.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/build_llvm.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/build_llvm.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/build_llvm_arc.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/build_llvm_arc.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/build_llvm_arc.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/build_llvm_arc.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/build_llvm_xtensa.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/build_llvm_xtensa.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/build_llvm_xtensa.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/build_llvm_xtensa.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/main.c b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/main.c similarity index 95% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/main.c rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/main.c index 0d85b99ce92..0a94175dc93 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-compiler/main.c +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-compiler/main.c @@ -174,7 +174,7 @@ print_help() printf(" Enable the specified LLVM passes, using comma to separate\n"); printf(" --use-prof-file= Use profile file collected by LLVM PGO (Profile-Guided Optimization)\n"); printf(" --enable-segue[=] Enable using segment register GS as the base address of linear memory,\n"); - printf(" only available on linux/linux-sgx x86-64, which may improve performance,\n"); + printf(" only available on linux x86-64, which may improve performance,\n"); printf(" flags can be: i32.load, i64.load, f32.load, f64.load, v128.load,\n"); printf(" i32.store, i64.store, f32.store, f64.store, v128.store\n"); printf(" Use comma to separate, e.g. --enable-segue=i32.load,i64.store\n"); @@ -184,9 +184,14 @@ print_help() printf(" multiple names, e.g.\n"); printf(" --emit-custom-sections=section1,section2,sectionN\n"); #if BH_HAS_DLFCN - printf(" --native-lib= Register native libraries to the WASM module, which\n"); - printf(" are shared object (.so) files, for example:\n"); - printf(" --native-lib=test1.so --native-lib=test2.so\n"); + printf(" --native-lib= Register native libraries to the WASM module, which\n"); + printf(" are shared object (.so) files, for example:\n"); + printf(" --native-lib=test1.so --native-lib=test2.so\n"); +#endif + printf(" --invoke-c-api-import Treat unknown import function as wasm-c-api import function and\n"); + printf(" quick call it from AOT code\n"); +#if WASM_ENABLE_LINUX_PERF != 0 + printf(" --enable-linux-perf Enable linux perf support\n"); #endif printf(" -v=n Set log verbose level (0 to 5, default is 2), larger with more log\n"); printf(" --version Show version information\n"); @@ -325,6 +330,9 @@ main(int argc, char *argv[]) void *native_handle_list[8] = { NULL }; uint32 native_handle_count = 0; #endif +#if WASM_ENABLE_LINUX_PERF != 0 + bool enable_linux_perf = false; +#endif option.opt_level = 3; option.size_level = 3; @@ -526,7 +534,15 @@ main(int argc, char *argv[]) native_lib_list[native_lib_count++] = argv[0] + 13; } #endif - else if (!strncmp(argv[0], "--version", 9)) { + else if (!strcmp(argv[0], "--invoke-c-api-import")) { + option.quick_invoke_c_api_import = true; + } +#if WASM_ENABLE_LINUX_PERF != 0 + else if (!strcmp(argv[0], "--enable-linux-perf")) { + enable_linux_perf = true; + } +#endif + else if (!strcmp(argv[0], "--version")) { uint32 major, minor, patch; wasm_runtime_get_version(&major, &minor, &patch); printf("wamrc %u.%u.%u\n", major, minor, patch); @@ -579,6 +595,9 @@ main(int argc, char *argv[]) init_args.mem_alloc_option.allocator.malloc_func = malloc; init_args.mem_alloc_option.allocator.realloc_func = realloc; init_args.mem_alloc_option.allocator.free_func = free; +#if WASM_ENABLE_LINUX_PERF != 0 + init_args.enable_linux_perf = enable_linux_perf; +#endif /* initialize runtime environment */ if (!wasm_runtime_full_init(&init_args)) { @@ -608,8 +627,10 @@ main(int argc, char *argv[]) goto fail1; } - if (get_package_type(wasm_file, wasm_file_size) != Wasm_Module_Bytecode) { - printf("Invalid file type: expected wasm file but got other\n"); + if (wasm_file_size >= 4 /* length of MAGIC NUMBER */ + && get_package_type(wasm_file, wasm_file_size) + != Wasm_Module_Bytecode) { + printf("Invalid wasm file: magic header not detected\n"); goto fail2; } diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/Kconfig b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/Kconfig similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/Kconfig rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/Kconfig diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/Makefile b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/Makefile similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/Makefile rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/Makefile diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/README.md b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/README.md similarity index 97% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/README.md rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/README.md index 14b172e0289..fd926af8624 100644 --- a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/README.md +++ b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/README.md @@ -8,7 +8,7 @@ Usually there are two tasks for integrating the WAMR into a particular project: The **[WAMR SDK](./wamr-sdk)** tools is helpful to finish the two tasks quickly. It supports menu configuration for selecting WAMR components and builds the WAMR to a SDK package that includes **runtime SDK** and **APP SDK**. The runtime SDK is used for building the native application and the APP SDK should be shipped to WASM application developers. -**Note**: [WASI-SDK](https://github.com/CraneStation/wasi-sdk/releases) version 7 and above should be installed before building the WAMR SDK. +**Note**: [WASI-SDK](https://github.com/WebAssembly/wasi-sdk/releases) version 7 and above should be installed before building the WAMR SDK. diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/assert.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/assert.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/assert.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/assert.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/ctype.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/ctype.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/ctype.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/ctype.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/errno.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/errno.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/errno.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/errno.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/fcntl.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/fcntl.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/fcntl.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/fcntl.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/inttypes.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/inttypes.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/inttypes.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/inttypes.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/limits.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/limits.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/limits.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/limits.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/pthread.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/pthread.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/pthread.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/pthread.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/semaphore.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/semaphore.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/semaphore.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/semaphore.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdarg.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdarg.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdarg.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdarg.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdbool.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdbool.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdbool.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdbool.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdint.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdint.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdint.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdint.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdio.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdio.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdio.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdio.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdlib.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdlib.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/stdlib.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/stdlib.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/string.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/string.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/string.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/string.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/strings.h b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/strings.h similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/include/strings.h rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/include/strings.h diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/libc-builtin-sysroot/share/defined-symbols.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/wamr_toolchain.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/wamr_toolchain.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/wamr_toolchain.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/wamr_toolchain.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/wasi_toolchain.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/wasi_toolchain.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/app/wasi_toolchain.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/app/wasi_toolchain.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/build_sdk.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/build_sdk.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/build_sdk.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/build_sdk.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/menuconfig.sh b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/menuconfig.sh similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/menuconfig.sh rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/menuconfig.sh diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/runtime/CMakeLists.txt b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/runtime/CMakeLists.txt similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/runtime/CMakeLists.txt rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/runtime/CMakeLists.txt diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/wamr_config_default.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/wamr_config_default.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/wamr_config_default.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/wamr_config_default.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/wamr_config_macos_release.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/wamr_config_macos_release.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/wamr_config_macos_release.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/wamr_config_macos_release.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/wamr_config_ubuntu_release.cmake b/lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/wamr_config_ubuntu_release.cmake similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/wamr-sdk/wamr_config_ubuntu_release.cmake rename to lib/wasm-micro-runtime-WAMR-1.3.3/wamr-sdk/wamr_config_ubuntu_release.cmake diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/zephyr/module.yml b/lib/wasm-micro-runtime-WAMR-1.3.3/zephyr/module.yml similarity index 100% rename from lib/wasm-micro-runtime-WAMR-1.3.0/zephyr/module.yml rename to lib/wasm-micro-runtime-WAMR-1.3.3/zephyr/module.yml