Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some compile warnings and typos #3854

Merged
merged 6 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ATTRIBUTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The WAMR fast interpreter is a clean room development. We would acknowledge the

### llvm

[LICENSE](./LICENCE.txt)
[LICENSE](./LICENSE)

### wasm-c-api

Expand Down
60 changes: 53 additions & 7 deletions core/iwasm/aot/aot_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2760,7 +2760,7 @@ load_exports(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
const uint8 *buf = *p_buf;
AOTExport *exports;
uint64 size;
uint32 i;
uint32 i, j;

/* Allocate memory */
size = sizeof(AOTExport) * (uint64)module->export_count;
Expand All @@ -2774,14 +2774,60 @@ load_exports(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
read_uint32(buf, buf_end, exports[i].index);
read_uint8(buf, buf_end, exports[i].kind);
read_string(buf, buf_end, exports[i].name);
#if 0 /* TODO: check kind and index */
if (export_funcs[i].index >=
module->func_count + module->import_func_count) {
set_error_buf(error_buf, error_buf_size,
"function index is out of range");
return false;

for (j = 0; j < i; j++) {
if (!strcmp(exports[i].name, exports[j].name)) {
set_error_buf(error_buf, error_buf_size,
"duplicate export name");
return false;
}
}

/* Check export kind and index */
switch (exports[i].kind) {
case EXPORT_KIND_FUNC:
if (exports[i].index
>= module->import_func_count + module->func_count) {
set_error_buf(error_buf, error_buf_size,
"unknown function");
return false;
}
break;
case EXPORT_KIND_TABLE:
if (exports[i].index
>= module->import_table_count + module->table_count) {
set_error_buf(error_buf, error_buf_size, "unknown table");
return false;
}
break;
case EXPORT_KIND_MEMORY:
if (exports[i].index
>= module->import_memory_count + module->memory_count) {
set_error_buf(error_buf, error_buf_size, "unknown memory");
return false;
}
break;
case EXPORT_KIND_GLOBAL:
if (exports[i].index
>= module->import_global_count + module->global_count) {
set_error_buf(error_buf, error_buf_size, "unknown global");
return false;
}
break;
#if WASM_ENABLE_TAGS != 0
/* TODO
case EXPORT_KIND_TAG:
if (index >= module->import_tag_count + module->tag_count) {
set_error_buf(error_buf, error_buf_size, "unknown tag");
return false;
}
break;
*/
#endif
default:
set_error_buf(error_buf, error_buf_size, "invalid export kind");
return false;
}
}

*p_buf = buf;
Expand Down
6 changes: 3 additions & 3 deletions core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ is_frame_per_function(WASMExecEnv *exec_env)
return module->feature_flags & WASM_FEATURE_FRAME_PER_FUNCTION;
}

#if WASM_ENABLE_DUMP_CALL_STACK != 0
static bool
is_frame_func_idx_disabled(WASMExecEnv *exec_env)
{
Expand All @@ -142,6 +143,7 @@ is_frame_func_idx_disabled(WASMExecEnv *exec_env)

return module->feature_flags & WASM_FEATURE_FRAME_NO_FUNC_IDX;
}
#endif

static void *
get_top_frame(WASMExecEnv *exec_env)
Expand Down Expand Up @@ -1475,9 +1477,7 @@ create_exports(AOTModuleInstance *module_inst, AOTModule *module,
}
}

