Skip to content
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
4 changes: 2 additions & 2 deletions core/iwasm/aot/arch/aot_reloc_aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ get_plt_table_size()
}

#define SIGN_EXTEND_TO_INT64(val, bits, val_ext) do { \
int64 m = ((int64)1 << (bits - 1)); \
val_ext = ((int64)val ^ m) - m; \
int64 m = (int64)((uint64)1 << (bits - 1)); \
val_ext = ((int64)val ^ m) - m; \
} while (0)

#define Page(expr) ((expr) & ~0xFFF)
Expand Down
14 changes: 7 additions & 7 deletions core/iwasm/common/wasm_c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,14 @@ wasm_store_delete(wasm_store_t *store)
for (i = 0; i != store_count; ++i) {
wasm_store_t *tmp;

if (!bh_vector_get((Vector *)singleton_engine->stores,
(uint32)i, &tmp)) {
if (!bh_vector_get((Vector *)singleton_engine->stores, (uint32)i,
&tmp)) {
break;
}

if (tmp == store) {
bh_vector_remove((Vector *)singleton_engine->stores,
(uint32)i, NULL);
bh_vector_remove((Vector *)singleton_engine->stores, (uint32)i,
NULL);
break;
}
}
Expand Down Expand Up @@ -1935,8 +1935,8 @@ wasm_module_validate(wasm_store_t *store, const wasm_byte_vec_t *binary)
return false;
}

if ((module_rt = wasm_runtime_load((uint8 *)binary->data, (uint32)binary->size,
error_buf, 128))) {
if ((module_rt = wasm_runtime_load(
(uint8 *)binary->data, (uint32)binary->size, error_buf, 128))) {
wasm_runtime_unload(module_rt);
return true;
}
Expand Down Expand Up @@ -3415,7 +3415,7 @@ wasm_table_get(const wasm_table_t *table, wasm_table_size_t index)
if (table->inst_comm_rt->module_type == Wasm_Module_AoT) {
AOTModuleInstance *inst_aot = (AOTModuleInstance *)table->inst_comm_rt;
AOTTableInstance *table_aot =
(AOTTableInstance*)inst_aot->tables.ptr + table->table_idx_rt;
(AOTTableInstance *)inst_aot->tables.ptr + table->table_idx_rt;
if (index >= table_aot->cur_size) {
return NULL;
}
Expand Down
4 changes: 3 additions & 1 deletion core/iwasm/common/wasm_c_api_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct wasm_memorytype_t {

struct wasm_externtype_t {
uint32 extern_kind;
/* reservered space */
uint8 data[1];
};

Expand Down Expand Up @@ -199,7 +200,8 @@ struct wasm_extern_t {
wasm_name_t *module_name;
wasm_name_t *name;
wasm_externkind_t kind;
uint8 data[4];
/* reservered space */
uint8 data[1];
};

struct wasm_instance_t {
Expand Down
10 changes: 5 additions & 5 deletions core/iwasm/compilation/aot.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,11 @@ aot_create_comp_data(WASMModule *module)
}
else {
j = i - module->import_table_count;
comp_data->tables[i].elem_type = module->tables[i].elem_type;
comp_data->tables[i].table_flags = module->tables[i].flags;
comp_data->tables[i].table_init_size = module->tables[i].init_size;
comp_data->tables[i].table_max_size = module->tables[i].max_size;
comp_data->tables[i].possible_grow = module->tables[i].possible_grow;
comp_data->tables[i].elem_type = module->tables[j].elem_type;
comp_data->tables[i].table_flags = module->tables[j].flags;
comp_data->tables[i].table_init_size = module->tables[j].init_size;
comp_data->tables[i].table_max_size = module->tables[j].max_size;
comp_data->tables[i].possible_grow = module->tables[j].possible_grow;
}
}
}
Expand Down
48 changes: 12 additions & 36 deletions core/iwasm/interpreter/wasm_interp_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ typedef float64 CellType_F64;
goto out_of_bounds; \
} while (0)

#define CHECK_ATOMIC_MEMORY_ACCESS() do { \
if (((uintptr_t)maddr & ((1 << align) - 1)) != 0) \
goto unaligned_atomic; \
#define CHECK_ATOMIC_MEMORY_ACCESS() do { \
if (((uintptr_t)maddr & (((uintptr_t)1 << align) - 1)) != 0)\
goto unaligned_atomic; \
} while (0)

static inline uint32
Expand Down Expand Up @@ -189,7 +189,7 @@ read_leb(const uint8 *buf, uint32 *p_offset, uint32 maxbits, bool sign)
}
if (sign && (shift < maxbits) && (byte & 0x40)) {
/* Sign extend */
result |= - ((uint64)1 << shift);
result |= (~((uint64)0)) << shift;
}
*p_offset = offset;
return result;
Expand Down Expand Up @@ -2060,31 +2060,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP (WASM_OP_I32_SHL):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC(uint32, uint32, I32, <<);
#else
DEF_OP_NUMERIC2(uint32, uint32, I32, <<);
#endif
HANDLE_OP_END ();
}

