Update unit test cases (#4214)

* Update gc unit test cases
* Update aot stack frame unit test cases
This commit is contained in:
Zhenwei Jin 2025-04-25 14:43:24 +08:00 committed by GitHub
parent c883fafead
commit 6d61e72344
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 237 additions and 277 deletions

View File

@ -17,6 +17,7 @@ set (WAMR_BUILD_LIBC_BUILTIN 0)
set (WAMR_BUILD_MULTI_MODULE 0) set (WAMR_BUILD_MULTI_MODULE 0)
set (WAMR_DISABLE_HW_BOUND_CHECK 1) set (WAMR_DISABLE_HW_BOUND_CHECK 1)
set (WAMR_DISABLE_WRITE_GS_BASE 1) set (WAMR_DISABLE_WRITE_GS_BASE 1)
set (WAMR_BUILD_GC 1)
include (../unit_common.cmake) include (../unit_common.cmake)
@ -31,15 +32,21 @@ file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
set (UNIT_SOURCE ${source_all}) set (UNIT_SOURCE ${source_all})
set (unit_test_sources set (unit_test_sources
${UNIT_SOURCE} ${UNIT_SOURCE}
${PLATFORM_SHARED_SOURCE} ${WAMR_RUNTIME_LIB_SOURCE}
${UTILS_SHARED_SOURCE} ${UNCOMMON_SHARED_SOURCE}
${MEM_ALLOC_SHARED_SOURCE} ${SRC_LIST}
${NATIVE_INTERFACE_SOURCE} ${PLATFORM_SHARED_SOURCE}
${IWASM_COMMON_SOURCE} ${UTILS_SHARED_SOURCE}
${IWASM_INTERP_SOURCE} ${MEM_ALLOC_SHARED_SOURCE}
${IWASM_AOT_SOURCE} ${LIB_HOST_AGENT_SOURCE}
${WASM_APP_LIB_SOURCE_ALL} ${NATIVE_INTERFACE_SOURCE}
${LIBC_BUILTIN_SOURCE}
${IWASM_COMMON_SOURCE}
${IWASM_INTERP_SOURCE}
${IWASM_AOT_SOURCE}
${IWASM_COMPL_SOURCE}
${WASM_APP_LIB_SOURCE_ALL}
) )
# Automatically build wasm-apps for this test # Automatically build wasm-apps for this test

View File

@ -162,57 +162,6 @@ TEST_F(AOTStackFrameTest, test1)
exec_env = wasm_runtime_create_exec_env(module_inst, 8 * 1024); exec_env = wasm_runtime_create_exec_env(module_inst, 8 * 1024);
ASSERT_TRUE(exec_env != NULL); ASSERT_TRUE(exec_env != NULL);
func_inst = wasm_runtime_lookup_function(module_inst, "test1");
ASSERT_TRUE(func_inst != NULL);
argv[0] = 33;
argv[1] = 44;
wasm_runtime_call_wasm(exec_env, func_inst, 2, argv);
ASSERT_TRUE(wasm_runtime_get_exception(module_inst));
frames = AOTStackFrameTest::my_frames;
frame_num = AOTStackFrameTest::my_frame_num;
ASSERT_TRUE(frames != NULL);
ASSERT_TRUE(frame_num == 1);
ASSERT_TRUE(frames[0]->lp[0] == 33);
ASSERT_TRUE(frames[0]->lp[1] == 44);
ASSERT_TRUE(frames[0]->lp[2] == 0x11223344);
ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL);
ASSERT_TRUE(*(float *)(frames[0]->lp + 5) == 5566.7788f);
ASSERT_TRUE(*(double *)(frames[0]->lp + 6) == 99887766.55443322);
wasm_runtime_destroy_exec_env(exec_env);
exec_env = NULL;
wasm_runtime_deinstantiate(module_inst);
module_inst = NULL;
wasm_runtime_unload(module);
module = NULL;
}
TEST_F(AOTStackFrameTest, test2)
{
MyAOTFrame *frame, **frames;
uint32 frame_num;
aot_set_stack_frame_callback(aot_stack_frame_cb);
bh_memcpy_s(test_aot_buf, sizeof(test_aot_buf), test_aot, sizeof(test_aot));
module = wasm_runtime_load(test_aot_buf, sizeof(test_aot), error_buf,
sizeof(error_buf));
ASSERT_TRUE(module != NULL);
module_inst = wasm_runtime_instantiate(module, 16384, 0, error_buf,
sizeof(error_buf));
ASSERT_TRUE(module_inst != NULL);
exec_env = wasm_runtime_create_exec_env(module_inst, 8 * 1024);
ASSERT_TRUE(exec_env != NULL);
func_inst = wasm_runtime_lookup_function(module_inst, "test2"); func_inst = wasm_runtime_lookup_function(module_inst, "test2");
ASSERT_TRUE(func_inst != NULL); ASSERT_TRUE(func_inst != NULL);
@ -233,11 +182,9 @@ TEST_F(AOTStackFrameTest, test2)
ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL); ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL);
ASSERT_TRUE(*(float *)(frames[0]->lp + 5) == 5566.7788f); ASSERT_TRUE(*(float *)(frames[0]->lp + 5) == 5566.7788f);
ASSERT_TRUE(*(double *)(frames[0]->lp + 6) == 99887766.55443322); ASSERT_TRUE(*(double *)(frames[0]->lp + 6) == 99887766.55443322);
ASSERT_TRUE(frames[0]->lp[8] == 0x1234);
ASSERT_TRUE(frames[0]->lp[9] == 0x5678);
} }
TEST_F(AOTStackFrameTest, test3) TEST_F(AOTStackFrameTest, test2)
{ {
MyAOTFrame *frame, **frames; MyAOTFrame *frame, **frames;
uint32 frame_num; uint32 frame_num;
@ -271,18 +218,14 @@ TEST_F(AOTStackFrameTest, test3)
ASSERT_TRUE(frames != NULL); ASSERT_TRUE(frames != NULL);
ASSERT_TRUE(frame_num == 2); ASSERT_TRUE(frame_num == 2);
ASSERT_TRUE(frames[0]->sp - frames[0]->lp == 5); // 5(i32) + 1(i64) local variables, occupied 7 * 4 bytes
ASSERT_TRUE(frames[0]->ip_offset == 24); ASSERT_TRUE(frames[0]->sp - frames[0]->lp == 7);
// offset of ip from module load address
ASSERT_TRUE(frames[0]->ip_offset == 163);
ASSERT_TRUE(frames[0]->lp[0] == 1234); ASSERT_TRUE(frames[0]->lp[0] == 1234);
ASSERT_TRUE(frames[0]->lp[1] == 5678); ASSERT_TRUE(frames[0]->lp[1] == 5678);
ASSERT_TRUE(frames[0]->lp[2] == 0x11223344); ASSERT_TRUE(frames[0]->lp[2] == 0x11223344);
ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL); ASSERT_TRUE(*(uint64 *)(frames[0]->lp + 3) == 0x12345678ABCDEF99LL);
ASSERT_TRUE(frames[1]->lp[0] == 0x1234);
ASSERT_TRUE(frames[1]->lp[1] == 0x5678);
ASSERT_TRUE(frames[1]->lp[2] == 0x11223344);
ASSERT_TRUE(*(uint64 *)(frames[1]->lp + 3) == 0x12345678ABCDEF99LL);
ASSERT_TRUE(*(float *)(frames[1]->lp + 5) == 5566.7788f);
ASSERT_TRUE(*(double *)(frames[1]->lp + 6) == 99887766.55443322);
} }

