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:
@ -38,8 +38,8 @@ typedef struct WASMExecEnv {
|
||||
/* Next thread's exec env of a WASM module instance. */
|
||||
struct WASMExecEnv *next;
|
||||
|
||||
/* Previous thread's exec env of a WASM module instance. */
|
||||
struct WASMExecEnv *prev;
|
||||
/* Current interpreter/AOT frame of current thread */
|
||||
struct WASMInterpFrame *cur_frame;
|
||||
|
||||
/* Note: field module_inst, argv_buf, native_stack_boundary,
|
||||
suspend_flags, aux_stack_boundary, aux_stack_bottom, and
|
||||
@ -84,6 +84,15 @@ typedef struct WASMExecEnv {
|
||||
*/
|
||||
uint8 *native_stack_top_min;
|
||||
|
||||
struct {
|
||||
/* The top boundary of the stack. */
|
||||
uint8 *top_boundary;
|
||||
/* The top to of the wasm stack which is free. */
|
||||
uint8 *top;
|
||||
/* The bottom of the wasm stack. */
|
||||
uint8 *bottom;
|
||||
} wasm_stack;
|
||||
|
||||
#if WASM_ENABLE_FAST_JIT != 0
|
||||
/**
|
||||
* Cache for
|
||||
@ -116,6 +125,11 @@ typedef struct WASMExecEnv {
|
||||
bool thread_is_detached;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_GC != 0
|
||||
/* Current local object reference variable */
|
||||
struct WASMLocalObjectRef *cur_local_object_ref;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
WASMCurrentEnvStatus *current_status;
|
||||
#endif
|
||||
@ -125,9 +139,6 @@ typedef struct WASMExecEnv {
|
||||
|
||||
void *user_data;
|
||||
|
||||
/* Current interpreter frame of current thread */
|
||||
struct WASMInterpFrame *cur_frame;
|
||||
|
||||
/* The native thread handle of current thread */
|
||||
korp_tid handle;
|
||||
|
||||
@ -151,18 +162,9 @@ typedef struct WASMExecEnv {
|
||||
/* The WASM stack of current thread */
|
||||
union {
|
||||
uint64 __make_it_8_byte_aligned_;
|
||||
|
||||
struct {
|
||||
/* The top boundary of the stack. */
|
||||
uint8 *top_boundary;
|
||||
|
||||
/* Top cell index which is free. */
|
||||
uint8 *top;
|
||||
|
||||
/* The WASM stack. */
|
||||
uint8 bottom[1];
|
||||
} s;
|
||||
} wasm_stack;
|
||||
/* The WASM stack. */
|
||||
uint8 bottom[1];
|
||||
} wasm_stack_u;
|
||||
} WASMExecEnv;
|
||||
|
||||
#if WASM_ENABLE_MEMORY_PROFILING != 0
|
||||
@ -209,7 +211,7 @@ wasm_exec_env_is_aux_stack_managed_by_runtime(WASMExecEnv *exec_env)
|
||||
static inline void *
|
||||
wasm_exec_env_alloc_wasm_frame(WASMExecEnv *exec_env, unsigned size)
|
||||
{
|
||||
uint8 *addr = exec_env->wasm_stack.s.top;
|
||||
uint8 *addr = exec_env->wasm_stack.top;
|
||||
|
||||
bh_assert(!(size & 3));
|
||||
|
||||
@ -220,17 +222,17 @@ wasm_exec_env_alloc_wasm_frame(WASMExecEnv *exec_env, unsigned size)
|
||||
frame size, we should check again before putting the function arguments
|
||||
into the outs area. */
|
||||
if (size * 2
|
||||
> (uint32)(uintptr_t)(exec_env->wasm_stack.s.top_boundary - addr)) {
|
||||
> (uint32)(uintptr_t)(exec_env->wasm_stack.top_boundary - addr)) {
|
||||
/* WASM stack overflow. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
exec_env->wasm_stack.s.top += size;
|
||||
exec_env->wasm_stack.top += size;
|
||||
|
||||
#if WASM_ENABLE_MEMORY_PROFILING != 0
|
||||
{
|
||||
uint32 wasm_stack_used =
|
||||
exec_env->wasm_stack.s.top - exec_env->wasm_stack.s.bottom;
|
||||
exec_env->wasm_stack.top - exec_env->wasm_stack.bottom;
|
||||
if (wasm_stack_used > exec_env->max_wasm_stack_used)
|
||||
exec_env->max_wasm_stack_used = wasm_stack_used;
|
||||
}
|
||||
@ -241,8 +243,8 @@ wasm_exec_env_alloc_wasm_frame(WASMExecEnv *exec_env, unsigned size)
|
||||
static inline void
|
||||
wasm_exec_env_free_wasm_frame(WASMExecEnv *exec_env, void *prev_top)
|
||||
{
|
||||
bh_assert((uint8 *)prev_top >= exec_env->wasm_stack.s.bottom);
|
||||
exec_env->wasm_stack.s.top = (uint8 *)prev_top;
|
||||
bh_assert((uint8 *)prev_top >= exec_env->wasm_stack.bottom);
|
||||
exec_env->wasm_stack.top = (uint8 *)prev_top;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,7 +257,7 @@ wasm_exec_env_free_wasm_frame(WASMExecEnv *exec_env, void *prev_top)
|
||||
static inline void *
|
||||
wasm_exec_env_wasm_stack_top(WASMExecEnv *exec_env)
|
||||
{
|
||||
return exec_env->wasm_stack.s.top;
|
||||
return exec_env->wasm_stack.top;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user