HANDLE_OP (WASM_OP_I32_SHR_S):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC(int32, uint32, I32, >>);
#else
DEF_OP_NUMERIC2(int32, uint32, I32, >>);
#endif
HANDLE_OP_END ();
}

HANDLE_OP (WASM_OP_I32_SHR_U):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC(uint32, uint32, I32, >>);
#else
DEF_OP_NUMERIC2(uint32, uint32, I32, >>);
#endif
HANDLE_OP_END ();
}

Expand Down Expand Up @@ -2211,31 +2199,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP (WASM_OP_I64_SHL):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC_64(uint64, uint64, I64, <<);
#else
DEF_OP_NUMERIC2_64(uint64, uint64, I64, <<);
#endif
HANDLE_OP_END ();
}

HANDLE_OP (WASM_OP_I64_SHR_S):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC_64(int64, uint64, I64, >>);
#else
DEF_OP_NUMERIC2_64(int64, uint64, I64, >>);
#endif
HANDLE_OP_END ();
}

HANDLE_OP (WASM_OP_I64_SHR_U):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC_64(uint64, uint64, I64, >>);
#else
DEF_OP_NUMERIC2_64(uint64, uint64, I64, >>);
#endif
HANDLE_OP_END ();
}

Expand Down Expand Up @@ -2266,12 +2242,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP (WASM_OP_F32_NEG):
{
int32 i32 = (int32)frame_sp[-1];
int32 sign_bit = i32 & (1 << 31);
uint32 u32 = frame_sp[-1];
uint32 sign_bit = u32 & ((uint32)1 << 31);
if (sign_bit)
frame_sp[-1] = i32 & ~(1 << 31);
frame_sp[-1] = u32 & ~((uint32)1 << 31);
else
frame_sp[-1] = (uint32)(i32 | (1 << 31));
frame_sp[-1] = u32 | ((uint32)1 << 31);
HANDLE_OP_END ();
}

Expand Down Expand Up @@ -2360,12 +2336,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP (WASM_OP_F64_NEG):
{
int64 i64 = GET_I64_FROM_ADDR(frame_sp - 2);
int64 sign_bit = i64 & (((int64)1) << 63);
uint64 u64 = GET_I64_FROM_ADDR(frame_sp - 2);
uint64 sign_bit = u64 & (((uint64)1) << 63);
if (sign_bit)
PUT_I64_TO_ADDR(frame_sp - 2, ((uint64)i64 & ~(((uint64)1) << 63)));
PUT_I64_TO_ADDR(frame_sp - 2, (u64 & ~(((uint64)1) << 63)));
else
PUT_I64_TO_ADDR(frame_sp - 2, ((uint64)i64 | (((uint64)1) << 63)));
PUT_I64_TO_ADDR(frame_sp - 2, (u64 | (((uint64)1) << 63)));
HANDLE_OP_END ();
}

Expand Down
40 changes: 8 additions & 32 deletions core/iwasm/interpreter/wasm_interp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,31 +1989,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP (WASM_OP_I32_SHL):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC(uint32, uint32, I32, <<);
#else
DEF_OP_NUMERIC2(uint32, uint32, I32, <<);
#endif
HANDLE_OP_END ();
}

HANDLE_OP (WASM_OP_I32_SHR_S):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC(int32, uint32, I32, >>);
#else
DEF_OP_NUMERIC2(int32, uint32, I32, >>);
#endif
HANDLE_OP_END ();
}

HANDLE_OP (WASM_OP_I32_SHR_U):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC(uint32, uint32, I32, >>);
#else
DEF_OP_NUMERIC2(uint32, uint32, I32, >>);
#endif
HANDLE_OP_END ();
}

Expand Down Expand Up @@ -2140,31 +2128,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP (WASM_OP_I64_SHL):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC_64(uint64, uint64, I64, <<);
#else
DEF_OP_NUMERIC2_64(uint64, uint64, I64, <<);
#endif
HANDLE_OP_END ();
}

HANDLE_OP (WASM_OP_I64_SHR_S):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC_64(int64, uint64, I64, >>);
#else
DEF_OP_NUMERIC2_64(int64, uint64, I64, >>);
#endif
HANDLE_OP_END ();
}

HANDLE_OP (WASM_OP_I64_SHR_U):
{
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_X86_32)
DEF_OP_NUMERIC_64(uint64, uint64, I64, >>);
#else
DEF_OP_NUMERIC2_64(uint64, uint64, I64, >>);
#endif
HANDLE_OP_END ();
}

Expand Down Expand Up @@ -2195,13 +2171,13 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP (WASM_OP_F32_NEG):
{
int32 i32 = (int32)frame_lp[GET_OFFSET()];
uint32 u32 = frame_lp[GET_OFFSET()];
uint32 sign_bit = u32 & ((uint32)1 << 31);
addr_ret = GET_OFFSET();
int32 sign_bit = i32 & (1 << 31);
if (sign_bit)
frame_lp[addr_ret] = i32 & ~(1 << 31);
frame_lp[addr_ret] = u32 & ~((uint32)1 << 31);
else
frame_lp[addr_ret] = (uint32)(i32 | (1 << 31));
frame_lp[addr_ret] = u32 | ((uint32)1 << 31);
HANDLE_OP_END ();
}