View File

@ -13,7 +13,7 @@ add_custom_target(aot-stack-frame-test-wasm ALL
-o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm -o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm
${CMAKE_CURRENT_LIST_DIR}/test.wast ${CMAKE_CURRENT_LIST_DIR}/test.wast
&& ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc && ${CMAKE_CURRENT_BINARY_DIR}/build-wamrc/wamrc
--enable-dump-call-stack --bounds-checks=1 --enable-dump-call-stack --bounds-checks=1 --enable-gc
-o ${CMAKE_CURRENT_BINARY_DIR}/test.aot -o ${CMAKE_CURRENT_BINARY_DIR}/test.aot
${CMAKE_CURRENT_BINARY_DIR}/test.wasm ${CMAKE_CURRENT_BINARY_DIR}/test.wasm
&& cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump && cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump

Binary file not shown.

View File

@ -26,10 +26,10 @@
(local (ref null struct)) (local (ref null struct))
local.get 0 local.get 0
ref.test null array ref.test (ref array)
drop drop
local.get 1 local.get 1
ref.cast i31 ref.cast (ref i31)
drop drop
) )
) )

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,18 +1,36 @@
(module (module
(type $vec (struct (field f32) (field $y (mut f32)) (field $z f32))) (type $vec (struct (field f32) (field $y (mut f32)) (field $z f32)))
;;(global (ref $vec) (struct.new_canon $vec (f32.const 1) (f32.const 2) (f32.const 3))) (global (ref $vec) (struct.new $vec (f32.const 1) (f32.const 2) (f32.const 3)))
(global (ref $vec) (struct.new_canon_default $vec)) (global (ref $vec) (struct.new_default $vec))
(func (export "new") (result anyref) (func (export "new") (result anyref)
(struct.new_canon_default $vec) (struct.new_default $vec)
) )
(func $get_0 (param $v (ref $vec)) (result f32) (func $get_0_0 (param $v (ref $vec)) (result f32)
(struct.get 0 0 (local.get $v))
)
(func (export "get_0_0") (result f32)
(call $get_0_0 (struct.new_default $vec))
)
(func $get_vec_0 (param $v (ref $vec)) (result f32)
(struct.get $vec 0 (local.get $v)) (struct.get $vec 0 (local.get $v))
) )
(func (export "get_0") (result f32) (func (export "get_vec_0") (result f32)
(call $get_0 (struct.new_canon_default $vec)) (call $get_vec_0 (struct.new_default $vec))
)
(func $get_0_y (param $v (ref $vec)) (result f32)
(struct.get 0 $y (local.get $v))
)
(func (export "get_0_y") (result f32)
(call $get_0_y (struct.new_default $vec))
)
(func $get_vec_y (param $v (ref $vec)) (result f32)
(struct.get $vec $y (local.get $v))
)
(func (export "get_vec_y") (result f32)
(call $get_vec_y (struct.new_default $vec))
) )
(func $set_get_y (param $v (ref $vec)) (param $y f32) (result f32) (func $set_get_y (param $v (ref $vec)) (param $y f32) (result f32)
@ -20,7 +38,7 @@
(struct.get $vec $y (local.get $v)) (struct.get $vec $y (local.get $v))
) )
(func (export "set_get_y") (param $y f32) (result f32) (func (export "set_get_y") (param $y f32) (result f32)
(call $set_get_y (struct.new_canon_default $vec) (local.get $y)) (call $set_get_y (struct.new_default $vec) (local.get $y))
) )
(func $set_get_1 (param $v (ref $vec)) (param $y f32) (result f32) (func $set_get_1 (param $v (ref $vec)) (param $y f32) (result f32)
@ -28,6 +46,6 @@
(struct.get $vec $y (local.get $v)) (struct.get $vec $y (local.get $v))
) )
(func (export "set_get_1") (param $y f32) (result f32) (func (export "set_get_1") (param $y f32) (result f32)
(call $set_get_1 (struct.new_canon_default $vec) (local.get $y)) (call $set_get_1 (struct.new_default $vec) (local.get $y))
) )
) )

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,11 +14,11 @@
(table.set $ta (i32.const 0) (ref.null any)) (table.set $ta (i32.const 0) (ref.null any))
(table.set $ta (i32.const 1) (ref.null struct)) (table.set $ta (i32.const 1) (ref.null struct))
(table.set $ta (i32.const 2) (ref.null none)) (table.set $ta (i32.const 2) (ref.null none))
(table.set $ta (i32.const 3) (i31.new (i32.const 7))) (table.set $ta (i32.const 3) (ref.i31 (i32.const 7)))
(table.set $ta (i32.const 4) (struct.new_canon_default $st)) (table.set $ta (i32.const 4) (struct.new_default $st))
(table.set $ta (i32.const 5) (array.new_canon_default $at (i32.const 0))) (table.set $ta (i32.const 5) (array.new_default $at (i32.const 0)))
(table.set $ta (i32.const 6) (extern.internalize (local.get $x))) (table.set $ta (i32.const 6) (any.convert_extern (local.get $x)))
(table.set $ta (i32.const 7) (extern.internalize (ref.null extern))) (table.set $ta (i32.const 7) (any.convert_extern (ref.null extern)))
(table.set $tf (i32.const 0) (ref.null nofunc)) (table.set $tf (i32.const 0) (ref.null nofunc))
(table.set $tf (i32.const 1) (ref.null func)) (table.set $tf (i32.const 1) (ref.null func))
@ -27,78 +27,71 @@
(table.set $te (i32.const 0) (ref.null noextern)) (table.set $te (i32.const 0) (ref.null noextern))
(table.set $te (i32.const 1) (ref.null extern)) (table.set $te (i32.const 1) (ref.null extern))
(table.set $te (i32.const 2) (local.get $x)) (table.set $te (i32.const 2) (local.get $x))
(table.set $te (i32.const 3) (extern.externalize (i31.new (i32.const 8)))) (table.set $te (i32.const 3) (extern.convert_any (ref.i31 (i32.const 8))))
(table.set $te (i32.const 4) (extern.externalize (struct.new_canon_default $st))) (table.set $te (i32.const 4) (extern.convert_any (struct.new_default $st)))
(table.set $te (i32.const 5) (extern.externalize (ref.null any))) (table.set $te (i32.const 5) (extern.convert_any (ref.null any)))
) )
(func (export "ref_test_null_data") (param $i i32) (result i32) (func (export "ref_test_null_data") (param $i i32) (result i32)
(i32.add (i32.add
(ref.is_null (table.get $ta (local.get $i))) (ref.is_null (table.get $ta (local.get $i)))
(ref.test null none (table.get $ta (local.get $i))) (ref.test nullref (table.get $ta (local.get $i)))
) )
) )
(func (export "ref_test_any") (param $i i32) (result i32) (func (export "ref_test_any") (param $i i32) (result i32)
(i32.add (i32.add
(ref.test any (table.get $ta (local.get $i))) (ref.test (ref any) (table.get $ta (local.get $i)))
(ref.test null any (table.get $ta (local.get $i))) (ref.test anyref (table.get $ta (local.get $i)))
) )
) )
(func (export "ref_test_eq") (param $i i32) (result i32) (func (export "ref_test_eq") (param $i i32) (result i32)
(i32.add (i32.add
(ref.test eq (table.get $ta (local.get $i))) (ref.test (ref eq) (table.get $ta (local.get $i)))
(ref.test null eq (table.get $ta (local.get $i))) (ref.test eqref (table.get $ta (local.get $i)))
) )
) )
(func (export "ref_test_i31") (param $i i32) (result i32) (func (export "ref_test_i31") (param $i i32) (result i32)
(i32.add (i32.add
(ref.test i31 (table.get $ta (local.get $i))) (ref.test (ref i31) (table.get $ta (local.get $i)))
(ref.test null i31 (table.get $ta (local.get $i))) (ref.test i31ref (table.get $ta (local.get $i)))
) )
) )
(func (export "ref_test_struct") (param $i i32) (result i32) (func (export "ref_test_struct") (param $i i32) (result i32)
(i32.add (i32.add
(ref.test struct (table.get $ta (local.get $i))) (ref.test (ref struct) (table.get $ta (local.get $i)))
(ref.test null struct (table.get $ta (local.get $i))) (ref.test structref (table.get $ta (local.get $i)))
) )
) )
(func (export "ref_test_array") (param $i i32) (result i32) (func (export "ref_test_array") (param $i i32) (result i32)
(i32.add (i32.add
(ref.test array (table.get $ta (local.get $i))) (ref.test (ref array) (table.get $ta (local.get $i)))
(ref.test null array (table.get $ta (local.get $i))) (ref.test arrayref (table.get $ta (local.get $i)))
) )
) )
(func (export "ref_test_null_func") (param $i i32) (result i32) (func (export "ref_test_null_func") (param $i i32) (result i32)
(i32.add (i32.add
(ref.is_null (table.get $tf (local.get $i))) (ref.is_null (table.get $tf (local.get $i)))
(ref.test null nofunc (table.get $tf (local.get $i))) (ref.test (ref null nofunc) (table.get $tf (local.get $i)))
) )
) )
(func (export "ref_test_func") (param $i i32) (result i32) (func (export "ref_test_func") (param $i i32) (result i32)
(i32.add (i32.add
(ref.test func (table.get $tf (local.get $i))) (ref.test (ref func) (table.get $tf (local.get $i)))
(ref.test null func (table.get $tf (local.get $i))) (ref.test funcref (table.get $tf (local.get $i)))
) )
) )
(func (export "ref_test_null_extern") (param $i i32) (result i32) (func (export "ref_test_null_extern") (param $i i32) (result i32)
(i32.add (i32.add
(ref.is_null (table.get $te (local.get $i))) (ref.is_null (table.get $te (local.get $i)))
(ref.test null noextern (table.get $te (local.get $i))) (ref.test (ref null noextern) (table.get $te (local.get $i)))
) )
) )
(func (export "ref_test_extern") (param $i i32) (result i32) (func (export "ref_test_extern") (param $i i32) (result i32)
(i32.add (i32.add
(ref.test extern (table.get $te (local.get $i))) (ref.test (ref extern) (table.get $te (local.get $i)))
(ref.test null extern (table.get $te (local.get $i))) (ref.test externref (table.get $te (local.get $i)))
) )
) )
) )

