Implement GC (Garbage Collection) feature for interpreter, AOT and LLVM-JIT (#3125)
Implement the GC (Garbage Collection) feature for interpreter mode, AOT mode and LLVM-JIT mode, and support most features of the latest spec proposal, and also enable the stringref feature. Use `cmake -DWAMR_BUILD_GC=1/0` to enable/disable the feature, and `wamrc --enable-gc` to generate the AOT file with GC supported. And update the AOT file version from 2 to 3 since there are many AOT ABI breaks, including the changes of AOT file format, the changes of AOT module/memory instance layouts, the AOT runtime APIs for the AOT code to invoke and so on.
This commit is contained in:
@ -16,6 +16,10 @@ if (NOT DEFINED WAMR_BUILD_TARGET)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
# Build as X86_64 by default in 64-bit platform
|
||||
set (WAMR_BUILD_TARGET "X86_64")
|
||||
if (NOT DEFINED WAMR_BUILD_SIMD)
|
||||
# Enable SIMD by default in 64-bit platform
|
||||
set (WAMR_BUILD_SIMD 1)
|
||||
endif ()
|
||||
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
# Build as X86_32 by default in 32-bit platform
|
||||
set (WAMR_BUILD_TARGET "X86_32")
|
||||
|
||||
@ -24,11 +24,17 @@ set (CMAKE_CXX_STANDARD 17)
|
||||
if (NOT DEFINED WAMR_BUILD_TARGET)
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
|
||||
set (WAMR_BUILD_TARGET "AARCH64")
|
||||
if (NOT DEFINED WAMR_BUILD_SIMD)
|
||||
set (WAMR_BUILD_SIMD 1)
|
||||
endif ()
|
||||
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")
|
||||
if (NOT DEFINED WAMR_BUILD_SIMD)
|
||||
set (WAMR_BUILD_SIMD 1)
|
||||
endif ()
|
||||
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
# Build as X86_32 by default in 32-bit platform
|
||||
set (WAMR_BUILD_TARGET "X86_32")
|
||||
@ -91,7 +97,6 @@ if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS)
|
||||
set (WAMR_BUILD_LIB_WASI_THREADS 0)
|
||||
endif()
|
||||
|
||||
|
||||
if (NOT DEFINED WAMR_BUILD_MINI_LOADER)
|
||||
# Disable wasm mini loader by default
|
||||
set (WAMR_BUILD_MINI_LOADER 0)
|
||||
|
||||
@ -215,12 +215,25 @@ else
|
||||
CFLAGS += -DWASM_ENABLE_BULK_MEMORY=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_AOT_STACK_FRAME), y)
|
||||
CFLAGS += -DWASM_ENABLE_AOT_STACK_FRAME=1
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_AOT_STACK_FRAME=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_PERF_PROFILING),y)
|
||||
CFLAGS += -DWASM_ENABLE_PERF_PROFILING=1
|
||||
CFLAGS += -DWASM_ENABLE_AOT_STACK_FRAME=1
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_PERF_PROFILING=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_GC_PERF_PROFILING),y)
|
||||
CFLAGS += -DWASM_ENABLE_GC_PERF_PROFILING=1
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_GC_PERF_PROFILING=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_MEMORY_PROFILING),y)
|
||||
CFLAGS += -DWASM_ENABLE_MEMORY_PROFILING=1
|
||||
else
|
||||
@ -235,6 +248,7 @@ endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_DUMP_CALL_STACK),y)
|
||||
CFLAGS += -DWASM_ENABLE_DUMP_CALL_STACK=1
|
||||
CFLAGS += -DWASM_ENABLE_AOT_STACK_FRAME=1
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_DUMP_CALL_STACK=0
|
||||
endif
|
||||
@ -304,6 +318,20 @@ else
|
||||
CFLAGS += -DWASM_ENABLE_LIB_WASI_THREADS=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_GC),y)
|
||||
CFLAGS += -DWASM_ENABLE_GC=1
|
||||
CSRCS += gc_common.c gc_type.c gc_object.c
|
||||
VPATH += $(IWASM_ROOT)/common/gc
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_GC=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_GC_MANUALLY),y)
|
||||
CFLAGS += -DWASM_GC_MANUALLY=1
|
||||
else
|
||||
CFLAGS += -DWASM_GC_MANUALLY=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_LIB_PTHREAD),y)
|
||||
CFLAGS += -DWASM_ENABLE_LIB_PTHREAD=1
|
||||
CSRCS += lib_pthread_wrapper.c
|
||||
@ -359,6 +387,12 @@ else
|
||||
CFLAGS += -DWASM_ENABLE_REF_TYPES=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_TAIL_CALL),y)
|
||||
CFLAGS += -DWASM_ENABLE_TAIL_CALL=1
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_TAIL_CALL=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_ENABLE_EXCE_HANDLING),y)
|
||||
CFLAGS += -DWASM_ENABLE_EXCE_HANDLING=1
|
||||
CFLAGS += -DWASM_ENABLE_TAGS=1
|
||||
@ -396,6 +430,7 @@ CSRCS += nuttx_platform.c \
|
||||
ems_kfc.c \
|
||||
ems_alloc.c \
|
||||
ems_hmu.c \
|
||||
ems_gc.c \
|
||||
bh_assert.c \
|
||||
bh_bitmap.c \
|
||||
bh_common.c \
|
||||
|
||||
@ -55,6 +55,10 @@ print_help()
|
||||
printf(" --jit-codecache-size=n Set fast jit maximum code cache size in bytes,\n");
|
||||
printf(" default is %u KB\n", FAST_JIT_DEFAULT_CODE_CACHE_SIZE / 1024);
|
||||
#endif
|
||||
#if WASM_ENABLE_GC != 0
|
||||
printf(" --gc-heap-size=n Set maximum gc heap size in bytes,\n");
|
||||
printf(" default is %u KB\n", GC_HEAP_SIZE_DEFAULT / 1024);
|
||||
#endif
|
||||
#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");
|
||||
@ -559,6 +563,9 @@ main(int argc, char *argv[])
|
||||
#if WASM_ENABLE_FAST_JIT != 0
|
||||
uint32 jit_code_cache_size = FAST_JIT_DEFAULT_CODE_CACHE_SIZE;
|
||||
#endif
|
||||
#if WASM_ENABLE_GC != 0
|
||||
uint32 gc_heap_size = GC_HEAP_SIZE_DEFAULT;
|
||||
#endif
|
||||
#if WASM_ENABLE_JIT != 0
|
||||
uint32 llvm_jit_size_level = 3;
|
||||
uint32 llvm_jit_opt_level = 3;
|
||||
@ -666,6 +673,13 @@ main(int argc, char *argv[])
|
||||
jit_code_cache_size = atoi(argv[0] + 21);
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_GC != 0
|
||||
else if (!strncmp(argv[0], "--gc-heap-size=", 15)) {
|
||||
if (argv[0][21] == '\0')
|
||||
return print_help();
|
||||
gc_heap_size = atoi(argv[0] + 15);
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_JIT != 0
|
||||
else if (!strncmp(argv[0], "--llvm-jit-size-level=", 22)) {
|
||||
if (argv[0][22] == '\0')
|
||||
@ -821,6 +835,10 @@ main(int argc, char *argv[])
|
||||
init_args.fast_jit_code_cache_size = jit_code_cache_size;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_GC != 0
|
||||
init_args.gc_heap_size = gc_heap_size;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_JIT != 0
|
||||
init_args.llvm_jit_size_level = llvm_jit_size_level;
|
||||
init_args.llvm_jit_opt_level = llvm_jit_opt_level;
|
||||
|
||||
Reference in New Issue
Block a user