Explorar o código

Remove JIT_STACK_FRAME macro (#3127)

Remove `JIT_STACK_FRAME` cmake variable and compilation macro, and
use `AOT_STACK_FRAME` instead, to avoid introducing too many macros.

Same as using `WASM_ENABLE_QUICK_AOT_ENTRY` macro to control code
for LLVM JIT.
Wenyong Huang hai 1 ano
pai
achega
51eaf809ac

+ 1 - 8
build-scripts/config_common.cmake

@@ -304,10 +304,6 @@ if (WAMR_BUILD_AOT_STACK_FRAME EQUAL 1)
   add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
   message ("     AOT stack frame enabled")
 endif ()
-if (WAMR_BUILD_JIT_STACK_FRAME EQUAL 1)
-  add_definitions (-DWASM_ENABLE_JIT_STACK_FRAME=1)
-  message ("     JIT stack frame enabled")
-endif ()
 if (WAMR_BUILD_MEMORY_PROFILING EQUAL 1)
   add_definitions (-DWASM_ENABLE_MEMORY_PROFILING=1)
   message ("     Memory profiling enabled")
@@ -362,12 +358,9 @@ if (WAMR_BUILD_PERF_PROFILING EQUAL 1 OR
     WAMR_BUILD_GC EQUAL 1)
   # Enable AOT/JIT stack frame when perf-profiling, dump-call-stack
   # or GC is enabled
-  if (WAMR_BUILD_AOT EQUAL 1)
+  if (WAMR_BUILD_AOT EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
     add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
   endif ()
-  if (WAMR_BUILD_JIT EQUAL 1)
-    add_definitions (-DWASM_ENABLE_JIT_STACK_FRAME=1)
-  endif ()
 endif ()
 if (WAMR_BUILD_EXCE_HANDLING EQUAL 1)
   add_definitions (-DWASM_ENABLE_EXCE_HANDLING=1)

+ 0 - 5
core/config.h

@@ -335,11 +335,6 @@
 #define WASM_ENABLE_AOT_STACK_FRAME 0
 #endif
 
-/* JIT stack frame */
-#ifndef WASM_ENABLE_JIT_STACK_FRAME
-#define WASM_ENABLE_JIT_STACK_FRAME 0
-#endif
-
 /* Heap verification */
 #ifndef BH_ENABLE_GC_VERIFY
 #define BH_ENABLE_GC_VERIFY 0

+ 9 - 10
core/iwasm/compilation/aot_emit_function.c

@@ -499,7 +499,7 @@ fail:
     return false;
 }
 
-#if WASM_ENABLE_AOT_STACK_FRAME != 0 || WASM_ENABLE_JIT_STACK_FRAME != 0
+#if WASM_ENABLE_AOT_STACK_FRAME != 0
 static bool
 call_aot_alloc_frame_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
                           LLVMValueRef func_idx)
@@ -514,7 +514,7 @@ call_aot_alloc_frame_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
     param_types[1] = I32_TYPE;
     ret_type = INT8_TYPE;
 
-#if WASM_ENABLE_JIT_STACK_FRAME != 0
+#if WASM_ENABLE_JIT != 0
     if (comp_ctx->is_jit_mode)
         GET_AOT_FUNCTION(llvm_jit_alloc_frame, 2);
     else
@@ -1148,8 +1148,7 @@ free_frame_for_aot_func(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
 
     return true;
 }
