diff --git a/tests/unit/aot-stack-frame/CMakeLists.txt b/tests/unit/aot-stack-frame/CMakeLists.txt index cbdc62f65..90a61aea7 100644 --- a/tests/unit/aot-stack-frame/CMakeLists.txt +++ b/tests/unit/aot-stack-frame/CMakeLists.txt @@ -17,6 +17,7 @@ set (WAMR_BUILD_LIBC_BUILTIN 0) set (WAMR_BUILD_MULTI_MODULE 0) set (WAMR_DISABLE_HW_BOUND_CHECK 1) set (WAMR_DISABLE_WRITE_GS_BASE 1) +set (WAMR_BUILD_GC 1) 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_test_sources - ${UNIT_SOURCE} - ${PLATFORM_SHARED_SOURCE} - ${UTILS_SHARED_SOURCE} - ${MEM_ALLOC_SHARED_SOURCE} - ${NATIVE_INTERFACE_SOURCE} - ${IWASM_COMMON_SOURCE} - ${IWASM_INTERP_SOURCE} - ${IWASM_AOT_SOURCE} - ${WASM_APP_LIB_SOURCE_ALL} + ${UNIT_SOURCE} + ${WAMR_RUNTIME_LIB_SOURCE} + ${UNCOMMON_SHARED_SOURCE} + ${SRC_LIST} + ${PLATFORM_SHARED_SOURCE} + ${UTILS_SHARED_SOURCE} + ${MEM_ALLOC_SHARED_SOURCE} + ${LIB_HOST_AGENT_SOURCE} + ${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 diff --git a/tests/unit/aot-stack-frame/aot_stack_frame_test.cc b/tests/unit/aot-stack-frame/aot_stack_frame_test.cc index 9bea2b2a0..bcc1e246c 100644 --- a/tests/unit/aot-stack-frame/aot_stack_frame_test.cc +++ b/tests/unit/aot-stack-frame/aot_stack_frame_test.cc @@ -162,57 +162,6 @@ TEST_F(AOTStackFrameTest, test1) exec_env = wasm_runtime_create_exec_env(module_inst, 8 * 1024); 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"); ASSERT_TRUE(func_inst != NULL); @@ -233,11 +182,9 @@ TEST_F(AOTStackFrameTest, test2) 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); - 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; uint32 frame_num; @@ -271,18 +218,14 @@ TEST_F(AOTStackFrameTest, test3) ASSERT_TRUE(frames != NULL); ASSERT_TRUE(frame_num == 2); - ASSERT_TRUE(frames[0]->sp - frames[0]->lp == 5); - ASSERT_TRUE(frames[0]->ip_offset == 24); + // 5(i32) + 1(i64) local variables, occupied 7 * 4 bytes + 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[1] == 5678); ASSERT_TRUE(frames[0]->lp[2] == 0x11223344); 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); } diff --git a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt index 2becb77c9..6c43a4184 100644 --- a/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt +++ b/tests/unit/aot-stack-frame/wasm-apps/CMakeLists.txt @@ -13,7 +13,7 @@ add_custom_target(aot-stack-frame-test-wasm ALL -o ${CMAKE_CURRENT_BINARY_DIR}/test.wasm ${CMAKE_CURRENT_LIST_DIR}/test.wast && ${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 ${CMAKE_CURRENT_BINARY_DIR}/test.wasm && cmake -B ${CMAKE_CURRENT_BINARY_DIR}/build-binarydump diff --git a/tests/unit/gc/wasm-apps/func1.wasm b/tests/unit/gc/wasm-apps/func1.wasm index 51b316b54..1553dec75 100644 Binary files a/tests/unit/gc/wasm-apps/func1.wasm and b/tests/unit/gc/wasm-apps/func1.wasm differ diff --git a/tests/unit/gc/wasm-apps/func1.wast b/tests/unit/gc/wasm-apps/func1.wast index 1b4941787..adc9640e7 100644 --- a/tests/unit/gc/wasm-apps/func1.wast +++ b/tests/unit/gc/wasm-apps/func1.wast @@ -26,10 +26,10 @@ (local (ref null struct)) local.get 0 - ref.test null array + ref.test (ref array) drop local.get 1 - ref.cast i31 + ref.cast (ref i31) drop ) ) diff --git a/tests/unit/gc/wasm-apps/func2.wasm b/tests/unit/gc/wasm-apps/func2.wasm index e5d852ce4..d8fc92d02 100644 Binary files a/tests/unit/gc/wasm-apps/func2.wasm and b/tests/unit/gc/wasm-apps/func2.wasm differ diff --git a/tests/unit/gc/wasm-apps/struct1.wasm b/tests/unit/gc/wasm-apps/struct1.wasm index 513442f96..d8fc92d02 100644 Binary files a/tests/unit/gc/wasm-apps/struct1.wasm and b/tests/unit/gc/wasm-apps/struct1.wasm differ diff --git a/tests/unit/gc/wasm-apps/struct2.wasm b/tests/unit/gc/wasm-apps/struct2.wasm index 497a96441..7d22e80fd 100644 Binary files a/tests/unit/gc/wasm-apps/struct2.wasm and b/tests/unit/gc/wasm-apps/struct2.wasm differ diff --git a/tests/unit/gc/wasm-apps/struct2.wast b/tests/unit/gc/wasm-apps/struct2.wast index 266841d62..8868c1bcd 100644 --- a/tests/unit/gc/wasm-apps/struct2.wast +++ b/tests/unit/gc/wasm-apps/struct2.wast @@ -1,18 +1,36 @@ (module (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_canon_default $vec)) + (global (ref $vec) (struct.new $vec (f32.const 1) (f32.const 2) (f32.const 3))) + (global (ref $vec) (struct.new_default $vec)) (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)) ) - (func (export "get_0") (result f32) - (call $get_0 (struct.new_canon_default $vec)) + (func (export "get_vec_0") (result f32) + (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) @@ -20,7 +38,7 @@ (struct.get $vec $y (local.get $v)) ) (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) @@ -28,6 +46,6 @@ (struct.get $vec $y (local.get $v)) ) (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)) ) ) diff --git a/tests/unit/gc/wasm-apps/struct3.wasm b/tests/unit/gc/wasm-apps/struct3.wasm index 0da32361a..bae7fbcb8 100644 Binary files a/tests/unit/gc/wasm-apps/struct3.wasm and b/tests/unit/gc/wasm-apps/struct3.wasm differ diff --git a/tests/unit/gc/wasm-apps/test1.wasm b/tests/unit/gc/wasm-apps/test1.wasm index d907e457f..d8fc92d02 100644 Binary files a/tests/unit/gc/wasm-apps/test1.wasm and b/tests/unit/gc/wasm-apps/test1.wasm differ diff --git a/tests/unit/gc/wasm-apps/test2.wasm b/tests/unit/gc/wasm-apps/test2.wasm index 04507f174..2fa7567b6 100644 Binary files a/tests/unit/gc/wasm-apps/test2.wasm and b/tests/unit/gc/wasm-apps/test2.wasm differ diff --git a/tests/unit/gc/wasm-apps/test2.wast b/tests/unit/gc/wasm-apps/test2.wast index c2f7f3636..50d469708 100644 --- a/tests/unit/gc/wasm-apps/test2.wast +++ b/tests/unit/gc/wasm-apps/test2.wast @@ -14,11 +14,11 @@ (table.set $ta (i32.const 0) (ref.null any)) (table.set $ta (i32.const 1) (ref.null struct)) (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 4) (struct.new_canon_default $st)) - (table.set $ta (i32.const 5) (array.new_canon_default $at (i32.const 0))) - (table.set $ta (i32.const 6) (extern.internalize (local.get $x))) - (table.set $ta (i32.const 7) (extern.internalize (ref.null extern))) + (table.set $ta (i32.const 3) (ref.i31 (i32.const 7))) + (table.set $ta (i32.const 4) (struct.new_default $st)) + (table.set $ta (i32.const 5) (array.new_default $at (i32.const 0))) + (table.set $ta (i32.const 6) (any.convert_extern (local.get $x))) + (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 1) (ref.null func)) @@ -27,78 +27,71 @@ (table.set $te (i32.const 0) (ref.null noextern)) (table.set $te (i32.const 1) (ref.null extern)) (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 4) (extern.externalize (struct.new_canon_default $st))) - (table.set $te (i32.const 5) (extern.externalize (ref.null any))) + (table.set $te (i32.const 3) (extern.convert_any (ref.i31 (i32.const 8)))) + (table.set $te (i32.const 4) (extern.convert_any (struct.new_default $st))) + (table.set $te (i32.const 5) (extern.convert_any (ref.null any))) ) (func (export "ref_test_null_data") (param $i i32) (result i32) (i32.add (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) (i32.add - (ref.test any (table.get $ta (local.get $i))) - (ref.test null any (table.get $ta (local.get $i))) + (ref.test (ref 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) (i32.add - (ref.test eq (table.get $ta (local.get $i))) - (ref.test null eq (table.get $ta (local.get $i))) + (ref.test (ref 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) (i32.add - (ref.test i31 (table.get $ta (local.get $i))) - (ref.test null i31 (table.get $ta (local.get $i))) + (ref.test (ref 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) (i32.add - (ref.test struct (table.get $ta (local.get $i))) - (ref.test null struct (table.get $ta (local.get $i))) + (ref.test (ref 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) (i32.add - (ref.test array (table.get $ta (local.get $i))) - (ref.test null array (table.get $ta (local.get $i))) + (ref.test (ref 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) (i32.add (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) (i32.add - (ref.test func (table.get $tf (local.get $i))) - (ref.test null func (table.get $tf (local.get $i))) + (ref.test (ref 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) (i32.add (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) (i32.add - (ref.test extern (table.get $te (local.get $i))) - (ref.test null extern (table.get $te (local.get $i))) + (ref.test (ref extern) (table.get $te (local.get $i))) + (ref.test externref (table.get $te (local.get $i))) ) ) ) diff --git a/tests/unit/gc/wasm-apps/test3.wasm b/tests/unit/gc/wasm-apps/test3.wasm index 8ee87dc81..c85f0ee7b 100644 Binary files a/tests/unit/gc/wasm-apps/test3.wasm and b/tests/unit/gc/wasm-apps/test3.wasm differ diff --git a/tests/unit/gc/wasm-apps/test3.wast b/tests/unit/gc/wasm-apps/test3.wast index 4df02ce8f..e551b14b4 100644 --- a/tests/unit/gc/wasm-apps/test3.wast +++ b/tests/unit/gc/wasm-apps/test3.wast @@ -11,105 +11,105 @@ (table 20 (ref null struct)) (func $init - (table.set (i32.const 0) (struct.new_canon_default $t0)) - (table.set (i32.const 10) (struct.new_canon_default $t0)) - (table.set (i32.const 1) (struct.new_canon_default $t1)) - (table.set (i32.const 11) (struct.new_canon_default $t1')) - (table.set (i32.const 2) (struct.new_canon_default $t2)) - (table.set (i32.const 12) (struct.new_canon_default $t2')) - (table.set (i32.const 3) (struct.new_canon_default $t3)) - (table.set (i32.const 4) (struct.new_canon_default $t4)) + (table.set (i32.const 0) (struct.new_default $t0)) + (table.set (i32.const 10) (struct.new_default $t0)) + (table.set (i32.const 1) (struct.new_default $t1)) + (table.set (i32.const 11) (struct.new_default $t1')) + (table.set (i32.const 2) (struct.new_default $t2)) + (table.set (i32.const 12) (struct.new_default $t2')) + (table.set (i32.const 3) (struct.new_default $t3)) + (table.set (i32.const 4) (struct.new_default $t4)) ) (func (export "test-sub") (call $init) (block $l ;; must hold - (br_if $l (i32.eqz (ref.test null $t0 (ref.null struct)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t0 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test 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 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 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) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 0))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref null $t0) (table.get (i32.const 3))))) + (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 null $t1 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t1 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test 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 null $t1 (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (ref.null $t4)))) + (br_if $l (i32.eqz (ref.test (ref null $t1) (table.get (i32.const 1))))) + (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 null $t2 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t2 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test 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) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t2) (ref.null $t4)))) + (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 null $t3 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t3 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test 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) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t3) (ref.null $t4)))) + (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 null $t4 (ref.null $t0)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t1)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t2)))) - (br_if $l (i32.eqz (ref.test null $t4 (ref.null $t3)))) - (br_if $l (i32.eqz (ref.test 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) (ref.null struct)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t0)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t1)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t2)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t3)))) + (br_if $l (i32.eqz (ref.test (ref null $t4) (ref.null $t4)))) + (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 $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 $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 0))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 3))))) + (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 $t1 (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 1))))) + (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 - (br_if $l (ref.test $t0 (ref.null struct))) - (br_if $l (ref.test $t1 (ref.null struct))) - (br_if $l (ref.test $t2 (ref.null struct))) - (br_if $l (ref.test $t3 (ref.null struct))) - (br_if $l (ref.test $t4 (ref.null struct))) + (br_if $l (ref.test (ref $t0) (ref.null struct))) + (br_if $l (ref.test (ref $t1) (ref.null struct))) + (br_if $l (ref.test (ref $t2) (ref.null struct))) + (br_if $l (ref.test (ref $t3) (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 $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 0)))) + (br_if $l (ref.test (ref $t1) (table.get (i32.const 3)))) + (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 $t2 (table.get (i32.const 1)))) - (br_if $l (ref.test $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 0)))) + (br_if $l (ref.test (ref $t2) (table.get (i32.const 1)))) + (br_if $l (ref.test (ref $t2) (table.get (i32.const 3)))) + (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 $t3 (table.get (i32.const 1)))) - (br_if $l (ref.test $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 0)))) + (br_if $l (ref.test (ref $t3) (table.get (i32.const 1)))) + (br_if $l (ref.test (ref $t3) (table.get (i32.const 2)))) + (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 $t4 (table.get (i32.const 1)))) - (br_if $l (ref.test $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 0)))) + (br_if $l (ref.test (ref $t4) (table.get (i32.const 1)))) + (br_if $l (ref.test (ref $t4) (table.get (i32.const 2)))) + (br_if $l (ref.test (ref $t4) (table.get (i32.const 3)))) (return) ) @@ -119,25 +119,25 @@ (func (export "test-canon") (call $init) (block $l - (br_if $l (i32.eqz (ref.test $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 $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 $t0 (table.get (i32.const 4))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 0))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 1))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 3))))) + (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 $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 10))))) + (br_if $l (i32.eqz (ref.test (ref $t0) (table.get (i32.const 11))))) + (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 $t1' (table.get (i32.const 2))))) + (br_if $l (i32.eqz (ref.test (ref $t1') (table.get (i32.const 1))))) + (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 $t1 (table.get (i32.const 12))))) + (br_if $l (i32.eqz (ref.test (ref $t1) (table.get (i32.const 11))))) + (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) ) diff --git a/tests/unit/gc/wasm-apps/test4.wasm b/tests/unit/gc/wasm-apps/test4.wasm index b4841a82c..e7522e88f 100644 Binary files a/tests/unit/gc/wasm-apps/test4.wasm and b/tests/unit/gc/wasm-apps/test4.wasm differ diff --git a/tests/unit/gc/wasm-apps/test4.wast b/tests/unit/gc/wasm-apps/test4.wast index 8bf02e430..eeec11faa 100644 --- a/tests/unit/gc/wasm-apps/test4.wast +++ b/tests/unit/gc/wasm-apps/test4.wast @@ -10,10 +10,10 @@ (func (export "init") (param $x externref) (table.set (i32.const 0) (ref.null any)) - (table.set (i32.const 1) (i31.new (i32.const 7))) - (table.set (i32.const 2) (struct.new_canon_default $st)) - (table.set (i32.const 3) (array.new_canon_default $at (i32.const 0))) - (table.set (i32.const 4) (extern.internalize (local.get $x))) + (table.set (i32.const 1) (ref.i31 (i32.const 7))) + (table.set (i32.const 2) (struct.new_default $st)) + (table.set (i32.const 3) (array.new_default $at (i32.const 0))) + (table.set (i32.const 4) (any.convert_extern (local.get $x))) (table.set (i32.const 5) (ref.null i31)) (table.set (i32.const 6) (ref.null struct)) (table.set (i32.const 7) (ref.null none)) @@ -21,26 +21,25 @@ (func (export "ref_cast_non_null") (param $i i32) (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) - (drop (ref.cast null any (table.get (local.get $i)))) - (drop (ref.cast null struct (table.get (local.get $i)))) - (drop (ref.cast null array (table.get (local.get $i)))) - (drop (ref.cast null i31 (table.get (local.get $i)))) - (drop (ref.cast null none (table.get (local.get $i)))) + (drop (ref.cast anyref (table.get (local.get $i)))) + (drop (ref.cast structref (table.get (local.get $i)))) + (drop (ref.cast arrayref (table.get (local.get $i)))) + (drop (ref.cast i31ref (table.get (local.get $i)))) + (drop (ref.cast nullref (table.get (local.get $i)))) ) (func (export "ref_cast_i31") (param $i i32) - (drop (ref.cast i31 (table.get (local.get $i)))) - (drop (ref.cast null i31 (table.get (local.get $i)))) + (drop (ref.cast (ref i31) (table.get (local.get $i)))) + (drop (ref.cast i31ref (table.get (local.get $i)))) ) (func (export "ref_cast_struct") (param $i i32) - (drop (ref.cast struct (table.get (local.get $i)))) - (drop (ref.cast null struct (table.get (local.get $i)))) + (drop (ref.cast (ref struct) (table.get (local.get $i)))) + (drop (ref.cast structref (table.get (local.get $i)))) ) (func (export "ref_cast_array") (param $i i32) - (drop (ref.cast array (table.get (local.get $i)))) - (drop (ref.cast null array (table.get (local.get $i)))) + (drop (ref.cast (ref array) (table.get (local.get $i)))) + (drop (ref.cast arrayref (table.get (local.get $i)))) ) ) - diff --git a/tests/unit/gc/wasm-apps/test5.wasm b/tests/unit/gc/wasm-apps/test5.wasm index 050ead4ae..e92d600d1 100644 Binary files a/tests/unit/gc/wasm-apps/test5.wasm and b/tests/unit/gc/wasm-apps/test5.wasm differ diff --git a/tests/unit/gc/wasm-apps/test5.wast b/tests/unit/gc/wasm-apps/test5.wast index 895473ce3..f74da50e8 100644 --- a/tests/unit/gc/wasm-apps/test5.wast +++ b/tests/unit/gc/wasm-apps/test5.wast @@ -11,75 +11,75 @@ (table 20 (ref null struct)) (func $init - (table.set (i32.const 0) (struct.new_canon_default $t0)) - (table.set (i32.const 10) (struct.new_canon_default $t0)) - (table.set (i32.const 1) (struct.new_canon_default $t1)) - (table.set (i32.const 11) (struct.new_canon_default $t1')) - (table.set (i32.const 2) (struct.new_canon_default $t2)) - (table.set (i32.const 12) (struct.new_canon_default $t2')) - (table.set (i32.const 3) (struct.new_canon_default $t3)) - (table.set (i32.const 4) (struct.new_canon_default $t4)) + (table.set (i32.const 0) (struct.new_default $t0)) + (table.set (i32.const 10) (struct.new_default $t0)) + (table.set (i32.const 1) (struct.new_default $t1)) + (table.set (i32.const 11) (struct.new_default $t1')) + (table.set (i32.const 2) (struct.new_default $t2)) + (table.set (i32.const 12) (struct.new_default $t2')) + (table.set (i32.const 3) (struct.new_default $t3)) + (table.set (i32.const 4) (struct.new_default $t4)) ) (func (export "test-sub") (call $init) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t0 (table.get (i32.const 0)))) - (drop (ref.cast null $t0 (table.get (i32.const 1)))) - (drop (ref.cast null $t0 (table.get (i32.const 2)))) - (drop (ref.cast null $t0 (table.get (i32.const 3)))) - (drop (ref.cast null $t0 (table.get (i32.const 4)))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 0)))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 1)))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 2)))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 3)))) + (drop (ref.cast (ref null $t0) (table.get (i32.const 4)))) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t1 (table.get (i32.const 1)))) - (drop (ref.cast null $t1 (table.get (i32.const 2)))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (drop (ref.cast (ref null $t1) (table.get (i32.const 1)))) + (drop (ref.cast (ref null $t1) (table.get (i32.const 2)))) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t2 (table.get (i32.const 2)))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (drop (ref.cast (ref null $t2) (table.get (i32.const 2)))) - (drop (ref.cast null $t0 (ref.null struct))) - (drop (ref.cast null $t3 (table.get (i32.const 3)))) + (drop (ref.cast (ref null $t0) (ref.null struct))) + (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 $t0 (table.get (i32.const 1)))) - (drop (ref.cast $t0 (table.get (i32.const 2)))) - (drop (ref.cast $t0 (table.get (i32.const 3)))) - (drop (ref.cast $t0 (table.get (i32.const 4)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 0)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 1)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 2)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 3)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 4)))) - (drop (ref.cast $t1 (table.get (i32.const 1)))) - (drop (ref.cast $t1 (table.get (i32.const 2)))) + (drop (ref.cast (ref $t1) (table.get (i32.const 1)))) + (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") (call $init) - (drop (ref.cast $t0 (table.get (i32.const 0)))) - (drop (ref.cast $t0 (table.get (i32.const 1)))) - (drop (ref.cast $t0 (table.get (i32.const 2)))) - (drop (ref.cast $t0 (table.get (i32.const 3)))) - (drop (ref.cast $t0 (table.get (i32.const 4)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 0)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 1)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 2)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 3)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 4)))) - (drop (ref.cast $t0 (table.get (i32.const 10)))) - (drop (ref.cast $t0 (table.get (i32.const 11)))) - (drop (ref.cast $t0 (table.get (i32.const 12)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 10)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 11)))) + (drop (ref.cast (ref $t0) (table.get (i32.const 12)))) - (drop (ref.cast $t1' (table.get (i32.const 1)))) - (drop (ref.cast $t1' (table.get (i32.const 2)))) + (drop (ref.cast (ref $t1') (table.get (i32.const 1)))) + (drop (ref.cast (ref $t1') (table.get (i32.const 2)))) - (drop (ref.cast $t1 (table.get (i32.const 11)))) - (drop (ref.cast $t1 (table.get (i32.const 12)))) + (drop (ref.cast (ref $t1) (table.get (i32.const 11)))) + (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)))) ) ) diff --git a/tests/unit/gc/wasm-apps/test6.wasm b/tests/unit/gc/wasm-apps/test6.wasm index b1abc1472..f6b7a9e4a 100644 Binary files a/tests/unit/gc/wasm-apps/test6.wasm and b/tests/unit/gc/wasm-apps/test6.wasm differ diff --git a/tests/unit/gc/wasm-apps/test6.wast b/tests/unit/gc/wasm-apps/test6.wast index 0959b36f0..cd8a5bf29 100644 --- a/tests/unit/gc/wasm-apps/test6.wast +++ b/tests/unit/gc/wasm-apps/test6.wast @@ -12,13 +12,13 @@ (func (export "init") (table.set (i32.const 0) (ref.null eq)) (table.set (i32.const 1) (ref.null i31)) - (table.set (i32.const 2) (i31.new (i32.const 7))) - (table.set (i32.const 3) (i31.new (i32.const 7))) - (table.set (i32.const 4) (i31.new (i32.const 8))) - (table.set (i32.const 5) (struct.new_canon_default $st)) - (table.set (i32.const 6) (struct.new_canon_default $st)) - (table.set (i32.const 7) (array.new_canon_default $at (i32.const 0))) - (table.set (i32.const 8) (array.new_canon_default $at (i32.const 0))) + (table.set (i32.const 2) (ref.i31 (i32.const 7))) + (table.set (i32.const 3) (ref.i31 (i32.const 7))) + (table.set (i32.const 4) (ref.i31 (i32.const 8))) + (table.set (i32.const 5) (struct.new_default $st)) + (table.set (i32.const 6) (struct.new_default $st)) + (table.set (i32.const 7) (array.new_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)