Commit db6f0440 authored by Manos Koukoutos's avatar Manos Koukoutos Committed by Commit Bot

[wasm-gc][tests] Add supertype argument to WASM_RTT_SUB

Change-Id: I6a2ef3d1c46ea57b17234d050b8f0be12e27a197
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2315985Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69037}
parent 2f839277
...@@ -676,10 +676,10 @@ TEST(BasicRTT) { ...@@ -676,10 +676,10 @@ TEST(BasicRTT) {
&sig_t_v, {}, {WASM_RTT_CANON(type_index), kExprEnd}); &sig_t_v, {}, {WASM_RTT_CANON(type_index), kExprEnd});
const uint32_t kRttSub = tester.DefineFunction( const uint32_t kRttSub = tester.DefineFunction(
&sig_t2_v, {}, &sig_t2_v, {},
{WASM_RTT_CANON(type_index), WASM_RTT_SUB(subtype_index), kExprEnd}); {WASM_RTT_SUB(subtype_index, WASM_RTT_CANON(type_index)), kExprEnd});
const uint32_t kRttSubGeneric = tester.DefineFunction( const uint32_t kRttSubGeneric = tester.DefineFunction(
&sig_t3_v, {}, &sig_t3_v, {},
{WASM_RTT_CANON(kLocalEqRef), WASM_RTT_SUB(type_index), kExprEnd}); {WASM_RTT_SUB(type_index, WASM_RTT_CANON(kLocalEqRef)), kExprEnd});
const uint32_t kStructWithRtt = tester.DefineFunction( const uint32_t kStructWithRtt = tester.DefineFunction(
&sig_q_v, {}, &sig_q_v, {},
{WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42), {WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42),
...@@ -698,10 +698,9 @@ TEST(BasicRTT) { ...@@ -698,10 +698,9 @@ TEST(BasicRTT) {
// The expected return value is 1+42 = 43. // The expected return value is 1+42 = 43.
const uint32_t kRefCast = tester.DefineFunction( const uint32_t kRefCast = tester.DefineFunction(
tester.sigs.i_v(), {optref(type_index)}, tester.sigs.i_v(), {optref(type_index)},
/* TODO(jkummerow): The macro order here is a bit of a hack. */ {WASM_LET_1_I(
{WASM_RTT_CANON(type_index), WASM_RTT(2, subtype_index),
WASM_LET_1_I( WASM_RTT_SUB(subtype_index, WASM_RTT_CANON(type_index)),
WASM_RTT(2, subtype_index), WASM_RTT_SUB(subtype_index),
WASM_SET_LOCAL(kLocalStructIndex, WASM_SET_LOCAL(kLocalStructIndex,
WASM_STRUCT_NEW_WITH_RTT( WASM_STRUCT_NEW_WITH_RTT(
subtype_index, WASM_I32V(11), WASM_I32V(42), subtype_index, WASM_I32V(11), WASM_I32V(42),
......
...@@ -474,8 +474,8 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { ...@@ -474,8 +474,8 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
#define WASM_RTT_CANON(typeidx) \ #define WASM_RTT_CANON(typeidx) \
WASM_GC_OP(kExprRttCanon), static_cast<byte>(typeidx) WASM_GC_OP(kExprRttCanon), static_cast<byte>(typeidx)
#define WASM_RTT_SUB(typeidx) \ #define WASM_RTT_SUB(typeidx, supertype) \
WASM_GC_OP(kExprRttSub), static_cast<byte>(typeidx) supertype, WASM_GC_OP(kExprRttSub), static_cast<byte>(typeidx)
#define WASM_I31_NEW(val) val, WASM_GC_OP(kExprI31New) #define WASM_I31_NEW(val) val, WASM_GC_OP(kExprI31New)
#define WASM_I31_GET_S(val) val, WASM_GC_OP(kExprI31GetS) #define WASM_I31_GET_S(val) val, WASM_GC_OP(kExprI31GetS)
......
...@@ -686,7 +686,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfCanon) { ...@@ -686,7 +686,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfCanon) {
WASM_FEATURE_SCOPE(gc); WASM_FEATURE_SCOPE(gc);
static const byte data[] = {SECTION( static const byte data[] = {SECTION(
Global, ENTRY_COUNT(1), WASM_RTT(2, kLocalI31Ref), 1, Global, ENTRY_COUNT(1), WASM_RTT(2, kLocalI31Ref), 1,
WASM_RTT_CANON(kLocalEqRef), WASM_RTT_SUB(kLocalI31Ref), kExprEnd)}; WASM_RTT_SUB(kLocalI31Ref, WASM_RTT_CANON(kLocalEqRef)), kExprEnd)};
ModuleResult result = DecodeModule(data, data + sizeof(data)); ModuleResult result = DecodeModule(data, data + sizeof(data));
WasmInitExpr expected = WasmInitExpr::RttSub( WasmInitExpr expected = WasmInitExpr::RttSub(
HeapType::kI31, WasmInitExpr::RttCanon(HeapType::kEq)); HeapType::kI31, WasmInitExpr::RttCanon(HeapType::kEq));
...@@ -698,10 +698,11 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfSubOfCanon) { ...@@ -698,10 +698,11 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfSubOfCanon) {
WASM_FEATURE_SCOPE(reftypes); WASM_FEATURE_SCOPE(reftypes);
WASM_FEATURE_SCOPE(typed_funcref); WASM_FEATURE_SCOPE(typed_funcref);
WASM_FEATURE_SCOPE(gc); WASM_FEATURE_SCOPE(gc);
static const byte data[] = { static const byte data[] = {SECTION(
SECTION(Global, ENTRY_COUNT(1), WASM_RTT(3, kLocalEqRef), 1, Global, ENTRY_COUNT(1), WASM_RTT(3, kLocalEqRef), 1,
WASM_RTT_CANON(kLocalEqRef), WASM_RTT_SUB(kLocalEqRef), WASM_RTT_SUB(kLocalEqRef,
WASM_RTT_SUB(kLocalEqRef), kExprEnd)}; WASM_RTT_SUB(kLocalEqRef, WASM_RTT_CANON(kLocalEqRef))),
kExprEnd)};
ModuleResult result = DecodeModule(data, data + sizeof(data)); ModuleResult result = DecodeModule(data, data + sizeof(data));
WasmInitExpr expected = WasmInitExpr::RttSub( WasmInitExpr expected = WasmInitExpr::RttSub(
HeapType::kEq, WasmInitExpr::RttSub( HeapType::kEq, WasmInitExpr::RttSub(
...@@ -723,7 +724,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfGlobal) { ...@@ -723,7 +724,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfGlobal) {
WASM_RTT(1, kLocalEqRef), // type WASM_RTT(1, kLocalEqRef), // type
0), // mutability 0), // mutability
SECTION(Global, ENTRY_COUNT(1), WASM_RTT(2, kLocalI31Ref), 1, SECTION(Global, ENTRY_COUNT(1), WASM_RTT(2, kLocalI31Ref), 1,
WASM_GET_GLOBAL(0), WASM_RTT_SUB(kLocalI31Ref), kExprEnd)}; WASM_RTT_SUB(kLocalI31Ref, WASM_GET_GLOBAL(0)), kExprEnd)};
ModuleResult result = DecodeModule(data, data + sizeof(data)); ModuleResult result = DecodeModule(data, data + sizeof(data));
WasmInitExpr expected = WasmInitExpr expected =
WasmInitExpr::RttSub(HeapType::kI31, WasmInitExpr::GlobalGet(0)); WasmInitExpr::RttSub(HeapType::kI31, WasmInitExpr::GlobalGet(0));
...@@ -744,7 +745,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfGlobalTypeError) { ...@@ -744,7 +745,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfGlobalTypeError) {
kLocalI32, // type kLocalI32, // type
0), // mutability 0), // mutability
SECTION(Global, ENTRY_COUNT(1), WASM_RTT(2, kLocalExternRef), 1, SECTION(Global, ENTRY_COUNT(1), WASM_RTT(2, kLocalExternRef), 1,
WASM_GET_GLOBAL(0), WASM_RTT_SUB(kLocalExternRef), kExprEnd)}; WASM_RTT_SUB(kLocalExternRef, WASM_GET_GLOBAL(0)), kExprEnd)};
ModuleResult result = DecodeModule(data, data + sizeof(data)); ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "rtt.sub requires a supertype rtt on stack"); EXPECT_NOT_OK(result, "rtt.sub requires a supertype rtt on stack");
} }
...@@ -755,7 +756,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubIllegalParent) { ...@@ -755,7 +756,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubIllegalParent) {
WASM_FEATURE_SCOPE(gc); WASM_FEATURE_SCOPE(gc);
static const byte data[] = {SECTION( static const byte data[] = {SECTION(
Global, ENTRY_COUNT(1), WASM_RTT(2, kLocalEqRef), 1, Global, ENTRY_COUNT(1), WASM_RTT(2, kLocalEqRef), 1,
WASM_RTT_CANON(kLocalExternRef), WASM_RTT_SUB(kLocalEqRef), kExprEnd)}; WASM_RTT_SUB(kLocalEqRef, WASM_RTT_CANON(kLocalExternRef)), kExprEnd)};
ModuleResult result = DecodeModule(data, data + sizeof(data)); ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "rtt.sub requires a supertype rtt on stack"); EXPECT_NOT_OK(result, "rtt.sub requires a supertype rtt on stack");
} }
...@@ -766,7 +767,7 @@ TEST_F(WasmModuleVerifyTest, RttSubGlobalTypeError) { ...@@ -766,7 +767,7 @@ TEST_F(WasmModuleVerifyTest, RttSubGlobalTypeError) {
WASM_FEATURE_SCOPE(gc); WASM_FEATURE_SCOPE(gc);
static const byte data[] = {SECTION( static const byte data[] = {SECTION(
Global, ENTRY_COUNT(1), WASM_RTT(1 /* Should be 2 */, kLocalI31Ref), 1, Global, ENTRY_COUNT(1), WASM_RTT(1 /* Should be 2 */, kLocalI31Ref), 1,
WASM_RTT_CANON(kLocalEqRef), WASM_RTT_SUB(kLocalI31Ref), kExprEnd)}; WASM_RTT_SUB(kLocalI31Ref, WASM_RTT_CANON(kLocalEqRef)), kExprEnd)};
ModuleResult result = DecodeModule(data, data + sizeof(data)); ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, EXPECT_NOT_OK(result,
"type error in init expression, expected (rtt 1 i31), got " "type error in init expression, expected (rtt 1 i31), got "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment