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:
@ -7,6 +7,9 @@
|
||||
#define __MEM_ALLOC_H
|
||||
|
||||
#include "bh_platform.h"
|
||||
#if WASM_ENABLE_GC != 0
|
||||
#include "../../common/gc/gc_object.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -14,6 +17,8 @@ extern "C" {
|
||||
|
||||
typedef void *mem_allocator_t;
|
||||
|
||||
typedef void (*gc_finalizer_t)(void *obj, void *data);
|
||||
|
||||
mem_allocator_t
|
||||
mem_allocator_create(void *mem, uint32_t size);
|
||||
|
||||
@ -45,6 +50,39 @@ mem_allocator_migrate(mem_allocator_t allocator, char *pool_buf_new,
|
||||
bool
|
||||
mem_allocator_is_heap_corrupted(mem_allocator_t allocator);
|
||||
|
||||
#if WASM_ENABLE_GC != 0
|
||||
void *
|
||||
mem_allocator_malloc_with_gc(mem_allocator_t allocator, uint32_t size);
|
||||
|
||||
#if WASM_GC_MANUALLY != 0
|
||||
void
|
||||
mem_allocator_free_with_gc(mem_allocator_t allocator, void *ptr);
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_THREAD_MGR == 0
|
||||
void
|
||||
mem_allocator_enable_gc_reclaim(mem_allocator_t allocator, void *exec_env);
|
||||
#else
|
||||
void
|
||||
mem_allocator_enable_gc_reclaim(mem_allocator_t allocator, void *cluster);
|
||||
#endif
|
||||
|
||||
int
|
||||
mem_allocator_add_root(mem_allocator_t allocator, WASMObjectRef obj);
|
||||
|
||||
bool
|
||||
mem_allocator_set_gc_finalizer(mem_allocator_t allocator, void *obj,
|
||||
gc_finalizer_t cb, void *data);
|
||||
|
||||
void
|
||||
mem_allocator_unset_gc_finalizer(mem_allocator_t allocator, void *obj);
|
||||
|
||||
#if WASM_ENABLE_GC_PERF_PROFILING != 0
|
||||
void
|
||||
mem_allocator_dump_perf_profiling(mem_allocator_t allocator);
|
||||
#endif
|
||||
#endif /* end of WASM_ENABLE_GC != 0 */
|
||||
|
||||
bool
|
||||
mem_allocator_get_alloc_info(mem_allocator_t allocator, void *mem_alloc_info);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user