Skip to content

Commit 719e267

Browse files
committed
add micro AMR_BUILD_LIME1 to enable minimal lime1 feature set
Signed-off-by: zhenweijin <[email protected]>
1 parent 14ced7c commit 719e267

18 files changed

+205
-36
lines changed

build-scripts/config_common.cmake

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ if (NOT DEFINED WAMR_BUILD_BULK_MEMORY)
219219
set (WAMR_BUILD_BULK_MEMORY 1)
220220
endif ()
221221

222+
if (NOT DEFINED WAMR_BUILD_BULK_MEMORY_OPT)
223+
set (WAMR_BUILD_BULK_MEMORY_OPT 0)
224+
endif ()
225+
226+
if (NOT DEFINED WAMR_BUILD_CALL_INDIRECT_OVERLONG)
227+
set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 0)
228+
endif ()
229+
222230
if (NOT DEFINED WAMR_BUILD_EXCE_HANDLING)
223231
set (WAMR_BUILD_EXCE_HANDLING 0)
224232
endif ()
@@ -251,10 +259,30 @@ if (NOT DEFINED WAMR_BUILD_EXTENDED_CONST_EXPR)
251259
set (WAMR_BUILD_EXTENDED_CONST_EXPR 0)
252260
endif ()
253261

262+
if (NOT DEFINED WAMR_BUILD_LIME1)
263+
set (WAMR_BUILD_LIME1 0)
264+
endif ()
265+
254266
########################################
255267
# Compilation options to marco
256268
########################################
257269

