mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 13:16:26 +00:00
Fix compile warnings/error reported in Windows (#3616)
Clear some compile warnings and fix undefined reference error for symbol ffs in Windows platform.
This commit is contained in:
parent
46695b992c
commit
73caf19e69
|
@ -1139,7 +1139,7 @@ memories_instantiate(AOTModuleInstance *module_inst, AOTModuleInstance *parent,
|
||||||
|
|
||||||
if (memory_inst->memory_data) {
|
if (memory_inst->memory_data) {
|
||||||
bh_memcpy_s((uint8 *)memory_inst->memory_data + base_offset,
|
bh_memcpy_s((uint8 *)memory_inst->memory_data + base_offset,
|
||||||
(uint32)memory_inst->memory_data_size - base_offset,
|
(uint32)(memory_inst->memory_data_size - base_offset),
|
||||||
data_seg->bytes, length);
|
data_seg->bytes, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1212,7 +1212,7 @@ aot_get_function_instance(AOTModuleInstance *module_inst, uint32 func_idx)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extra->function_count = func_count;
|
extra->function_count = (uint32)func_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* instantiate function if needed */
|
/* instantiate function if needed */
|
||||||
|
@ -1764,8 +1764,8 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
|
||||||
aot_get_data_section_addr(module, AOT_STACK_SIZES_SECTION_NAME, NULL);
|
aot_get_data_section_addr(module, AOT_STACK_SIZES_SECTION_NAME, NULL);
|
||||||
|
|
||||||
#if WASM_ENABLE_PERF_PROFILING != 0
|
#if WASM_ENABLE_PERF_PROFILING != 0
|
||||||
total_size = (uint64)sizeof(AOTFuncPerfProfInfo)
|
total_size = sizeof(AOTFuncPerfProfInfo)
|
||||||
* (module->import_func_count + module->func_count);
|
* ((uint64)module->import_func_count + module->func_count);
|
||||||
if (!(module_inst->func_perf_profilings =
|
if (!(module_inst->func_perf_profilings =
|
||||||
runtime_malloc(total_size, error_buf, error_buf_size))) {
|
runtime_malloc(total_size, error_buf, error_buf_size))) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -2536,7 +2536,7 @@ execute_malloc_function(AOTModuleInstance *module_inst, WASMExecEnv *exec_env,
|
||||||
if (ret) {
|
if (ret) {
|
||||||
#if WASM_ENABLE_MEMORY64 != 0
|
#if WASM_ENABLE_MEMORY64 != 0
|
||||||
if (is_memory64)
|
if (is_memory64)
|
||||||
*p_result = GET_I64_FROM_ADDR(&argv.u64);
|
*p_result = argv.u64;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,7 +104,9 @@ bool
|
||||||
is_valid_func_type(const WASMFuncType *func_type)
|
is_valid_func_type(const WASMFuncType *func_type)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < func_type->param_count + func_type->result_count; i++) {
|
for (i = 0;
|
||||||
|
i < (unsigned)(func_type->param_count + func_type->result_count);
|
||||||
|
i++) {
|
||||||
if (!is_valid_value_type(func_type->types[i]))
|
if (!is_valid_value_type(func_type->types[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -930,13 +930,13 @@ wasm_runtime_enlarge_memory(WASMModuleInstanceCommon *module_inst,
|
||||||
#if WASM_ENABLE_AOT != 0
|
#if WASM_ENABLE_AOT != 0
|
||||||
if (module_inst->module_type == Wasm_Module_AoT) {
|
if (module_inst->module_type == Wasm_Module_AoT) {
|
||||||
return aot_enlarge_memory((AOTModuleInstance *)module_inst,
|
return aot_enlarge_memory((AOTModuleInstance *)module_inst,
|
||||||
inc_page_count);
|
(uint32)inc_page_count);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if WASM_ENABLE_INTERP != 0
|
#if WASM_ENABLE_INTERP != 0
|
||||||
if (module_inst->module_type == Wasm_Module_Bytecode) {
|
if (module_inst->module_type == Wasm_Module_Bytecode) {
|
||||||
return wasm_enlarge_memory((WASMModuleInstance *)module_inst,
|
return wasm_enlarge_memory((WASMModuleInstance *)module_inst,
|
||||||
inc_page_count);
|
(uint32)inc_page_count);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,23 @@ get_memory_check_bound(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
return mem_check_bound;
|
return mem_check_bound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(_WIN32_)
|
||||||
|
static inline int
|
||||||
|
ffs(int n)
|
||||||
|
{
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while (!(n & 1)) {
|
||||||
|
pos++;
|
||||||
|
n >>= 1;
|
||||||
|
}
|
||||||
|
return pos + 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static LLVMValueRef
|
static LLVMValueRef
|
||||||
get_memory_curr_page_count(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
|
get_memory_curr_page_count(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
|
||||||
|
|
||||||
|
@ -198,7 +215,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
* has the natural alignment. for platforms using mmap, it can
|
* has the natural alignment. for platforms using mmap, it can
|
||||||
* be even larger. for now, use a conservative value.
|
* be even larger. for now, use a conservative value.
|
||||||
*/
|
*/
|
||||||
const int max_align = 8;
|
const unsigned int max_align = 8;
|
||||||
int shift = ffs((int)(unsigned int)mem_offset);
|
int shift = ffs((int)(unsigned int)mem_offset);
|
||||||
if (shift == 0) {
|
if (shift == 0) {
|
||||||
*alignp = max_align;
|
*alignp = max_align;
|
||||||
|
|
|
@ -749,7 +749,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
|
||||||
* and more importantly doesn't involve relocations.
|
* and more importantly doesn't involve relocations.
|
||||||
*/
|
*/
|
||||||
LLVMAttributeRef attr_short_call = LLVMCreateStringAttribute(
|
LLVMAttributeRef attr_short_call = LLVMCreateStringAttribute(
|
||||||
comp_ctx->context, "short-call", strlen("short-call"), "", 0);
|
comp_ctx->context, "short-call", (unsigned)strlen("short-call"),
|
||||||
|
"", 0);
|
||||||
LLVMAddAttributeAtIndex(func, LLVMAttributeFunctionIndex,
|
LLVMAddAttributeAtIndex(func, LLVMAttributeFunctionIndex,
|
||||||
attr_short_call);
|
attr_short_call);
|
||||||
}
|
}
|
||||||
|
@ -3529,7 +3530,7 @@ aot_block_destroy(AOTCompContext *comp_ctx, AOTBlock *block)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
|
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
|
||||||
uint32 offset, uint32 bytes)
|
uint64 offset, uint32 bytes)
|
||||||
{
|
{
|
||||||
AOTCheckedAddr *node = func_ctx->checked_addr_list;
|
AOTCheckedAddr *node = func_ctx->checked_addr_list;
|
||||||
|
|
||||||
|
@ -3573,7 +3574,7 @@ aot_checked_addr_list_del(AOTFuncContext *func_ctx, uint32 local_idx)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aot_checked_addr_list_find(AOTFuncContext *func_ctx, uint32 local_idx,
|
aot_checked_addr_list_find(AOTFuncContext *func_ctx, uint32 local_idx,
|
||||||
uint32 offset, uint32 bytes)
|
uint64 offset, uint32 bytes)
|
||||||
{
|
{
|
||||||
AOTCheckedAddr *node = func_ctx->checked_addr_list;
|
AOTCheckedAddr *node = func_ctx->checked_addr_list;
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ typedef struct AOTBlockStack {
|
||||||
typedef struct AOTCheckedAddr {
|
typedef struct AOTCheckedAddr {
|
||||||
struct AOTCheckedAddr *next;
|
struct AOTCheckedAddr *next;
|
||||||
uint32 local_idx;
|
uint32 local_idx;
|
||||||
uint32 offset;
|
uint64 offset;
|
||||||
uint32 bytes;
|
uint32 bytes;
|
||||||
} AOTCheckedAddr, *AOTCheckedAddrList;
|
} AOTCheckedAddr, *AOTCheckedAddrList;
|
||||||
|
|
||||||
|
@ -574,14 +574,14 @@ wasm_type_to_llvm_type(const AOTCompContext *comp_ctx,
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
|
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
|
||||||
uint32 offset, uint32 bytes);
|
uint64 offset, uint32 bytes);
|
||||||
|
|
||||||
void
|
void
|
||||||
aot_checked_addr_list_del(AOTFuncContext *func_ctx, uint32 local_idx);
|
aot_checked_addr_list_del(AOTFuncContext *func_ctx, uint32 local_idx);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aot_checked_addr_list_find(AOTFuncContext *func_ctx, uint32 local_idx,
|
aot_checked_addr_list_find(AOTFuncContext *func_ctx, uint32 local_idx,
|
||||||
uint32 offset, uint32 bytes);
|
uint64 offset, uint32 bytes);
|
||||||
|
|
||||||
void
|
void
|
||||||
aot_checked_addr_list_destroy(AOTFuncContext *func_ctx);
|
aot_checked_addr_list_destroy(AOTFuncContext *func_ctx);
|
||||||
|
|
|
@ -411,7 +411,7 @@ aot_compress_aot_func_names(AOTCompContext *comp_ctx, uint32 *p_size)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
compressed_str_len = Result.size();
|
compressed_str_len = (uint32)Result.size();
|
||||||
if (!(compressed_str = (char *)wasm_runtime_malloc(compressed_str_len))) {
|
if (!(compressed_str = (char *)wasm_runtime_malloc(compressed_str_len))) {
|
||||||
aot_set_last_error("allocate memory failed");
|
aot_set_last_error("allocate memory failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -189,7 +189,7 @@ PartitionFunction(GlobalValueSet Requested)
|
||||||
auto GVName = GV->getName(); /* get the function name */
|
auto GVName = GV->getName(); /* get the function name */
|
||||||
const char *gvname = GVName.begin(); /* C function name */
|
const char *gvname = GVName.begin(); /* C function name */
|
||||||
const char *wrapper;
|
const char *wrapper;
|
||||||
uint32 prefix_len = strlen(AOT_FUNC_PREFIX);
|
uint32 prefix_len = (uint32)strlen(AOT_FUNC_PREFIX);
|
||||||
|
|
||||||
LOG_DEBUG("requested func %s", gvname);
|
LOG_DEBUG("requested func %s", gvname);
|
||||||
/* Convert "aot_func#n_wrapper" to "aot_func#n" */
|
/* Convert "aot_func#n_wrapper" to "aot_func#n" */
|
||||||
|
|
|
@ -281,7 +281,7 @@ aot_compile_simd_load_zero(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
/* data_length in bytes */
|
/* data_length in bytes */
|
||||||
static bool
|
static bool
|
||||||
simd_store(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, uint32 align,
|
simd_store(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, uint32 align,
|
||||||
uint32 offset, uint32 data_length, LLVMValueRef value,
|
mem_offset_t offset, uint32 data_length, LLVMValueRef value,
|
||||||
LLVMTypeRef value_ptr_type, bool enable_segue)
|
LLVMTypeRef value_ptr_type, bool enable_segue)
|
||||||
{
|
{
|
||||||
LLVMValueRef maddr, result;
|
LLVMValueRef maddr, result;
|
||||||
|
|
|
@ -5644,8 +5644,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* allowing the destination and source to overlap */
|
/* allowing the destination and source to overlap */
|
||||||
|
#if WASM_ENABLE_MEMORY64 == 0
|
||||||
bh_memmove_s(mdst, (uint32)(linear_mem_size - dst),
|
bh_memmove_s(mdst, (uint32)(linear_mem_size - dst),
|
||||||
msrc, len);
|
msrc, (uint32)len);
|
||||||
|
#else
|
||||||
|
/* use memmove when memory64 is enabled since len
|
||||||
|
may be larger than UINT32_MAX */
|
||||||
|
memmove(mdst, msrc, len);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WASM_OP_MEMORY_FILL:
|
case WASM_OP_MEMORY_FILL:
|
||||||
|
|
|
@ -1608,7 +1608,7 @@ execute_malloc_function(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
|
||||||
if (ret) {
|
if (ret) {
|
||||||
#if WASM_ENABLE_MEMORY64 != 0
|
#if WASM_ENABLE_MEMORY64 != 0
|
||||||
if (is_memory64)
|
if (is_memory64)
|
||||||
*p_result = GET_I64_FROM_ADDR(&argv.u64);
|
*p_result = argv.u64;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -2184,8 +2184,8 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
|
||||||
heap_size = APP_HEAP_SIZE_MAX;
|
heap_size = APP_HEAP_SIZE_MAX;
|
||||||
|
|
||||||
module_inst_mem_inst_size =
|
module_inst_mem_inst_size =
|
||||||
(uint64)sizeof(WASMMemoryInstance)
|
sizeof(WASMMemoryInstance)
|
||||||
* (module->import_memory_count + module->memory_count);
|
* ((uint64)module->import_memory_count + module->memory_count);
|
||||||
|
|
||||||
#if WASM_ENABLE_JIT != 0
|
#if WASM_ENABLE_JIT != 0
|
||||||
/* If the module doesn't have memory, reserve one mem_info space
|
/* If the module doesn't have memory, reserve one mem_info space
|
||||||
|
@ -2615,7 +2615,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
|
||||||
|
|
||||||
if (memory_data) {
|
if (memory_data) {
|
||||||
bh_memcpy_s(memory_data + base_offset,
|
bh_memcpy_s(memory_data + base_offset,
|
||||||
(uint32)memory_size - base_offset, data_seg->data,
|
(uint32)(memory_size - base_offset), data_seg->data,
|
||||||
length);
|
length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user