mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-16 09:18:29 +00:00
Merge main into dev/gc
This commit is contained in:
commit
ec107a32b7
|
@ -106,6 +106,28 @@ read_leb(const uint8 *buf, const uint8 *buf_end, uint32 *p_offset,
|
|||
res = (int64)res64; \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Since Wamrc uses a full feature Wasm loader,
|
||||
* add a post-validator here to run checks according
|
||||
* to options, like enable_tail_call, enable_ref_types,
|
||||
* and so on.
|
||||
*/
|
||||
static bool
|
||||
aot_validate_wasm(AOTCompContext *comp_ctx)
|
||||
{
|
||||
if (!comp_ctx->enable_ref_types) {
|
||||
/* Doesn't support multiple tables unless enabling reference type */
|
||||
if (comp_ctx->comp_data->import_table_count
|
||||
+ comp_ctx->comp_data->table_count
|
||||
> 1) {
|
||||
aot_set_last_error("multiple tables");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define COMPILE_ATOMIC_RMW(OP, NAME) \
|
||||
case WASM_OP_ATOMIC_RMW_I32_##NAME: \
|
||||
bytes = 4; \
|
||||
|
@ -977,7 +999,13 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
|
|||
read_leb_uint32(frame_ip, frame_ip_end, opcode1);
|
||||
opcode = (uint32)opcode1;
|
||||
|
||||
/* TODO: --enable-bulk-memory ? */
|
||||
#if WASM_ENABLE_BULK_MEMORY != 0
|
||||
if (WASM_OP_MEMORY_INIT <= opcode
|
||||
&& opcode <= WASM_OP_MEMORY_FILL
|
||||
&& !comp_ctx->enable_bulk_memory) {
|
||||
goto unsupport_bulk_memory;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (WASM_OP_TABLE_INIT <= opcode && opcode <= WASM_OP_TABLE_FILL
|
||||
|
@ -2458,7 +2486,7 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
|
|||
}
|
||||
|
||||
default:
|
||||
aot_set_last_error("unsupported opcode");
|
||||
aot_set_last_error("unsupported SIMD opcode");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -2489,14 +2517,21 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
|
|||
#if WASM_ENABLE_SIMD != 0
|
||||
unsupport_simd:
|
||||
aot_set_last_error("SIMD instruction was found, "
|
||||
"try adding --enable-simd option?");
|
||||
"try removing --disable-simd option");
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
unsupport_ref_types:
|
||||
aot_set_last_error("reference type instruction was found, "
|
||||
"try adding --enable-ref-types option?");
|
||||
"try removing --disable-ref-types option");
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_BULK_MEMORY != 0
|
||||
unsupport_bulk_memory:
|
||||
aot_set_last_error("bulk memory instruction was found, "
|
||||
"try removing --disable-bulk-memory option");
|
||||
return false;
|
||||
#endif
|
||||
|
||||
|
@ -2511,6 +2546,10 @@ aot_compile_wasm(AOTCompContext *comp_ctx)
|
|||
bool ret;
|
||||
uint32 i;
|
||||
|
||||
if (!aot_validate_wasm(comp_ctx)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bh_print_time("Begin to compile WASM bytecode to LLVM IR");
|
||||
|
||||
for (i = 0; i < comp_ctx->func_ctx_count; i++)
|
||||
|
@ -2637,11 +2676,6 @@ aot_emit_object_file(AOTCompContext *comp_ctx, char *file_name)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
extern void
|
||||
wasm_set_ref_types_flag(bool enable);
|
||||
#endif
|
||||
|
||||
typedef struct AOTFileMap {
|
||||
uint8 *wasm_file_buf;
|
||||
uint32 wasm_file_size;
|
||||
|
@ -2744,10 +2778,6 @@ aot_compile_wasm_file(const uint8 *wasm_file_buf, uint32 wasm_file_size,
|
|||
option.enable_aux_stack_frame = true;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
wasm_set_ref_types_flag(option.enable_ref_types);
|
||||
#endif
|
||||
|
||||
memset(&init_args, 0, sizeof(RuntimeInitArgs));
|
||||
|
||||
init_args.mem_alloc_type = Alloc_With_Allocator;
|
||||
|
|
|
@ -218,16 +218,11 @@ type2str(uint8 type)
|
|||
static bool
|
||||
is_32bit_type(uint8 type)
|
||||
{
|
||||
if (type == VALUE_TYPE_I32
|
||||
|| type == VALUE_TYPE_F32
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
/* TODO: refactor the implementation of reference types feature,
|
||||
funcref and externref are 32-bit only when the system is
|
||||
32-bit */
|
||||
|| (wasm_get_ref_types_flag() /* && sizeof(uintptr_t) == 4 */
|
||||
&& (type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF))
|
||||
#elif WASM_ENABLE_GC != 0
|
||||
if (type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32
|
||||
#if WASM_ENABLE_GC != 0
|
||||
|| (sizeof(uintptr_t) == 4 && wasm_is_type_reftype(type))
|
||||
#elif WASM_ENABLE_REF_TYPES != 0
|
||||
|| (type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF)
|
||||
#endif
|
||||
)
|
||||
return true;
|
||||
|
@ -264,8 +259,7 @@ is_value_type(uint8 type)
|
|||
|| wasm_is_type_reftype(type)
|
||||
#endif
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
|| (wasm_get_ref_types_flag()
|
||||
&& (type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF))
|
||||
|| type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF
|
||||
#endif
|
||||
#if WASM_ENABLE_SIMD != 0
|
||||
#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0)
|
||||
|
@ -518,10 +512,6 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end,
|
|||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
case INIT_EXPR_TYPE_FUNCREF_CONST:
|
||||
{
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto illegal_opcode;
|
||||
}
|
||||
|
||||
if (type != VALUE_TYPE_FUNCREF)
|
||||
goto fail_type_mismatch;
|
||||
read_leb_uint32(p, p_end, init_expr->u.ref_index);
|
||||
|
@ -531,10 +521,6 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end,
|
|||
{
|
||||
uint8 reftype;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto illegal_opcode;
|
||||
}
|
||||
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
reftype = read_uint8(p);
|
||||
if (reftype != type)
|
||||
|
@ -550,9 +536,6 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end,
|
|||
break;
|
||||
default:
|
||||
{
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
illegal_opcode:
|
||||
#endif
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"illegal opcode "
|
||||
"or constant expression required "
|
||||
|
@ -1793,8 +1776,7 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end,
|
|||
declare_elem_type = read_uint8(p);
|
||||
if (VALUE_TYPE_FUNCREF != declare_elem_type
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
&& (wasm_get_ref_types_flag()
|
||||
&& VALUE_TYPE_EXTERNREF != declare_elem_type)
|
||||
&& VALUE_TYPE_EXTERNREF != declare_elem_type
|
||||
#endif
|
||||
) {
|
||||
set_error_buf(error_buf, error_buf_size, "incompatible import type");
|
||||
|
@ -2091,8 +2073,7 @@ load_table(const uint8 **p_buf, const uint8 *buf_end, WASMTable *table,
|
|||
table->elem_type = read_uint8(p);
|
||||
if (VALUE_TYPE_FUNCREF != table->elem_type
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
&& (wasm_get_ref_types_flag()
|
||||
&& VALUE_TYPE_EXTERNREF != table->elem_type)
|
||||
&& VALUE_TYPE_EXTERNREF != table->elem_type
|
||||
#endif
|
||||
) {
|
||||
set_error_buf(error_buf, error_buf_size, "incompatible import type");
|
||||
|
@ -2269,16 +2250,13 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
|
|||
read_leb_uint32(p, p_end, u32);
|
||||
module->import_table_count++;
|
||||
|
||||
if (
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
!wasm_get_ref_types_flag() &&
|
||||
|
||||
#endif
|
||||
module->import_table_count > 1) {
|
||||
#if WASM_ENABLE_REF_TYPES == 0
|
||||
if (module->import_table_count > 1) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"multiple tables");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case IMPORT_KIND_MEMORY: /* import memory */
|
||||
|
@ -2589,8 +2567,8 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
|
|||
#endif
|
||||
#endif
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
&& (wasm_get_ref_types_flag() && type != VALUE_TYPE_FUNCREF
|
||||
&& type != VALUE_TYPE_EXTERNREF)
|
||||
&& type != VALUE_TYPE_FUNCREF
|
||||
&& type != VALUE_TYPE_EXTERNREF
|
||||
#endif
|
||||
) {
|
||||
if (type == VALUE_TYPE_V128)
|
||||
|
@ -2657,15 +2635,13 @@ load_table_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
|
|||
WASMTable *table;
|
||||
|
||||
read_leb_uint32(p, p_end, table_count);
|
||||
if (
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
!wasm_get_ref_types_flag() &&
|
||||
#endif
|
||||
module->import_table_count + table_count > 1) {
|
||||
#if WASM_ENABLE_REF_TYPES == 0
|
||||
if (module->import_table_count + table_count > 1) {
|
||||
/* a total of one table is allowed */
|
||||
set_error_buf(error_buf, error_buf_size, "multiple tables");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (table_count) {
|
||||
module->table_count = table_count;
|
||||
|
@ -2919,14 +2895,12 @@ static bool
|
|||
check_table_index(const WASMModule *module, uint32 table_index, char *error_buf,
|
||||
uint32 error_buf_size)
|
||||
{
|
||||
if (
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
!wasm_get_ref_types_flag() &&
|
||||
#endif
|
||||
table_index != 0) {
|
||||
#if WASM_ENABLE_REF_TYPES == 0
|
||||
if (table_index != 0) {
|
||||
set_error_buf(error_buf, error_buf_size, "zero byte expected");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (table_index >= module->import_table_count + module->table_count) {
|
||||
set_error_buf_v(error_buf, error_buf_size, "unknown table %d",
|
||||
|
@ -3005,21 +2979,15 @@ load_func_index_vec(const uint8 **p_buf, const uint8 *buf_end,
|
|||
InitializerExpression init_expr = { 0 };
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
if (!use_init_expr) {
|
||||
read_leb_uint32(p, p_end, function_index);
|
||||
}
|
||||
else {
|
||||
if (!use_init_expr) {
|
||||
read_leb_uint32(p, p_end, function_index);
|
||||
}
|
||||
else {
|
||||
if (!load_init_expr(&p, p_end, &init_expr,
|
||||
table_segment->elem_type, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(&p, p_end, &init_expr, table_segment->elem_type,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
function_index = init_expr.u.ref_index;
|
||||
}
|
||||
function_index = init_expr.u.ref_index;
|
||||
}
|
||||
#else
|
||||
read_leb_uint32(p, p_end, function_index);
|
||||
|
@ -3070,100 +3038,90 @@ load_table_segment_section(const uint8 *buf, const uint8 *buf_end,
|
|||
}
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (wasm_get_ref_types_flag()) {
|
||||
read_leb_uint32(p, p_end, table_segment->mode);
|
||||
/* last three bits */
|
||||
table_segment->mode = table_segment->mode & 0x07;
|
||||
switch (table_segment->mode) {
|
||||
/* elemkind/elemtype + active */
|
||||
case 0:
|
||||
case 4:
|
||||
table_segment->elem_type = VALUE_TYPE_FUNCREF;
|
||||
table_segment->table_index = 0;
|
||||
read_leb_uint32(p, p_end, table_segment->mode);
|
||||
/* last three bits */
|
||||
table_segment->mode = table_segment->mode & 0x07;
|
||||
switch (table_segment->mode) {
|
||||
/* elemkind/elemtype + active */
|
||||
case 0:
|
||||
case 4:
|
||||
table_segment->elem_type = VALUE_TYPE_FUNCREF;
|
||||
table_segment->table_index = 0;
|
||||
|
||||
if (!check_table_index(module,
|
||||
table_segment->table_index,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(
|
||||
&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(
|
||||
&p, p_end, module, table_segment,
|
||||
table_segment->mode == 0 ? false : true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
/* elemkind + passive/declarative */
|
||||
case 1:
|
||||
case 3:
|
||||
if (!load_elem_type(&p, p_end,
|
||||
&table_segment->elem_type, true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module,
|
||||
table_segment, false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
/* elemkind/elemtype + table_idx + active */
|
||||
case 2:
|
||||
case 6:
|
||||
if (!load_table_index(&p, p_end, module,
|
||||
&table_segment->table_index,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(
|
||||
&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_elem_type(
|
||||
&p, p_end, &table_segment->elem_type,
|
||||
table_segment->mode == 2 ? true : false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(
|
||||
&p, p_end, module, table_segment,
|
||||
table_segment->mode == 2 ? false : true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
case 5:
|
||||
case 7:
|
||||
if (!load_elem_type(&p, p_end,
|
||||
&table_segment->elem_type, false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module,
|
||||
table_segment, true, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"unknown element segment kind");
|
||||
if (!check_table_index(module, table_segment->table_index,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
}
|
||||
if (!load_init_expr(&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
table_segment->mode == 0 ? false
|
||||
: true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
/* elemkind + passive/declarative */
|
||||
case 1:
|
||||
case 3:
|
||||
if (!load_elem_type(&p, p_end, &table_segment->elem_type,
|
||||
true, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
false, error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
/* elemkind/elemtype + table_idx + active */
|
||||
case 2:
|
||||
case 6:
|
||||
if (!load_table_index(&p, p_end, module,
|
||||
&table_segment->table_index,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
if (!load_elem_type(&p, p_end, &table_segment->elem_type,
|
||||
table_segment->mode == 2 ? true : false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
table_segment->mode == 2 ? false
|
||||
: true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
case 5:
|
||||
case 7:
|
||||
if (!load_elem_type(&p, p_end, &table_segment->elem_type,
|
||||
false, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
true, error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"unknown element segment kind");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
#else
|
||||
/*
|
||||
* like: 00 41 05 0b 04 00 01 00 01
|
||||
* for: (elem 0 (offset (i32.const 5)) $f1 $f2 $f1 $f2)
|
||||
*/
|
||||
if (!load_table_index(&p, p_end, module,
|
||||
&table_segment->table_index, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment, false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
#endif /* WASM_ENABLE_REF_TYPES != 0 */
|
||||
{
|
||||
/*
|
||||
* like: 00 41 05 0b 04 00 01 00 01
|
||||
* for: (elem 0 (offset (i32.const 5)) $f1 $f2 $f1 $f2)
|
||||
*/
|
||||
if (!load_table_index(&p, p_end, module,
|
||||
&table_segment->table_index, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
false, error_buf, error_buf_size))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4435,41 +4393,21 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
|||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
case WASM_OP_SELECT_T:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
skip_leb_uint32(p, p_end); /* vec length */
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
u8 = read_uint8(p); /* typeidx */
|
||||
break;
|
||||
case WASM_OP_TABLE_GET:
|
||||
case WASM_OP_TABLE_SET:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
skip_leb_uint32(p, p_end); /* table index */
|
||||
break;
|
||||
case WASM_OP_REF_NULL:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
u8 = read_uint8(p); /* type */
|
||||
break;
|
||||
case WASM_OP_REF_IS_NULL:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case WASM_OP_REF_FUNC:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
skip_leb_uint32(p, p_end); /* func index */
|
||||
break;
|
||||
#endif /* WASM_ENABLE_REF_TYPES */
|
||||
|
@ -4774,27 +4712,18 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
|||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
case WASM_OP_TABLE_INIT:
|
||||
case WASM_OP_TABLE_COPY:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
/* tableidx */
|
||||
skip_leb_uint32(p, p_end);
|
||||
/* elemidx */
|
||||
skip_leb_uint32(p, p_end);
|
||||
break;
|
||||
case WASM_OP_ELEM_DROP:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
/* elemidx */
|
||||
skip_leb_uint32(p, p_end);
|
||||
break;
|
||||
case WASM_OP_TABLE_SIZE:
|
||||
case WASM_OP_TABLE_GROW:
|
||||
case WASM_OP_TABLE_FILL:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
skip_leb_uint32(p, p_end); /* table idx */
|
||||
break;
|
||||
#endif /* WASM_ENABLE_REF_TYPES */
|
||||
|
@ -6968,17 +6897,8 @@ get_table_seg_elem_type(const WASMModule *module, uint32 table_seg_idx,
|
|||
uint32 error_buf_size)
|
||||
{
|
||||
if (table_seg_idx >= module->table_seg_count) {
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
set_error_buf(error_buf, error_buf_size, "unknown table segment");
|
||||
}
|
||||
else {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"unknown elem segment %u", table_seg_idx);
|
||||
}
|
||||
#else
|
||||
set_error_buf(error_buf, error_buf_size, "unknown table segment");
|
||||
#endif
|
||||
set_error_buf_v(error_buf, error_buf_size, "unknown elem segment %u",
|
||||
table_seg_idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -7527,14 +7447,7 @@ re_scan:
|
|||
|
||||
read_leb_uint32(p, p_end, type_idx);
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
table_idx = read_uint8(p);
|
||||
}
|
||||
else {
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
#else
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
table_idx = read_uint8(p);
|
||||
|
@ -7790,10 +7703,6 @@ re_scan:
|
|||
{
|
||||
uint8 vec_len, ref_type;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, vec_len);
|
||||
if (!vec_len) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
|
@ -7878,10 +7787,6 @@ re_scan:
|
|||
{
|
||||
uint8 decl_ref_type;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
if (!get_table_elem_type(module, table_idx, &decl_ref_type,
|
||||
error_buf, error_buf_size))
|
||||
|
@ -7911,10 +7816,6 @@ re_scan:
|
|||
{
|
||||
uint8 ref_type;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
ref_type = read_uint8(p);
|
||||
if (ref_type != VALUE_TYPE_FUNCREF
|
||||
|
@ -7931,10 +7832,6 @@ re_scan:
|
|||
}
|
||||
case WASM_OP_REF_IS_NULL:
|
||||
{
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
if (!wasm_loader_pop_frame_ref_offset(loader_ctx,
|
||||
VALUE_TYPE_FUNCREF,
|
||||
|
@ -7958,10 +7855,6 @@ re_scan:
|
|||
}
|
||||
case WASM_OP_REF_FUNC:
|
||||
{
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, func_idx);
|
||||
|
||||
if (!check_function_index(module, func_idx, error_buf,
|
||||
|
@ -8896,10 +8789,6 @@ re_scan:
|
|||
{
|
||||
uint8 seg_ref_type = 0, tbl_ref_type = 0;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_seg_idx);
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
|
||||
|
@ -8930,10 +8819,6 @@ re_scan:
|
|||
}
|
||||
case WASM_OP_ELEM_DROP:
|
||||
{
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_seg_idx);
|
||||
if (!get_table_seg_elem_type(module, table_seg_idx,
|
||||
NULL, error_buf,
|
||||
|
@ -8949,10 +8834,6 @@ re_scan:
|
|||
uint8 src_ref_type, dst_ref_type;
|
||||
uint32 src_tbl_idx, dst_tbl_idx;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, src_tbl_idx);
|
||||
if (!get_table_elem_type(module, src_tbl_idx,
|
||||
&src_ref_type, error_buf,
|
||||
|
@ -8982,10 +8863,6 @@ re_scan:
|
|||
}
|
||||
case WASM_OP_TABLE_SIZE:
|
||||
{
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
/* TODO: shall we create a new function to check
|
||||
table idx instead of using below function? */
|
||||
|
@ -9005,10 +8882,6 @@ re_scan:
|
|||
{
|
||||
uint8 decl_ref_type;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto unsupported_opcode;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
if (!get_table_elem_type(module, table_idx,
|
||||
&decl_ref_type, error_buf,
|
||||
|
@ -9843,9 +9716,6 @@ re_scan:
|
|||
#endif /* end of WASM_ENABLE_SHARED_MEMORY */
|
||||
|
||||
default:
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
unsupported_opcode:
|
||||
#endif
|
||||
set_error_buf_v(error_buf, error_buf_size, "%s %02x",
|
||||
"unsupported opcode", opcode);
|
||||
goto fail;
|
||||
|
@ -9911,19 +9781,3 @@ fail:
|
|||
(void)align;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
static bool ref_types_flag = true;
|
||||
|
||||
void
|
||||
wasm_set_ref_types_flag(bool enable)
|
||||
{
|
||||
ref_types_flag = enable;
|
||||
}
|
||||
|
||||
bool
|
||||
wasm_get_ref_types_flag()
|
||||
{
|
||||
return ref_types_flag;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -70,14 +70,6 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
|||
uint8 block_type, uint8 **p_else_addr,
|
||||
uint8 **p_end_addr);
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
void
|
||||
wasm_set_ref_types_flag(bool enable);
|
||||
|
||||
bool
|
||||
wasm_get_ref_types_flag();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -45,8 +45,7 @@ is_32bit_type(uint8 type)
|
|||
{
|
||||
if (type == VALUE_TYPE_I32 || type == VALUE_TYPE_F32
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
|| (wasm_get_ref_types_flag()
|
||||
&& (type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF))
|
||||
|| type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF)
|
||||
#endif
|
||||
)
|
||||
return true;
|
||||
|
@ -268,10 +267,6 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end,
|
|||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
case INIT_EXPR_TYPE_FUNCREF_CONST:
|
||||
{
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bh_assert(type == VALUE_TYPE_FUNCREF);
|
||||
read_leb_uint32(p, p_end, init_expr->u.ref_index);
|
||||
break;
|
||||
|
@ -280,10 +275,6 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end,
|
|||
{
|
||||
uint8 reftype;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
reftype = read_uint8(p);
|
||||
|
||||
|
@ -459,8 +450,7 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end,
|
|||
declare_elem_type = read_uint8(p);
|
||||
bh_assert(VALUE_TYPE_FUNCREF == declare_elem_type
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
|| (wasm_get_ref_types_flag()
|
||||
&& VALUE_TYPE_EXTERNREF == declare_elem_type)
|
||||
|| VALUE_TYPE_EXTERNREF == declare_elem_type
|
||||
#endif
|
||||
);
|
||||
|
||||
|
@ -585,8 +575,7 @@ load_table(const uint8 **p_buf, const uint8 *buf_end, WASMTable *table,
|
|||
table->elem_type = read_uint8(p);
|
||||
bh_assert((VALUE_TYPE_FUNCREF == table->elem_type)
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
|| (wasm_get_ref_types_flag()
|
||||
&& VALUE_TYPE_EXTERNREF == table->elem_type)
|
||||
|| VALUE_TYPE_EXTERNREF == table->elem_type
|
||||
#endif
|
||||
);
|
||||
|
||||
|
@ -709,12 +698,9 @@ load_import_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
|
|||
if (flags & 1)
|
||||
read_leb_uint32(p, p_end, u32);
|
||||
module->import_table_count++;
|
||||
bh_assert(
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
wasm_get_ref_types_flag() ||
|
||||
#if WASM_ENABLE_REF_TYPES == 0
|
||||
bh_assert(module->import_table_count <= 1);
|
||||
#endif
|
||||
module->import_table_count <= 1);
|
||||
|
||||
break;
|
||||
|
||||
case IMPORT_KIND_MEMORY: /* import memory */
|
||||
|
@ -988,9 +974,8 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
|
|||
type = read_uint8(p_code);
|
||||
bh_assert((type >= VALUE_TYPE_F64 && type <= VALUE_TYPE_I32)
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
|| (wasm_get_ref_types_flag()
|
||||
&& (type == VALUE_TYPE_FUNCREF
|
||||
|| type == VALUE_TYPE_EXTERNREF))
|
||||
|| type == VALUE_TYPE_FUNCREF
|
||||
|| type == VALUE_TYPE_EXTERNREF
|
||||
#endif
|
||||
);
|
||||
for (k = 0; k < sub_local_count; k++) {
|
||||
|
@ -1034,11 +1019,9 @@ load_table_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
|
|||
WASMTable *table;
|
||||
|
||||
read_leb_uint32(p, p_end, table_count);
|
||||
bh_assert(
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
wasm_get_ref_types_flag() ||
|
||||
#if WASM_ENABLE_REF_TYPES == 0
|
||||
bh_assert(module->import_table_count + table_count <= 1);
|
||||
#endif
|
||||
module->import_table_count + table_count <= 1);
|
||||
|
||||
if (table_count) {
|
||||
module->table_count = table_count;
|
||||
|
@ -1234,13 +1217,11 @@ static bool
|
|||
check_table_index(const WASMModule *module, uint32 table_index, char *error_buf,
|
||||
uint32 error_buf_size)
|
||||
{
|
||||
if (
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
!wasm_get_ref_types_flag() &&
|
||||
#endif
|
||||
table_index != 0) {
|
||||
#if WASM_ENABLE_REF_TYPES == 0
|
||||
if (table_index != 0) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (table_index >= module->import_table_count + module->table_count) {
|
||||
return false;
|
||||
|
@ -1315,21 +1296,15 @@ load_func_index_vec(const uint8 **p_buf, const uint8 *buf_end,
|
|||
InitializerExpression init_expr = { 0 };
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
if (!use_init_expr) {
|
||||
read_leb_uint32(p, p_end, function_index);
|
||||
}
|
||||
else {
|
||||
if (!use_init_expr) {
|
||||
read_leb_uint32(p, p_end, function_index);
|
||||
}
|
||||
else {
|
||||
if (!load_init_expr(&p, p_end, &init_expr,
|
||||
table_segment->elem_type, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(&p, p_end, &init_expr, table_segment->elem_type,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
function_index = init_expr.u.ref_index;
|
||||
}
|
||||
function_index = init_expr.u.ref_index;
|
||||
}
|
||||
#else
|
||||
read_leb_uint32(p, p_end, function_index);
|
||||
|
@ -1373,111 +1348,100 @@ load_table_segment_section(const uint8 *buf, const uint8 *buf_end,
|
|||
bh_assert(p < p_end);
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (wasm_get_ref_types_flag()) {
|
||||
read_leb_uint32(p, p_end, table_segment->mode);
|
||||
/* last three bits */
|
||||
table_segment->mode = table_segment->mode & 0x07;
|
||||
switch (table_segment->mode) {
|
||||
/* elemkind/elemtype + active */
|
||||
case 0:
|
||||
case 4:
|
||||
table_segment->elem_type = VALUE_TYPE_FUNCREF;
|
||||
table_segment->table_index = 0;
|
||||
read_leb_uint32(p, p_end, table_segment->mode);
|
||||
/* last three bits */
|
||||
table_segment->mode = table_segment->mode & 0x07;
|
||||
switch (table_segment->mode) {
|
||||
/* elemkind/elemtype + active */
|
||||
case 0:
|
||||
case 4:
|
||||
table_segment->elem_type = VALUE_TYPE_FUNCREF;
|
||||
table_segment->table_index = 0;
|
||||
|
||||
if (!check_table_index(module,
|
||||
table_segment->table_index,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
if (!load_init_expr(
|
||||
&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
if (!load_func_index_vec(
|
||||
&p, p_end, module, table_segment,
|
||||
table_segment->mode == 0 ? false : true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
/* elemkind + passive/declarative */
|
||||
case 1:
|
||||
case 3:
|
||||
if (!load_elem_type(&p, p_end,
|
||||
&table_segment->elem_type, true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module,
|
||||
table_segment, false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
/* elemkind/elemtype + table_idx + active */
|
||||
case 2:
|
||||
case 6:
|
||||
if (!load_table_index(&p, p_end, module,
|
||||
&table_segment->table_index,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(
|
||||
&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_elem_type(
|
||||
&p, p_end, &table_segment->elem_type,
|
||||
table_segment->mode == 2 ? true : false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(
|
||||
&p, p_end, module, table_segment,
|
||||
table_segment->mode == 2 ? false : true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
case 5:
|
||||
case 7:
|
||||
if (!load_elem_type(&p, p_end,
|
||||
&table_segment->elem_type, false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module,
|
||||
table_segment, true, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
if (!check_table_index(module, table_segment->table_index,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!load_init_expr(&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
table_segment->mode == 0 ? false
|
||||
: true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
/* elemkind + passive/declarative */
|
||||
case 1:
|
||||
case 3:
|
||||
if (!load_elem_type(&p, p_end, &table_segment->elem_type,
|
||||
true, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
false, error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
/* elemkind/elemtype + table_idx + active */
|
||||
case 2:
|
||||
case 6:
|
||||
if (!load_table_index(&p, p_end, module,
|
||||
&table_segment->table_index,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_init_expr(&p, p_end, &table_segment->base_offset,
|
||||
VALUE_TYPE_I32, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
if (!load_elem_type(&p, p_end, &table_segment->elem_type,
|
||||
table_segment->mode == 2 ? true : false,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
table_segment->mode == 2 ? false
|
||||
: true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
case 5:
|
||||
case 7:
|
||||
if (!load_elem_type(&p, p_end, &table_segment->elem_type,
|
||||
false, error_buf, error_buf_size))
|
||||
return false;
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
true, error_buf, error_buf_size))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
else
|
||||
#else
|
||||
read_leb_uint32(p, p_end, table_index);
|
||||
bh_assert(table_index
|
||||
< module->import_table_count + module->table_count);
|
||||
|
||||
table_segment->table_index = table_index;
|
||||
|
||||
/* initialize expression */
|
||||
if (!load_init_expr(&p, p_end, &(table_segment->base_offset),
|
||||
VALUE_TYPE_I32, error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
read_leb_uint32(p, p_end, function_count);
|
||||
table_segment->function_count = function_count;
|
||||
total_size = sizeof(uint32) * (uint64)function_count;
|
||||
if (total_size > 0
|
||||
&& !(table_segment->func_indexes = (uint32 *)loader_malloc(
|
||||
total_size, error_buf, error_buf_size))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
table_segment->mode == 0 ? false : true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
#endif /* WASM_ENABLE_REF_TYPES != 0 */
|
||||
{
|
||||
read_leb_uint32(p, p_end, table_index);
|
||||
bh_assert(table_index
|
||||
< module->import_table_count + module->table_count);
|
||||
|
||||
table_segment->table_index = table_index;
|
||||
|
||||
/* initialize expression */
|
||||
if (!load_init_expr(&p, p_end, &(table_segment->base_offset),
|
||||
VALUE_TYPE_I32, error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
read_leb_uint32(p, p_end, function_count);
|
||||
table_segment->function_count = function_count;
|
||||
total_size = sizeof(uint32) * (uint64)function_count;
|
||||
if (total_size > 0
|
||||
&& !(table_segment->func_indexes = (uint32 *)loader_malloc(
|
||||
total_size, error_buf, error_buf_size))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
table_segment->mode == 0 ? false
|
||||
: true,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2605,41 +2569,21 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
|||
break;
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
case WASM_OP_SELECT_T:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
skip_leb_uint32(p, p_end); /* vec length */
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
u8 = read_uint8(p); /* typeidx */
|
||||
break;
|
||||
case WASM_OP_TABLE_GET:
|
||||
case WASM_OP_TABLE_SET:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
skip_leb_uint32(p, p_end); /* table index */
|
||||
break;
|
||||
case WASM_OP_REF_NULL:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
u8 = read_uint8(p); /* type */
|
||||
break;
|
||||
case WASM_OP_REF_IS_NULL:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case WASM_OP_REF_FUNC:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
skip_leb_uint32(p, p_end); /* func index */
|
||||
break;
|
||||
#endif /* WASM_ENABLE_REF_TYPES */
|
||||
|
@ -2872,27 +2816,18 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
|||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
case WASM_OP_TABLE_INIT:
|
||||
case WASM_OP_TABLE_COPY:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
/* tableidx */
|
||||
skip_leb_uint32(p, p_end);
|
||||
/* elemidx */
|
||||
skip_leb_uint32(p, p_end);
|
||||
break;
|
||||
case WASM_OP_ELEM_DROP:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
/* elemidx */
|
||||
skip_leb_uint32(p, p_end);
|
||||
break;
|
||||
case WASM_OP_TABLE_SIZE:
|
||||
case WASM_OP_TABLE_GROW:
|
||||
case WASM_OP_TABLE_FILL:
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
return false;
|
||||
}
|
||||
skip_leb_uint32(p, p_end); /* table idx */
|
||||
break;
|
||||
#endif /* WASM_ENABLE_REF_TYPES */
|
||||
|
@ -4486,8 +4421,7 @@ is_value_type(uint8 type)
|
|||
if (type == VALUE_TYPE_I32 || type == VALUE_TYPE_I64
|
||||
|| type == VALUE_TYPE_F32 || type == VALUE_TYPE_F64
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
|| (wasm_get_ref_types_flag()
|
||||
&& (type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF))
|
||||
|| type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF
|
||||
#endif
|
||||
)
|
||||
return true;
|
||||
|
@ -5274,14 +5208,7 @@ re_scan:
|
|||
read_leb_uint32(p, p_end, type_idx);
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
table_idx = read_uint8(p);
|
||||
}
|
||||
else {
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
#else
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
table_idx = read_uint8(p);
|
||||
|
@ -5478,10 +5405,6 @@ re_scan:
|
|||
{
|
||||
uint8 vec_len, ref_type;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, vec_len);
|
||||
if (!vec_len) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
|
@ -5557,11 +5480,6 @@ re_scan:
|
|||
uint8 decl_ref_type;
|
||||
uint32 table_idx;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
if (!get_table_elem_type(module, table_idx, &decl_ref_type,
|
||||
error_buf, error_buf_size))
|
||||
|
@ -5591,11 +5509,6 @@ re_scan:
|
|||
{
|
||||
uint8 ref_type;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
;
|
||||
}
|
||||
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
ref_type = read_uint8(p);
|
||||
if (ref_type != VALUE_TYPE_FUNCREF
|
||||
|
@ -5612,11 +5525,6 @@ re_scan:
|
|||
}
|
||||
case WASM_OP_REF_IS_NULL:
|
||||
{
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
if (!wasm_loader_pop_frame_ref_offset(loader_ctx,
|
||||
VALUE_TYPE_FUNCREF,
|
||||
|
@ -5641,11 +5549,6 @@ re_scan:
|
|||
case WASM_OP_REF_FUNC:
|
||||
{
|
||||
uint32 func_idx = 0;
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, func_idx);
|
||||
|
||||
if (!check_function_index(module, func_idx, error_buf,
|
||||
|
@ -6399,10 +6302,6 @@ re_scan:
|
|||
uint8 seg_ref_type, tbl_ref_type;
|
||||
uint32 table_seg_idx, table_idx;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_seg_idx);
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
|
||||
|
@ -6434,10 +6333,6 @@ re_scan:
|
|||
case WASM_OP_ELEM_DROP:
|
||||
{
|
||||
uint32 table_seg_idx;
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_seg_idx);
|
||||
if (!get_table_seg_elem_type(module, table_seg_idx,
|
||||
NULL, error_buf,
|
||||
|
@ -6453,10 +6348,6 @@ re_scan:
|
|||
uint8 src_ref_type, dst_ref_type;
|
||||
uint32 src_tbl_idx, dst_tbl_idx;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, src_tbl_idx);
|
||||
if (!get_table_elem_type(module, src_tbl_idx,
|
||||
&src_ref_type, error_buf,
|
||||
|
@ -6487,9 +6378,6 @@ re_scan:
|
|||
case WASM_OP_TABLE_SIZE:
|
||||
{
|
||||
uint32 table_idx;
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
/* TODO: shall we create a new function to check
|
||||
|
@ -6511,10 +6399,6 @@ re_scan:
|
|||
uint8 decl_ref_type;
|
||||
uint32 table_idx;
|
||||
|
||||
if (!wasm_get_ref_types_flag()) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
read_leb_uint32(p, p_end, table_idx);
|
||||
if (!get_table_elem_type(module, table_idx,
|
||||
&decl_ref_type, error_buf,
|
||||
|
@ -6759,19 +6643,3 @@ fail:
|
|||
#endif
|
||||
return return_value;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
static bool ref_types_flag = true;
|
||||
|
||||
void
|
||||
wasm_set_ref_types_flag(bool enable)
|
||||
{
|
||||
ref_types_flag = enable;
|
||||
}
|
||||
|
||||
bool
|
||||
wasm_get_ref_types_flag()
|
||||
{
|
||||
return ref_types_flag;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -269,7 +269,7 @@ Usage: wamrc [options] -o output_file wasm_file
|
|||
object Native object file
|
||||
llvmir-unopt Unoptimized LLVM IR
|
||||
llvmir-opt Optimized LLVM IR
|
||||
--enable-bulk-memory Enable the post-MVP bulk memory feature
|
||||
--disable-bulk-memory Disable the MVP bulk memory feature
|
||||
--enable-multi-thread Enable multi-thread feature, the dependent features bulk-memory and
|
||||
thread-mgr will be enabled automatically
|
||||
--enable-tail-call Enable the post-MVP tail call feature
|
||||
|
@ -277,7 +277,7 @@ Usage: wamrc [options] -o output_file wasm_file
|
|||
currently 128-bit SIMD is only supported for x86-64 target,
|
||||
and by default it is enabled in x86-64 target and disabled
|
||||
in other targets
|
||||
--enable-ref-types Enable the post-MVP reference types feature
|
||||
--disable-ref-types Disable the MVP reference types feature
|
||||
--disable-aux-stack-check Disable auxiliary stack overflow/underflow check
|
||||
--enable-dump-call-stack Enable stack trace feature
|
||||
--enable-perf-profiling Enable function performance profiling
|
||||
|
|
|
@ -113,14 +113,54 @@ else
|
|||
CFLAGS += -DWASM_ENABLE_AOT=0
|
||||
endif
|
||||
|
||||
CFLAGS += -DWASM_ENABLE_INTERP=1
|
||||
CSRCS += wasm_runtime.c
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_FAST),y)
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_FAST), y)
|
||||
CFLAGS += -DWASM_ENABLE_FAST_INTERP=1
|
||||
CFLAGS += -DWASM_ENABLE_INTERP=1
|
||||
CSRCS += wasm_interp_fast.c
|
||||
CSRCS += wasm_runtime.c
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_FAST_INTERP=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_CLASSIC), y)
|
||||
CFLAGS += -DWASM_ENABLE_INTERP=1
|
||||
CSRCS += wasm_interp_classic.c
|
||||
CSRCS += wasm_runtime.c
|
||||
endif
|
||||
|
||||
ifeq ($(findstring y,$(CONFIG_INTERPRETERS_WAMR_FAST)$(CONFIG_INTERPRETERS_WAMR_CLASSIC)), y)
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_MINILOADER),y)
|
||||
CFLAGS += -DWASM_ENABLE_MINI_LOADER=1
|
||||
CSRCS += wasm_mini_loader.c
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_MINI_LOADER=0
|
||||
CSRCS += wasm_loader.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_SHARED_MEMORY),y)
|
||||
CFLAGS += -DWASM_ENABLE_SHARED_MEMORY=1
|
||||
CSRCS += wasm_shared_memory.c
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_SHARED_MEMORY=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_BULK_MEMORY),y)
|
||||
CFLAGS += -DWASM_ENABLE_BULK_MEMORY=1
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_BULK_MEMORY=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_MEMORY_PROFILING),y)
|
||||
CFLAGS += -DWASM_ENABLE_MEMORY_PROFILING=1
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_MEMORY_PROFILING=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_MEMORY_TRACING),y)
|
||||
CFLAGS += -DWASM_ENABLE_MEMORY_TRACING=1
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_MEMORY_TRACING=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN),y)
|
||||
|
@ -150,14 +190,6 @@ else
|
|||
CFLAGS += -DWASM_ENABLE_LIB_PTHREAD=0
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_MINILOADER),y)
|
||||
CFLAGS += -DWASM_ENABLE_MINI_LOADER=1
|
||||
CSRCS += wasm_mini_loader.c
|
||||
else
|
||||
CFLAGS += -DWASM_ENABLE_MINI_LOADER=0
|
||||
CSRCS += wasm_loader.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_INTERPRETERS_WAMR_DISABLE_HW_BOUND_CHECK),y)
|
||||
CFLAGS += -DWASM_DISABLE_HW_BOUND_CHECK=1
|
||||
else
|
||||
|
|
|
@ -157,7 +157,7 @@ foreach(EX ${EXAMPLES})
|
|||
# generate .aot file
|
||||
if(${WAMR_BUILD_AOT} EQUAL 1)
|
||||
add_custom_target(${EX}_AOT
|
||||
COMMAND ${WAMRC} --enable-ref-types -o ${PROJECT_BINARY_DIR}/${EX}.aot
|
||||
COMMAND ${WAMRC} -o ${PROJECT_BINARY_DIR}/${EX}.aot
|
||||
${PROJECT_BINARY_DIR}/${EX}.wasm
|
||||
DEPENDS ${EX}_WASM
|
||||
BYPRODUCTS ${PROJECT_BINARY_DIR}/${EX}.aot
|
||||
|
|
|
@ -49,7 +49,7 @@ def ignore_the_case(
|
|||
aot_flag=False,
|
||||
sgx_flag=False,
|
||||
multi_module_flag=False,
|
||||
reference_type_flag=True,
|
||||
multi_thread_flag=False,
|
||||
simd_flag=False,
|
||||
):
|
||||
if case_name in ["comments", "inline-module", "names"]:
|
||||
|
@ -98,7 +98,7 @@ def test_case(
|
|||
aot_flag=False,
|
||||
sgx_flag=False,
|
||||
multi_module_flag=False,
|
||||
reference_type_flag=True,
|
||||
multi_thread_flag=False,
|
||||
simd_flag=False,
|
||||
clean_up_flag=True,
|
||||
verbose_flag=True,
|
||||
|
@ -112,7 +112,7 @@ def test_case(
|
|||
aot_flag,
|
||||
sgx_flag,
|
||||
multi_module_flag,
|
||||
reference_type_flag,
|
||||
multi_thread_flag,
|
||||
simd_flag,
|
||||
):
|
||||
return True
|
||||
|
@ -130,8 +130,8 @@ def test_case(
|
|||
CMD.append("--aot-target")
|
||||
CMD.append(target)
|
||||
|
||||
if reference_type_flag:
|
||||
CMD.append("--ref_types")
|
||||
if multi_thread_flag:
|
||||
CMD.append("--multi-thread")
|
||||
|
||||
if sgx_flag:
|
||||
CMD.append("--sgx")
|
||||
|
@ -193,7 +193,7 @@ def test_suite(
|
|||
aot_flag=False,
|
||||
sgx_flag=False,
|
||||
multi_module_flag=False,
|
||||
reference_type_flag=True,
|
||||
multi_thread_flag=False,
|
||||
simd_flag=False,
|
||||
clean_up_flag=True,
|
||||
verbose_flag=True,
|
||||
|
@ -215,7 +215,7 @@ def test_suite(
|
|||
aot_flag,
|
||||
sgx_flag,
|
||||
multi_module_flag,
|
||||
reference_type_flag,
|
||||
multi_thread_flag,
|
||||
simd_flag,
|
||||
clean_up_flag,
|
||||
verbose_flag,
|
||||
|
@ -237,7 +237,7 @@ def test_suite_parallelly(
|
|||
aot_flag=False,
|
||||
sgx_flag=False,
|
||||
multi_module_flag=False,
|
||||
reference_type_flag=True,
|
||||
multi_thread_flag=False,
|
||||
simd_flag=False,
|
||||
clean_up_flag=False,
|
||||
verbose_flag=False,
|
||||
|
@ -264,7 +264,7 @@ def test_suite_parallelly(
|
|||
aot_flag,
|
||||
sgx_flag,
|
||||
multi_module_flag,
|
||||
reference_type_flag,
|
||||
multi_thread_flag,
|
||||
simd_flag,
|
||||
clean_up_flag,
|
||||
verbose_flag,
|
||||
|
@ -310,11 +310,11 @@ def main():
|
|||
help="Specify Target ",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-r",
|
||||
"-p",
|
||||
action="store_true",
|
||||
default=False,
|
||||
dest="reference_type_flag",
|
||||
help="Running with the Reference-type feature",
|
||||
dest="multi_thread_flag",
|
||||
help="Running with the Multi-Thread feature",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-S",
|
||||
|
@ -337,13 +337,6 @@ def main():
|
|||
dest="sgx_flag",
|
||||
help="Running with SGX environment",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--parl",
|
||||
action="store_true",
|
||||
default=False,
|
||||
dest="parl_flag",
|
||||
help="To run whole test suite parallelly",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--no_clean_up",
|
||||
action="store_false",
|
||||
|
@ -351,6 +344,13 @@ def main():
|
|||
dest="clean_up_flag",
|
||||
help="Does not remove tmpfiles. But it will be enabled while running parallelly",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--parl",
|
||||
action="store_true",
|
||||
default=False,
|
||||
dest="parl_flag",
|
||||
help="To run whole test suite parallelly",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--quiet",
|
||||
action="store_false",
|
||||
|
@ -385,7 +385,7 @@ def main():
|
|||
options.aot_flag,
|
||||
options.sgx_flag,
|
||||
options.multi_module_flag,
|
||||
options.reference_type_flag,
|
||||
options.multi_thread_flag,
|
||||
options.simd_flag,
|
||||
options.clean_up_flag,
|
||||
options.verbose_flag,
|
||||
|
@ -401,7 +401,7 @@ def main():
|
|||
options.aot_flag,
|
||||
options.sgx_flag,
|
||||
options.multi_module_flag,
|
||||
options.reference_type_flag,
|
||||
options.multi_thread_flag,
|
||||
options.simd_flag,
|
||||
options.clean_up_flag,
|
||||
options.verbose_flag,
|
||||
|
@ -417,7 +417,7 @@ def main():
|
|||
options.aot_flag,
|
||||
options.sgx_flag,
|
||||
options.multi_module_flag,
|
||||
options.reference_type_flag,
|
||||
options.multi_thread_flag,
|
||||
options.simd_flag,
|
||||
options.clean_up_flag,
|
||||
options.verbose_flag,
|
||||
|
|
|
@ -210,8 +210,8 @@ parser.add_argument('--sgx', action='store_true',
|
|||
parser.add_argument('--simd', default=False, action='store_true',
|
||||
help="Enable SIMD")
|
||||
|
||||
parser.add_argument('--ref_types', default=False, action='store_true',
|
||||
help="Enable Reference types")
|
||||
parser.add_argument('--multi-thread', default=False, action='store_true',
|
||||
help="Enable Multi-thread")
|
||||
|
||||
parser.add_argument('--verbose', default=False, action='store_true',
|
||||
help='show more logs')
|
||||
|
@ -939,12 +939,11 @@ def compile_wasm_to_aot(wasm_tempfile, aot_tempfile, runner, opts, r):
|
|||
if opts.sgx:
|
||||
cmd.append("-sgx")
|
||||
|
||||
if opts.simd:
|
||||
cmd.append("--enable-simd")
|
||||
if not opts.simd:
|
||||
cmd.append("--disable-simd")
|
||||
|
||||
if opts.ref_types:
|
||||
cmd.append("--enable-ref-types")
|
||||
cmd.append("--enable-bulk-memory")
|
||||
if opts.multi_thread:
|
||||
cmd.append("--enable-multi-thread")
|
||||
|
||||
# disable llvm link time optimization as it might convert
|
||||
# code of tail call into code of dead loop, and stack overflow
|
||||
|
|
|
@ -40,9 +40,6 @@ ENABLE_GC=0
|
|||
#unit test case arrary
|
||||
TEST_CASE_ARR=()
|
||||
SGX_OPT=""
|
||||
# enable reference-types and bulk-memory by default
|
||||
# as they are finished and merged into spec
|
||||
ENABLE_REF_TYPES=1
|
||||
PLATFORM=$(uname -s | tr A-Z a-z)
|
||||
PARALLELISM=0
|
||||
|
||||
|
@ -106,9 +103,6 @@ do
|
|||
p)
|
||||
echo "enable multi thread feature"
|
||||
ENABLE_MULTI_THREAD=1
|
||||
# Disable reference-types when multi-thread is enabled
|
||||
echo "disable reference-types for multi thread"
|
||||
ENABLE_REF_TYPES=0
|
||||
;;
|
||||
S)
|
||||
echo "enable SIMD feature"
|
||||
|
@ -168,7 +162,6 @@ readonly CLASSIC_INTERP_COMPILE_FLAGS="\
|
|||
-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \
|
||||
-DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \
|
||||
-DWAMR_BUILD_SPEC_TEST=1 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=${ENABLE_MULTI_MODULE} \
|
||||
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
||||
|
||||
readonly FAST_INTERP_COMPILE_FLAGS="\
|
||||
|
@ -176,7 +169,6 @@ readonly FAST_INTERP_COMPILE_FLAGS="\
|
|||
-DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 \
|
||||
-DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \
|
||||
-DWAMR_BUILD_SPEC_TEST=1 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=${ENABLE_MULTI_MODULE} \
|
||||
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
||||
|
||||
# jit: report linking error if set COLLECT_CODE_COVERAGE,
|
||||
|
@ -185,15 +177,13 @@ readonly JIT_COMPILE_FLAGS="\
|
|||
-DWAMR_BUILD_TARGET=${TARGET} \
|
||||
-DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \
|
||||
-DWAMR_BUILD_JIT=1 -DWAMR_BUILD_AOT=1 \
|
||||
-DWAMR_BUILD_SPEC_TEST=1 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=${ENABLE_MULTI_MODULE}"
|
||||
-DWAMR_BUILD_SPEC_TEST=1"
|
||||
|
||||
readonly AOT_COMPILE_FLAGS="\
|
||||
-DWAMR_BUILD_TARGET=${TARGET} \
|
||||
-DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \
|
||||
-DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=1 \
|
||||
-DWAMR_BUILD_SPEC_TEST=1 \
|
||||
-DWAMR_BUILD_MULTI_MODULE=${ENABLE_MULTI_MODULE} \
|
||||
-DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}"
|
||||
|
||||
readonly COMPILE_FLAGS=(
|
||||
|
@ -412,9 +402,8 @@ function spec_test()
|
|||
fi
|
||||
fi
|
||||
|
||||
# reference type in all mode
|
||||
if [[ ${ENABLE_REF_TYPES} == 1 ]]; then
|
||||
ARGS_FOR_SPEC_TEST+="-r "
|
||||
if [[ ${ENABLE_MULTI_THREAD} == 1 ]]; then
|
||||
ARGS_FOR_SPEC_TEST+="-p "
|
||||
fi
|
||||
|
||||
# require warmc only in aot mode
|
||||
|
@ -561,20 +550,26 @@ function collect_coverage()
|
|||
function trigger()
|
||||
{
|
||||
local EXTRA_COMPILE_FLAGS=""
|
||||
# default enabled features
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_BULK_MEMORY=1"
|
||||
|
||||
if [[ ${ENABLE_MULTI_MODULE} == 1 ]];then
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_MULTI_MODULE=1"
|
||||
else
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_MULTI_MODULE=0"
|
||||
fi
|
||||
|
||||
if [[ ${ENABLE_MULTI_THREAD} == 1 ]];then
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_PTHREAD=1"
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=0"
|
||||
else
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=1"
|
||||
fi
|
||||
|
||||
if [[ ${ENABLE_SIMD} == 1 ]]; then
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SIMD=1"
|
||||
fi
|
||||
|
||||
if [[ ${ENABLE_REF_TYPES} == 1 ]]; then
|
||||
# spec test cases for reference type depends on
|
||||
# multi-module and bulk memory
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=1"
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_MULTI_MODULE=1"
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_BULK_MEMORY=1"
|
||||
else
|
||||
EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SIMD=0"
|
||||
fi
|
||||
|
||||
if [[ ${ENABLE_GC} == 1 ]]; then
|
||||
|
|
|
@ -9,11 +9,6 @@
|
|||
#include "wasm_export.h"
|
||||
#include "aot_export.h"
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
extern void
|
||||
wasm_set_ref_types_flag(bool enable);
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
static int
|
||||
print_help()
|
||||
|
@ -48,7 +43,7 @@ print_help()
|
|||
printf(" object Native object file\n");
|
||||
printf(" llvmir-unopt Unoptimized LLVM IR\n");
|
||||
printf(" llvmir-opt Optimized LLVM IR\n");
|
||||
printf(" --enable-bulk-memory Enable the post-MVP bulk memory feature\n");
|
||||
printf(" --disable-bulk-memory Disable the MVP bulk memory feature\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(" --enable-tail-call Enable the post-MVP tail call feature\n");
|
||||
|
@ -56,7 +51,7 @@ print_help()
|
|||
printf(" currently 128-bit SIMD is only supported for x86-64 target,\n");
|
||||
printf(" and by default it is enabled in x86-64 target and disabled\n");
|
||||
printf(" in other targets\n");
|
||||
printf(" --enable-ref-types Enable the post-MVP reference types feature\n");
|
||||
printf(" --disable-ref-types Disable the MVP reference types feature\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-perf-profiling Enable function performance profiling\n");
|
||||
|
@ -94,6 +89,8 @@ main(int argc, char *argv[])
|
|||
option.bounds_checks = 2;
|
||||
option.enable_simd = true;
|
||||
option.enable_aux_stack_check = true;
|
||||
option.enable_bulk_memory = true;
|
||||
option.enable_ref_types = true;
|
||||
|
||||
/* Process options */
|
||||
for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
|
||||
|
@ -164,12 +161,13 @@ main(int argc, char *argv[])
|
|||
if (log_verbose_level < 0 || log_verbose_level > 5)
|
||||
return print_help();
|
||||
}
|
||||
else if (!strcmp(argv[0], "--enable-bulk-memory")) {
|
||||
option.enable_bulk_memory = true;
|
||||
else if (!strcmp(argv[0], "--disable-bulk-memory")) {
|
||||
option.enable_bulk_memory = false;
|
||||
}
|
||||
else if (!strcmp(argv[0], "--enable-multi-thread")) {
|
||||
option.enable_bulk_memory = true;
|
||||
option.enable_thread_mgr = true;
|
||||
option.enable_ref_types = false;
|
||||
}
|
||||
else if (!strcmp(argv[0], "--enable-tail-call")) {
|
||||
option.enable_tail_call = true;
|
||||
|
@ -181,8 +179,8 @@ main(int argc, char *argv[])
|
|||
else if (!strcmp(argv[0], "--disable-simd")) {
|
||||
option.enable_simd = false;
|
||||
}
|
||||
else if (!strcmp(argv[0], "--enable-ref-types")) {
|
||||
option.enable_ref_types = true;
|
||||
else if (!strcmp(argv[0], "--disable-ref-types")) {
|
||||
option.enable_ref_types = false;
|
||||
}
|
||||
else if (!strcmp(argv[0], "--disable-aux-stack-check")) {
|
||||
option.enable_aux_stack_check = false;
|
||||
|
@ -214,10 +212,6 @@ main(int argc, char *argv[])
|
|||
option.is_sgx_platform = true;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
wasm_set_ref_types_flag(option.enable_ref_types);
|
||||
#endif
|
||||
|
||||
wasm_file_name = argv[0];
|
||||
|
||||
memset(&init_args, 0, sizeof(RuntimeInitArgs));
|
||||
|
|
Loading…
Reference in New Issue
Block a user