[wasm-gc] Split and rename gc tests
Bug: v8:7748 Change-Id: I58e8216e3d51aa9da3e6a819cdf2614b4509e1a9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2250249 Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#68428}
This commit is contained in:
parent
30f409c751
commit
36532d1beb
@ -156,9 +156,8 @@ TEST(WasmBasicStruct) {
|
||||
FunctionSig sig_q_v(1, 0, kRefTypes);
|
||||
|
||||
// Test struct.new and struct.get.
|
||||
|
||||
tester.DefineFunction(
|
||||
"f", tester.sigs.i_v(), {},
|
||||
"get1", tester.sigs.i_v(), {},
|
||||
{WASM_STRUCT_GET(
|
||||
type_index, 0,
|
||||
WASM_STRUCT_NEW(type_index, WASM_I32V(42), WASM_I32V(64))),
|
||||
@ -166,7 +165,7 @@ TEST(WasmBasicStruct) {
|
||||
|
||||
// Test struct.new and struct.get.
|
||||
tester.DefineFunction(
|
||||
"g", tester.sigs.i_v(), {},
|
||||
"get2", tester.sigs.i_v(), {},
|
||||
{WASM_STRUCT_GET(
|
||||
type_index, 1,
|
||||
WASM_STRUCT_NEW(type_index, WASM_I32V(42), WASM_I32V(64))),
|
||||
@ -174,14 +173,14 @@ TEST(WasmBasicStruct) {
|
||||
|
||||
// Test struct.new, returning struct references to JS.
|
||||
tester.DefineFunction(
|
||||
"h", &sig_q_v, {},
|
||||
"getJs", &sig_q_v, {},
|
||||
{WASM_STRUCT_NEW(type_index, WASM_I32V(42), WASM_I32V(64)), kExprEnd});
|
||||
|
||||
// Test struct.set, struct refs types in locals.
|
||||
uint32_t j_local_index = 0;
|
||||
uint32_t j_field_index = 0;
|
||||
tester.DefineFunction(
|
||||
"j", tester.sigs.i_v(), {kOptRefType},
|
||||
"set", tester.sigs.i_v(), {kOptRefType},
|
||||
{WASM_SET_LOCAL(j_local_index, WASM_STRUCT_NEW(type_index, WASM_I32V(42),
|
||||
WASM_I32V(64))),
|
||||
WASM_STRUCT_SET(type_index, j_field_index, WASM_GET_LOCAL(j_local_index),
|
||||
@ -190,13 +189,29 @@ TEST(WasmBasicStruct) {
|
||||
WASM_GET_LOCAL(j_local_index)),
|
||||
kExprEnd});
|
||||
|
||||
// Test struct.set, ref.as_non_null,
|
||||
// struct refs types in globals and if-results.
|
||||
tester.CompileModule();
|
||||
|
||||
tester.CheckResult("get1", 42, {});
|
||||
tester.CheckResult("get2", 64, {});
|
||||
CHECK(tester.GetJSResult("getJs", {}).ToHandleChecked()->IsWasmStruct());
|
||||
tester.CheckResult("set", -99, {});
|
||||
}
|
||||
|
||||
// Test struct.set, ref.as_non_null,
|
||||
// struct refs types in globals and if-results.
|
||||
TEST(WasmRefAsNonNull) {
|
||||
WasmGCTester tester;
|
||||
uint32_t type_index =
|
||||
tester.DefineStruct({F(kWasmI32, true), F(kWasmI32, true)});
|
||||
ValueType kRefTypes[] = {ref(type_index)};
|
||||
ValueType kOptRefType = optref(type_index);
|
||||
FunctionSig sig_q_v(1, 0, kRefTypes);
|
||||
|
||||
uint32_t k_global_index = tester.AddGlobal(
|
||||
kOptRefType, true, WasmInitExpr(WasmInitExpr::kRefNullConst));
|
||||
uint32_t k_field_index = 0;
|
||||
tester.DefineFunction(
|
||||
"k", tester.sigs.i_v(), {},
|
||||
"f", tester.sigs.i_v(), {},
|
||||
{WASM_SET_GLOBAL(
|
||||
k_global_index,
|
||||
WASM_STRUCT_NEW(type_index, WASM_I32V(55), WASM_I32V(66))),
|
||||
@ -207,10 +222,20 @@ TEST(WasmBasicStruct) {
|
||||
WASM_REF_NULL_GC(type_index)))),
|
||||
kExprEnd});
|
||||
|
||||
// Test br_on_null 1.
|
||||
tester.CompileModule();
|
||||
tester.CheckResult("f", 55, {});
|
||||
}
|
||||
|
||||
TEST(WasmBrOnNull) {
|
||||
WasmGCTester tester;
|
||||
uint32_t type_index =
|
||||
tester.DefineStruct({F(kWasmI32, true), F(kWasmI32, true)});
|
||||
ValueType kRefTypes[] = {ref(type_index)};
|
||||
ValueType kOptRefType = optref(type_index);
|
||||
FunctionSig sig_q_v(1, 0, kRefTypes);
|
||||
uint32_t l_local_index = 0;
|
||||
tester.DefineFunction(
|
||||
"l", tester.sigs.i_v(), {kOptRefType},
|
||||
"taken", tester.sigs.i_v(), {kOptRefType},
|
||||
{WASM_BLOCK_I(WASM_I32V(42),
|
||||
// Branch will be taken.
|
||||
// 42 left on stack outside the block (not 52).
|
||||
@ -218,10 +243,9 @@ TEST(WasmBasicStruct) {
|
||||
WASM_I32V(52), WASM_BR(0)),
|
||||
kExprEnd});
|
||||
|
||||
// Test br_on_null 2.
|
||||
uint32_t m_field_index = 0;
|
||||
tester.DefineFunction(
|
||||
"m", tester.sigs.i_v(), {},
|
||||
"notTaken", tester.sigs.i_v(), {},
|
||||
{WASM_BLOCK_I(
|
||||
WASM_I32V(42),
|
||||
WASM_STRUCT_GET(
|
||||
@ -233,10 +257,22 @@ TEST(WasmBasicStruct) {
|
||||
WASM_BR(0)),
|
||||
kExprEnd});
|
||||
|
||||
// Test ref.eq
|
||||
tester.CompileModule();
|
||||
tester.CheckResult("taken", 42, {});
|
||||
tester.CheckResult("notTaken", 52, {});
|
||||
}
|
||||
|
||||
TEST(WasmRefEq) {
|
||||
WasmGCTester tester;
|
||||
uint32_t type_index =
|
||||
tester.DefineStruct({F(kWasmI32, true), F(kWasmI32, true)});
|
||||
ValueType kRefTypes[] = {ref(type_index)};
|
||||
ValueType kOptRefType = optref(type_index);
|
||||
FunctionSig sig_q_v(1, 0, kRefTypes);
|
||||
|
||||
uint32_t n_local_index = 0;
|
||||
tester.DefineFunction(
|
||||
"n", tester.sigs.i_v(), {kOptRefType},
|
||||
"f", tester.sigs.i_v(), {kOptRefType},
|
||||
{WASM_SET_LOCAL(n_local_index, WASM_STRUCT_NEW(type_index, WASM_I32V(55),
|
||||
WASM_I32V(66))),
|
||||
WASM_I32_ADD(
|
||||
@ -259,21 +295,9 @@ TEST(WasmBasicStruct) {
|
||||
WASM_REF_NULL_GC(type_index)),
|
||||
WASM_I32V(3))))),
|
||||
kExprEnd});
|
||||
// Result: 0b1001
|
||||
|
||||
/************************* End of test definitions *************************/
|
||||
|
||||
tester.CompileModule();
|
||||
|
||||
tester.CheckResult("f", 42, {});
|
||||
tester.CheckResult("g", 64, {});
|
||||
|
||||
CHECK(tester.GetJSResult("h", {}).ToHandleChecked()->IsWasmStruct());
|
||||
tester.CheckResult("j", -99, {});
|
||||
tester.CheckResult("k", 55, {});
|
||||
tester.CheckResult("l", 42, {});
|
||||
tester.CheckResult("m", 52, {});
|
||||
tester.CheckResult("n", 0b1001, {});
|
||||
tester.CheckResult("f", 0b1001, {});
|
||||
}
|
||||
|
||||
TEST(WasmPackedStructU) {
|
||||
|
Loading…
Reference in New Issue
Block a user