فهرست منبع

add micro AMR_BUILD_LIME1 to enable minimal lime1 feature set (#4571)

Signed-off-by: zhenweijin <zhenwei.jin@intel.com>
Zhenwei Jin 4 ماه پیش
والد
کامیت
e6fe6060e4

+ 1 - 0
.github/workflows/compilation_on_android_ubuntu.yml

@@ -166,6 +166,7 @@ jobs:
             "-DWAMR_BUILD_MULTI_MEMORY=1",
             "-DWAMR_BUILD_MULTI_MEMORY=1",
             "-DWAMR_BUILD_SHARED=1",
             "-DWAMR_BUILD_SHARED=1",
             "-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
             "-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
+            "-DWAMR_BUILD_LIME1=1 -DWAMR_BUILD_BULK_MEMORY=0 -DWAMR_BUILD_REF_TYPES=0 -DWAMR_BUILD_SIMD=0",
           ]
           ]
         os: [ubuntu-22.04]
         os: [ubuntu-22.04]
         platform: [android, linux]
         platform: [android, linux]

+ 40 - 0
build-scripts/config_common.cmake

@@ -221,6 +221,14 @@ if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
   set (WAMR_BUILD_BULK_MEMORY 1)
   set (WAMR_BUILD_BULK_MEMORY 1)
 endif ()
 endif ()
 
 
+if (NOT DEFINED WAMR_BUILD_BULK_MEMORY_OPT)
+  set (WAMR_BUILD_BULK_MEMORY_OPT 0)
+endif ()
+
+if (NOT DEFINED WAMR_BUILD_CALL_INDIRECT_OVERLONG)
+  set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 0)
+endif ()
+
 if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
 if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
   set (WAMR_BUILD_EXCE_HANDLING 0)
   set (WAMR_BUILD_EXCE_HANDLING 0)
 endif ()
 endif ()
@@ -253,10 +261,27 @@ if (NOT DEFINED WAMR_BUILD_EXTENDED_CONST_EXPR)
   set (WAMR_BUILD_EXTENDED_CONST_EXPR 0)
   set (WAMR_BUILD_EXTENDED_CONST_EXPR 0)
 endif ()
 endif ()
 
 
+if (NOT DEFINED WAMR_BUILD_LIME1)
+  set (WAMR_BUILD_LIME1 0)
+endif ()
+
 ########################################
 ########################################
 # Compilation options to marco
 # Compilation options to marco
 ########################################
 ########################################
 
 
+if (WAMR_BUILD_LIME1 EQUAL 1)
+  set (WAMR_BUILD_BULK_MEMORY_OPT 1)
+  set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 1)
+  set (WAMR_BUILD_EXTENDED_CONST_EXPR 1)
+endif ()
+
+if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
+  set (WAMR_BUILD_BULK_MEMORY_OPT 1)
+endif ()
+if (WAMR_BUILD_REF_TYPES EQUAL 1)
+  set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 1)
+endif ()
+
 message ("-- Build Configurations:")
 message ("-- Build Configurations:")
 message ("     Build as target ${WAMR_BUILD_TARGET}")
 message ("     Build as target ${WAMR_BUILD_TARGET}")
 message ("     Build for platform ${WAMR_BUILD_PLATFORM}")
 message ("     Build for platform ${WAMR_BUILD_PLATFORM}")
@@ -366,6 +391,11 @@ if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
 else ()
 else ()
   add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
   add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
 endif ()
 endif ()
+if (WAMR_BUILD_BULK_MEMORY_OPT EQUAL 1)
+  add_definitions (-DWASM_ENABLE_BULK_MEMORY_OPT=1)
+else()
+  add_definitions (-DWASM_ENABLE_BULK_MEMORY_OPT=0)
+endif ()
 if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
 if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
   add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
   add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
   message ("     Shared memory enabled")
   message ("     Shared memory enabled")
@@ -457,6 +487,11 @@ endif ()
 if (WAMR_BUILD_REF_TYPES EQUAL 1)
 if (WAMR_BUILD_REF_TYPES EQUAL 1)
   add_definitions (-DWASM_ENABLE_REF_TYPES=1)
   add_definitions (-DWASM_ENABLE_REF_TYPES=1)
 endif ()
 endif ()
+if (WAMR_BUILD_CALL_INDIRECT_OVERLONG EQUAL 1)
+  add_definitions (-DWASM_ENABLE_CALL_INDIRECT_OVERLONG=1)
+else ()
+  add_definitions(-DWASM_ENABLE_CALL_INDIRECT_OVERLONG=0)
+endif ()
 if (WAMR_BUILD_GC EQUAL 1)
 if (WAMR_BUILD_GC EQUAL 1)
   if (WAMR_TEST_GC EQUAL 1)
   if (WAMR_TEST_GC EQUAL 1)
     message("      GC testing enabled")
     message("      GC testing enabled")
@@ -727,6 +762,9 @@ else()
   message ("     Extended constant expression disabled")
   message ("     Extended constant expression disabled")
   add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=0)
   add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=0)
 endif ()
 endif ()
+if (WAMR_BUILD_LIME1 EQUAL 1)
+  message ("     Lime1 enabled")
+endif ()
 ########################################
 ########################################
 # Show Phase4 Wasm proposals status.
 # Show Phase4 Wasm proposals status.
 ########################################
 ########################################
