Update spec test to latest commit (#3293)
- Update spec test cases to commit bc76fd79cfe61033d7f4ad4a7e8fc4f996dc5ba8 on Apr. 3 - Update wabt binary to 1.0.34 to support newer spec cases - Add comparison between table declared elem type and table elem segment value type - Add a function to decide whether to execute test cases in a running mode - Keep using interpreter in GC spec because wat2wasm in wabt can't compile if.wast w/o errors - Re-factoring threads spec test case processing - Since wabt 1.0.34 release isn't compatible with ubuntu 20.04, compile it from source code - Disable CI to run aot multi-module temporarily, and will enable it in another PR
This commit is contained in:
@ -120,7 +120,6 @@ check_global_init_expr(const AOTModule *module, uint32 global_index,
|
||||
return false;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_GC == 0
|
||||
/**
|
||||
* Currently, constant expressions occurring as initializers of
|
||||
* globals are further constrained in that contained global.get
|
||||
@ -129,24 +128,26 @@ check_global_init_expr(const AOTModule *module, uint32 global_index,
|
||||
* And initializer expression cannot reference a mutable global.
|
||||
*/
|
||||
if (global_index >= module->import_global_count
|
||||
|| module->import_globals->type.is_mutable) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"constant expression required");
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (global_index >= module->import_global_count + module->global_count) {
|
||||
/* make spec test happy */
|
||||
#if WASM_ENABLE_GC != 0
|
||||
+ module->global_count
|
||||
#endif
|
||||
) {
|
||||
set_error_buf_v(error_buf, error_buf_size, "unknown global %u",
|
||||
global_index);
|
||||
return false;
|
||||
}
|
||||
if (global_index < module->import_global_count
|
||||
&& module->import_globals[global_index].type.is_mutable) {
|
||||
|
||||
if (
|
||||
/* make spec test happy */
|
||||
#if WASM_ENABLE_GC != 0
|
||||
global_index < module->import_global_count &&
|
||||
#endif
|
||||
module->import_globals[global_index].type.is_mutable) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"constant expression required");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -830,39 +830,35 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
|
||||
read_leb_uint32(p, p_end, cur_value.global_index);
|
||||
global_idx = cur_value.global_index;
|
||||
|
||||
#if WASM_ENABLE_GC == 0
|
||||
if (global_idx >= module->import_global_count) {
|
||||
/**
|
||||
* Currently, constant expressions occurring as initializers
|
||||
* of globals are further constrained in that contained
|
||||
* global.get instructions are
|
||||
* only allowed to refer to imported globals.
|
||||
*/
|
||||
/*
|
||||
* Currently, constant expressions occurring as initializers
|
||||
* of globals are further constrained in that contained
|
||||
* global.get instructions are
|
||||
* only allowed to refer to imported globals.
|
||||
*
|
||||
* https://webassembly.github.io/spec/core/valid/instructions.html#constant-expressions
|
||||
*/
|
||||
if (global_idx >= module->import_global_count
|
||||
/* make spec test happy */
|
||||
#if WASM_ENABLE_GC != 0
|
||||
+ module->global_count
|
||||
#endif
|
||||
) {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"unknown global %u", global_idx);
|
||||
goto fail;
|
||||
}
|
||||
if (module->import_globals[global_idx]
|
||||
if (
|
||||
/* make spec test happy */
|
||||
#if WASM_ENABLE_GC != 0
|
||||
global_idx < module->import_global_count &&
|
||||
#endif
|
||||
module->import_globals[global_idx]
|
||||
.u.global.type.is_mutable) {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"constant expression required");
|
||||
goto fail;
|
||||
}
|
||||
#else
|
||||
if (global_idx
|
||||
>= module->import_global_count + module->global_count) {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"unknown global %u", global_idx);
|
||||
goto fail;
|
||||
}
|
||||
if (global_idx < module->import_global_count
|
||||
&& module->import_globals[global_idx]
|
||||
.u.global.type.is_mutable) {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"constant expression required");
|
||||
goto fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (global_idx < module->import_global_count) {
|
||||
global_type = module->import_globals[global_idx]
|
||||
@ -4244,6 +4240,43 @@ fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Element segments must match element type of table */
|
||||
static bool
|
||||
check_table_elem_type(WASMModule *module, uint32 table_index,
|
||||
uint32 type_from_elem_seg, char *error_buf,
|
||||
uint32 error_buf_size)
|
||||
{
|
||||
uint32 table_declared_elem_type;
|
||||
|
||||
if (table_index < module->import_table_count)
|
||||
table_declared_elem_type =
|
||||
module->import_tables[table_index].u.table.elem_type;
|
||||
else
|
||||
table_declared_elem_type = (module->tables + table_index)->elem_type;
|
||||
|
||||
if (table_declared_elem_type == type_from_elem_seg)
|
||||
return true;
|
||||
|
||||
#if WASM_ENABLE_GC != 0
|
||||
/*
|
||||
* balance in: anyref, funcref, (ref.null func) and (ref.func)
|
||||
*/
|
||||
if (table_declared_elem_type == REF_TYPE_ANYREF)
|
||||
return true;
|
||||
|
||||
if (table_declared_elem_type == VALUE_TYPE_FUNCREF
|
||||
&& type_from_elem_seg == REF_TYPE_HT_NON_NULLABLE)
|
||||
return true;
|
||||
|
||||
if (table_declared_elem_type == REF_TYPE_HT_NULLABLE
|
||||
&& type_from_elem_seg == REF_TYPE_HT_NON_NULLABLE)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
set_error_buf(error_buf, error_buf_size, "type mismatch");
|
||||
return false;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
|
||||
static bool
|
||||
load_elem_type(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
|
||||
@ -4479,6 +4512,12 @@ load_table_segment_section(const uint8 *buf, const uint8 *buf_end,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!check_table_elem_type(module,
|
||||
table_segment->table_index,
|
||||
table_segment->elem_type,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
/* elemkind + passive/declarative */
|
||||
@ -4530,6 +4569,13 @@ load_table_segment_section(const uint8 *buf, const uint8 *buf_end,
|
||||
error_buf_size))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!check_table_elem_type(module,
|
||||
table_segment->table_index,
|
||||
table_segment->elem_type,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
break;
|
||||
case 5:
|
||||
case 7:
|
||||
@ -4566,6 +4612,13 @@ load_table_segment_section(const uint8 *buf, const uint8 *buf_end,
|
||||
if (!load_func_index_vec(&p, p_end, module, table_segment,
|
||||
error_buf, error_buf_size))
|
||||
return false;
|
||||
|
||||
table_segment->elem_type = VALUE_TYPE_FUNCREF;
|
||||
|
||||
if (!check_table_elem_type(module, table_segment->table_index,
|
||||
table_segment->elem_type, error_buf,
|
||||
error_buf_size))
|
||||
return false;
|
||||
#endif /* end of WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 */
|
||||
|
||||
#if WASM_ENABLE_WAMR_COMPILER != 0
|
||||
|
||||
@ -1001,6 +1001,12 @@ print_i32_wrapper(wasm_exec_env_t exec_env, int32 i32)
|
||||
os_printf("in specttest.print_i32(%" PRId32 ")\n", i32);
|
||||
}
|
||||
|
||||
static void
|
||||
print_i64_wrapper(wasm_exec_env_t exec_env, int64 i64)
|
||||
{
|
||||
os_printf("in specttest.print_i64(%" PRId32 ")\n", i64);
|
||||
}
|
||||
|
||||
static void
|
||||
print_i32_f32_wrapper(wasm_exec_env_t exec_env, int32 i32, float f32)
|
||||
{
|
||||
@ -1091,6 +1097,7 @@ static NativeSymbol native_symbols_libc_builtin[] = {
|
||||
static NativeSymbol native_symbols_spectest[] = {
|
||||
REG_NATIVE_FUNC(print, "()"),
|
||||
REG_NATIVE_FUNC(print_i32, "(i)"),
|
||||
REG_NATIVE_FUNC(print_i64, "(I)"),
|
||||
REG_NATIVE_FUNC(print_i32_f32, "(if)"),
|
||||
REG_NATIVE_FUNC(print_f64_f64, "(FF)"),
|
||||
REG_NATIVE_FUNC(print_f32, "(f)"),
|
||||
@ -1136,6 +1143,7 @@ static WASMNativeGlobalDef native_global_defs[] = {
|
||||
{ "test", "global-f32", VALUE_TYPE_F32, false, .value.f32 = 0 },
|
||||
{ "test", "global-mut-i32", VALUE_TYPE_I32, true, .value.i32 = 0 },
|
||||
{ "test", "global-mut-i64", VALUE_TYPE_I64, true, .value.i64 = 0 },
|
||||
{ "test", "g", VALUE_TYPE_I32, true, .value.i32 = 0 },
|
||||
#if WASM_ENABLE_GC != 0
|
||||
{ "G", "g", VALUE_TYPE_I32, false, .value.i32 = 4 },
|
||||
{ "M", "g", REF_TYPE_HT_NON_NULLABLE, false, .value.gc_obj = 0 },
|
||||
|
||||
Reference in New Issue
Block a user