Binary file not shown.

View File

@ -11,105 +11,105 @@
(table 20 (ref null struct)) (table 20 (ref null struct))
(func $init (func $init
(table.set (i32.const 0) (struct.new_canon_default $t0)) (table.set (i32.const 0) (struct.new_default $t0))
(table.set (i32.const 10) (struct.new_canon_default $t0)) (table.set (i32.const 10) (struct.new_default $t0))
(table.set (i32.const 1) (struct.new_canon_default $t1)) (table.set (i32.const 1) (struct.new_default $t1))
(table.set (i32.const 11) (struct.new_canon_default $t1')) (table.set (i32.const 11) (struct.new_default $t1'))
(table.set (i32.const 2) (struct.new_canon_default $t2)) (table.set (i32.const 2) (struct.new_default $t2))
(table.set (i32.const 12) (struct.new_canon_default $t2')) (table.set (i32.const 12) (struct.new_default $t2'))
(table.set (i32.const 3) (struct.new_canon_default $t3)) (table.set (i32.const 3) (struct.new_default $t3))
(table.set (i32.const 4) (struct.new_canon_default $t4)) (table.set (i32.const 4) (struct.new_default $t4))
) )
(func (export "test-sub") (func (export "test-sub")
(call $init) (call $init)
(block $l (block $l
;; must hold ;; must hold
(br_if $l (i32.eqz (ref.test null $t0 (ref.null struct)))) (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t0)))) (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t1)))) (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t2)))) (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t3)))) (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t0 (ref.null $t4)))) (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 0))))) (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 1))))) (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 3))))) (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test null $t0 (table.get (i32.const 4))))) (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null struct)))) (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t0)))) (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t1)))) (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t2)))) (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t3)))) (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t1 (ref.null $t4)))) (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t1 (table.get (i32.const 1))))) (br_if $l (i32.eqz (ref.test (ref null $t1) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test null $t1 (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref null $t1) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null struct)))) (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t0)))) (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t1)))) (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t2)))) (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t3)))) (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t2 (ref.null $t4)))) (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t2 (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref null $t2) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null struct)))) (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t0)))) (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t1)))) (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t2)))) (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t3)))) (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t3 (ref.null $t4)))) (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t3 (table.get (i32.const 3))))) (br_if $l (i32.eqz (ref.test (ref null $t3) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null struct)))) (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null struct))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t0)))) (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t0))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t1)))) (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t1))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t2)))) (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t2))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t3)))) (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t3))))
(br_if $l (i32.eqz (ref.test null $t4 (ref.null $t4)))) (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t4))))
(br_if $l (i32.eqz (ref.test null $t4 (table.get (i32.const 4))))) (br_if $l (i32.eqz (ref.test (ref null $t4) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 0))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 1))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 3))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 4))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 1))))) (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t2 (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref $t2) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t3 (table.get (i32.const 3))))) (br_if $l (i32.eqz (ref.test (ref $t3) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test $t4 (table.get (i32.const 4))))) (br_if $l (i32.eqz (ref.test (ref $t4) (table.get (i32.const 4)))))
;; must not hold ;; must not hold
(br_if $l (ref.test $t0 (ref.null struct))) (br_if $l (ref.test (ref $t0) (ref.null struct)))
(br_if $l (ref.test $t1 (ref.null struct))) (br_if $l (ref.test (ref $t1) (ref.null struct)))
(br_if $l (ref.test $t2 (ref.null struct))) (br_if $l (ref.test (ref $t2) (ref.null struct)))
(br_if $l (ref.test $t3 (ref.null struct))) (br_if $l (ref.test (ref $t3) (ref.null struct)))
(br_if $l (ref.test $t4 (ref.null struct))) (br_if $l (ref.test (ref $t4) (ref.null struct)))
(br_if $l (ref.test $t1 (table.get (i32.const 0)))) (br_if $l (ref.test (ref $t1) (table.get (i32.const 0))))
(br_if $l (ref.test $t1 (table.get (i32.const 3)))) (br_if $l (ref.test (ref $t1) (table.get (i32.const 3))))
(br_if $l (ref.test $t1 (table.get (i32.const 4)))) (br_if $l (ref.test (ref $t1) (table.get (i32.const 4))))
(br_if $l (ref.test $t2 (table.get (i32.const 0)))) (br_if $l (ref.test (ref $t2) (table.get (i32.const 0))))
(br_if $l (ref.test $t2 (table.get (i32.const 1)))) (br_if $l (ref.test (ref $t2) (table.get (i32.const 1))))
(br_if $l (ref.test $t2 (table.get (i32.const 3)))) (br_if $l (ref.test (ref $t2) (table.get (i32.const 3))))
(br_if $l (ref.test $t2 (table.get (i32.const 4)))) (br_if $l (ref.test (ref $t2) (table.get (i32.const 4))))
(br_if $l (ref.test $t3 (table.get (i32.const 0)))) (br_if $l (ref.test (ref $t3) (table.get (i32.const 0))))
(br_if $l (ref.test $t3 (table.get (i32.const 1)))) (br_if $l (ref.test (ref $t3) (table.get (i32.const 1))))
(br_if $l (ref.test $t3 (table.get (i32.const 2)))) (br_if $l (ref.test (ref $t3) (table.get (i32.const 2))))
(br_if $l (ref.test $t3 (table.get (i32.const 4)))) (br_if $l (ref.test (ref $t3) (table.get (i32.const 4))))
(br_if $l (ref.test $t4 (table.get (i32.const 0)))) (br_if $l (ref.test (ref $t4) (table.get (i32.const 0))))
(br_if $l (ref.test $t4 (table.get (i32.const 1)))) (br_if $l (ref.test (ref $t4) (table.get (i32.const 1))))
(br_if $l (ref.test $t4 (table.get (i32.const 2)))) (br_if $l (ref.test (ref $t4) (table.get (i32.const 2))))
(br_if $l (ref.test $t4 (table.get (i32.const 3)))) (br_if $l (ref.test (ref $t4) (table.get (i32.const 3))))
(return) (return)
) )
@ -119,25 +119,25 @@
(func (export "test-canon") (func (export "test-canon")
(call $init) (call $init)
(block $l (block $l
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 0))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 0)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 1))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 3))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 3)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 4))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 4)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 10))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 10)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 11))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 11)))))
(br_if $l (i32.eqz (ref.test $t0 (table.get (i32.const 12))))) (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 12)))))
(br_if $l (i32.eqz (ref.test $t1' (table.get (i32.const 1))))) (br_if $l (i32.eqz (ref.test (ref $t1') (table.get (i32.const 1)))))
(br_if $l (i32.eqz (ref.test $t1' (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref $t1') (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 11))))) (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 11)))))
(br_if $l (i32.eqz (ref.test $t1 (table.get (i32.const 12))))) (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 12)))))
(br_if $l (i32.eqz (ref.test $t2' (table.get (i32.const 2))))) (br_if $l (i32.eqz (ref.test (ref $t2') (table.get (i32.const 2)))))
(br_if $l (i32.eqz (ref.test $t2 (table.get (i32.const 12))))) (br_if $l (i32.eqz (ref.test (ref $t2) (table.get (i32.const 12)))))
(return) (return)
) )

