Skip to content

Commit e6fe606

Browse files
authored
add micro AMR_BUILD_LIME1 to enable minimal lime1 feature set (#4571)
Signed-off-by: zhenweijin <[email protected]>
1 parent 92b065a commit e6fe606

20 files changed

+217
-37
lines changed

.github/workflows/compilation_on_android_ubuntu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ jobs:
166166
"-DWAMR_BUILD_MULTI_MEMORY=1",
167167
"-DWAMR_BUILD_SHARED=1",
168168
"-DWAMR_BUILD_EXTENDED_CONST_EXPR=1",
169+
"-DWAMR_BUILD_LIME1=1 -DWAMR_BUILD_BULK_MEMORY=0 -DWAMR_BUILD_REF_TYPES=0 -DWAMR_BUILD_SIMD=0",
169170
]
170171
os: [ubuntu-22.04]
171172
platform: [android, linux]

build-scripts/config_common.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
221221
set (WAMR_BUILD_BULK_MEMORY 1)
222222
endif ()
223223

224+
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY_OPT)
225+
set (WAMR_BUILD_BULK_MEMORY_OPT 0)
226+
endif ()
227+
228+
if (NOT DEFINED WAMR_BUILD_CALL_INDIRECT_OVERLONG)
229+
set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 0)
230+
endif ()
231+
224232
if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
225233
set (WAMR_BUILD_EXCE_HANDLING 0)
226234
endif ()
@@ -253,10 +261,27 @@ if (NOT DEFINED WAMR_BUILD_EXTENDED_CONST_EXPR)
253261
set (WAMR_BUILD_EXTENDED_CONST_EXPR 0)
254262
endif ()
255263

264+
if (NOT DEFINED WAMR_BUILD_LIME1)
265+
set (WAMR_BUILD_LIME1 0)
266+
endif ()
267+
256268
########################################
257269
# Compilation options to marco
258270
########################################
259271

