Skip to content

Commit

Permalink
implement atomic opcode in AOT/JIT (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
xujuntwt95329 authored Aug 3, 2020
1 parent cc05f8f commit 29e45e1
Show file tree
Hide file tree
Showing 20 changed files with 1,446 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.vscode
**/*build/
core/deps/lv_drivers
core/deps/llvm
core/deps/lvgl
core/deps/tlsf
core/deps/**
core/shared/mem-alloc/tlsf
core/app-framework/wgl

Expand Down
40 changes: 17 additions & 23 deletions core/iwasm/aot/aot_reloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,22 @@ typedef struct {
#define REG_SYM(symbol) { #symbol, (void*)symbol }

#if WASM_ENABLE_BULK_MEMORY != 0
#define REG_COMMON_SYMBOLS \
REG_SYM(aot_set_exception_with_id), \
REG_SYM(aot_invoke_native), \
REG_SYM(aot_call_indirect), \
REG_SYM(wasm_runtime_enlarge_memory), \
REG_SYM(wasm_runtime_set_exception), \
REG_SYM(fmin), \
REG_SYM(fminf), \
REG_SYM(fmax), \
REG_SYM(fmaxf), \
REG_SYM(ceil), \
REG_SYM(ceilf), \
REG_SYM(floor), \
REG_SYM(floorf), \
REG_SYM(trunc), \
REG_SYM(truncf), \
REG_SYM(rint), \
REG_SYM(rintf), \
REG_SYM(memset), \
REG_SYM(memmove), \
#define REG_BULK_MEMORY_SYM() \
REG_SYM(aot_memory_init), \
REG_SYM(aot_data_drop)
REG_SYM(aot_data_drop),
#else
#define REG_BULK_MEMORY_SYM()
#endif

#if WASM_ENABLE_SHARED_MEMORY != 0
#include "wasm_shared_memory.h"
#define REG_ATOMIC_WAIT_SYM() \
REG_SYM(wasm_runtime_atomic_wait), \
REG_SYM(wasm_runtime_atomic_notify),
#else
#define REG_ATOMIC_WAIT_SYM()
#endif

#define REG_COMMON_SYMBOLS \
REG_SYM(aot_set_exception_with_id), \
REG_SYM(aot_invoke_native), \
Expand All @@ -53,8 +46,9 @@ typedef struct {
REG_SYM(trunc), \
REG_SYM(truncf), \
REG_SYM(rint), \
REG_SYM(rintf)
#endif
REG_SYM(rintf), \
REG_BULK_MEMORY_SYM() \
REG_ATOMIC_WAIT_SYM()

#define CHECK_RELOC_OFFSET(data_size) do { \
if (!check_reloc_offset(target_section_size, reloc_offset, data_size, \
Expand Down
3 changes: 3 additions & 0 deletions core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,9 @@ aot_set_exception_with_id(AOTModuleInstance *module_inst,
case EXCE_NATIVE_STACK_OVERFLOW:
aot_set_exception(module_inst, "native stack overflow");
break;
case EXCE_UNALIGNED_ATOMIC:
aot_set_exception(module_inst, "unaligned atomic");
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions core/iwasm/aot/aot_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef enum AOTExceptionID {
EXCE_UNINITIALIZED_ELEMENT,
EXCE_CALL_UNLINKED_IMPORT_FUNC,
EXCE_NATIVE_STACK_OVERFLOW,
EXCE_UNALIGNED_ATOMIC,
EXCE_NUM,
} AOTExceptionID;

Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/aot/arch/aot_reloc_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void __aeabi_f2iz();
void __aeabi_f2d();

static SymbolMap target_sym_map[] = {
REG_COMMON_SYMBOLS,
REG_COMMON_SYMBOLS
/* compiler-rt symbols that come from compiler(e.g. gcc) */
REG_SYM(__divdi3),
REG_SYM(__udivdi3),
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/aot/arch/aot_reloc_thumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void __aeabi_f2iz();
void __aeabi_f2d();

static SymbolMap target_sym_map[] = {
REG_COMMON_SYMBOLS,
REG_COMMON_SYMBOLS
/* compiler-rt symbols that come from compiler(e.g. gcc) */
REG_SYM(__divdi3),
REG_SYM(__udivdi3),
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/aot/arch/aot_reloc_x86_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void __moddi3();
void __umoddi3();

static SymbolMap target_sym_map[] = {
REG_COMMON_SYMBOLS,
REG_COMMON_SYMBOLS
/* compiler-rt symbols that come from compiler(e.g. gcc) */
REG_SYM(__divdi3),
REG_SYM(__udivdi3),
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/aot/arch/aot_reloc_xtensa.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void __modsi3();
void __divdi3();

static SymbolMap target_sym_map[] = {
REG_COMMON_SYMBOLS,
REG_COMMON_SYMBOLS

/* API's for soft-float */
/* TODO: only register these symbols when Floating-Point Coprocessor
Expand Down
5 changes: 5 additions & 0 deletions core/iwasm/common/wasm_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
#include "wasm_runtime_common.h"
#include "bh_log.h"

#if !defined(BH_PLATFORM_ZEPHYR) && !defined(BH_PLATFORM_ALIOS_THINGS)
#define ENABLE_QUICKSORT 1
#else
#define ENABLE_QUICKSORT 0
#endif

#define ENABLE_SORT_DEBUG 0

#if ENABLE_SORT_DEBUG != 0
Expand Down
Loading

0 comments on commit 29e45e1

Please sign in to comment.