Binary file not shown.

View File

@ -10,10 +10,10 @@
(func (export "init") (param $x externref) (func (export "init") (param $x externref)
(table.set (i32.const 0) (ref.null any)) (table.set (i32.const 0) (ref.null any))
(table.set (i32.const 1) (i31.new (i32.const 7))) (table.set (i32.const 1) (ref.i31 (i32.const 7)))
(table.set (i32.const 2) (struct.new_canon_default $st)) (table.set (i32.const 2) (struct.new_default $st))
(table.set (i32.const 3) (array.new_canon_default $at (i32.const 0))) (table.set (i32.const 3) (array.new_default $at (i32.const 0)))
(table.set (i32.const 4) (extern.internalize (local.get $x))) (table.set (i32.const 4) (any.convert_extern (local.get $x)))
(table.set (i32.const 5) (ref.null i31)) (table.set (i32.const 5) (ref.null i31))
(table.set (i32.const 6) (ref.null struct)) (table.set (i32.const 6) (ref.null struct))
(table.set (i32.const 7) (ref.null none)) (table.set (i32.const 7) (ref.null none))
@ -21,26 +21,25 @@
(func (export "ref_cast_non_null") (param $i i32) (func (export "ref_cast_non_null") (param $i i32)
(drop (ref.as_non_null (table.get (local.get $i)))) (drop (ref.as_non_null (table.get (local.get $i))))
(drop (ref.cast null any (table.get (local.get $i)))) (drop (ref.cast (ref null any) (table.get (local.get $i))))
) )
(func (export "ref_cast_null") (param $i i32) (func (export "ref_cast_null") (param $i i32)
(drop (ref.cast null any (table.get (local.get $i)))) (drop (ref.cast anyref (table.get (local.get $i))))
(drop (ref.cast null struct (table.get (local.get $i)))) (drop (ref.cast structref (table.get (local.get $i))))
(drop (ref.cast null array (table.get (local.get $i)))) (drop (ref.cast arrayref (table.get (local.get $i))))
(drop (ref.cast null i31 (table.get (local.get $i)))) (drop (ref.cast i31ref (table.get (local.get $i))))
(drop (ref.cast null none (table.get (local.get $i)))) (drop (ref.cast nullref (table.get (local.get $i))))
) )
(func (export "ref_cast_i31") (param $i i32) (func (export "ref_cast_i31") (param $i i32)
(drop (ref.cast i31 (table.get (local.get $i)))) (drop (ref.cast (ref i31) (table.get (local.get $i))))
(drop (ref.cast null i31 (table.get (local.get $i)))) (drop (ref.cast i31ref (table.get (local.get $i))))
) )
(func (export "ref_cast_struct") (param $i i32) (func (export "ref_cast_struct") (param $i i32)
(drop (ref.cast struct (table.get (local.get $i)))) (drop (ref.cast (ref struct) (table.get (local.get $i))))
(drop (ref.cast null struct (table.get (local.get $i)))) (drop (ref.cast structref (table.get (local.get $i))))
) )
(func (export "ref_cast_array") (param $i i32) (func (export "ref_cast_array") (param $i i32)
(drop (ref.cast array (table.get (local.get $i)))) (drop (ref.cast (ref array) (table.get (local.get $i))))
(drop (ref.cast null array (table.get (local.get $i)))) (drop (ref.cast arrayref (table.get (local.get $i))))
) )
) )

Binary file not shown.

View File

@ -11,75 +11,75 @@
(table 20 (ref null struct)) (table 20 (ref null struct))
(func $init (func $init
(table.set (i32.const 0) (struct.new_canon_default $t0)) (table.set (i32.const 0) (struct.new_default $t0))
(table.set (i32.const 10) (struct.new_canon_default $t0)) (table.set (i32.const 10) (struct.new_default $t0))
(table.set (i32.const 1) (struct.new_canon_default $t1)) (table.set (i32.const 1) (struct.new_default $t1))
(table.set (i32.const 11) (struct.new_canon_default $t1')) (table.set (i32.const 11) (struct.new_default $t1'))
(table.set (i32.const 2) (struct.new_canon_default $t2)) (table.set (i32.const 2) (struct.new_default $t2))
(table.set (i32.const 12) (struct.new_canon_default $t2')) (table.set (i32.const 12) (struct.new_default $t2'))
(table.set (i32.const 3) (struct.new_canon_default $t3)) (table.set (i32.const 3) (struct.new_default $t3))
(table.set (i32.const 4) (struct.new_canon_default $t4)) (table.set (i32.const 4) (struct.new_default $t4))
) )
(func (export "test-sub") (func (export "test-sub")
(call $init) (call $init)
(drop (ref.cast null $t0 (ref.null struct))) (drop (ref.cast (ref null $t0) (ref.null struct)))
(drop (ref.cast null $t0 (table.get (i32.const 0)))) (drop (ref.cast (ref null $t0) (table.get (i32.const 0))))
(drop (ref.cast null $t0 (table.get (i32.const 1)))) (drop (ref.cast (ref null $t0) (table.get (i32.const 1))))
(drop (ref.cast null $t0 (table.get (i32.const 2)))) (drop (ref.cast (ref null $t0) (table.get (i32.const 2))))
(drop (ref.cast null $t0 (table.get (i32.const 3)))) (drop (ref.cast (ref null $t0) (table.get (i32.const 3))))
(drop (ref.cast null $t0 (table.get (i32.const 4)))) (drop (ref.cast (ref null $t0) (table.get (i32.const 4))))
(drop (ref.cast null $t0 (ref.null struct))) (drop (ref.cast (ref null $t0) (ref.null struct)))
(drop (ref.cast null $t1 (table.get (i32.const 1)))) (drop (ref.cast (ref null $t1) (table.get (i32.const 1))))
(drop (ref.cast null $t1 (table.get (i32.const 2)))) (drop (ref.cast (ref null $t1) (table.get (i32.const 2))))
(drop (ref.cast null $t0 (ref.null struct))) (drop (ref.cast (ref null $t0) (ref.null struct)))
(drop (ref.cast null $t2 (table.get (i32.const 2)))) (drop (ref.cast (ref null $t2) (table.get (i32.const 2))))
(drop (ref.cast null $t0 (ref.null struct))) (drop (ref.cast (ref null $t0) (ref.null struct)))
(drop (ref.cast null $t3 (table.get (i32.const 3)))) (drop (ref.cast (ref null $t3) (table.get (i32.const 3))))
(drop (ref.cast null $t4 (table.get (i32.const 4)))) (drop (ref.cast (ref null $t4) (table.get (i32.const 4))))
(drop (ref.cast $t0 (table.get (i32.const 0)))) (drop (ref.cast (ref $t0) (table.get (i32.const 0))))
(drop (ref.cast $t0 (table.get (i32.const 1)))) (drop (ref.cast (ref $t0) (table.get (i32.const 1))))
(drop (ref.cast $t0 (table.get (i32.const 2)))) (drop (ref.cast (ref $t0) (table.get (i32.const 2))))
(drop (ref.cast $t0 (table.get (i32.const 3)))) (drop (ref.cast (ref $t0) (table.get (i32.const 3))))
(drop (ref.cast $t0 (table.get (i32.const 4)))) (drop (ref.cast (ref $t0) (table.get (i32.const 4))))
(drop (ref.cast $t1 (table.get (i32.const 1)))) (drop (ref.cast (ref $t1) (table.get (i32.const 1))))
(drop (ref.cast $t1 (table.get (i32.const 2)))) (drop (ref.cast (ref $t1) (table.get (i32.const 2))))
(drop (ref.cast $t2 (table.get (i32.const 2)))) (drop (ref.cast (ref $t2) (table.get (i32.const 2))))
(drop (ref.cast $t3 (table.get (i32.const 3)))) (drop (ref.cast (ref $t3) (table.get (i32.const 3))))
(drop (ref.cast $t4 (table.get (i32.const 4)))) (drop (ref.cast (ref $t4) (table.get (i32.const 4))))
) )
(func (export "test-canon") (func (export "test-canon")
(call $init) (call $init)
(drop (ref.cast $t0 (table.get (i32.const 0)))) (drop (ref.cast (ref $t0) (table.get (i32.const 0))))
(drop (ref.cast $t0 (table.get (i32.const 1)))) (drop (ref.cast (ref $t0) (table.get (i32.const 1))))
(drop (ref.cast $t0 (table.get (i32.const 2)))) (drop (ref.cast (ref $t0) (table.get (i32.const 2))))
(drop (ref.cast $t0 (table.get (i32.const 3)))) (drop (ref.cast (ref $t0) (table.get (i32.const 3))))
(drop (ref.cast $t0 (table.get (i32.const 4)))) (drop (ref.cast (ref $t0) (table.get (i32.const 4))))
(drop (ref.cast $t0 (table.get (i32.const 10)))) (drop (ref.cast (ref $t0) (table.get (i32.const 10))))
(drop (ref.cast $t0 (table.get (i32.const 11)))) (drop (ref.cast (ref $t0) (table.get (i32.const 11))))
(drop (ref.cast $t0 (table.get (i32.const 12)))) (drop (ref.cast (ref $t0) (table.get (i32.const 12))))
(drop (ref.cast $t1' (table.get (i32.const 1)))) (drop (ref.cast (ref $t1') (table.get (i32.const 1))))
(drop (ref.cast $t1' (table.get (i32.const 2)))) (drop (ref.cast (ref $t1') (table.get (i32.const 2))))
(drop (ref.cast $t1 (table.get (i32.const 11)))) (drop (ref.cast (ref $t1) (table.get (i32.const 11))))
(drop (ref.cast $t1 (table.get (i32.const 12)))) (drop (ref.cast (ref $t1) (table.get (i32.const 12))))
(drop (ref.cast $t2' (table.get (i32.const 2)))) (drop (ref.cast (ref $t2') (table.get (i32.const 2))))
(drop (ref.cast $t2 (table.get (i32.const 12)))) (drop (ref.cast (ref $t2) (table.get (i32.const 12))))
) )
) )