270+
if (WAMR_BUILD_LIME1 EQUAL 1)
271+
set (WAMR_BUILD_BULK_MEMORY 0)
272+
set (WAMR_BUILD_BULK_MEMORY_OPT 1)
273+
set (WAMR_BUILD_REF_TYPES 0)
274+
set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 1)
275+
set (WAMR_BUILD_EXTENDED_CONST_EXPR 1)
276+
set (WAMR_BUILD_SIMD 0)
277+
endif ()
278+
279+
if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
280+
set (WAMR_BUILD_BULK_MEMORY_OPT 1)
281+
endif ()
282+
if (WAMR_BUILD_REF_TYPES EQUAL 1)
283+
set (WAMR_BUILD_CALL_INDIRECT_OVERLONG 1)
284+
endif ()
285+
258286
message ("-- Build Configurations:")
259287
message (" Build as target ${WAMR_BUILD_TARGET}")
260288
message (" Build for platform ${WAMR_BUILD_PLATFORM}")
@@ -364,6 +392,11 @@ if (WAMR_BUILD_BULK_MEMORY EQUAL 1)
364392
else ()
365393
add_definitions (-DWASM_ENABLE_BULK_MEMORY=0)
366394
endif ()
395+
if (WAMR_BUILD_BULK_MEMORY_OPT EQUAL 1)
396+
add_definitions (-DWASM_ENABLE_BULK_MEMORY_OPT=1)
397+
else()
398+
add_definitions (-DWASM_ENABLE_BULK_MEMORY_OPT=0)
399+
endif ()
367400
if (WAMR_BUILD_SHARED_MEMORY EQUAL 1)
368401
add_definitions (-DWASM_ENABLE_SHARED_MEMORY=1)
369402
message (" Shared memory enabled")
@@ -455,6 +488,11 @@ endif ()
455488
if (WAMR_BUILD_REF_TYPES EQUAL 1)
456489
add_definitions (-DWASM_ENABLE_REF_TYPES=1)
457490
endif ()
491+
if (WAMR_BUILD_CALL_INDIRECT_OVERLONG EQUAL 1)
492+
add_definitions (-DWASM_ENABLE_CALL_INDIRECT_OVERLONG=1)
493+
else ()
494+
add_definitions(-DWASM_ENABLE_CALL_INDIRECT_OVERLONG=0)
495+
endif ()
458496
if (WAMR_BUILD_GC EQUAL 1)
459497
if (WAMR_TEST_GC EQUAL 1)
460498
message(" GC testing enabled")
@@ -725,6 +763,9 @@ else()
725763
message (" Extended constant expression disabled")
726764
add_definitions(-DWASM_ENABLE_EXTENDED_CONST_EXPR=0)
727765
endif ()
766+
if (WAMR_BUILD_LIME1 EQUAL 1)
767+
message (" Lime1 enabled")
768+
endif ()
728769
########################################
729770
# Show Phase4 Wasm proposals status.
730771
########################################
@@ -738,6 +779,8 @@ message (
738779
" \"WebAssembly C and C++ API\"\n"
739780
" Configurable. 0 is OFF. 1 is ON:\n"
740781
" \"Bulk Memory Operation\" via WAMR_BUILD_BULK_MEMORY: ${WAMR_BUILD_BULK_MEMORY}\n"
782+
" \"Bulk-memory-opt\" via WAMR_BUILD_BULK_MEMORY_OPT: ${WAMR_BUILD_BULK_MEMORY_OPT}\n"
783+
" \"Call-indirect-overlong\" via WAMR_BUILD_CALL_INDIRECT_OVERLONG: ${WAMR_BUILD_CALL_INDIRECT_OVERLONG}\n"
741784
" \"Extended Constant Expressions\" via WAMR_BUILD_EXTENDED_CONST_EXPR: ${WAMR_BUILD_EXTENDED_CONST_EXPR}\n"
742785
" \"Fixed-width SIMD\" via WAMR_BUILD_SIMD: ${WAMR_BUILD_SIMD}\n"
743786
" \"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_GC
583591
#define WASM_ENABLE_GC 0
584592
#endif

core/iwasm/compilation/aot_compiler.c

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

12401240
read_leb_uint32(frame_ip, frame_ip_end, type_idx);
1241-
1242-
if (comp_ctx->enable_gc || comp_ctx->enable_ref_types) {
1241+
if (comp_ctx->enable_gc || comp_ctx->enable_ref_types
1242+
|| comp_ctx->enable_call_indirect_overlong) {
12431243
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
12441244
}
12451245
else {
@@ -2464,6 +2464,14 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
24642464
UINT8_MAX */
24652465
opcode = (uint8)opcode1;
24662466

2467+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
2468+
if (WASM_OP_MEMORY_COPY <= opcode
2469+
&& opcode <= WASM_OP_MEMORY_FILL
2470+
&& !comp_ctx->enable_bulk_memory_opt) {
2471+
goto unsupport_bulk_memory_opt;
2472+
}
2473+
#endif
2474+
24672475
#if WASM_ENABLE_BULK_MEMORY != 0
24682476
if (WASM_OP_MEMORY_INIT <= opcode
24692477
&& opcode <= WASM_OP_MEMORY_FILL
@@ -2532,6 +2540,8 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
25322540
return false;
25332541
break;
25342542
}
2543+
#endif /* WASM_ENABLE_BULK_MEMORY */
2544+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
25352545
case WASM_OP_MEMORY_COPY:
25362546
{
25372547
frame_ip += 2;
@@ -2546,7 +2556,7 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
25462556
return false;
25472557
break;
25482558
}
2549-
#endif /* WASM_ENABLE_BULK_MEMORY */
2559+
#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
25502560
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
25512561
case WASM_OP_TABLE_INIT:
25522562
{
@@ -3973,6 +3983,13 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
39733983
return false;
39743984
#endif
39753985

3986+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
3987+
unsupport_bulk_memory_opt:
3988+
aot_set_last_error("bulk memory opt instruction was found, "
3989+
"try enabling bulk-memory-opt or bulk-memory option");
3990+
return false;
3991+
#endif
3992+
39763993
#if WASM_ENABLE_BULK_MEMORY != 0
39773994
unsupport_bulk_memory:
39783995
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,6 +2724,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
27242724
if (option->enable_bulk_memory)
27252725
comp_ctx->enable_bulk_memory = true;
27262726

2727+
if (option->enable_bulk_memory_opt)
2728+
comp_ctx->enable_bulk_memory_opt = true;
2729+
27272730
if (option->enable_thread_mgr)
27282731
comp_ctx->enable_thread_mgr = true;
27292732

@@ -2733,6 +2736,9 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
27332736
if (option->enable_ref_types)
27342737
comp_ctx->enable_ref_types = true;
27352738

2739+
if (option->enable_call_indirect_overlong)
2740+
comp_ctx->enable_call_indirect_overlong = true;
2741+
27362742
comp_ctx->aux_stack_frame_type = option->aux_stack_frame_type;
27372743
comp_ctx->call_stack_features = option->call_stack_features;
27382744

@@ -3318,6 +3324,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
33183324
/* Return error if ref-types and GC are disabled by command line but
33193325
ref-types instructions are used */
33203326
if (!option->enable_ref_types && !option->enable_gc
3327+
&& !option->enable_call_indirect_overlong
33213328
&& wasm_module->is_ref_types_used) {
33223329
aot_set_last_error("ref-types instruction was found, "
33233330
"try removing --disable-ref-types option "
@@ -3331,9 +3338,13 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
33313338
}
33323339
if (!wasm_module->is_ref_types_used) {
33333340
option->enable_ref_types = comp_ctx->enable_ref_types = false;
3341+
option->enable_call_indirect_overlong =
3342+
comp_ctx->enable_call_indirect_overlong = false;
33343343
}
33353344
if (!wasm_module->is_bulk_memory_used) {
33363345
option->enable_bulk_memory = comp_ctx->enable_bulk_memory = false;
3346+
option->enable_bulk_memory_opt = comp_ctx->enable_bulk_memory_opt =
3347+
false;
33373348
}
33383349
#endif
33393350

core/iwasm/compilation/aot_llvm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ typedef struct AOTCompContext {
413413
/* Bulk memory feature */
414414
bool enable_bulk_memory;
415415

416+
/* Bulk memory opt feature */
417+
bool enable_bulk_memory_opt;
418+
416419
/* Boundary Check */
417420
bool enable_bound_check;
418421

@@ -449,6 +452,9 @@ typedef struct AOTCompContext {
449452
/* Reference Types */
450453
bool enable_ref_types;
451454

455+
/* Call Indirect Overlong */
456+
bool enable_call_indirect_overlong;
457+
452458
/* Disable LLVM built-in intrinsics */
453459
bool disable_llvm_intrinsics;
454460

@@ -464,6 +470,9 @@ typedef struct AOTCompContext {
464470
/* Enable extended constant expression */
465471
bool enable_extended_const;
466472

473+
/* Enable Lime1 */
474+
bool enable_lime1;
475+
467476
/* Treat unknown import function as wasm-c-api import function
468477
and allow to directly invoke it from AOT/JIT code */
469478
bool quick_invoke_c_api_import;

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);

core/iwasm/fast-jit/jit_frontend.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ jit_compile_func(JitCompContext *cc)
16271627

16281628
read_leb_uint32(frame_ip, frame_ip_end, type_idx);
16291629

1630-
#if WASM_ENABLE_REF_TYPES != 0
1630+
#if WASM_ENABLE_CALL_INDIRECT_OVERLONG != 0
16311631
read_leb_uint32(frame_ip, frame_ip_end, tbl_idx);
16321632
#else
16331633
frame_ip++;
@@ -2336,6 +2336,8 @@ jit_compile_func(JitCompContext *cc)
23362336
return false;
23372337
break;
23382338
}
2339+
#endif /* WASM_ENABLE_BULK_MEMORY */
2340+
#if WASM_ENABLE_BULK_MEMORY_OPT != 0
23392341
case WASM_OP_MEMORY_COPY:
23402342
{
23412343
uint32 src_mem_idx, dst_mem_idx;
@@ -2353,7 +2355,7 @@ jit_compile_func(JitCompContext *cc)
23532355
return false;
23542356
break;
23552357
}
2356-
#endif /* WASM_ENABLE_BULK_MEMORY */
2358+
#endif /* WASM_ENABLE_BULK_MEMORY_OPT */
23572359
#if WASM_ENABLE_REF_TYPES != 0
23582360
case WASM_OP_TABLE_INIT:
23592361
{

0 commit comments

Comments
 (0)