#if WASM_ENABLE_MULTI_MEMORY == 0
bh_assert(module_inst->export_memory_count <= 1);
#else
#if WASM_ENABLE_MULTI_MEMORY != 0
if (module_inst->export_memory_count) {
module_inst->export_memories = export_memories_instantiate(
module, module_inst, module_inst->export_memory_count, error_buf,
Expand Down
3 changes: 2 additions & 1 deletion core/iwasm/common/wasm_runtime_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -3592,7 +3592,8 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
char mapping_copy_buf[256];
char *mapping_copy = mapping_copy_buf;
char *map_mapped = NULL, *map_host = NULL;
const unsigned long max_len = strlen(map_dir_list[i]) * 2 + 3;
const unsigned long max_len =
(unsigned long)strlen(map_dir_list[i]) * 2 + 3;

/* Allocation limit for runtime environments with reduced stack size */
if (max_len > 256) {
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/compilation/aot_emit_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ check_suspend_flags(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
aot_set_last_error("llvm build LOAD failed");
return false;
}
/* Set terminate_flags memory accecc to volatile, so that the value
/* Set terminate_flags memory access to volatile, so that the value
will always be loaded from memory rather than register */
LLVMSetVolatile(terminate_flags, true);

Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/compilation/aot_emit_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,7 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef *param_values = NULL, *value_rets = NULL;
LLVMValueRef *result_phis = NULL, value_ret, import_func_count;
#if WASM_ENABLE_MEMORY64 != 0
LLVMValueRef u32_max, u32_cmp_result;
LLVMValueRef u32_max, u32_cmp_result = NULL;
#endif
LLVMTypeRef *param_types = NULL, ret_type;
LLVMTypeRef llvm_func_type, llvm_func_ptr_type;
Expand Down
12 changes: 9 additions & 3 deletions core/iwasm/compilation/aot_emit_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "aot_emit_gc.h"
#endif

#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
#if WASM_ENABLE_MEMORY64 != 0
static bool
zero_extend_u64(AOTCompContext *comp_ctx, LLVMValueRef *value, const char *name)
{
Expand All @@ -23,17 +25,18 @@ zero_extend_u64(AOTCompContext *comp_ctx, LLVMValueRef *value, const char *name)
}
return true;
}
#endif

/* check whether a table64 elem idx is greater than UINT32_MAX, if so, throw
* exception, otherwise trunc it to uint32 */
static bool
check_tbl_elem_idx_and_trunc(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef *elem_idx, uint32 tbl_idx)
{
#if WASM_ENABLE_MEMORY64 != 0
LLVMValueRef u32_max, u32_cmp_result;
LLVMBasicBlockRef check_elem_idx_succ;

#if WASM_ENABLE_MEMORY64 != 0
if (!IS_TABLE64(tbl_idx)) {
return true;
}
Expand Down Expand Up @@ -69,12 +72,15 @@ check_tbl_elem_idx_and_trunc(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
EXCE_OUT_OF_BOUNDS_TABLE_ACCESS, true,
u32_cmp_result, check_elem_idx_succ)))
goto fail;
#endif

return true;
fail:
return false;
#else
return true;
#endif
}
#endif /* WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC !=0 */

uint64
get_tbl_inst_offset(const AOTCompContext *comp_ctx,
Expand Down Expand Up @@ -738,4 +744,4 @@ aot_compile_op_table_fill(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
return false;
}

#endif /* WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC !=0 */
#endif /* WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC !=0 */
4 changes: 2 additions & 2 deletions core/iwasm/include/wasm_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,8 @@ wasm_application_execute_main(wasm_module_inst_t module_inst, int32_t argc,
char *argv[]);

/**
* Find the specified function in argv[0] from a WASM module instance
* and execute that function.
* Find the specified function from a WASM module instance and execute
* that function.
*
* @param module_inst the WASM module instance
* @param name the name of the function to execute.
Expand Down
9 changes: 5 additions & 4 deletions core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,8 @@ execute_interruptible_poll_oneoff(
uint32 i;

const __wasi_timestamp_t timeout = get_timeout_for_poll_oneoff(
in, nsubscriptions),
time_quant = 1e9;
in, (uint32)nsubscriptions),
time_quant = (__wasi_timestamp_t)1e9;
const uint64 size_to_copy =
nsubscriptions * (uint64)sizeof(wasi_subscription_t);
__wasi_subscription_t *in_copy = NULL;
Expand All @@ -1034,12 +1034,13 @@ execute_interruptible_poll_oneoff(
return __WASI_ENOMEM;
}

bh_memcpy_s(in_copy, size_to_copy, in, size_to_copy);
bh_memcpy_s(in_copy, (uint32)size_to_copy, in, (uint32)size_to_copy);

while (timeout == (__wasi_timestamp_t)-1 || elapsed <= timeout) {
/* update timeout for clock subscription events */
update_clock_subscription_data(
in_copy, nsubscriptions, min_uint64(time_quant, timeout - elapsed));
in_copy, (uint32)nsubscriptions,
min_uint64(time_quant, timeout - elapsed));
err = wasmtime_ssp_poll_oneoff(exec_env, curfds, in_copy, out,
nsubscriptions, nevents);
elapsed += time_quant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3130,7 +3130,7 @@ compare_address(const struct addr_pool *addr_pool_entry,
}
addr_size = 16;
}
max_addr_mask = addr_size * 8;
max_addr_mask = (uint8)(addr_size * 8);