Expand Down Expand Up @@ -2290,14 +2266,14 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

HANDLE_OP (WASM_OP_F64_NEG):
{
int64 i64 = GET_I64_FROM_ADDR(frame_lp + GET_OFFSET());
int64 sign_bit = i64 & (((int64)1) << 63);
uint64 u64 = GET_I64_FROM_ADDR(frame_lp + GET_OFFSET());
uint64 sign_bit = u64 & (((uint64)1) << 63);
if (sign_bit)
PUT_I64_TO_ADDR(frame_lp + GET_OFFSET(),
((uint64)i64 & ~(((uint64)1) << 63)));
(u64 & ~(((uint64)1) << 63)));
else
PUT_I64_TO_ADDR(frame_lp + GET_OFFSET(),
((uint64)i64 | (((uint64)1) << 63)));
(u64 | (((uint64)1) << 63)));
HANDLE_OP_END ();
}

Expand Down
12 changes: 6 additions & 6 deletions core/iwasm/interpreter/wasm_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ read_leb(uint8 **p_buf, const uint8 *buf_end,
}
else if (sign && maxbits == 32) {
if (shift < maxbits) {
/* Sign extend */
result = (((int32)result) << (maxbits - shift))
>> (maxbits - shift);
/* Sign extend, second highest bit is the sign bit */
if ((uint8)byte & 0x40)
result |= (~((uint64)0)) << shift;
}
else {
/* The top bits should be a sign-extension of the sign bit */
Expand All @@ -136,9 +136,9 @@ read_leb(uint8 **p_buf, const uint8 *buf_end,
}
else if (sign && maxbits == 64) {
if (shift < maxbits) {
/* Sign extend */
result = (((int64)result) << (maxbits - shift))
>> (maxbits - shift);
/* Sign extend, second highest bit is the sign bit */
if ((uint8)byte & 0x40)
result |= (~((uint64)0)) << shift;
}
else {
/* The top bits should be a sign-extension of the sign bit */
Expand Down
12 changes: 6 additions & 6 deletions core/iwasm/interpreter/wasm_mini_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ read_leb(uint8 **p_buf, const uint8 *buf_end,
}
else if (sign && maxbits == 32) {
if (shift < maxbits) {
/* Sign extend */
result = (((int32)result) << (maxbits - shift))
>> (maxbits - shift);
/* Sign extend, second highest bit is the sign bit */
if ((uint8)byte & 0x40)
result |= (~((uint64)0)) << shift;
}
else {
/* The top bits should be a sign-extension of the sign bit */
Expand All @@ -105,9 +105,9 @@ read_leb(uint8 **p_buf, const uint8 *buf_end,
}
else if (sign && maxbits == 64) {
if (shift < maxbits) {
/* Sign extend */
result = (((int64)result) << (maxbits - shift))
>> (maxbits - shift);
/* Sign extend, second highest bit is the sign bit */
if ((uint8)byte & 0x40)
result |= (~((uint64)0)) << shift;
}
else {
/* The top bits should be a sign-extension of the sign bit */
Expand Down
14 changes: 7 additions & 7 deletions core/shared/mem-alloc/ems/ems_gc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ hmu_verify(void *vheap, hmu_t *hmu);
* hmu bit operation
*/

#define SETBIT(v, offset) (v) |= (1 << (offset))
#define GETBIT(v, offset) ((v) & (1 << (offset)) ? 1 : 0)
#define CLRBIT(v, offset) (v) &= (uint32)(~(1 << (offset)))
#define SETBIT(v, offset) (v) |= ((uint32)1 << (offset))
#define GETBIT(v, offset) ((v) & ((uint32)1 << (offset)) ? 1 : 0)
#define CLRBIT(v, offset) (v) &= (~((uint32)1 << (offset)))

#define SETBITS(v, offset, size, value) do { \
(v) &= (uint32)(~(((1 << size) - 1) << offset));\
(v) |= (uint32)(value << offset); \
(v) &= ~((((uint32)1 << size) - 1) << offset); \
(v) |= ((uint32)value << offset); \
} while(0)
#define CLRBITS(v, offset, size) (v) &= ~(((1 << size) - 1) << offset)
#define GETBITS(v, offset, size) (((v) & ((uint32)(((1 << size) - 1) << offset))) >> offset)
#define CLRBITS(v, offset, size) (v) &= ~((((uint32)1 << size) - 1) << offset)
#define GETBITS(v, offset, size) (((v) & (((((uint32)1 << size) - 1) << offset))) >> offset)

/**
* gc object layout definition
Expand Down
7 changes: 6 additions & 1 deletion product-mini/platforms/darwin/main.c
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
#include "../posix/main.c"
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/

#include "../posix/main.c"
Loading