-#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 || \
-          WASM_ENABLE_JIT_STACK_FRAME != 0 */
+#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
 
 /**
  * Check whether the app address and its buffer are inside the linear memory,
@@ -1444,7 +1443,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
     }
 
     if (comp_ctx->enable_aux_stack_frame) {
-#if WASM_ENABLE_AOT_STACK_FRAME != 0 || WASM_ENABLE_JIT_STACK_FRAME != 0
+#if WASM_ENABLE_AOT_STACK_FRAME != 0
         if (!alloc_frame_for_aot_func(comp_ctx, func_ctx, func_idx))
             return false;
 #endif
@@ -1796,7 +1795,7 @@ aot_compile_op_call(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
     }
 
     if (comp_ctx->enable_aux_stack_frame) {
-#if WASM_ENABLE_AOT_STACK_FRAME != 0 || WASM_ENABLE_JIT_STACK_FRAME != 0
+#if WASM_ENABLE_AOT_STACK_FRAME != 0
         if (!free_frame_for_aot_func(comp_ctx, func_ctx))
             goto fail;
 #endif
@@ -2356,7 +2355,7 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
     }
 
     if (comp_ctx->enable_aux_stack_frame) {
-#if WASM_ENABLE_AOT_STACK_FRAME != 0 || WASM_ENABLE_JIT_STACK_FRAME != 0
+#if WASM_ENABLE_AOT_STACK_FRAME != 0
         /*  TODO: use current frame instead of allocating new frame
                   for WASM_OP_RETURN_CALL_INDIRECT */
         if (!call_aot_alloc_frame_func(comp_ctx, func_ctx, func_idx))
@@ -2546,7 +2545,7 @@ aot_compile_op_call_indirect(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
     }
 
     if (comp_ctx->enable_aux_stack_frame) {
-#if WASM_ENABLE_AOT_STACK_FRAME != 0 || WASM_ENABLE_JIT_STACK_FRAME != 0
+#if WASM_ENABLE_AOT_STACK_FRAME != 0
         if (!free_frame_for_aot_func(comp_ctx, func_ctx))
             goto fail;
 #endif
@@ -2853,7 +2852,7 @@ aot_compile_op_call_ref(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
     }
 
     if (comp_ctx->enable_aux_stack_frame) {
-#if WASM_ENABLE_AOT_STACK_FRAME != 0 || WASM_ENABLE_JIT_STACK_FRAME != 0
+#if WASM_ENABLE_AOT_STACK_FRAME != 0
         /*  TODO: use current frame instead of allocating new frame
                   for WASM_OP_RETURN_CALL_REF */
         if (!call_aot_alloc_frame_func(comp_ctx, func_ctx, func_idx))
@@ -3050,7 +3049,7 @@ aot_compile_op_call_ref(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
     }
 
     if (comp_ctx->enable_aux_stack_frame) {
-#if WASM_ENABLE_AOT_STACK_FRAME != 0 || WASM_ENABLE_JIT_STACK_FRAME != 0
+#if WASM_ENABLE_AOT_STACK_FRAME != 0
         if (!free_frame_for_aot_func(comp_ctx, func_ctx))
             goto fail;
 #endif

+ 4 - 4
core/iwasm/interpreter/wasm_interp_classic.c

@@ -6546,7 +6546,7 @@ fast_jit_call_func_bytecode(WASMModuleInstance *module_inst,
 
 #if WASM_ENABLE_JIT != 0
 #if WASM_ENABLE_DUMP_CALL_STACK != 0 || WASM_ENABLE_PERF_PROFILING != 0 \
-    || WASM_ENABLE_JIT_STACK_FRAME != 0
+    || WASM_ENABLE_AOT_STACK_FRAME != 0
 #if WASM_ENABLE_GC == 0
 bool
 llvm_jit_alloc_frame(WASMExecEnv *exec_env, uint32 func_index)
@@ -6783,7 +6783,7 @@ llvm_jit_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
 }
 #endif /* end of WASM_ENABLE_DUMP_CALL_STACK != 0 \
           || WASM_ENABLE_PERF_PROFILING != 0      \
-          || WASM_ENABLE_JIT_STACK_FRAME != 0 */
+          || WASM_ENABLE_AOT_STACK_FRAME != 0 */
 
 static bool
 llvm_jit_call_func_bytecode(WASMModuleInstance *module_inst,
@@ -6798,7 +6798,7 @@ llvm_jit_call_func_bytecode(WASMModuleInstance *module_inst,
     bool ret = false;
 
 #if (WASM_ENABLE_DUMP_CALL_STACK != 0) || (WASM_ENABLE_PERF_PROFILING != 0) \
-    || (WASM_ENABLE_JIT_STACK_FRAME != 0)
+    || (WASM_ENABLE_AOT_STACK_FRAME != 0)
     if (!llvm_jit_alloc_frame(exec_env, function - module_inst->e->functions)) {
         /* wasm operand stack overflow has been thrown,
            no need to throw again */
@@ -6911,7 +6911,7 @@ llvm_jit_call_func_bytecode(WASMModuleInstance *module_inst,
 fail:
 
 #if (WASM_ENABLE_DUMP_CALL_STACK != 0) || (WASM_ENABLE_PERF_PROFILING != 0) \
-    || (WASM_ENABLE_JIT_STACK_FRAME != 0)
+    || (WASM_ENABLE_AOT_STACK_FRAME != 0)
     llvm_jit_free_frame_internal(exec_env);
 #endif
 

+ 1 - 1
core/iwasm/interpreter/wasm_loader.c

@@ -5234,7 +5234,7 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf,
 #endif
     option.enable_aux_stack_check = true;
 #if WASM_ENABLE_PERF_PROFILING != 0 || WASM_ENABLE_DUMP_CALL_STACK != 0 \
-    || WASM_ENABLE_JIT_STACK_FRAME != 0
+    || WASM_ENABLE_AOT_STACK_FRAME != 0
     option.enable_aux_stack_frame = true;
 #endif
 #if WASM_ENABLE_PERF_PROFILING != 0

+ 1 - 1
core/iwasm/interpreter/wasm_mini_loader.c

@@ -2143,7 +2143,7 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf,
 #endif
     option.enable_aux_stack_check = true;
 #if WASM_ENABLE_PERF_PROFILING != 0 || WASM_ENABLE_DUMP_CALL_STACK != 0 \
-    || WASM_ENABLE_JIT_STACK_FRAME != 0
+    || WASM_ENABLE_AOT_STACK_FRAME != 0
     option.enable_aux_stack_frame = true;
 #endif
 #if WASM_ENABLE_PERF_PROFILING != 0

+ 1 - 1
core/iwasm/interpreter/wasm_runtime.h

@@ -783,7 +783,7 @@ llvm_jit_table_grow(WASMModuleInstance *module_inst, uint32 tbl_idx,
 #endif
 
 #if WASM_ENABLE_DUMP_CALL_STACK != 0 || WASM_ENABLE_PERF_PROFILING != 0 \
-    || WASM_ENABLE_JIT_STACK_FRAME != 0
+    || WASM_ENABLE_AOT_STACK_FRAME != 0
 bool
 llvm_jit_alloc_frame(WASMExecEnv *exec_env, uint32 func_index);
 

+ 1 - 5
doc/build_wamr.md

@@ -132,11 +132,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM
 
 #### **Enable AOT stack frame feature**
 - **WAMR_BUILD_AOT_STACK_FRAME**=1/0, default to disable if not set
-> Note: if it is enabled, the AOT stack frames (like stack frame of classic interpreter but only necessary data is committed) will be created for AOT mode in function calls. And please add `--enable-dump-call-stack` option to wamrc during compiling AOT module.
-
-#### **ENABLE JIT stack frame feature**
-- **WAMR_BUILD_JIT_STACK_FRAME**=1/0, default to disable if not set
-> Note: if it is enabled, the JIT stack frames (like stack frame of classic interpreter but only necessary data is committed) will be created for JIT mode in function calls.
+> Note: if it is enabled, the AOT or JIT stack frames (like stack frame of classic interpreter but only necessary data is committed) will be created for AOT or JIT mode in function calls. And please add `--enable-dump-call-stack` option to wamrc during compiling AOT module.
 
 #### **Enable dump call stack feature**
 - **WAMR_BUILD_DUMP_CALL_STACK**=1/0, default to disable if not set