272+
if (WAMR_BUILD_LIME1 EQUAL 1)
273+
set (WAMR_BUILD_BULK_MEMORY_OPT 1)
274+
set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 1)
275+
set (WAMR_BUILD_EXTENDED_CONST_EXPR 1)
276+
endif ()
277+
278+
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
279+
set (WAMR_BUILD_BULK_MEMORY_OPT 1)
280+
endif ()
281+
if (WAMR_BUILD_REF_TYPES EQUAL 1)
282+
set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 1)
283+
endif ()
284+
260285
message ("-- Build Configurations:")
261286
message (" Build as target ${WAMR_BUILD_TARGET}")
262287
message (" Build for platform ${WAMR_BUILD_PLATFORM}")
@@ -366,6 +391,11 @@ if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
366391
else ()
367392
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
368393
endif ()
394+
if (WAMR_BUILD_BULK_MEMORY_OPT EQUAL 1)
395+
add_definitions (-DWASM_ENABLE_BULK_MEMORY_OPT=1)
396+
else()
397+
add_definitions (-DWASM_ENABLE_BULK_MEMORY_OPT=0)
398+
endif ()
369399
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
370400
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
371401
message (" Shared memory enabled")
@@ -457,6 +487,11 @@ endif ()
457487
if (WAMR_BUILD_REF_TYPES EQUAL 1)
458488
add_definitions (-DWASM_ENABLE_REF_TYPES=1)
459489
endif ()
490+
if (WAMR_BUILD_CALL_INDIRECT_OVERLONG EQUAL 1)
491+
add_definitions (-DWASM_ENABLE_CALL_INDIRECT_OVERLONG=1)
492+
else ()
493+
add_definitions(-DWASM_ENABLE_CALL_INDIRECT_OVERLONG=0)
494+
endif ()
460495
if (WAMR_BUILD_GC EQUAL 1)
461496
if (WAMR_TEST_GC EQUAL 1)
462497
message(" GC testing enabled")
@@ -727,6 +762,9 @@ else()
727762
message (" Extended constant expression disabled")
728763
add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=0)
729764
endif ()
765+
if (WAMR_BUILD_LIME1 EQUAL 1)
766+
message (" Lime1 enabled")
767+
endif ()
730768
########################################
731769
# Show Phase4 Wasm proposals status.
732770
########################################
@@ -742,6 +780,8 @@ message (
742780
" \"Branch Hinting\"\n"
743781
" Configurable. 0 is OFF. 1 is ON:\n"
744782
" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
783+
" \"Bulk-memory-opt\" via WAMR_BUILD_BULK_MEMORY_OPT: ${WAMR_BUILD_BULK_MEMORY_OPT}\n"
784+
" \"Call-indirect-overlong\" via WAMR_BUILD_CALL_INDIRECT_OVERLONG: ${WAMR_BUILD_CALL_INDIRECT_OVERLONG}\n"
745785
" \"Extended Constant Expressions\" via WAMR_BUILD_EXTENDED_CONST_EXPR: ${WAMR_BUILD_EXTENDED_CONST_EXPR}\n"
746786
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
747787
" \"Garbage Collection\" via WAMR_BUILD_GC: ${WAMR_BUILD_GC}\n"

core/config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@
214214
#define WASM_ENABLE_BULK_MEMORY 0
215215
#endif
216216

217+
#ifndef WASM_ENABLE_BULK_MEMORY_OPT
218+
#define WASM_ENABLE_BULK_MEMORY_OPT 0
219+
#endif
220+
217221
/* Shared memory */
218222
#ifndef WASM_ENABLE_SHARED_MEMORY
219223
#define WASM_ENABLE_SHARED_MEMORY 0
@@ -579,6 +583,10 @@ unless used elsewhere */
579583
#define WASM_ENABLE_REF_TYPES 0
580584
#endif
581585

586+
#ifndef WASM_ENABLE_CALL_INDIRECT_OVERLONG
587+
#define WASM_ENABLE_CALL_INDIRECT_OVERLONG 0
588+
#endif
589+
582590
#ifndef WASM_ENABLE_BRANCH_HINTS
583591
#define WASM_ENABLE_BRANCH_HINTS 0
584592
#endif

core/iwasm/compilation/aot_compiler.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,8 +1236,8 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
12361236
uint32 tbl_idx;
12371237

12381238
read_leb_uint32(frame_ip, frame_ip_end, type_idx);
1239-
1240-
if (comp_ctx->enable_gc || comp_ctx->enable_ref_types) {
1239+
if (comp_ctx->enable_gc
1240+
|| comp_ctx->enable_call_indirect_overlong) {
12411241
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
12421242
}
12431243
else {
@@ -2462,6 +2462,14 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
24622462
UINT8_MAX */
24632463
opcode = (uint8)opcode1;
24642464

2465+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
2466+
if (WASM_OP_MEMORY_COPY <= opcode
2467+
&& opcode <= WASM_OP_MEMORY_FILL
2468+
&& !comp_ctx->enable_bulk_memory_opt) {
2469+
goto unsupport_bulk_memory_opt;
2470+
}
2471+
#endif
2472+
24652473
#if WASM_ENABLE_BULK_MEMORY != 0
24662474
if (WASM_OP_MEMORY_INIT <= opcode
24672475
&& opcode <= WASM_OP_MEMORY_FILL
@@ -2530,6 +2538,8 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
25302538
return false;
25312539
break;
25322540
}
2541+
#endif /* WASM_ENABLE_BULK_MEMORY */
2542+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
25332543
case WASM_OP_MEMORY_COPY:
25342544
{
25352545
frame_ip += 2;
@@ -2544,7 +2554,7 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
25442554
return false;
25452555
break;
25462556
}
2547-
#endif /* WASM_ENABLE_BULK_MEMORY */
2557+
#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
25482558
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
25492559
case WASM_OP_TABLE_INIT:
25502560
{
@@ -3971,6 +3981,13 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
39713981
return false;
39723982
#endif
39733983

3984+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
3985+
unsupport_bulk_memory_opt:
3986+
aot_set_last_error("bulk memory opt instruction was found, "
3987+
"try enabling bulk-memory-opt or bulk-memory option");
3988+
return false;
3989+
#endif
3990+
39743991
#if WASM_ENABLE_BULK_MEMORY != 0
39753992
unsupport_bulk_memory:
39763993
aot_set_last_error("bulk memory instruction was found, "

core/iwasm/compilation/aot_emit_memory.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
14811481
return false;
14821482
}
14831483

1484-
#if WASM_ENABLE_BULK_MEMORY != 0 || WASM_ENABLE_STRINGREF != 0
1484+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0 || WASM_ENABLE_STRINGREF != 0
14851485
LLVMValueRef
14861486
check_bulk_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
14871487
LLVMValueRef offset, LLVMValueRef bytes)
@@ -1769,7 +1769,9 @@ aot_compile_op_data_drop(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
17691769
fail:
17701770
return false;
17711771
}
1772+
#endif /* end of WASM_ENABLE_BULK_MEMORY */
17721773

1774+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
17731775
bool
17741776
aot_compile_op_memory_copy(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
17751777
{
@@ -1931,7 +1933,7 @@ aot_compile_op_memory_fill(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
19311933
fail:
19321934
return false;
19331935
}
1934-
#endif /* end of WASM_ENABLE_BULK_MEMORY */
1936+
#endif /* end of WASM_ENABLE_BULK_MEMORY_OPT */
19351937

19361938
#if WASM_ENABLE_SHARED_MEMORY != 0
19371939
bool

core/iwasm/compilation/aot_emit_memory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ aot_compile_op_memory_init(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
7878
bool
7979
aot_compile_op_data_drop(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
8080
uint32 seg_index);
81+
#endif
8182

83+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
8284
bool
8385
aot_compile_op_memory_copy(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
8486

core/iwasm/compilation/aot_llvm.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2731,6 +2731,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
27312731
if (option->enable_bulk_memory)
27322732
comp_ctx->enable_bulk_memory = true;
27332733

2734+
if (option->enable_bulk_memory_opt)
2735+
comp_ctx->enable_bulk_memory_opt = true;
2736+
27342737
if (option->enable_thread_mgr)
27352738
comp_ctx->enable_thread_mgr = true;
27362739

@@ -2740,6 +2743,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
27402743
if (option->enable_ref_types)
27412744
comp_ctx->enable_ref_types = true;
27422745

2746+
if (option->enable_call_indirect_overlong)
2747+
comp_ctx->enable_call_indirect_overlong = true;
2748+
27432749
comp_ctx->aux_stack_frame_type = option->aux_stack_frame_type;
27442750
comp_ctx->call_stack_features = option->call_stack_features;
27452751

@@ -3324,7 +3330,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
33243330

33253331
/* Return error if ref-types and GC are disabled by command line but
33263332
ref-types instructions are used */
3327-
if (!option->enable_ref_types && !option->enable_gc
3333+
if (!option->enable_call_indirect_overlong && !option->enable_gc
33283334
&& wasm_module->is_ref_types_used) {
33293335
aot_set_last_error("ref-types instruction was found, "
33303336
"try removing --disable-ref-types option "
@@ -3338,9 +3344,13 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
33383344
}
33393345
if (!wasm_module->is_ref_types_used) {
33403346
option->enable_ref_types = comp_ctx->enable_ref_types = false;
3347+
option->enable_call_indirect_overlong =
3348+
comp_ctx->enable_call_indirect_overlong = false;
33413349
}
33423350
if (!wasm_module->is_bulk_memory_used) {
33433351
option->enable_bulk_memory = comp_ctx->enable_bulk_memory = false;
3352+
option->enable_bulk_memory_opt = comp_ctx->enable_bulk_memory_opt =
3353+
false;
33443354
}
33453355
#endif
33463356

core/iwasm/compilation/aot_llvm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ typedef struct AOTCompContext {
416416
/* Bulk memory feature */
417417
bool enable_bulk_memory;
418418

419+
/* Bulk memory opt feature. will be enabled alongside the
420+
* enable_bulk_memory */
421+
bool enable_bulk_memory_opt;
422+
419423
/* Boundary Check */
420424
bool enable_bound_check;
421425

@@ -452,6 +456,9 @@ typedef struct AOTCompContext {
452456
/* Reference Types */
453457
bool enable_ref_types;
454458

459+
/* Call Indirect Overlong. will be enabled alongside the enable_ref_types */
460+
bool enable_call_indirect_overlong;
461+
455462
/* Disable LLVM built-in intrinsics */
456463
bool disable_llvm_intrinsics;
457464

core/iwasm/fast-jit/fe/jit_emit_memory.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,9 @@ jit_compile_op_data_drop(JitCompContext *cc, uint32 seg_idx)
713713
return jit_emit_callnative(cc, wasm_data_drop, 0, args,
714714
sizeof(args) / sizeof(args[0]));
715715
}
716+
#endif
716717

718+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
717719
static int
718720
wasm_copy_memory(WASMModuleInstance *inst, uint32 src_mem_idx,
719721
uint32 dst_mem_idx, uint32 len, uint32 src_offset,

core/iwasm/fast-jit/fe/jit_emit_memory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ jit_compile_op_memory_init(JitCompContext *cc, uint32 mem_idx, uint32 seg_idx);
5555

5656
bool
5757
jit_compile_op_data_drop(JitCompContext *cc, uint32 seg_idx);
58+
#endif
5859

60+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
5961
bool
6062
jit_compile_op_memory_copy(JitCompContext *cc, uint32 src_mem_idx,
6163
uint32 dst_mem_idx);

0 commit comments

Comments
 (0)