@@ -742,6 +780,8 @@ message (
 "       \"Branch Hinting\"\n"
 "       \"Branch Hinting\"\n"
 "     Configurable. 0 is OFF. 1 is ON:\n"
 "     Configurable. 0 is OFF. 1 is ON:\n"
 "       \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
 "       \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
+"       \"Bulk-memory-opt\" via WAMR_BUILD_BULK_MEMORY_OPT: ${WAMR_BUILD_BULK_MEMORY_OPT}\n"
+"       \"Call-indirect-overlong\" via WAMR_BUILD_CALL_INDIRECT_OVERLONG: ${WAMR_BUILD_CALL_INDIRECT_OVERLONG}\n"
 "       \"Extended Constant Expressions\" via WAMR_BUILD_EXTENDED_CONST_EXPR: ${WAMR_BUILD_EXTENDED_CONST_EXPR}\n"
 "       \"Extended Constant Expressions\" via WAMR_BUILD_EXTENDED_CONST_EXPR: ${WAMR_BUILD_EXTENDED_CONST_EXPR}\n"
 "       \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
 "       \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
 "       \"Garbage Collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
 "       \"Garbage Collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"

+ 8 - 0
core/config.h

@@ -214,6 +214,10 @@
 #define WASM_ENABLE_BULK_MEMORY 0
 #define WASM_ENABLE_BULK_MEMORY 0
 #endif
 #endif
 
 
+#ifndef WASM_ENABLE_BULK_MEMORY_OPT
+#define WASM_ENABLE_BULK_MEMORY_OPT 0
+#endif
+
 /* Shared memory */
 /* Shared memory */
 #ifndef WASM_ENABLE_SHARED_MEMORY
 #ifndef WASM_ENABLE_SHARED_MEMORY
 #define WASM_ENABLE_SHARED_MEMORY 0
 #define WASM_ENABLE_SHARED_MEMORY 0
@@ -579,6 +583,10 @@ unless used elsewhere */
 #define WASM_ENABLE_REF_TYPES 0
 #define WASM_ENABLE_REF_TYPES 0
 #endif
 #endif
 
 
+#ifndef WASM_ENABLE_CALL_INDIRECT_OVERLONG
+#define WASM_ENABLE_CALL_INDIRECT_OVERLONG 0
+#endif
+
 #ifndef WASM_ENABLE_BRANCH_HINTS
 #ifndef WASM_ENABLE_BRANCH_HINTS
 #define WASM_ENABLE_BRANCH_HINTS 0
 #define WASM_ENABLE_BRANCH_HINTS 0
 #endif
 #endif

+ 20 - 3
core/iwasm/compilation/aot_compiler.c

@@ -1236,8 +1236,8 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
                 uint32 tbl_idx;
                 uint32 tbl_idx;
 
 
                 read_leb_uint32(frame_ip, frame_ip_end, type_idx);
                 read_leb_uint32(frame_ip, frame_ip_end, type_idx);
-
-                if (comp_ctx->enable_gc || comp_ctx->enable_ref_types) {
+                if (comp_ctx->enable_gc
+                    || comp_ctx->enable_call_indirect_overlong) {
                     read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
                     read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
                 }
                 }
                 else {
                 else {
@@ -2462,6 +2462,14 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
                    UINT8_MAX */
                    UINT8_MAX */
                 opcode = (uint8)opcode1;
                 opcode = (uint8)opcode1;
 
 
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
+                if (WASM_OP_MEMORY_COPY <= opcode
+                    && opcode <= WASM_OP_MEMORY_FILL
+                    && !comp_ctx->enable_bulk_memory_opt) {
+                    goto unsupport_bulk_memory_opt;
+                }
+#endif
+
 #if WASM_ENABLE_BULK_MEMORY != 0
 #if WASM_ENABLE_BULK_MEMORY != 0
                 if (WASM_OP_MEMORY_INIT <= opcode
                 if (WASM_OP_MEMORY_INIT <= opcode
                     && opcode <= WASM_OP_MEMORY_FILL
                     && opcode <= WASM_OP_MEMORY_FILL
@@ -2530,6 +2538,8 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
                             return false;
                             return false;
                         break;
                         break;
                     }
                     }
+#endif /* WASM_ENABLE_BULK_MEMORY */
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
                     case WASM_OP_MEMORY_COPY:
                     case WASM_OP_MEMORY_COPY:
                     {
                     {
                         frame_ip += 2;
                         frame_ip += 2;
@@ -2544,7 +2554,7 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
                             return false;
                             return false;
                         break;
                         break;
                     }
                     }
-#endif /* WASM_ENABLE_BULK_MEMORY */
+#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_INIT:
                     {
                     {
@@ -3971,6 +3981,13 @@ unsupport_gc_and_ref_types:
     return false;
     return false;
 #endif
 #endif
 
 
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
+unsupport_bulk_memory_opt:
+    aot_set_last_error("bulk memory opt instruction was found, "
+                       "try enabling bulk-memory-opt or bulk-memory option");
+    return false;
+#endif
+
 #if WASM_ENABLE_BULK_MEMORY != 0
 #if WASM_ENABLE_BULK_MEMORY != 0
 unsupport_bulk_memory:
 unsupport_bulk_memory:
     aot_set_last_error("bulk memory instruction was found, "
     aot_set_last_error("bulk memory instruction was found, "

+ 4 - 2
core/iwasm/compilation/aot_emit_memory.c

@@ -1481,7 +1481,7 @@ fail:
     return false;
     return false;
 }
 }
 
 
-#if WASM_ENABLE_BULK_MEMORY != 0 || WASM_ENABLE_STRINGREF != 0
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0 || WASM_ENABLE_STRINGREF != 0
 LLVMValueRef
 LLVMValueRef
 check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
 check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
                            LLVMValueRef offset, LLVMValueRef bytes)
                            LLVMValueRef offset, LLVMValueRef bytes)
@@ -1769,7 +1769,9 @@ aot_compile_op_data_drop(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
 fail:
 fail:
     return false;
     return false;
 }
 }
+#endif /* end of WASM_ENABLE_BULK_MEMORY */
 
 
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
 bool
 bool
 aot_compile_op_memory_copy(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
 aot_compile_op_memory_copy(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
 {
 {
@@ -1931,7 +1933,7 @@ aot_compile_op_memory_fill(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
 fail:
 fail:
     return false;
     return false;
 }
 }
-#endif /* end of WASM_ENABLE_BULK_MEMORY */
+#endif /* end of WASM_ENABLE_BULK_MEMORY_OPT */
 
 
 #if WASM_ENABLE_SHARED_MEMORY != 0
 #if WASM_ENABLE_SHARED_MEMORY != 0
 bool
 bool

+ 2 - 0
core/iwasm/compilation/aot_emit_memory.h

@@ -78,7 +78,9 @@ aot_compile_op_memory_init(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
 bool
 bool
 aot_compile_op_data_drop(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
 aot_compile_op_data_drop(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
                          uint32 seg_index);
                          uint32 seg_index);
+#endif
 
 
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
 bool
 bool
 aot_compile_op_memory_copy(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
 aot_compile_op_memory_copy(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
 
 

+ 11 - 1
core/iwasm/compilation/aot_llvm.c

@@ -2731,6 +2731,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
     if (option->enable_bulk_memory)
     if (option->enable_bulk_memory)
         comp_ctx->enable_bulk_memory = true;
         comp_ctx->enable_bulk_memory = true;
 
 
+    if (option->enable_bulk_memory_opt)
+        comp_ctx->enable_bulk_memory_opt = true;
+
     if (option->enable_thread_mgr)
     if (option->enable_thread_mgr)
         comp_ctx->enable_thread_mgr = true;
         comp_ctx->enable_thread_mgr = true;
 
 
@@ -2740,6 +2743,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
     if (option->enable_ref_types)
     if (option->enable_ref_types)
         comp_ctx->enable_ref_types = true;
         comp_ctx->enable_ref_types = true;
 
 
+    if (option->enable_call_indirect_overlong)
+        comp_ctx->enable_call_indirect_overlong = true;
+
     comp_ctx->aux_stack_frame_type = option->aux_stack_frame_type;
     comp_ctx->aux_stack_frame_type = option->aux_stack_frame_type;
     comp_ctx->call_stack_features = option->call_stack_features;
     comp_ctx->call_stack_features = option->call_stack_features;
 
 
@@ -3324,7 +3330,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
 
 
     /* Return error if ref-types and GC are disabled by command line but
     /* Return error if ref-types and GC are disabled by command line but
        ref-types instructions are used */
        ref-types instructions are used */
-    if (!option->enable_ref_types && !option->enable_gc
+    if (!option->enable_call_indirect_overlong && !option->enable_gc
         && wasm_module->is_ref_types_used) {
         && wasm_module->is_ref_types_used) {
         aot_set_last_error("ref-types instruction was found, "
         aot_set_last_error("ref-types instruction was found, "
                            "try removing --disable-ref-types option "
                            "try removing --disable-ref-types option "
@@ -3338,9 +3344,13 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
     }
     }
     if (!wasm_module->is_ref_types_used) {
     if (!wasm_module->is_ref_types_used) {
         option->enable_ref_types = comp_ctx->enable_ref_types = false;
         option->enable_ref_types = comp_ctx->enable_ref_types = false;
+        option->enable_call_indirect_overlong =
+            comp_ctx->enable_call_indirect_overlong = false;
     }
     }
     if (!wasm_module->is_bulk_memory_used) {
     if (!wasm_module->is_bulk_memory_used) {
         option->enable_bulk_memory = comp_ctx->enable_bulk_memory = false;
         option->enable_bulk_memory = comp_ctx->enable_bulk_memory = false;
+        option->enable_bulk_memory_opt = comp_ctx->enable_bulk_memory_opt =
+            false;
     }
     }
 #endif
 #endif
 
 

+ 7 - 0
core/iwasm/compilation/aot_llvm.h

@@ -416,6 +416,10 @@ typedef struct AOTCompContext {
     /* Bulk memory feature */
     /* Bulk memory feature */
     bool enable_bulk_memory;
     bool enable_bulk_memory;
 
 
+    /*  Bulk memory opt feature. will be enabled alongside the
+     * enable_bulk_memory */
+    bool enable_bulk_memory_opt;
+
     /* Boundary Check */
     /* Boundary Check */
     bool enable_bound_check;
     bool enable_bound_check;
 
 
@@ -452,6 +456,9 @@ typedef struct AOTCompContext {
     /* Reference Types */
     /* Reference Types */
     bool enable_ref_types;
     bool enable_ref_types;
 
 
+    /* Call Indirect Overlong. will be enabled alongside the enable_ref_types */
+    bool enable_call_indirect_overlong;
+
     /* Disable LLVM built-in intrinsics */
     /* Disable LLVM built-in intrinsics */
     bool disable_llvm_intrinsics;
     bool disable_llvm_intrinsics;
 
 

+ 2 - 0
core/iwasm/fast-jit/fe/jit_emit_memory.c

@@ -713,7 +713,9 @@ jit_compile_op_data_drop(JitCompContext *cc, uint32 seg_idx)
     return jit_emit_callnative(cc, wasm_data_drop, 0, args,
     return jit_emit_callnative(cc, wasm_data_drop, 0, args,
                                sizeof(args) / sizeof(args[0]));
                                sizeof(args) / sizeof(args[0]));
 }
 }
+#endif
 
 
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
 static int
 static int
 wasm_copy_memory(WASMModuleInstance *inst, uint32 src_mem_idx,
 wasm_copy_memory(WASMModuleInstance *inst, uint32 src_mem_idx,
                  uint32 dst_mem_idx, uint32 len, uint32 src_offset,
                  uint32 dst_mem_idx, uint32 len, uint32 src_offset,

+ 2 - 0
core/iwasm/fast-jit/fe/jit_emit_memory.h

@@ -55,7 +55,9 @@ jit_compile_op_memory_init(JitCompContext *cc, uint32 mem_idx, uint32 seg_idx);
 
 
 bool
 bool
 jit_compile_op_data_drop(JitCompContext *cc, uint32 seg_idx);
 jit_compile_op_data_drop(JitCompContext *cc, uint32 seg_idx);
+#endif
 
 
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
 bool
 bool
 jit_compile_op_memory_copy(JitCompContext *cc, uint32 src_mem_idx,
 jit_compile_op_memory_copy(JitCompContext *cc, uint32 src_mem_idx,
                            uint32 dst_mem_idx);
                            uint32 dst_mem_idx);

+ 4 - 2
core/iwasm/fast-jit/jit_frontend.c

@@ -1627,7 +1627,7 @@ jit_compile_func(JitCompContext *cc)
 
 
                 read_leb_uint32(frame_ip, frame_ip_end, type_idx);
                 read_leb_uint32(frame_ip, frame_ip_end, type_idx);
 
 
-#if WASM_ENABLE_REF_TYPES != 0
+#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0
                 read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
                 read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
 #else
 #else
                 frame_ip++;
                 frame_ip++;
@@ -2336,6 +2336,8 @@ jit_compile_func(JitCompContext *cc)
                             return false;
                             return false;
                         break;
                         break;
                     }
                     }
+#endif /* WASM_ENABLE_BULK_MEMORY */
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
                     case WASM_OP_MEMORY_COPY:
                     case WASM_OP_MEMORY_COPY:
                     {
                     {
                         uint32 src_mem_idx, dst_mem_idx;
                         uint32 src_mem_idx, dst_mem_idx;
@@ -2353,7 +2355,7 @@ jit_compile_func(JitCompContext *cc)
                             return false;
                             return false;
                         break;
                         break;
                     }
                     }
-#endif /* WASM_ENABLE_BULK_MEMORY */
+#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
 #if WASM_ENABLE_REF_TYPES != 0
 #if WASM_ENABLE_REF_TYPES != 0
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_INIT:
                     {
                     {

+ 3 - 0
core/iwasm/include/aot_comp_option.h

@@ -62,13 +62,16 @@ typedef struct AOTCompOption {
     char *cpu_features;
     char *cpu_features;
     bool is_sgx_platform;
     bool is_sgx_platform;
     bool enable_bulk_memory;
     bool enable_bulk_memory;
+    bool enable_bulk_memory_opt;
     bool enable_thread_mgr;
     bool enable_thread_mgr;
     bool enable_tail_call;
     bool enable_tail_call;
     bool enable_simd;
     bool enable_simd;
     bool enable_ref_types;
     bool enable_ref_types;
+    bool enable_call_indirect_overlong;
     bool enable_gc;
     bool enable_gc;
     bool enable_aux_stack_check;
     bool enable_aux_stack_check;
     bool enable_extended_const;
     bool enable_extended_const;
+    bool enable_lime1;
     AOTStackFrameType aux_stack_frame_type;
     AOTStackFrameType aux_stack_frame_type;
     AOTCallStackFeatures call_stack_features;
     AOTCallStackFeatures call_stack_features;
     bool enable_perf_profiling;
     bool enable_perf_profiling;

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

@@ -1567,7 +1567,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
     WASMMemoryInstance *memory = wasm_get_default_memory(module);
     WASMMemoryInstance *memory = wasm_get_default_memory(module);
 #if !defined(OS_ENABLE_HW_BOUND_CHECK)              \
 #if !defined(OS_ENABLE_HW_BOUND_CHECK)              \
     || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
     || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
-    || WASM_ENABLE_BULK_MEMORY != 0
+    || WASM_ENABLE_BULK_MEMORY_OPT != 0
     uint64 linear_mem_size = 0;
     uint64 linear_mem_size = 0;
     if (memory)
     if (memory)
 #if WASM_ENABLE_THREAD_MGR == 0
 #if WASM_ENABLE_THREAD_MGR == 0
@@ -2370,7 +2370,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                 cur_type = wasm_types[tidx];
                 cur_type = wasm_types[tidx];
 
 
                 /* clang-format off */
                 /* clang-format off */
-#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
+#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0 || WASM_ENABLE_GC != 0
                 read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
                 read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
 #else
 #else
                 frame_ip++;
                 frame_ip++;
@@ -5774,6 +5774,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                                           segment);
                                           segment);
                         break;
                         break;
                     }
                     }
+#endif /* WASM_ENABLE_BULK_MEMORY */
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
                     case WASM_OP_MEMORY_COPY:
                     case WASM_OP_MEMORY_COPY:
                     {
                     {
                         mem_offset_t dst, src, len;
                         mem_offset_t dst, src, len;
@@ -5894,7 +5896,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                         memset(mdst, fill_val, len);
                         memset(mdst, fill_val, len);
                         break;
                         break;
                     }
                     }
-#endif /* WASM_ENABLE_BULK_MEMORY */
+#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_INIT:
                     {
                     {
@@ -6879,7 +6881,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
 
 
 #if !defined(OS_ENABLE_HW_BOUND_CHECK)              \
 #if !defined(OS_ENABLE_HW_BOUND_CHECK)              \
     || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
     || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
-    || WASM_ENABLE_BULK_MEMORY != 0
+    || WASM_ENABLE_BULK_MEMORY_OPT != 0
     out_of_bounds:
     out_of_bounds:
         wasm_set_exception(module, "out of bounds memory access");
         wasm_set_exception(module, "out of bounds memory access");
 #endif
 #endif

+ 5 - 3
core/iwasm/interpreter/wasm_interp_fast.c

@@ -1501,7 +1501,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
     WASMMemoryInstance *memory = wasm_get_default_memory(module);
     WASMMemoryInstance *memory = wasm_get_default_memory(module);
 #if !defined(OS_ENABLE_HW_BOUND_CHECK)              \
 #if !defined(OS_ENABLE_HW_BOUND_CHECK)              \
     || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
     || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
-    || WASM_ENABLE_BULK_MEMORY != 0
+    || WASM_ENABLE_BULK_MEMORY_OPT != 0
     uint64 linear_mem_size = 0;
     uint64 linear_mem_size = 0;
     if (memory)
     if (memory)
 #if WASM_ENABLE_THREAD_MGR == 0
 #if WASM_ENABLE_THREAD_MGR == 0
@@ -5200,6 +5200,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                                           segment);
                                           segment);
                         break;
                         break;
                     }
                     }
+#endif /* WASM_ENABLE_BULK_MEMORY */
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
                     case WASM_OP_MEMORY_COPY:
                     case WASM_OP_MEMORY_COPY:
                     {
                     {
                         uint32 dst, src, len;
                         uint32 dst, src, len;
@@ -5290,7 +5292,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                         memset(mdst, fill_val, len);
                         memset(mdst, fill_val, len);
                         break;
                         break;
                     }
                     }
-#endif /* WASM_ENABLE_BULK_MEMORY */
+#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_INIT:
                     {
                     {
@@ -7805,7 +7807,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
 
 
 #if !defined(OS_ENABLE_HW_BOUND_CHECK)              \
 #if !defined(OS_ENABLE_HW_BOUND_CHECK)              \
     || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
     || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
-    || WASM_ENABLE_BULK_MEMORY != 0
+    || WASM_ENABLE_BULK_MEMORY_OPT != 0
     out_of_bounds:
     out_of_bounds:
         wasm_set_exception(module, "out of bounds memory access");
         wasm_set_exception(module, "out of bounds memory access");
 #endif
 #endif

+ 31 - 18
core/iwasm/interpreter/wasm_loader.c

@@ -5869,6 +5869,9 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf,
 #if WASM_ENABLE_BULK_MEMORY != 0
 #if WASM_ENABLE_BULK_MEMORY != 0
     option.enable_bulk_memory = true;
     option.enable_bulk_memory = true;
 #endif
 #endif
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
+    option.enable_bulk_memory_opt = true;
+#endif
 #if WASM_ENABLE_THREAD_MGR != 0
 #if WASM_ENABLE_THREAD_MGR != 0
     option.enable_thread_mgr = true;
     option.enable_thread_mgr = true;
 #endif
 #endif
@@ -5882,6 +5885,9 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf,
     option.enable_ref_types = true;
     option.enable_ref_types = true;
 #elif WASM_ENABLE_GC != 0
 #elif WASM_ENABLE_GC != 0
     option.enable_gc = true;
     option.enable_gc = true;
+#endif
+#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0
+    option.enable_call_indirect_overlong = true;
 #endif
 #endif
     option.enable_aux_stack_check = true;
     option.enable_aux_stack_check = true;
 #if WASM_ENABLE_PERF_PROFILING != 0 || WASM_ENABLE_DUMP_CALL_STACK != 0 \
 #if WASM_ENABLE_PERF_PROFILING != 0 || WASM_ENABLE_DUMP_CALL_STACK != 0 \
@@ -7739,7 +7745,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
             case WASM_OP_RETURN_CALL_INDIRECT:
             case WASM_OP_RETURN_CALL_INDIRECT:
 #endif
 #endif
                 skip_leb_uint32(p, p_end); /* typeidx */
                 skip_leb_uint32(p, p_end); /* typeidx */
-#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
+#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0 || WASM_ENABLE_GC != 0
                 skip_leb_uint32(p, p_end); /* tableidx */
                 skip_leb_uint32(p, p_end); /* tableidx */
 #else
 #else
                 u8 = read_uint8(p); /* 0x00 */
                 u8 = read_uint8(p); /* 0x00 */
@@ -8164,6 +8170,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
                     case WASM_OP_DATA_DROP:
                     case WASM_OP_DATA_DROP:
                         skip_leb_uint32(p, p_end);
                         skip_leb_uint32(p, p_end);
                         break;
                         break;
+#endif /* WASM_ENABLE_BULK_MEMORY */
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
                     case WASM_OP_MEMORY_COPY:
                     case WASM_OP_MEMORY_COPY:
                         skip_leb_memidx(p, p_end);
                         skip_leb_memidx(p, p_end);
                         skip_leb_memidx(p, p_end);
                         skip_leb_memidx(p, p_end);
@@ -8171,7 +8179,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
                     case WASM_OP_MEMORY_FILL:
                     case WASM_OP_MEMORY_FILL:
                         skip_leb_memidx(p, p_end);
                         skip_leb_memidx(p, p_end);
                         break;
                         break;
-#endif /* WASM_ENABLE_BULK_MEMORY */
+#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
 #if WASM_ENABLE_REF_TYPES != 0
 #if WASM_ENABLE_REF_TYPES != 0
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_COPY:
                     case WASM_OP_TABLE_COPY:
@@ -12987,7 +12995,7 @@ re_scan:
 #endif
 #endif
 
 
                 pb_read_leb_uint32(p, p_end, type_idx);
                 pb_read_leb_uint32(p, p_end, type_idx);
-#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
+#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0 || WASM_ENABLE_GC != 0
 #if WASM_ENABLE_WAMR_COMPILER != 0
 #if WASM_ENABLE_WAMR_COMPILER != 0
                 if (p + 1 < p_end && *p != 0x00) {
                 if (p + 1 < p_end && *p != 0x00) {
                     /*
                     /*
@@ -15673,8 +15681,11 @@ re_scan:
                         emit_uint32(loader_ctx, data_seg_idx);
                         emit_uint32(loader_ctx, data_seg_idx);
 #endif
 #endif
                         if (module->import_memory_count == 0
                         if (module->import_memory_count == 0
-                            && module->memory_count == 0)
-                            goto fail_unknown_memory;
+                            && module->memory_count == 0) {
+                            set_error_buf(error_buf, error_buf_size,
+                                          "unknown memory 0");
+                            goto fail;
+                        }
 
 
                         pb_read_leb_uint32(p, p_end, memidx);
                         pb_read_leb_uint32(p, p_end, memidx);
                         check_memidx(module, memidx);
                         check_memidx(module, memidx);
@@ -15723,6 +15734,12 @@ re_scan:
 #endif
 #endif
                         break;
                         break;
                     }
                     }
+                    fail_data_cnt_sec_require:
+                        set_error_buf(error_buf, error_buf_size,
+                                      "data count section required");
+                        goto fail;
+#endif /* WASM_ENABLE_BULK_MEMORY */
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
                     case WASM_OP_MEMORY_COPY:
                     case WASM_OP_MEMORY_COPY:
                     {
                     {
                         CHECK_BUF(p, p_end, sizeof(int16));
                         CHECK_BUF(p, p_end, sizeof(int16));
@@ -15733,8 +15750,11 @@ re_scan:
                         check_memidx(module, memidx);
                         check_memidx(module, memidx);
 
 
                         if (module->import_memory_count == 0
                         if (module->import_memory_count == 0
-                            && module->memory_count == 0)
-                            goto fail_unknown_memory;
+                            && module->memory_count == 0) {
+                            set_error_buf(error_buf, error_buf_size,
+                                          "unknown memory 0");
+                            goto fail;
+                        }
 
 
                         POP_MEM_OFFSET();
                         POP_MEM_OFFSET();
                         POP_MEM_OFFSET();
                         POP_MEM_OFFSET();
@@ -15753,7 +15773,9 @@ re_scan:
                         check_memidx(module, memidx);
                         check_memidx(module, memidx);
                         if (module->import_memory_count == 0
                         if (module->import_memory_count == 0
                             && module->memory_count == 0) {
                             && module->memory_count == 0) {
-                            goto fail_unknown_memory;
+                            set_error_buf(error_buf, error_buf_size,
+                                          "unknown memory 0");
+                            goto fail;
                         }
                         }
                         POP_MEM_OFFSET();
                         POP_MEM_OFFSET();
                         POP_I32();
                         POP_I32();
@@ -15766,16 +15788,7 @@ re_scan:
 #endif
 #endif
                         break;
                         break;
                     }
                     }
-
-                    fail_unknown_memory:
-                        set_error_buf(error_buf, error_buf_size,
-                                      "unknown memory 0");
-                        goto fail;
-                    fail_data_cnt_sec_require:
-                        set_error_buf(error_buf, error_buf_size,
-                                      "data count section required");
-                        goto fail;
-#endif /* WASM_ENABLE_BULK_MEMORY */
+#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
 #if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_INIT:
                     {
                     {

+ 14 - 4
core/iwasm/interpreter/wasm_mini_loader.c

@@ -2388,6 +2388,9 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf,
 #if WASM_ENABLE_BULK_MEMORY != 0
 #if WASM_ENABLE_BULK_MEMORY != 0
     option.enable_bulk_memory = true;
     option.enable_bulk_memory = true;
 #endif
 #endif
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
+    option.enable_bulk_memory_opt = true;
+#endif
 #if WASM_ENABLE_THREAD_MGR != 0
 #if WASM_ENABLE_THREAD_MGR != 0
     option.enable_thread_mgr = true;
     option.enable_thread_mgr = true;
 #endif
 #endif
@@ -2399,6 +2402,9 @@ init_llvm_jit_functions_stage1(WASMModule *module, char *error_buf,
 #endif
 #endif
 #if WASM_ENABLE_REF_TYPES != 0
 #if WASM_ENABLE_REF_TYPES != 0
     option.enable_ref_types = true;
     option.enable_ref_types = true;
+#endif
+#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0
+    option.enable_call_indirect_overlong = true;
 #endif
 #endif
     option.enable_aux_stack_check = true;
     option.enable_aux_stack_check = true;
 #if WASM_ENABLE_PERF_PROFILING != 0 || WASM_ENABLE_DUMP_CALL_STACK != 0 \
 #if WASM_ENABLE_PERF_PROFILING != 0 || WASM_ENABLE_DUMP_CALL_STACK != 0 \
@@ -3849,7 +3855,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
             case WASM_OP_RETURN_CALL_INDIRECT:
             case WASM_OP_RETURN_CALL_INDIRECT:
 #endif
 #endif
                 skip_leb_uint32(p, p_end); /* typeidx */
                 skip_leb_uint32(p, p_end); /* typeidx */
-#if WASM_ENABLE_REF_TYPES != 0
+#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0
                 skip_leb_uint32(p, p_end); /* tableidx */
                 skip_leb_uint32(p, p_end); /* tableidx */
 #else
 #else
                 u8 = read_uint8(p); /* 0x00 */
                 u8 = read_uint8(p); /* 0x00 */
@@ -4111,6 +4117,8 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
                     case WASM_OP_DATA_DROP:
                     case WASM_OP_DATA_DROP:
                         skip_leb_uint32(p, p_end);
                         skip_leb_uint32(p, p_end);
                         break;
                         break;
+#endif
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
                     case WASM_OP_MEMORY_COPY:
                     case WASM_OP_MEMORY_COPY:
                         skip_leb_memidx(p, p_end);
                         skip_leb_memidx(p, p_end);
                         skip_leb_memidx(p, p_end);
                         skip_leb_memidx(p, p_end);
@@ -4118,7 +4126,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
                     case WASM_OP_MEMORY_FILL:
                     case WASM_OP_MEMORY_FILL:
                         skip_leb_memidx(p, p_end);
                         skip_leb_memidx(p, p_end);
                         break;
                         break;
-#endif
+#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
 #if WASM_ENABLE_REF_TYPES != 0
 #if WASM_ENABLE_REF_TYPES != 0
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_COPY:
                     case WASM_OP_TABLE_COPY:
@@ -7069,7 +7077,7 @@ re_scan:
 
 
                 pb_read_leb_uint32(p, p_end, type_idx);
                 pb_read_leb_uint32(p, p_end, type_idx);
 
 
-#if WASM_ENABLE_REF_TYPES != 0
+#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0
                 pb_read_leb_uint32(p, p_end, table_idx);
                 pb_read_leb_uint32(p, p_end, table_idx);
 #else
 #else
                 CHECK_BUF(p, p_end, 1);
                 CHECK_BUF(p, p_end, 1);
@@ -8274,6 +8282,8 @@ re_scan:
 #endif
 #endif
                         break;
                         break;
                     }
                     }
+#endif /* WASM_ENABLE_BULK_MEMORY */
+#if WASM_ENABLE_BULK_MEMORY_OPT != 0
                     case WASM_OP_MEMORY_COPY:
                     case WASM_OP_MEMORY_COPY:
                     {
                     {
                         CHECK_MEMORY();
                         CHECK_MEMORY();
@@ -8306,7 +8316,7 @@ re_scan:
 #endif
 #endif
                         break;
                         break;
                     }
                     }
-#endif /* WASM_ENABLE_BULK_MEMORY */
+#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
 #if WASM_ENABLE_REF_TYPES != 0
 #if WASM_ENABLE_REF_TYPES != 0
                     case WASM_OP_TABLE_INIT:
                     case WASM_OP_TABLE_INIT:
                     {
                     {

+ 19 - 0
doc/build_wamr.md

@@ -297,6 +297,18 @@ Currently we only profile the memory consumption of module, module_instance and
 - **WAMR_BUILD_EXTENDED_CONST_EXPR**=1/0, default to disable if not set.
 - **WAMR_BUILD_EXTENDED_CONST_EXPR**=1/0, default to disable if not set.
 > Note: See [Extended Constant Expressions](https://github.com/WebAssembly/extended-const/blob/main/proposals/extended-const/Overview.md) for more details.
 > Note: See [Extended Constant Expressions](https://github.com/WebAssembly/extended-const/blob/main/proposals/extended-const/Overview.md) for more details.
 
 
+### **Enable bulk-memory-opt**
+- **WAMR_BUILD_BULK_MEMORY_OPT**=1/0, default to disable if not set.
+> Note: See [bulk-memory-opt](https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#bulk-memory-opt) for more details.
+
+### **Enable call-indirect-overlong**
+- **WAMR_BUILD_CALL_INDIRECT_OVERLONG**=1/0, default to disable if not set.
+> Note: See [call-indirect-overlong](https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#call-indirect-overlong) for more details.
+
+### **Enable Lime1 target**
+- **WAMR_BUILD_LIME1**=1/0, default to disable if not set.
+> Note: See [Lime1](https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1) for more details.
+
 ### **Configurable memory access boundary check**
 ### **Configurable memory access boundary check**
 - **WAMR_CONFIGURABLE_BOUNDS_CHECKS**=1/0, default to disable if not set
 - **WAMR_CONFIGURABLE_BOUNDS_CHECKS**=1/0, default to disable if not set
 > Note: If it is enabled, allow to run `iwasm --disable-bounds-checks` to disable the memory access boundary checks for interpreter mode.
 > Note: If it is enabled, allow to run `iwasm --disable-bounds-checks` to disable the memory access boundary checks for interpreter mode.
@@ -366,3 +378,10 @@ For Valgrind, begin with the following configurations and add additional ones as
   -DWAMR_DISABLE_WRITE_GS_BASE=0
   -DWAMR_DISABLE_WRITE_GS_BASE=0
   #...
   #...
 ```
 ```
+
+To enable the minimal Lime1 feature set, we need to disable some features that are on by default, such as 
+bulk memory and reference types:
+
+```Bash
+cmake .. -DWAMR_BUILD_LIME1=1 -DWAMR_BUILD_BULK_MEMORY=0 -DWAMR_BUILD_REF_TYPES=0 -DDWAMR_BUILD_SIMD=0
+```

+ 5 - 0
doc/build_wasm_app.md

@@ -355,6 +355,8 @@ Usage: wamrc [options] -o output_file wasm_file
                               llvmir-unopt   Unoptimized LLVM IR
                               llvmir-unopt   Unoptimized LLVM IR
                               llvmir-opt     Optimized LLVM IR
                               llvmir-opt     Optimized LLVM IR
   --disable-bulk-memory     Disable the MVP bulk memory feature
   --disable-bulk-memory     Disable the MVP bulk memory feature
+  --enable-bulk-memory-opt  Enable bulk memory opt feature
+  --enable-extended-const   Enable extended const expr feature
   --enable-multi-thread     Enable multi-thread feature, the dependent features bulk-memory and
   --enable-multi-thread     Enable multi-thread feature, the dependent features bulk-memory and
                             thread-mgr will be enabled automatically
                             thread-mgr will be enabled automatically
   --enable-tail-call        Enable the post-MVP tail call feature
   --enable-tail-call        Enable the post-MVP tail call feature
@@ -363,6 +365,9 @@ Usage: wamrc [options] -o output_file wasm_file
                               and by default it is enabled in x86-64 target and disabled
                               and by default it is enabled in x86-64 target and disabled
                               in other targets
                               in other targets
   --disable-ref-types       Disable the MVP reference types feature
   --disable-ref-types       Disable the MVP reference types feature
+  --enable-call-indirect-overlong
+                            Enable call indirect overlong feature
+  --enable-lime1            Enable Lime1
   --disable-aux-stack-check Disable auxiliary stack overflow/underflow check
   --disable-aux-stack-check Disable auxiliary stack overflow/underflow check
   --enable-dump-call-stack  Enable stack trace feature
   --enable-dump-call-stack  Enable stack trace feature
   --enable-perf-profiling   Enable function performance profiling
   --enable-perf-profiling   Enable function performance profiling

+ 2 - 0
wamr-compiler/CMakeLists.txt

@@ -41,11 +41,13 @@ endif()
 add_definitions(-DWASM_ENABLE_INTERP=1)
 add_definitions(-DWASM_ENABLE_INTERP=1)
 add_definitions(-DWASM_ENABLE_WAMR_COMPILER=1)
 add_definitions(-DWASM_ENABLE_WAMR_COMPILER=1)
 add_definitions(-DWASM_ENABLE_BULK_MEMORY=1)
 add_definitions(-DWASM_ENABLE_BULK_MEMORY=1)
+add_definitions(-DWASM_ENABLE_BULK_MEMORY_OPT=1)
 add_definitions(-DWASM_DISABLE_HW_BOUND_CHECK=1)
 add_definitions(-DWASM_DISABLE_HW_BOUND_CHECK=1)
 add_definitions(-DWASM_ENABLE_SHARED_MEMORY=1)
 add_definitions(-DWASM_ENABLE_SHARED_MEMORY=1)
 add_definitions(-DWASM_ENABLE_THREAD_MGR=1)
 add_definitions(-DWASM_ENABLE_THREAD_MGR=1)
 add_definitions(-DWASM_ENABLE_TAIL_CALL=1)
 add_definitions(-DWASM_ENABLE_TAIL_CALL=1)
 add_definitions(-DWASM_ENABLE_REF_TYPES=1)
 add_definitions(-DWASM_ENABLE_REF_TYPES=1)
+add_definitions(-DWASM_ENABLE_CALL_INDIRECT_OVERLONG=1)
 add_definitions(-DWASM_ENABLE_BRANCH_HINTS=1)
 add_definitions(-DWASM_ENABLE_BRANCH_HINTS=1)
 add_definitions(-DWASM_ENABLE_CUSTOM_NAME_SECTION=1)
 add_definitions(-DWASM_ENABLE_CUSTOM_NAME_SECTION=1)
 add_definitions(-DWASM_ENABLE_AOT_STACK_FRAME=1)
 add_definitions(-DWASM_ENABLE_AOT_STACK_FRAME=1)

+ 31 - 0
wamr-compiler/main.c

@@ -159,6 +159,8 @@ print_help()
     printf("                              llvmir-unopt   Unoptimized LLVM IR\n");
     printf("                              llvmir-unopt   Unoptimized LLVM IR\n");
     printf("                              llvmir-opt     Optimized LLVM IR\n");
     printf("                              llvmir-opt     Optimized LLVM IR\n");
     printf("  --disable-bulk-memory     Disable the MVP bulk memory feature\n");
     printf("  --disable-bulk-memory     Disable the MVP bulk memory feature\n");
+    printf("  --enable-bulk-memory-opt  Enable bulk memory opt feature\n");
+    printf("  --enable-extended-const   Enable extended const expr feature\n");
     printf("  --enable-multi-thread     Enable multi-thread feature, the dependent features bulk-memory and\n");
     printf("  --enable-multi-thread     Enable multi-thread feature, the dependent features bulk-memory and\n");
     printf("                            thread-mgr will be enabled automatically\n");
     printf("                            thread-mgr will be enabled automatically\n");
     printf("  --enable-tail-call        Enable the post-MVP tail call feature\n");
     printf("  --enable-tail-call        Enable the post-MVP tail call feature\n");
@@ -167,6 +169,9 @@ print_help()
     printf("                              and by default it is enabled in them and disabled in other targets\n");
     printf("                              and by default it is enabled in them and disabled in other targets\n");
     printf("  --disable-ref-types       Disable the MVP reference types feature, it will be disabled forcibly if\n");
     printf("  --disable-ref-types       Disable the MVP reference types feature, it will be disabled forcibly if\n");
     printf("                              GC is enabled\n");
     printf("                              GC is enabled\n");
+    printf("  --enable-call-indirect-overlong\n");
+    printf("                            Enable call indirect overlong feature\n");
+    printf("  --enable-lime1            Enable Lime1\n");
     printf("  --disable-aux-stack-check Disable auxiliary stack overflow/underflow check\n");
     printf("  --disable-aux-stack-check Disable auxiliary stack overflow/underflow check\n");
     printf("  --enable-dump-call-stack  Enable stack trace feature\n");
     printf("  --enable-dump-call-stack  Enable stack trace feature\n");
     printf("  --call-stack-features=<features>\n");
     printf("  --call-stack-features=<features>\n");
@@ -423,9 +428,12 @@ main(int argc, char *argv[])
     option.enable_simd = true;
     option.enable_simd = true;
     option.enable_aux_stack_check = true;
     option.enable_aux_stack_check = true;
     option.enable_bulk_memory = true;
     option.enable_bulk_memory = true;
+    option.enable_bulk_memory_opt = false;
     option.enable_ref_types = true;
     option.enable_ref_types = true;
+    option.enable_call_indirect_overlong = false;
     option.enable_gc = false;
     option.enable_gc = false;
     option.enable_extended_const = false;
     option.enable_extended_const = false;
+    option.enable_lime1 = false;
     aot_call_stack_features_init_default(&option.call_stack_features);
     aot_call_stack_features_init_default(&option.call_stack_features);
 
 
     /* Process options */
     /* Process options */
@@ -519,6 +527,9 @@ main(int argc, char *argv[])
         else if (!strcmp(argv[0], "--disable-bulk-memory")) {
         else if (!strcmp(argv[0], "--disable-bulk-memory")) {
             option.enable_bulk_memory = false;
             option.enable_bulk_memory = false;
         }
         }
+        else if (!strcmp(argv[0], "--enable-bulk-memory-opt")) {
+            option.enable_bulk_memory_opt = true;
+        }
         else if (!strcmp(argv[0], "--enable-multi-thread")) {
         else if (!strcmp(argv[0], "--enable-multi-thread")) {
             option.enable_bulk_memory = true;
             option.enable_bulk_memory = true;
             option.enable_thread_mgr = true;
             option.enable_thread_mgr = true;
@@ -536,12 +547,18 @@ main(int argc, char *argv[])
         else if (!strcmp(argv[0], "--disable-ref-types")) {
         else if (!strcmp(argv[0], "--disable-ref-types")) {
             option.enable_ref_types = false;
             option.enable_ref_types = false;
         }
         }
+        else if (!strcmp(argv[0], "--enable-call-indirect-overlong")) {
+            option.enable_call_indirect_overlong = true;
+        }
         else if (!strcmp(argv[0], "--disable-aux-stack-check")) {
         else if (!strcmp(argv[0], "--disable-aux-stack-check")) {
             option.enable_aux_stack_check = false;
             option.enable_aux_stack_check = false;
         }
         }
         else if (!strcmp(argv[0], "--enable-extended-const")) {
         else if (!strcmp(argv[0], "--enable-extended-const")) {
             option.enable_extended_const = true;
             option.enable_extended_const = true;
         }
         }
+        else if (!strcmp(argv[0], "--enable-lime1")) {
+            option.enable_lime1 = true;
+        }
         else if (!strcmp(argv[0], "--enable-dump-call-stack")) {
         else if (!strcmp(argv[0], "--enable-dump-call-stack")) {
             option.aux_stack_frame_type = AOT_STACK_FRAME_TYPE_STANDARD;
             option.aux_stack_frame_type = AOT_STACK_FRAME_TYPE_STANDARD;
         }
         }
@@ -747,6 +764,20 @@ main(int argc, char *argv[])
         option.bounds_checks = true;
         option.bounds_checks = true;
     }
     }
 
 
+    if (option.enable_bulk_memory) {
+        option.enable_bulk_memory_opt = true;
+    }
+
+    if (option.enable_ref_types) {
+        option.enable_call_indirect_overlong = true;
+    }
+
+    if (option.enable_lime1) {
+        option.enable_call_indirect_overlong = true;
+        option.enable_bulk_memory_opt = true;
+        option.enable_extended_const = true;
+    }
+
     if (!use_dummy_wasm) {
     if (!use_dummy_wasm) {
         wasm_file_name = argv[0];
         wasm_file_name = argv[0];