Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/compilation_on_android_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ jobs:
"-DWAMR_BUILD_MULTI_MEMORY=1",
"-DWAMR_BUILD_SHARED=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]
platform: [android, linux]
Expand Down
40 changes: 40 additions & 0 deletions build-scripts/config_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
set (WAMR_BUILD_BULK_MEMORY 1)
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)
set (WAMR_BUILD_EXCE_HANDLING 0)
endif ()
Expand Down Expand Up @@ -253,10 +261,27 @@ if (NOT DEFINED WAMR_BUILD_EXTENDED_CONST_EXPR)
set (WAMR_BUILD_EXTENDED_CONST_EXPR 0)
endif ()

if (NOT DEFINED WAMR_BUILD_LIME1)
set (WAMR_BUILD_LIME1 0)
endif ()

########################################
# 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 as target ${WAMR_BUILD_TARGET}")
message (" Build for platform ${WAMR_BUILD_PLATFORM}")
Expand Down Expand Up @@ -366,6 +391,11 @@ if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
else ()
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
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)
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
message (" Shared memory enabled")
Expand Down Expand Up @@ -457,6 +487,11 @@ endif ()
if (WAMR_BUILD_REF_TYPES EQUAL 1)
add_definitions (-DWASM_ENABLE_REF_TYPES=1)
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_TEST_GC EQUAL 1)
message(" GC testing enabled")
Expand Down Expand Up @@ -727,6 +762,9 @@ else()
message (" Extended constant expression disabled")
add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=0)
endif ()
if (WAMR_BUILD_LIME1 EQUAL 1)
message (" Lime1 enabled")
endif ()
########################################
# Show Phase4 Wasm proposals status.
########################################
Expand All @@ -742,6 +780,8 @@ message (
" \"Branch Hinting\"\n"
" Configurable. 0 is OFF. 1 is ON:\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"
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
" \"Garbage Collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"
Expand Down
8 changes: 8 additions & 0 deletions core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@
#define WASM_ENABLE_BULK_MEMORY 0
#endif

#ifndef WASM_ENABLE_BULK_MEMORY_OPT
#define WASM_ENABLE_BULK_MEMORY_OPT 0
#endif

/* Shared memory */
#ifndef WASM_ENABLE_SHARED_MEMORY
#define WASM_ENABLE_SHARED_MEMORY 0
Expand Down Expand Up @@ -579,6 +583,10 @@ unless used elsewhere */
#define WASM_ENABLE_REF_TYPES 0
#endif

#ifndef WASM_ENABLE_CALL_INDIRECT_OVERLONG
#define WASM_ENABLE_CALL_INDIRECT_OVERLONG 0
#endif

#ifndef WASM_ENABLE_BRANCH_HINTS
#define WASM_ENABLE_BRANCH_HINTS 0
#endif
Expand Down
23 changes: 20 additions & 3 deletions core/iwasm/compilation/aot_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,8 +1236,8 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
uint32 tbl_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);
}
else {
Expand Down Expand Up @@ -2462,6 +2462,14 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
UINT8_MAX */
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_OP_MEMORY_INIT <= opcode
&& opcode <= WASM_OP_MEMORY_FILL
Expand Down Expand Up @@ -2530,6 +2538,8 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
return false;
break;
}
#endif /* WASM_ENABLE_BULK_MEMORY */
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
case WASM_OP_MEMORY_COPY:
{
frame_ip += 2;
Expand All @@ -2544,7 +2554,7 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
return false;
break;
}
#endif /* WASM_ENABLE_BULK_MEMORY */
#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
case WASM_OP_TABLE_INIT:
{
Expand Down Expand Up @@ -3971,6 +3981,13 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
return false;
#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
unsupport_bulk_memory:
aot_set_last_error("bulk memory instruction was found, "
Expand Down
6 changes: 4 additions & 2 deletions core/iwasm/compilation/aot_emit_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
return false;
}

#if WASM_ENABLE_BULK_MEMORY != 0 || WASM_ENABLE_STRINGREF != 0
#if WASM_ENABLE_BULK_MEMORY_OPT != 0 || WASM_ENABLE_STRINGREF != 0
LLVMValueRef
check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
LLVMValueRef offset, LLVMValueRef bytes)
Expand Down Expand Up @@ -1769,7 +1769,9 @@ aot_compile_op_data_drop(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
fail:
return false;
}
#endif /* end of WASM_ENABLE_BULK_MEMORY */