Binary file not shown.

View File

@ -12,13 +12,13 @@
(func (export "init") (func (export "init")
(table.set (i32.const 0) (ref.null eq)) (table.set (i32.const 0) (ref.null eq))
(table.set (i32.const 1) (ref.null i31)) (table.set (i32.const 1) (ref.null i31))
(table.set (i32.const 2) (i31.new (i32.const 7))) (table.set (i32.const 2) (ref.i31 (i32.const 7)))
(table.set (i32.const 3) (i31.new (i32.const 7))) (table.set (i32.const 3) (ref.i31 (i32.const 7)))
(table.set (i32.const 4) (i31.new (i32.const 8))) (table.set (i32.const 4) (ref.i31 (i32.const 8)))
(table.set (i32.const 5) (struct.new_canon_default $st)) (table.set (i32.const 5) (struct.new_default $st))
(table.set (i32.const 6) (struct.new_canon_default $st)) (table.set (i32.const 6) (struct.new_default $st))
(table.set (i32.const 7) (array.new_canon_default $at (i32.const 0))) (table.set (i32.const 7) (array.new_default $at (i32.const 0)))
(table.set (i32.const 8) (array.new_canon_default $at (i32.const 0))) (table.set (i32.const 8) (array.new_default $at (i32.const 0)))
) )
(func (export "eq") (param $i i32) (param $j i32) (result i32) (func (export "eq") (param $i i32) (param $j i32) (result i32)