/* IPv4 0.0.0.0 or IPv6 :: means any address */
if (basebuf[0] == 0 && !memcmp(basebuf, basebuf + 1, addr_size - 1)) {
Expand Down
2 changes: 1 addition & 1 deletion core/shared/platform/windows/win_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ os_clock_res_get(__wasi_clockid_t clock_id, __wasi_timestamp_t *resolution)
case __WASI_CLOCK_PROCESS_CPUTIME_ID:
case __WASI_CLOCK_THREAD_CPUTIME_ID:
{
#if WINAPI_PARTITION_DESKTOP
#if WINAPI_PARTITION_DESKTOP && WASM_ENABLE_WAMR_COMPILER == 0
ULONG maximum_time;
ULONG minimum_time;
ULONG current_time;
Expand Down
4 changes: 2 additions & 2 deletions samples/multi-thread/wasm-apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.14)
project(wasm-apps)

set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
Expand Down Expand Up @@ -43,4 +43,4 @@ add_executable(main_thread_exception.wasm main_thread_exception.c)
target_link_libraries(main_thread_exception.wasm)

add_executable(main_global_atomic.wasm main_global_atomic.c)
target_link_libraries(main_global_atomic.wasm)
target_link_libraries(main_global_atomic.wasm)
2 changes: 1 addition & 1 deletion samples/spawn-thread/wasm-apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.14)
project(wasm-apps)

set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
Expand Down
Binary file removed tests/unit/runtime-common/wasm-apps/main.aot
Binary file not shown.
Binary file removed tests/unit/wasm-vm/wasm-apps/binarydump
Binary file not shown.
11 changes: 11 additions & 0 deletions tests/unit/wasm-vm/wasm-apps/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

readonly CURR_DIR=$PWD
readonly BINARYDUMP_DIR=$PWD/../../../../test-tools/binarydump-tool

# build binarydump
cd $BINARYDUMP_DIR
mkdir -p build && cd build
cmake .. && make -j
cp -a binarydump $CURR_DIR

cd $CURR_DIR

## build app1
/opt/wasi-sdk/bin/clang -O3 \
-z stack-size=4096 -Wl,--initial-memory=65536 \
Expand Down
2 changes: 1 addition & 1 deletion tests/wamr-test-suites/test_wamr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ function spec_test()
# Reset to commit: "Merge remote-tracking branch 'upstream/main' into merge2"
git reset --hard 48e69f394869c55b7bbe14ac963c09f4605490b6
git checkout 044d0d2e77bdcbe891f7e0b9dd2ac01d56435f0b -- test/core/elem.wast test/core/data.wast
# Patch table64 extension
# Patch table64 extension
git checkout 940398cd4823522a9b36bec4984be4b153dedb81 -- test/core/call_indirect.wast test/core/table.wast test/core/table_copy.wast test/core/table_copy_mixed.wast test/core/table_fill.wast test/core/table_get.wast test/core/table_grow.wast test/core/table_init.wast test/core/table_set.wast test/core/table_size.wast
git apply ../../spec-test-script/memory64_ignore_cases.patch || exit 1
elif [[ ${ENABLE_MULTI_MEMORY} == 1 ]]; then
Expand Down
Loading