#if WASM_ENABLE_BULK_MEMORY_OPT != 0
bool
aot_compile_op_memory_copy(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
{
Expand Down Expand Up @@ -1931,7 +1933,7 @@ aot_compile_op_memory_fill(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
fail:
return false;
}
#endif /* end of WASM_ENABLE_BULK_MEMORY */
#endif /* end of WASM_ENABLE_BULK_MEMORY_OPT */

#if WASM_ENABLE_SHARED_MEMORY != 0
bool
Expand Down
2 changes: 2 additions & 0 deletions core/iwasm/compilation/aot_emit_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ aot_compile_op_memory_init(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
bool
aot_compile_op_data_drop(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
uint32 seg_index);
#endif

#if WASM_ENABLE_BULK_MEMORY_OPT != 0
bool
aot_compile_op_memory_copy(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);

Expand Down
12 changes: 11 additions & 1 deletion core/iwasm/compilation/aot_llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
if (option->enable_bulk_memory)
comp_ctx->enable_bulk_memory = true;

if (option->enable_bulk_memory_opt)
comp_ctx->enable_bulk_memory_opt = true;

if (option->enable_thread_mgr)
comp_ctx->enable_thread_mgr = true;

Expand All @@ -2740,6 +2743,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
if (option->enable_ref_types)
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->call_stack_features = option->call_stack_features;

Expand Down Expand Up @@ -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
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) {
aot_set_last_error("ref-types instruction was found, "
"try removing --disable-ref-types option "
Expand All @@ -3338,9 +3344,13 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
}
if (!wasm_module->is_ref_types_used) {
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) {
option->enable_bulk_memory = comp_ctx->enable_bulk_memory = false;
option->enable_bulk_memory_opt = comp_ctx->enable_bulk_memory_opt =
false;
}
#endif

Expand Down
7 changes: 7 additions & 0 deletions core/iwasm/compilation/aot_llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ typedef struct AOTCompContext {
/* Bulk memory feature */
bool enable_bulk_memory;

/* Bulk memory opt feature. will be enabled alongside the
* enable_bulk_memory */
bool enable_bulk_memory_opt;

/* Boundary Check */
bool enable_bound_check;

Expand Down Expand Up @@ -452,6 +456,9 @@ typedef struct AOTCompContext {
/* Reference 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 */
bool disable_llvm_intrinsics;

Expand Down
2 changes: 2 additions & 0 deletions core/iwasm/fast-jit/fe/jit_emit_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,9 @@ jit_compile_op_data_drop(JitCompContext *cc, uint32 seg_idx)
return jit_emit_callnative(cc, wasm_data_drop, 0, args,
sizeof(args) / sizeof(args[0]));
}
#endif

#if WASM_ENABLE_BULK_MEMORY_OPT != 0
static int
wasm_copy_memory(WASMModuleInstance *inst, uint32 src_mem_idx,
uint32 dst_mem_idx, uint32 len, uint32 src_offset,
Expand Down
2 changes: 2 additions & 0 deletions core/iwasm/fast-jit/fe/jit_emit_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ jit_compile_op_memory_init(JitCompContext *cc, uint32 mem_idx, uint32 seg_idx);

bool
jit_compile_op_data_drop(JitCompContext *cc, uint32 seg_idx);
#endif

#if WASM_ENABLE_BULK_MEMORY_OPT != 0
bool
jit_compile_op_memory_copy(JitCompContext *cc, uint32 src_mem_idx,
uint32 dst_mem_idx);
Expand Down
6 changes: 4 additions & 2 deletions core/iwasm/fast-jit/jit_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ jit_compile_func(JitCompContext *cc)

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);
#else
frame_ip++;
Expand Down Expand Up @@ -2336,6 +2336,8 @@ jit_compile_func(JitCompContext *cc)
return false;
break;
}
#endif /* WASM_ENABLE_BULK_MEMORY */
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
case WASM_OP_MEMORY_COPY:
{
uint32 src_mem_idx, dst_mem_idx;
Expand All @@ -2353,7 +2355,7 @@ jit_compile_func(JitCompContext *cc)
return false;
break;
}
#endif /* WASM_ENABLE_BULK_MEMORY */
#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
#if WASM_ENABLE_REF_TYPES != 0
case WASM_OP_TABLE_INIT:
{
Expand Down
3 changes: 3 additions & 0 deletions core/iwasm/include/aot_comp_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ typedef struct AOTCompOption {
char *cpu_features;
bool is_sgx_platform;
bool enable_bulk_memory;
bool enable_bulk_memory_opt;
bool enable_thread_mgr;
bool enable_tail_call;
bool enable_simd;
bool enable_ref_types;
bool enable_call_indirect_overlong;
bool enable_gc;
bool enable_aux_stack_check;
bool enable_extended_const;
bool enable_lime1;
AOTStackFrameType aux_stack_frame_type;
AOTCallStackFeatures call_stack_features;
bool enable_perf_profiling;
Expand Down
10 changes: 6 additions & 4 deletions core/iwasm/interpreter/wasm_interp_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
WASMMemoryInstance *memory = wasm_get_default_memory(module);
#if !defined(OS_ENABLE_HW_BOUND_CHECK) \
|| WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
|| WASM_ENABLE_BULK_MEMORY != 0
|| WASM_ENABLE_BULK_MEMORY_OPT != 0
uint64 linear_mem_size = 0;
if (memory)
#if WASM_ENABLE_THREAD_MGR == 0
Expand Down Expand Up @@ -2370,7 +2370,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
cur_type = wasm_types[tidx];

/* 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);
#else
frame_ip++;
Expand Down Expand Up @@ -5774,6 +5774,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
segment);
break;
}
#endif /* WASM_ENABLE_BULK_MEMORY */
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
case WASM_OP_MEMORY_COPY:
{
mem_offset_t dst, src, len;
Expand Down Expand Up @@ -5894,7 +5896,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
memset(mdst, fill_val, len);
break;
}
#endif /* WASM_ENABLE_BULK_MEMORY */
#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
case WASM_OP_TABLE_INIT:
{
Expand Down Expand Up @@ -6879,7 +6881,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,

#if !defined(OS_ENABLE_HW_BOUND_CHECK) \
|| WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \
|| WASM_ENABLE_BULK_MEMORY != 0
|| WASM_ENABLE_BULK_MEMORY_OPT != 0
out_of_bounds:
wasm_set_exception(module, "out of bounds memory access");
#endif
Expand Down
Loading
Loading