Commit ad52bf8a authored by Matthias Liedtke's avatar Matthias Liedtke Committed by V8 LUCI CQ

[wasm-gc] Cleanup: Rename remaining '_static' op codes

Bug: v8:7748
Change-Id: Ie94e8f7f5afdaea7b4406bf8c57b294bf8f5733c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3865959Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82851}
parent c728b8a5
...@@ -2035,8 +2035,8 @@ class WasmDecoder : public Decoder { ...@@ -2035,8 +2035,8 @@ class WasmDecoder : public Decoder {
if (io) io->ArrayCopy(dst_imm, src_imm); if (io) io->ArrayCopy(dst_imm, src_imm);
return length + dst_imm.length + src_imm.length; return length + dst_imm.length + src_imm.length;
} }
case kExprArrayNewDataStatic: case kExprArrayNewData:
case kExprArrayNewElemStatic: { case kExprArrayNewElem: {
ArrayIndexImmediate<validate> array_imm(decoder, pc + length); ArrayIndexImmediate<validate> array_imm(decoder, pc + length);
IndexImmediate<validate> data_imm( IndexImmediate<validate> data_imm(
decoder, pc + length + array_imm.length, "segment index"); decoder, pc + length + array_imm.length, "segment index");
...@@ -2054,15 +2054,15 @@ class WasmDecoder : public Decoder { ...@@ -2054,15 +2054,15 @@ class WasmDecoder : public Decoder {
if (io) io->BranchDepth(imm); if (io) io->BranchDepth(imm);
return length + imm.length; return length + imm.length;
} }
case kExprRefTestStatic: case kExprRefTest:
case kExprRefCastStatic: case kExprRefCast:
case kExprRefCastNopStatic: { case kExprRefCastNop: {
IndexImmediate<validate> imm(decoder, pc + length, "type index"); IndexImmediate<validate> imm(decoder, pc + length, "type index");
if (io) io->TypeIndex(imm); if (io) io->TypeIndex(imm);
return length + imm.length; return length + imm.length;
} }
case kExprBrOnCastStatic: case kExprBrOnCast:
case kExprBrOnCastStaticFail: { case kExprBrOnCastFail: {
BranchDepthImmediate<validate> branch(decoder, pc + length); BranchDepthImmediate<validate> branch(decoder, pc + length);
IndexImmediate<validate> index(decoder, pc + length + branch.length, IndexImmediate<validate> index(decoder, pc + length + branch.length,
"type index"); "type index");
...@@ -2280,17 +2280,17 @@ class WasmDecoder : public Decoder { ...@@ -2280,17 +2280,17 @@ class WasmDecoder : public Decoder {
case kExprArrayNewDefault: case kExprArrayNewDefault:
case kExprArrayLenDeprecated: case kExprArrayLenDeprecated:
case kExprArrayLen: case kExprArrayLen:
case kExprRefTestStatic: case kExprRefTest:
case kExprRefCastStatic: case kExprRefCast:
case kExprRefCastNopStatic: case kExprRefCastNop:
case kExprBrOnCastStatic: case kExprBrOnCast:
case kExprBrOnCastStaticFail: case kExprBrOnCastFail:
return {1, 1}; return {1, 1};
case kExprStructSet: case kExprStructSet:
return {2, 0}; return {2, 0};
case kExprArrayNew: case kExprArrayNew:
case kExprArrayNewDataStatic: case kExprArrayNewData:
case kExprArrayNewElemStatic: case kExprArrayNewElem:
case kExprArrayGet: case kExprArrayGet:
case kExprArrayGetS: case kExprArrayGetS:
case kExprArrayGetU: case kExprArrayGetU:
...@@ -4437,7 +4437,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4437,7 +4437,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
Push(value); Push(value);
return opcode_length + imm.length; return opcode_length + imm.length;
} }
case kExprArrayNewDataStatic: { case kExprArrayNewData: {
ArrayIndexImmediate<validate> array_imm(this, ArrayIndexImmediate<validate> array_imm(this,
this->pc_ + opcode_length); this->pc_ + opcode_length);
if (!this->Validate(this->pc_ + opcode_length, array_imm)) return 0; if (!this->Validate(this->pc_ + opcode_length, array_imm)) return 0;
...@@ -4479,7 +4479,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4479,7 +4479,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
Push(array); Push(array);
return opcode_length + array_imm.length + data_segment.length; return opcode_length + array_imm.length + data_segment.length;
} }
case kExprArrayNewElemStatic: { case kExprArrayNewElem: {
ArrayIndexImmediate<validate> array_imm(this, ArrayIndexImmediate<validate> array_imm(this,
this->pc_ + opcode_length); this->pc_ + opcode_length);
if (!this->Validate(this->pc_ + opcode_length, array_imm)) return 0; if (!this->Validate(this->pc_ + opcode_length, array_imm)) return 0;
...@@ -4696,7 +4696,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4696,7 +4696,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
Push(value); Push(value);
return opcode_length; return opcode_length;
} }
case kExprRefTestStatic: { case kExprRefTest: {
NON_CONST_ONLY NON_CONST_ONLY
IndexImmediate<validate> imm(this, this->pc_ + opcode_length, IndexImmediate<validate> imm(this, this->pc_ + opcode_length,
"type index"); "type index");
...@@ -4740,7 +4740,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4740,7 +4740,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
Push(value); Push(value);
return opcode_length; return opcode_length;
} }
case kExprRefCastNopStatic: { case kExprRefCastNop: {
// Temporary non-standard instruction, for performance experiments. // Temporary non-standard instruction, for performance experiments.
if (!VALIDATE(this->enabled_.has_ref_cast_nop())) { if (!VALIDATE(this->enabled_.has_ref_cast_nop())) {
this->DecodeError( this->DecodeError(
...@@ -4767,7 +4767,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4767,7 +4767,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
Push(value); Push(value);
return opcode_length; return opcode_length;
} }
case kExprRefCastStatic: { case kExprRefCast: {
NON_CONST_ONLY NON_CONST_ONLY
IndexImmediate<validate> imm(this, this->pc_ + opcode_length, IndexImmediate<validate> imm(this, this->pc_ + opcode_length,
"type index"); "type index");
...@@ -4817,7 +4817,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4817,7 +4817,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
Push(value); Push(value);
return opcode_length; return opcode_length;
} }
case kExprBrOnCastStatic: { case kExprBrOnCast: {
NON_CONST_ONLY NON_CONST_ONLY
BranchDepthImmediate<validate> branch_depth(this, BranchDepthImmediate<validate> branch_depth(this,
this->pc_ + opcode_length); this->pc_ + opcode_length);
...@@ -4886,7 +4886,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> { ...@@ -4886,7 +4886,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
Push(obj); // Restore stack state on fallthrough. Push(obj); // Restore stack state on fallthrough.
return pc_offset; return pc_offset;
} }
case kExprBrOnCastStaticFail: { case kExprBrOnCastFail: {
NON_CONST_ONLY NON_CONST_ONLY
BranchDepthImmediate<validate> branch_depth(this, BranchDepthImmediate<validate> branch_depth(this,
this->pc_ + opcode_length); this->pc_ + opcode_length);
......
...@@ -702,16 +702,16 @@ bool V8_EXPORT_PRIVATE IsJSCompatibleSignature(const FunctionSig* sig, ...@@ -702,16 +702,16 @@ bool V8_EXPORT_PRIVATE IsJSCompatibleSignature(const FunctionSig* sig,
V(ArrayNewFixed, 0xfb1a, _, "array.new_fixed") \ V(ArrayNewFixed, 0xfb1a, _, "array.new_fixed") \
V(ArrayNew, 0xfb1b, _, "array.new") \ V(ArrayNew, 0xfb1b, _, "array.new") \
V(ArrayNewDefault, 0xfb1c, _, "array.new_default") \ V(ArrayNewDefault, 0xfb1c, _, "array.new_default") \
V(ArrayNewDataStatic, 0xfb1d, _, "array.new_data_static") \ V(ArrayNewData, 0xfb1d, _, "array.new_data") \
V(ArrayNewElemStatic, 0xfb1f, _, "array.new_elem_static") \ V(ArrayNewElem, 0xfb1f, _, "array.new_elem") \
V(I31New, 0xfb20, _, "i31.new") \ V(I31New, 0xfb20, _, "i31.new") \
V(I31GetS, 0xfb21, _, "i31.get_s") \ V(I31GetS, 0xfb21, _, "i31.get_s") \
V(I31GetU, 0xfb22, _, "i31.get_u") \ V(I31GetU, 0xfb22, _, "i31.get_u") \
V(RefTestStatic, 0xfb44, _, "ref.test_static") \ V(RefTest, 0xfb44, _, "ref.test") \
V(RefCastStatic, 0xfb45, _, "ref.cast_static") \ V(RefCast, 0xfb45, _, "ref.cast") \
V(BrOnCastStatic, 0xfb46, _, "br_on_cast_static") \ V(BrOnCast, 0xfb46, _, "br_on_cast") \
V(BrOnCastStaticFail, 0xfb47, _, "br_on_cast_static_fail") \ V(BrOnCastFail, 0xfb47, _, "br_on_cast_fail") \
V(RefCastNopStatic, 0xfb48, _, "ref.cast_nop_static") \ V(RefCastNop, 0xfb48, _, "ref.cast_nop") \
V(RefIsData, 0xfb51, _, "ref.is_data") \ V(RefIsData, 0xfb51, _, "ref.is_data") \
V(RefIsI31, 0xfb52, _, "ref.is_i31") \ V(RefIsI31, 0xfb52, _, "ref.is_i31") \
V(RefIsArray, 0xfb53, _, "ref.is_array") \ V(RefIsArray, 0xfb53, _, "ref.is_array") \
......
...@@ -469,7 +469,7 @@ WASM_COMPILED_EXEC_TEST(WasmBrOnNonNull) { ...@@ -469,7 +469,7 @@ WASM_COMPILED_EXEC_TEST(WasmBrOnNonNull) {
tester.CheckResult(kNotTaken, 11); tester.CheckResult(kNotTaken, 11);
} }
WASM_COMPILED_EXEC_TEST(RefCastStatic) { WASM_COMPILED_EXEC_TEST(RefCast) {
WasmGCTester tester(execution_tier); WasmGCTester tester(execution_tier);
const byte supertype_index = tester.DefineStruct({F(kWasmI32, true)}); const byte supertype_index = tester.DefineStruct({F(kWasmI32, true)});
...@@ -503,7 +503,7 @@ WASM_COMPILED_EXEC_TEST(RefCastStatic) { ...@@ -503,7 +503,7 @@ WASM_COMPILED_EXEC_TEST(RefCastStatic) {
{WASM_LOCAL_SET( {WASM_LOCAL_SET(
0, WASM_STRUCT_NEW(subtype1_index, WASM_I32V(10), WASM_F32(20))), 0, WASM_STRUCT_NEW(subtype1_index, WASM_I32V(10), WASM_F32(20))),
WASM_STRUCT_GET(subtype1_index, 0, WASM_STRUCT_GET(subtype1_index, 0,
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), subtype1_index)), WASM_REF_CAST(WASM_LOCAL_GET(0), subtype1_index)),
WASM_END}); WASM_END});
const byte kTestFailed = tester.DefineFunction( const byte kTestFailed = tester.DefineFunction(
...@@ -511,26 +511,26 @@ WASM_COMPILED_EXEC_TEST(RefCastStatic) { ...@@ -511,26 +511,26 @@ WASM_COMPILED_EXEC_TEST(RefCastStatic) {
{WASM_LOCAL_SET( {WASM_LOCAL_SET(
0, WASM_STRUCT_NEW(subtype1_index, WASM_I32V(10), WASM_F32(20))), 0, WASM_STRUCT_NEW(subtype1_index, WASM_I32V(10), WASM_F32(20))),
WASM_STRUCT_GET(subtype2_index, 0, WASM_STRUCT_GET(subtype2_index, 0,
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), subtype2_index)), WASM_REF_CAST(WASM_LOCAL_GET(0), subtype2_index)),
WASM_END}); WASM_END});
const byte kFuncTestSuccessfulSuper = tester.DefineFunction( const byte kFuncTestSuccessfulSuper = tester.DefineFunction(
tester.sigs.i_v(), {ValueType::RefNull(function_type_index)}, tester.sigs.i_v(), {ValueType::RefNull(function_type_index)},
{WASM_LOCAL_SET(0, WASM_REF_FUNC(function_index)), {WASM_LOCAL_SET(0, WASM_REF_FUNC(function_index)),
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), function_type_index), WASM_DROP, WASM_REF_CAST(WASM_LOCAL_GET(0), function_type_index), WASM_DROP,
WASM_I32V(0), WASM_END}); WASM_I32V(0), WASM_END});
const byte kFuncTestSuccessfulSub = tester.DefineFunction( const byte kFuncTestSuccessfulSub = tester.DefineFunction(
tester.sigs.i_v(), {ValueType::RefNull(function_type_index)}, tester.sigs.i_v(), {ValueType::RefNull(function_type_index)},
{WASM_LOCAL_SET(0, WASM_REF_FUNC(function_index)), {WASM_LOCAL_SET(0, WASM_REF_FUNC(function_index)),
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), function_subtype1_index), WASM_REF_CAST(WASM_LOCAL_GET(0), function_subtype1_index), WASM_DROP,
WASM_DROP, WASM_I32V(0), WASM_END}); WASM_I32V(0), WASM_END});
const byte kFuncTestFailed = tester.DefineFunction( const byte kFuncTestFailed = tester.DefineFunction(
tester.sigs.i_v(), {ValueType::RefNull(function_type_index)}, tester.sigs.i_v(), {ValueType::RefNull(function_type_index)},
{WASM_LOCAL_SET(0, WASM_REF_FUNC(function_index)), {WASM_LOCAL_SET(0, WASM_REF_FUNC(function_index)),
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), function_subtype2_index), WASM_REF_CAST(WASM_LOCAL_GET(0), function_subtype2_index), WASM_DROP,
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_I32V(1), WASM_END});
tester.CompileModule(); tester.CompileModule();
tester.CheckResult(kTestSuccessful, 10); tester.CheckResult(kTestSuccessful, 10);
...@@ -540,7 +540,7 @@ WASM_COMPILED_EXEC_TEST(RefCastStatic) { ...@@ -540,7 +540,7 @@ WASM_COMPILED_EXEC_TEST(RefCastStatic) {
tester.CheckHasThrown(kFuncTestFailed); tester.CheckHasThrown(kFuncTestFailed);
} }
WASM_COMPILED_EXEC_TEST(RefCastStaticNoChecks) { WASM_COMPILED_EXEC_TEST(RefCastNoChecks) {
FlagScope<bool> scope(&v8_flags.experimental_wasm_assume_ref_cast_succeeds, FlagScope<bool> scope(&v8_flags.experimental_wasm_assume_ref_cast_succeeds,
true); true);
WasmGCTester tester(execution_tier); WasmGCTester tester(execution_tier);
...@@ -555,14 +555,14 @@ WASM_COMPILED_EXEC_TEST(RefCastStaticNoChecks) { ...@@ -555,14 +555,14 @@ WASM_COMPILED_EXEC_TEST(RefCastStaticNoChecks) {
tester.sigs.i_v(), {ValueType::RefNull(supertype_index)}, tester.sigs.i_v(), {ValueType::RefNull(supertype_index)},
{WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype1_index)), {WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype1_index)),
WASM_STRUCT_GET(subtype1_index, 0, WASM_STRUCT_GET(subtype1_index, 0,
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), subtype1_index)), WASM_REF_CAST(WASM_LOCAL_GET(0), subtype1_index)),
WASM_END}); WASM_END});
const byte kTestFailed = tester.DefineFunction( const byte kTestFailed = tester.DefineFunction(
tester.sigs.i_v(), {ValueType::RefNull(supertype_index)}, tester.sigs.i_v(), {ValueType::RefNull(supertype_index)},
{WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype1_index)), {WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype1_index)),
WASM_STRUCT_GET(subtype2_index, 0, WASM_STRUCT_GET(subtype2_index, 0,
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), subtype2_index)), WASM_REF_CAST(WASM_LOCAL_GET(0), subtype2_index)),
WASM_END}); WASM_END});
tester.CompileModule(); tester.CompileModule();
...@@ -584,14 +584,13 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) { ...@@ -584,14 +584,13 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) {
WASM_LOCAL_SET(1, WASM_STRUCT_NEW(other_type_index, WASM_F32(1.0))), WASM_LOCAL_SET(1, WASM_STRUCT_NEW(other_type_index, WASM_F32(1.0))),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(1),
// The type check fails, so this branch isn't taken. // The type check fails, so this branch isn't taken.
WASM_BR_ON_CAST_STATIC(0, type_index), WASM_DROP, WASM_BR_ON_CAST(0, type_index), WASM_DROP,
WASM_LOCAL_SET(0, WASM_I32V(221)), // (Final result) - 1 WASM_LOCAL_SET(0, WASM_I32V(221)), // (Final result) - 1
WASM_LOCAL_SET(1, WASM_STRUCT_NEW(type_index, WASM_I32V(1))), WASM_LOCAL_SET(1, WASM_STRUCT_NEW(type_index, WASM_I32V(1))),
WASM_LOCAL_GET(1), WASM_LOCAL_GET(1),
// This branch is taken. // This branch is taken.
WASM_BR_ON_CAST_STATIC(0, type_index), WASM_BR_ON_CAST(0, type_index), WASM_GC_OP(kExprRefCast), type_index,
WASM_GC_OP(kExprRefCastStatic), type_index,
// Not executed due to the branch. // Not executed due to the branch.
WASM_LOCAL_SET(0, WASM_I32V(333))), WASM_LOCAL_SET(0, WASM_I32V(333))),
...@@ -600,14 +599,13 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) { ...@@ -600,14 +599,13 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) {
const byte kTestNull = tester.DefineFunction( const byte kTestNull = tester.DefineFunction(
tester.sigs.i_v(), {kWasmI32, kWasmDataRef}, tester.sigs.i_v(), {kWasmI32, kWasmDataRef},
{WASM_BLOCK_R(ValueType::RefNull(type_index), {WASM_BLOCK_R(
WASM_LOCAL_SET(0, WASM_I32V(111)), ValueType::RefNull(type_index), WASM_LOCAL_SET(0, WASM_I32V(111)),
WASM_LOCAL_GET(1), // Put a nullref onto the value stack. WASM_LOCAL_GET(1), // Put a nullref onto the value stack.
// Not taken for nullref. // Not taken for nullref.
WASM_BR_ON_CAST_STATIC(0, type_index), WASM_BR_ON_CAST(0, type_index), WASM_GC_OP(kExprRefCast), type_index,
WASM_GC_OP(kExprRefCastStatic), type_index,
WASM_LOCAL_SET(0, WASM_I32V(222))), // Final result.
WASM_LOCAL_SET(0, WASM_I32V(222))), // Final result.
WASM_DROP, WASM_LOCAL_GET(0), kExprEnd}); WASM_DROP, WASM_LOCAL_GET(0), kExprEnd});
const byte kTypedAfterBranch = tester.DefineFunction( const byte kTypedAfterBranch = tester.DefineFunction(
...@@ -617,7 +615,7 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) { ...@@ -617,7 +615,7 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) {
// The inner block should take the early branch with a struct // The inner block should take the early branch with a struct
// on the stack. // on the stack.
WASM_BLOCK_R(ValueType::Ref(type_index), WASM_LOCAL_GET(1), WASM_BLOCK_R(ValueType::Ref(type_index), WASM_LOCAL_GET(1),
WASM_BR_ON_CAST_STATIC(0, type_index), WASM_BR_ON_CAST(0, type_index),
// Returning 123 is the unreachable failure case. // Returning 123 is the unreachable failure case.
WASM_I32V(123), WASM_BR(1)), WASM_I32V(123), WASM_BR(1)),
// The outer block catches the struct left behind by the inner block // The outer block catches the struct left behind by the inner block
...@@ -653,9 +651,9 @@ WASM_COMPILED_EXEC_TEST(BrOnCastFail) { ...@@ -653,9 +651,9 @@ WASM_COMPILED_EXEC_TEST(BrOnCastFail) {
WASM_LOCAL_SET(0, WASM_SEQ(value)), \ WASM_LOCAL_SET(0, WASM_SEQ(value)), \
WASM_BLOCK( \ WASM_BLOCK( \
WASM_BLOCK_R(kWasmDataRef, WASM_LOCAL_GET(0), \ WASM_BLOCK_R(kWasmDataRef, WASM_LOCAL_GET(0), \
WASM_BR_ON_CAST_STATIC_FAIL(0, type0), \ WASM_BR_ON_CAST_FAIL(0, type0), \
WASM_GC_OP(kExprStructGet), type0, 0, kExprReturn), \ WASM_GC_OP(kExprStructGet), type0, 0, kExprReturn), \
kExprBrOnNull, 0, WASM_GC_OP(kExprRefCastStatic), type1, \ kExprBrOnNull, 0, WASM_GC_OP(kExprRefCast), type1, \
WASM_GC_OP(kExprStructGet), type1, 1, kExprReturn), \ WASM_GC_OP(kExprStructGet), type1, 1, kExprReturn), \
WASM_I32V(null_value), kExprEnd WASM_I32V(null_value), kExprEnd
...@@ -683,9 +681,9 @@ WASM_COMPILED_EXEC_TEST(BrOnCastFail) { ...@@ -683,9 +681,9 @@ WASM_COMPILED_EXEC_TEST(BrOnCastFail) {
0, WASM_STRUCT_NEW(type1, WASM_I64V(10), WASM_I32V(field1_value))), 0, WASM_STRUCT_NEW(type1, WASM_I64V(10), WASM_I32V(field1_value))),
WASM_BLOCK( WASM_BLOCK(
WASM_BLOCK_R(kWasmDataRef, WASM_LOCAL_GET(0), WASM_BLOCK_R(kWasmDataRef, WASM_LOCAL_GET(0),
WASM_BR_ON_CAST_STATIC_FAIL(0, type0), WASM_BR_ON_CAST_FAIL(0, type0),
WASM_GC_OP(kExprStructGet), type0, 0, kExprReturn), WASM_GC_OP(kExprStructGet), type0, 0, kExprReturn),
kExprBrOnNull, 0, WASM_GC_OP(kExprRefCastStatic), type1, kExprBrOnNull, 0, WASM_GC_OP(kExprRefCast), type1,
WASM_GC_OP(kExprStructGet), type1, 1, kExprReturn), WASM_GC_OP(kExprStructGet), type1, 1, kExprReturn),
WASM_I32V(null_value), kExprEnd}); WASM_I32V(null_value), kExprEnd});
...@@ -1194,79 +1192,75 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) { ...@@ -1194,79 +1192,75 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) {
const byte kRefTestNull = tester.DefineFunction( const byte kRefTestNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_TEST_STATIC(WASM_REF_NULL(type_index), subtype_index), {WASM_REF_TEST(WASM_REF_NULL(type_index), subtype_index), kExprEnd});
kExprEnd});
// Upcasts should be optimized away for nominal types. // Upcasts should be optimized away for nominal types.
const byte kRefTestUpcast = tester.DefineFunction( const byte kRefTestUpcast = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_TEST_STATIC(WASM_STRUCT_NEW_DEFAULT(subtype_index), type_index), {WASM_REF_TEST(WASM_STRUCT_NEW_DEFAULT(subtype_index), type_index),
kExprEnd}); kExprEnd});
const byte kRefTestUpcastNull = tester.DefineFunction( const byte kRefTestUpcastNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_TEST_STATIC(WASM_REF_NULL(subtype_index), type_index), {WASM_REF_TEST(WASM_REF_NULL(subtype_index), type_index), kExprEnd});
kExprEnd});
const byte kRefTestUnrelatedNullable = tester.DefineFunction( const byte kRefTestUnrelatedNullable = tester.DefineFunction(
tester.sigs.i_v(), {refNull(subtype_index)}, tester.sigs.i_v(), {refNull(subtype_index)},
{WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype_index)), {WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype_index)),
WASM_REF_TEST_STATIC(WASM_LOCAL_GET(0), sig_index), kExprEnd}); WASM_REF_TEST(WASM_LOCAL_GET(0), sig_index), kExprEnd});
const byte kRefTestUnrelatedNull = tester.DefineFunction( const byte kRefTestUnrelatedNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_TEST_STATIC(WASM_REF_NULL(subtype_index), sig_index), {WASM_REF_TEST(WASM_REF_NULL(subtype_index), sig_index), kExprEnd});
kExprEnd});
const byte kRefTestUnrelatedNonNullable = tester.DefineFunction( const byte kRefTestUnrelatedNonNullable = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_TEST_STATIC(WASM_STRUCT_NEW_DEFAULT(type_index), sig_index), {WASM_REF_TEST(WASM_STRUCT_NEW_DEFAULT(type_index), sig_index),
kExprEnd}); kExprEnd});
const byte kRefCastNull = const byte kRefCastNull =
tester.DefineFunction(tester.sigs.i_v(), {}, tester.DefineFunction(tester.sigs.i_v(), {},
{WASM_REF_IS_NULL(WASM_REF_CAST_STATIC( {WASM_REF_IS_NULL(WASM_REF_CAST(
WASM_REF_NULL(type_index), subtype_index)), WASM_REF_NULL(type_index), subtype_index)),
kExprEnd}); kExprEnd});
const byte kRefCastUpcast = tester.DefineFunction( const byte kRefCastUpcast = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_IS_NULL(WASM_REF_CAST_STATIC( {WASM_REF_IS_NULL(
WASM_STRUCT_NEW_DEFAULT(subtype_index), type_index)), WASM_REF_CAST(WASM_STRUCT_NEW_DEFAULT(subtype_index), type_index)),
kExprEnd}); kExprEnd});
const byte kRefCastUpcastNull = const byte kRefCastUpcastNull =
tester.DefineFunction(tester.sigs.i_v(), {}, tester.DefineFunction(tester.sigs.i_v(), {},
{WASM_REF_IS_NULL(WASM_REF_CAST_STATIC( {WASM_REF_IS_NULL(WASM_REF_CAST(
WASM_REF_NULL(subtype_index), type_index)), WASM_REF_NULL(subtype_index), type_index)),
kExprEnd}); kExprEnd});
const byte kRefCastUnrelatedNullable = tester.DefineFunction( const byte kRefCastUnrelatedNullable = tester.DefineFunction(
tester.sigs.i_v(), {refNull(subtype_index)}, tester.sigs.i_v(), {refNull(subtype_index)},
{WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype_index)), {WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype_index)),
WASM_REF_IS_NULL(WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), sig_index)), WASM_REF_IS_NULL(WASM_REF_CAST(WASM_LOCAL_GET(0), sig_index)),
kExprEnd});
const byte kRefCastUnrelatedNull = tester.DefineFunction(
tester.sigs.i_v(), {},
{WASM_REF_IS_NULL(WASM_REF_CAST(WASM_REF_NULL(subtype_index), sig_index)),
kExprEnd}); kExprEnd});
const byte kRefCastUnrelatedNull =
tester.DefineFunction(tester.sigs.i_v(), {},
{WASM_REF_IS_NULL(WASM_REF_CAST_STATIC(
WASM_REF_NULL(subtype_index), sig_index)),
kExprEnd});
const byte kRefCastUnrelatedNonNullable = tester.DefineFunction( const byte kRefCastUnrelatedNonNullable = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_IS_NULL(WASM_REF_CAST_STATIC( {WASM_REF_IS_NULL(
WASM_STRUCT_NEW_DEFAULT(type_index), sig_index)), WASM_REF_CAST(WASM_STRUCT_NEW_DEFAULT(type_index), sig_index)),
kExprEnd}); kExprEnd});
const byte kBrOnCastNull = tester.DefineFunction( const byte kBrOnCastNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(subtype_index), WASM_REF_NULL(type_index), {WASM_BLOCK_R(refNull(subtype_index), WASM_REF_NULL(type_index),
WASM_BR_ON_CAST_STATIC(0, subtype_index), WASM_DROP, WASM_BR_ON_CAST(0, subtype_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
const byte kBrOnCastUpcast = tester.DefineFunction( const byte kBrOnCastUpcast = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(type_index), WASM_STRUCT_NEW_DEFAULT(subtype_index), {WASM_BLOCK_R(refNull(type_index), WASM_STRUCT_NEW_DEFAULT(subtype_index),
WASM_BR_ON_CAST_STATIC(0, type_index), WASM_DROP, WASM_BR_ON_CAST(0, type_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
const byte kBrOnCastUpcastNull = tester.DefineFunction( const byte kBrOnCastUpcastNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(type_index), WASM_REF_NULL(subtype_index), {WASM_BLOCK_R(refNull(type_index), WASM_REF_NULL(subtype_index),
WASM_BR_ON_CAST_STATIC(0, type_index), WASM_DROP, WASM_BR_ON_CAST(0, type_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
...@@ -1274,28 +1268,28 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) { ...@@ -1274,28 +1268,28 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) {
tester.sigs.i_v(), {refNull(subtype_index)}, tester.sigs.i_v(), {refNull(subtype_index)},
{WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype_index)), {WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype_index)),
WASM_BLOCK_R(refNull(sig_index), WASM_LOCAL_GET(0), WASM_BLOCK_R(refNull(sig_index), WASM_LOCAL_GET(0),
WASM_BR_ON_CAST_STATIC(0, sig_index), WASM_DROP, WASM_BR_ON_CAST(0, sig_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
const byte kBrOnCastUnrelatedNull = tester.DefineFunction( const byte kBrOnCastUnrelatedNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(sig_index), WASM_REF_NULL(subtype_index), {WASM_BLOCK_R(refNull(sig_index), WASM_REF_NULL(subtype_index),
WASM_BR_ON_CAST_STATIC(0, sig_index), WASM_DROP, WASM_BR_ON_CAST(0, sig_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
const byte kBrOnCastUnrelatedNonNullable = tester.DefineFunction( const byte kBrOnCastUnrelatedNonNullable = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(sig_index), WASM_STRUCT_NEW_DEFAULT(subtype_index), {WASM_BLOCK_R(refNull(sig_index), WASM_STRUCT_NEW_DEFAULT(subtype_index),
WASM_BR_ON_CAST_STATIC(0, sig_index), WASM_DROP, WASM_BR_ON_CAST(0, sig_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
const byte kBrOnCastFailNull = tester.DefineFunction( const byte kBrOnCastFailNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(type_index), WASM_REF_NULL(type_index), {WASM_BLOCK_R(refNull(type_index), WASM_REF_NULL(type_index),
WASM_BR_ON_CAST_STATIC_FAIL(0, subtype_index), WASM_DROP, WASM_BR_ON_CAST_FAIL(0, subtype_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
...@@ -1303,14 +1297,14 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) { ...@@ -1303,14 +1297,14 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) {
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(subtype_index), {WASM_BLOCK_R(refNull(subtype_index),
WASM_STRUCT_NEW_DEFAULT(subtype_index), WASM_STRUCT_NEW_DEFAULT(subtype_index),
WASM_BR_ON_CAST_STATIC_FAIL(0, type_index), WASM_DROP, WASM_BR_ON_CAST_FAIL(0, type_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
const byte kBrOnCastFailUpcastNull = tester.DefineFunction( const byte kBrOnCastFailUpcastNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(subtype_index), WASM_REF_NULL(subtype_index), {WASM_BLOCK_R(refNull(subtype_index), WASM_REF_NULL(subtype_index),
WASM_BR_ON_CAST_STATIC_FAIL(0, type_index), WASM_DROP, WASM_BR_ON_CAST_FAIL(0, type_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
...@@ -1318,14 +1312,14 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) { ...@@ -1318,14 +1312,14 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) {
tester.sigs.i_v(), {refNull(subtype_index)}, tester.sigs.i_v(), {refNull(subtype_index)},
{WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype_index)), {WASM_LOCAL_SET(0, WASM_STRUCT_NEW_DEFAULT(subtype_index)),
WASM_BLOCK_R(refNull(subtype_index), WASM_LOCAL_GET(0), WASM_BLOCK_R(refNull(subtype_index), WASM_LOCAL_GET(0),
WASM_BR_ON_CAST_STATIC_FAIL(0, sig_index), WASM_DROP, WASM_BR_ON_CAST_FAIL(0, sig_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
const byte kBrOnCastFailUnrelatedNull = tester.DefineFunction( const byte kBrOnCastFailUnrelatedNull = tester.DefineFunction(
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(subtype_index), WASM_REF_NULL(subtype_index), {WASM_BLOCK_R(refNull(subtype_index), WASM_REF_NULL(subtype_index),
WASM_BR_ON_CAST_STATIC_FAIL(0, sig_index), WASM_DROP, WASM_BR_ON_CAST_FAIL(0, sig_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
...@@ -1333,7 +1327,7 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) { ...@@ -1333,7 +1327,7 @@ WASM_COMPILED_EXEC_TEST(RefTrivialCastsStatic) {
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_BLOCK_R(refNull(subtype_index), {WASM_BLOCK_R(refNull(subtype_index),
WASM_STRUCT_NEW_DEFAULT(subtype_index), WASM_STRUCT_NEW_DEFAULT(subtype_index),
WASM_BR_ON_CAST_STATIC_FAIL(0, sig_index), WASM_DROP, WASM_BR_ON_CAST_FAIL(0, sig_index), WASM_DROP,
WASM_RETURN(WASM_I32V(0))), WASM_RETURN(WASM_I32V(0))),
WASM_DROP, WASM_I32V(1), WASM_END}); WASM_DROP, WASM_I32V(1), WASM_END});
...@@ -1486,7 +1480,7 @@ WASM_COMPILED_EXEC_TEST(FunctionRefs) { ...@@ -1486,7 +1480,7 @@ WASM_COMPILED_EXEC_TEST(FunctionRefs) {
const byte cast = tester.DefineFunction( const byte cast = tester.DefineFunction(
&sig_func, {kWasmFuncRef}, &sig_func, {kWasmFuncRef},
{WASM_LOCAL_SET(0, WASM_REF_FUNC(func_index)), {WASM_LOCAL_SET(0, WASM_REF_FUNC(func_index)),
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), sig_index), kExprEnd}); WASM_REF_CAST(WASM_LOCAL_GET(0), sig_index), kExprEnd});
const byte cast_reference = tester.DefineFunction( const byte cast_reference = tester.DefineFunction(
&sig_func, {}, {WASM_REF_FUNC(sig_index), kExprEnd}); &sig_func, {}, {WASM_REF_FUNC(sig_index), kExprEnd});
...@@ -1494,12 +1488,12 @@ WASM_COMPILED_EXEC_TEST(FunctionRefs) { ...@@ -1494,12 +1488,12 @@ WASM_COMPILED_EXEC_TEST(FunctionRefs) {
const byte test = tester.DefineFunction( const byte test = tester.DefineFunction(
tester.sigs.i_v(), {kWasmFuncRef}, tester.sigs.i_v(), {kWasmFuncRef},
{WASM_LOCAL_SET(0, WASM_REF_FUNC(func_index)), {WASM_LOCAL_SET(0, WASM_REF_FUNC(func_index)),
WASM_REF_TEST_STATIC(WASM_LOCAL_GET(0), sig_index), kExprEnd}); WASM_REF_TEST(WASM_LOCAL_GET(0), sig_index), kExprEnd});
const byte test_fail = tester.DefineFunction( const byte test_fail = tester.DefineFunction(
tester.sigs.i_v(), {kWasmFuncRef}, tester.sigs.i_v(), {kWasmFuncRef},
{WASM_LOCAL_SET(0, WASM_REF_FUNC(func_index)), {WASM_LOCAL_SET(0, WASM_REF_FUNC(func_index)),
WASM_REF_TEST_STATIC(WASM_LOCAL_GET(0), other_sig_index), kExprEnd}); WASM_REF_TEST(WASM_LOCAL_GET(0), other_sig_index), kExprEnd});
tester.CompileModule(); tester.CompileModule();
...@@ -1604,11 +1598,10 @@ WASM_COMPILED_EXEC_TEST(CastNullRef) { ...@@ -1604,11 +1598,10 @@ WASM_COMPILED_EXEC_TEST(CastNullRef) {
tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_IS_NULL(WASM_REF_AS_I31(WASM_REF_NULL(kNoneCode))), kExprEnd}); {WASM_REF_IS_NULL(WASM_REF_AS_I31(WASM_REF_NULL(kNoneCode))), kExprEnd});
byte struct_idx = tester.DefineStruct({F(wasm::kWasmI32, true)}); byte struct_idx = tester.DefineStruct({F(wasm::kWasmI32, true)});
byte to_struct = byte to_struct = tester.DefineFunction(
tester.DefineFunction(tester.sigs.i_v(), {}, tester.sigs.i_v(), {},
{WASM_REF_IS_NULL(WASM_REF_CAST_STATIC( {WASM_REF_IS_NULL(WASM_REF_CAST(WASM_REF_NULL(kNoneCode), struct_idx)),
WASM_REF_NULL(kNoneCode), struct_idx)), kExprEnd});
kExprEnd});
tester.CompileModule(); tester.CompileModule();
// Generic casts trap on null. // Generic casts trap on null.
tester.CheckHasThrown(to_non_null); tester.CheckHasThrown(to_non_null);
...@@ -1878,7 +1871,7 @@ WASM_COMPILED_EXEC_TEST(CastsBenchmark) { ...@@ -1878,7 +1871,7 @@ WASM_COMPILED_EXEC_TEST(CastsBenchmark) {
WASM_LOCAL_GET(sum), WASM_LOCAL_GET(sum),
WASM_STRUCT_GET( WASM_STRUCT_GET(
SuperType, 0, SuperType, 0,
WASM_REF_CAST_STATIC( WASM_REF_CAST(
WASM_ARRAY_GET( WASM_ARRAY_GET(
ListType, WASM_LOCAL_GET(list), ListType, WASM_LOCAL_GET(list),
WASM_I32_AND(WASM_LOCAL_GET(i), WASM_I32_AND(WASM_LOCAL_GET(i),
...@@ -2025,7 +2018,7 @@ WASM_COMPILED_EXEC_TEST(JsAccess) { ...@@ -2025,7 +2018,7 @@ WASM_COMPILED_EXEC_TEST(JsAccess) {
tester.DefineExportedFunction( tester.DefineExportedFunction(
"consumer", &sig_i_super, "consumer", &sig_i_super,
{WASM_STRUCT_GET(type_index, 0, {WASM_STRUCT_GET(type_index, 0,
WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), type_index)), WASM_REF_CAST(WASM_LOCAL_GET(0), type_index)),
kExprEnd}); kExprEnd});
tester.CompileModule(); tester.CompileModule();
......
...@@ -521,17 +521,17 @@ inline uint16_t ExtractPrefixedOpcodeBytes(WasmOpcode opcode) { ...@@ -521,17 +521,17 @@ inline uint16_t ExtractPrefixedOpcodeBytes(WasmOpcode opcode) {
#define WASM_REF_IS_NULL(val) val, kExprRefIsNull #define WASM_REF_IS_NULL(val) val, kExprRefIsNull
#define WASM_REF_AS_NON_NULL(val) val, kExprRefAsNonNull #define WASM_REF_AS_NON_NULL(val) val, kExprRefAsNonNull
#define WASM_REF_EQ(lhs, rhs) lhs, rhs, kExprRefEq #define WASM_REF_EQ(lhs, rhs) lhs, rhs, kExprRefEq
#define WASM_REF_TEST_STATIC(ref, typeidx) \ #define WASM_REF_TEST(ref, typeidx) \
ref, WASM_GC_OP(kExprRefTestStatic), static_cast<byte>(typeidx) ref, WASM_GC_OP(kExprRefTest), static_cast<byte>(typeidx)
#define WASM_REF_CAST_STATIC(ref, typeidx) \ #define WASM_REF_CAST(ref, typeidx) \
ref, WASM_GC_OP(kExprRefCastStatic), static_cast<byte>(typeidx) ref, WASM_GC_OP(kExprRefCast), static_cast<byte>(typeidx)
// Takes a reference value from the value stack to allow sequences of // Takes a reference value from the value stack to allow sequences of
// conditional branches. // conditional branches.
#define WASM_BR_ON_CAST_STATIC(depth, typeidx) \ #define WASM_BR_ON_CAST(depth, typeidx) \
WASM_GC_OP(kExprBrOnCastStatic), static_cast<byte>(depth), \ WASM_GC_OP(kExprBrOnCast), static_cast<byte>(depth), \
static_cast<byte>(typeidx) static_cast<byte>(typeidx)
#define WASM_BR_ON_CAST_STATIC_FAIL(depth, typeidx) \ #define WASM_BR_ON_CAST_FAIL(depth, typeidx) \
WASM_GC_OP(kExprBrOnCastStaticFail), static_cast<byte>(depth), \ WASM_GC_OP(kExprBrOnCastFail), static_cast<byte>(depth), \
static_cast<byte>(typeidx) static_cast<byte>(typeidx)
#define WASM_GC_INTERNALIZE(extern) extern, WASM_GC_OP(kExprExternInternalize) #define WASM_GC_INTERNALIZE(extern) extern, WASM_GC_OP(kExprExternInternalize)
......
...@@ -23,12 +23,12 @@ builder.addFunction('main', sig_index) ...@@ -23,12 +23,12 @@ builder.addFunction('main', sig_index)
.addBody([ .addBody([
// Cast to sub1 and write field 0. // Cast to sub1 and write field 0.
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, sub1, kGCPrefix, kExprRefCast, sub1,
kExprI32Const, 42, kExprI32Const, 42,
kGCPrefix, kExprStructSet, sub1, 0, kGCPrefix, kExprStructSet, sub1, 0,
// Cast to sub2 and read field 0. // Cast to sub2 and read field 0.
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, sub2, kGCPrefix, kExprRefCast, sub2,
kGCPrefix, kExprStructGet, sub2, 0]) kGCPrefix, kExprStructGet, sub2, 0])
.exportFunc(); .exportFunc();
......
...@@ -15,15 +15,15 @@ let sig = makeSig([wasmRefNullType(supertype)], [kWasmI32]); ...@@ -15,15 +15,15 @@ let sig = makeSig([wasmRefNullType(supertype)], [kWasmI32]);
let callee = builder.addFunction("callee", sig).addBody([ let callee = builder.addFunction("callee", sig).addBody([
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefTestStatic, sub1, kGCPrefix, kExprRefTest, sub1,
kExprIf, kWasmVoid, kExprIf, kWasmVoid,
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, sub1, kGCPrefix, kExprRefCast, sub1,
kGCPrefix, kExprStructGet, sub1, 0, kGCPrefix, kExprStructGet, sub1, 0,
kExprReturn, kExprReturn,
kExprElse, kExprElse,
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, sub2, kGCPrefix, kExprRefCast, sub2,
// This {ref.as_non_null} initially believes that it operates on a // This {ref.as_non_null} initially believes that it operates on a
// (ref null sub2), and when getting inlined into {crash} realizes // (ref null sub2), and when getting inlined into {crash} realizes
// that its actual type is {bottom} because this branch is unreachable. // that its actual type is {bottom} because this branch is unreachable.
......
...@@ -19,8 +19,8 @@ let sig = makeSig([wasmRefNullType(supertype)], [kWasmI32]); ...@@ -19,8 +19,8 @@ let sig = makeSig([wasmRefNullType(supertype)], [kWasmI32]);
let callee1 = builder.addFunction('callee1', sig).addBody([ let callee1 = builder.addFunction('callee1', sig).addBody([
kExprBlock, kWasmRef, subtype, kExprBlock, kWasmRef, subtype,
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprBrOnCastStatic, 0, subtype, kGCPrefix, kExprBrOnCast, 0, subtype,
kGCPrefix, kExprRefCastStatic, unused_type, kGCPrefix, kExprRefCast, unused_type,
kGCPrefix, kExprStructGet, unused_type, 0, kGCPrefix, kExprStructGet, unused_type, 0,
kExprReturn, kExprReturn,
kExprEnd, kExprEnd,
...@@ -30,7 +30,7 @@ let callee1 = builder.addFunction('callee1', sig).addBody([ ...@@ -30,7 +30,7 @@ let callee1 = builder.addFunction('callee1', sig).addBody([
let callee2 = builder.addFunction('callee2', sig).addBody([ let callee2 = builder.addFunction('callee2', sig).addBody([
kExprBlock, kWasmRef, subtype, kExprBlock, kWasmRef, subtype,
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprBrOnCastStatic, 0, subtype, kGCPrefix, kExprBrOnCast, 0, subtype,
kExprUnreachable, kExprUnreachable,
kExprReturn, kExprReturn,
kExprEnd, kExprEnd,
...@@ -44,7 +44,7 @@ let callee3 = builder.addFunction('callee3', sig).addBody([ ...@@ -44,7 +44,7 @@ let callee3 = builder.addFunction('callee3', sig).addBody([
kExprUnreachable, kExprUnreachable,
kExprReturn, kExprReturn,
kExprEnd, kExprEnd,
kGCPrefix, kExprRefCastStatic, subtype, kGCPrefix, kExprRefCast, subtype,
kGCPrefix, kExprStructGet, subtype, 1 kGCPrefix, kExprStructGet, subtype, 1
]); ]);
......
...@@ -24,7 +24,7 @@ let crash = builder.addFunction("crash", kSig_v_i).exportFunc() ...@@ -24,7 +24,7 @@ let crash = builder.addFunction("crash", kSig_v_i).exportFunc()
kExprDrop, kExprDrop,
kExprElse, kExprElse,
kExprLocalGet, 1, kExprLocalGet, 1,
kGCPrefix, kExprRefCastStatic, sub2, kGCPrefix, kExprRefCast, sub2,
kGCPrefix, kExprStructGet, sub2, 0, kGCPrefix, kExprStructGet, sub2, 0,
kExprDrop, kExprDrop,
kExprEnd]); kExprEnd]);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
(function TestArrayNewElemStatic() { (function TestArrayNewElem() {
print(arguments.callee.name); print(arguments.callee.name);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]); let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
...@@ -36,7 +36,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -36,7 +36,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
.addBody([ .addBody([
kExprI32Const, 0, // offset kExprI32Const, 0, // offset
kExprLocalGet, 0, // length kExprLocalGet, 0, // length
kGCPrefix, kExprArrayNewElemStatic, array_type_index, kGCPrefix, kExprArrayNewElem, array_type_index,
segment, segment,
kExprLocalGet, 1, // index in the array kExprLocalGet, 1, // index in the array
kGCPrefix, kExprArrayGet, array_type_index, kGCPrefix, kExprArrayGet, array_type_index,
...@@ -78,7 +78,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -78,7 +78,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
assertTraps(kTrapElementSegmentOutOfBounds, () => init_and_get_active(1, 0)); assertTraps(kTrapElementSegmentOutOfBounds, () => init_and_get_active(1, 0));
})(); })();
(function TestArrayNewElemStaticConstant() { (function TestArrayNewElemConstant() {
print(arguments.callee.name); print(arguments.callee.name);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]); let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
...@@ -107,10 +107,10 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -107,10 +107,10 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
let array_segment = builder.addPassiveElementSegment( let array_segment = builder.addPassiveElementSegment(
[[...wasmI32Const(0), ...wasmI32Const(3), [[...wasmI32Const(0), ...wasmI32Const(3),
kGCPrefix, kExprArrayNewElemStatic, kGCPrefix, kExprArrayNewElem,
array_type_index, passive_segment], array_type_index, passive_segment],
[...wasmI32Const(0), ...wasmI32Const(0), [...wasmI32Const(0), ...wasmI32Const(0),
kGCPrefix, kExprArrayNewElemStatic, kGCPrefix, kExprArrayNewElem,
array_type_index, active_segment]], array_type_index, active_segment]],
array_type); array_type);
...@@ -124,7 +124,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -124,7 +124,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
kExprLocalGet, 0, // offset in table kExprLocalGet, 0, // offset in table
kExprTableGet, table, kExprTableGet, table,
kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefAsData,
kGCPrefix, kExprRefCastStatic, array_type_index, kGCPrefix, kExprRefCast, array_type_index,
kExprLocalGet, 1, // index in the array kExprLocalGet, 1, // index in the array
kGCPrefix, kExprArrayGet, array_type_index, kGCPrefix, kExprArrayGet, array_type_index,
kGCPrefix, kExprStructGet, struct_type_index, 0]) kGCPrefix, kExprStructGet, struct_type_index, 0])
...@@ -159,7 +159,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -159,7 +159,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
assertTraps(kTrapArrayOutOfBounds, () => table_get(0, 3)); assertTraps(kTrapArrayOutOfBounds, () => table_get(0, 3));
})(); })();
(function TestArrayNewElemStaticMistypedSegment() { (function TestArrayNewElemMistypedSegment() {
print(arguments.callee.name); print(arguments.callee.name);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]); let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
...@@ -174,7 +174,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -174,7 +174,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
.addBody([ .addBody([
kExprI32Const, 0, // offset kExprI32Const, 0, // offset
kExprLocalGet, 0, // length kExprLocalGet, 0, // length
kGCPrefix, kExprArrayNewElemStatic, array_type_index, kGCPrefix, kExprArrayNewElem, array_type_index,
passive_segment, passive_segment,
kExprLocalGet, 1, // index in the array kExprLocalGet, 1, // index in the array
kGCPrefix, kExprArrayGet, array_type_index, kGCPrefix, kExprArrayGet, array_type_index,
...@@ -201,14 +201,14 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -201,14 +201,14 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
builder.addGlobal( builder.addGlobal(
wasmRefNullType(array_type_index), false, wasmRefNullType(array_type_index), false,
[...wasmI32Const(0), ...wasmI32Const(1), [...wasmI32Const(0), ...wasmI32Const(1),
kGCPrefix, kExprArrayNewElemStatic, kGCPrefix, kExprArrayNewElem,
array_type_index, passive_segment]); array_type_index, passive_segment]);
assertThrows(() => builder.instantiate(), WebAssembly.CompileError, assertThrows(() => builder.instantiate(), WebAssembly.CompileError,
/invalid element segment index/); /invalid element segment index/);
})(); })();
(function TestArrayNewElemStaticConstantArrayTooLarge() { (function TestArrayNewElemConstantArrayTooLarge() {
print(arguments.callee.name); print(arguments.callee.name);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]); let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
...@@ -233,7 +233,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -233,7 +233,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
let array_segment = builder.addPassiveElementSegment( let array_segment = builder.addPassiveElementSegment(
[[...wasmI32Const(0), ...wasmI32Const(1 << 30), [[...wasmI32Const(0), ...wasmI32Const(1 << 30),
kGCPrefix, kExprArrayNewElemStatic, kGCPrefix, kExprArrayNewElem,
array_type_index, passive_segment]], array_type_index, passive_segment]],
array_type array_type
); );
...@@ -247,7 +247,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -247,7 +247,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
assertTraps(kTrapArrayTooLarge, () => instance.exports.init()); assertTraps(kTrapArrayTooLarge, () => instance.exports.init());
})(); })();
(function TestArrayNewElemStaticConstantElementSegmentOutOfBounds() { (function TestArrayNewElemConstantElementSegmentOutOfBounds() {
print(arguments.callee.name); print(arguments.callee.name);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]); let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
...@@ -272,7 +272,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -272,7 +272,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
let array_segment = builder.addPassiveElementSegment( let array_segment = builder.addPassiveElementSegment(
[[...wasmI32Const(0), ...wasmI32Const(10), [[...wasmI32Const(0), ...wasmI32Const(10),
kGCPrefix, kExprArrayNewElemStatic, kGCPrefix, kExprArrayNewElem,
array_type_index, passive_segment]], array_type_index, passive_segment]],
array_type array_type
); );
...@@ -286,7 +286,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -286,7 +286,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
assertTraps(kTrapElementSegmentOutOfBounds, () => instance.exports.init()); assertTraps(kTrapElementSegmentOutOfBounds, () => instance.exports.init());
})(); })();
(function TestArrayNewElemStaticConstantActiveSegment() { (function TestArrayNewElemConstantActiveSegment() {
print(arguments.callee.name); print(arguments.callee.name);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]); let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
...@@ -312,7 +312,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -312,7 +312,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
let array_segment = builder.addPassiveElementSegment( let array_segment = builder.addPassiveElementSegment(
[[...wasmI32Const(0), ...wasmI32Const(3), [[...wasmI32Const(0), ...wasmI32Const(3),
kGCPrefix, kExprArrayNewElemStatic, kGCPrefix, kExprArrayNewElem,
array_type_index, active_segment]], array_type_index, active_segment]],
array_type array_type
); );
......
...@@ -21,7 +21,7 @@ builder.addFunction('getHelloArray', makeSig([], [kWasmArrayRef])) ...@@ -21,7 +21,7 @@ builder.addFunction('getHelloArray', makeSig([], [kWasmArrayRef]))
builder.addFunction('getChar', makeSig([kWasmArrayRef, kWasmI32], [kWasmI32])) builder.addFunction('getChar', makeSig([kWasmArrayRef, kWasmI32], [kWasmI32]))
.addBody([ .addBody([
kExprLocalGet, 0, kGCPrefix, kExprRefAsData, kGCPrefix, kExprLocalGet, 0, kGCPrefix, kExprRefAsData, kGCPrefix,
kExprRefCastStatic, i16Array, kExprLocalGet, 1, kGCPrefix, kExprArrayGetS, kExprRefCast, i16Array, kExprLocalGet, 1, kGCPrefix, kExprArrayGetS,
i16Array i16Array
]) ])
.exportFunc(); .exportFunc();
......
...@@ -17,7 +17,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -17,7 +17,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
kGCPrefix, kExprStructNew, struct, kGCPrefix, kExprStructNew, struct,
kExprLocalSet, 1, kExprLocalSet, 1,
kExprLocalGet, 1, kExprLocalGet, 1,
kGCPrefix, kExprRefCastNopStatic, struct, kGCPrefix, kExprRefCastNop, struct,
kGCPrefix, kExprStructGet, struct, 0, kGCPrefix, kExprStructGet, struct, 0,
]).exportFunc(); ]).exportFunc();
......
...@@ -45,7 +45,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -45,7 +45,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
/subtyping depth is greater than allowed/); /subtyping depth is greater than allowed/);
})(); })();
(function TestArrayNewDataStatic() { (function TestArrayNewData() {
print(arguments.callee.name); print(arguments.callee.name);
let builder = new WasmModuleBuilder(); let builder = new WasmModuleBuilder();
builder.setEarlyDataCountSection(); builder.setEarlyDataCountSection();
...@@ -62,7 +62,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -62,7 +62,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
let global = builder.addGlobal( let global = builder.addGlobal(
wasmRefType(array_type_index), true, wasmRefType(array_type_index), true,
[...wasmI32Const(1), ...wasmI32Const(2), [...wasmI32Const(1), ...wasmI32Const(2),
kGCPrefix, kExprArrayNewDataStatic, array_type_index, data_segment], kGCPrefix, kExprArrayNewData, array_type_index, data_segment],
builder); builder);
builder.addFunction("global_get", kSig_i_i) builder.addFunction("global_get", kSig_i_i)
...@@ -76,7 +76,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -76,7 +76,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
builder.addFunction("init_from_data", kSig_i_iii) builder.addFunction("init_from_data", kSig_i_iii)
.addBody([ .addBody([
kExprLocalGet, 0, kExprLocalGet, 1, kExprLocalGet, 0, kExprLocalGet, 1,
kGCPrefix, kExprArrayNewDataStatic, kGCPrefix, kExprArrayNewData,
array_type_index, data_segment, array_type_index, data_segment,
kExprLocalGet, 2, kExprLocalGet, 2,
kGCPrefix, kExprArrayGetS, array_type_index]) kGCPrefix, kExprArrayGetS, array_type_index])
......
...@@ -409,29 +409,29 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -409,29 +409,29 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
.addLocals(kWasmI32, 1) .addLocals(kWasmI32, 1)
.addBody([ .addBody([
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefTestStatic, sub_struct, kGCPrefix, kExprRefTest, sub_struct,
// These casts have to be preserved. // These casts have to be preserved.
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, mid_struct, kGCPrefix, kExprRefCast, mid_struct,
kGCPrefix, kExprRefCastStatic, sub_struct, kGCPrefix, kExprRefCast, sub_struct,
kGCPrefix, kExprStructGet, sub_struct, 1, kGCPrefix, kExprStructGet, sub_struct, 1,
...addToLocal, ...addToLocal,
kExprIf, kWasmVoid, kExprIf, kWasmVoid,
// Both these casts should be optimized away. // Both these casts should be optimized away.
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, mid_struct, kGCPrefix, kExprRefCast, mid_struct,
kGCPrefix, kExprRefCastStatic, sub_struct, kGCPrefix, kExprRefCast, sub_struct,
kGCPrefix, kExprStructGet, sub_struct, 1, kGCPrefix, kExprStructGet, sub_struct, 1,
...addToLocal, ...addToLocal,
kExprBlock, kWasmRefNull, super_struct, kExprBlock, kWasmRefNull, super_struct,
kExprLocalGet, 0, kExprLocalGet, 0,
// This should also get optimized away. // This should also get optimized away.
kGCPrefix, kExprBrOnCastStaticFail, 0, mid_struct, kGCPrefix, kExprBrOnCastFail, 0, mid_struct,
// So should this, despite being represented by a TypeGuard alias. // So should this, despite being represented by a TypeGuard alias.
kGCPrefix, kExprRefCastStatic, sub_struct, kGCPrefix, kExprRefCast, sub_struct,
kGCPrefix, kExprStructGet, sub_struct, 1, kGCPrefix, kExprStructGet, sub_struct, 1,
...addToLocal, ...addToLocal,
kExprLocalGet, 0, // Due to the branch result type. kExprLocalGet, 0, // Due to the branch result type.
...@@ -440,13 +440,13 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -440,13 +440,13 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
kExprElse, kExprElse,
// This (always trapping) cast should be preserved. // This (always trapping) cast should be preserved.
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, sub_struct, kGCPrefix, kExprRefCast, sub_struct,
kGCPrefix, kExprStructGet, sub_struct, 1, kGCPrefix, kExprStructGet, sub_struct, 1,
...addToLocal, ...addToLocal,
kExprEnd, kExprEnd,
// This cast should be preserved. // This cast should be preserved.
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, sub_struct, kGCPrefix, kExprRefCast, sub_struct,
kGCPrefix, kExprStructGet, sub_struct, 1, kGCPrefix, kExprStructGet, sub_struct, 1,
kExprLocalGet, 1, kExprI32Add kExprLocalGet, 1, kExprI32Add
]) ])
...@@ -468,8 +468,8 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -468,8 +468,8 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
.addBody([ .addBody([
// Cast from struct_a to struct_b via common base type struct_super. // Cast from struct_a to struct_b via common base type struct_super.
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefCastStatic, struct_super, kGCPrefix, kExprRefCast, struct_super,
kGCPrefix, kExprRefCastStatic, struct_b, // annotated as 'ref null none' kGCPrefix, kExprRefCast, struct_b, // annotated as 'ref null none'
kExprRefIsNull, kExprRefIsNull,
]); ]);
...@@ -514,7 +514,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -514,7 +514,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
// local.get 0 is known to be null until end of block. // local.get 0 is known to be null until end of block.
kExprLocalGet, 0, kExprLocalGet, 0,
// This cast is a no-op and shold be optimized away. // This cast is a no-op and shold be optimized away.
kGCPrefix, kExprRefCastStatic, struct_b, kGCPrefix, kExprRefCast, struct_b,
kExprEnd, kExprEnd,
kExprRefIsNull, kExprRefIsNull,
]); ]);
......
...@@ -120,14 +120,14 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -120,14 +120,14 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
builder.addFunction("main", makeSig([wasmRefType(kWasmFuncRef)], [kWasmI32])) builder.addFunction("main", makeSig([wasmRefType(kWasmFuncRef)], [kWasmI32]))
.addBody([ .addBody([
// Type check the function // Type check the function
kExprLocalGet, 0, kGCPrefix, kExprRefCastStatic, sig, kExprLocalGet, 0, kGCPrefix, kExprRefCast, sig,
kExprDrop, kExprDrop,
// Introduce unknown effect // Introduce unknown effect
kExprCallFunction, effect, kExprCallFunction, effect,
// TF should be able to eliminate the second type check, and return the // TF should be able to eliminate the second type check, and return the
// constant 1. // constant 1.
kExprLocalGet, 0, kExprLocalGet, 0,
kGCPrefix, kExprRefTestStatic, sig]) kGCPrefix, kExprRefTest, sig])
.exportFunc(); .exportFunc();
var instance = builder.instantiate({m : { f: function () {} }}); var instance = builder.instantiate({m : { f: function () {} }});
......
...@@ -75,7 +75,7 @@ for (let [typeName, type] of Object.entries(tableTypes)) { ...@@ -75,7 +75,7 @@ for (let [typeName, type] of Object.entries(tableTypes)) {
.addBody([ .addBody([
kExprLocalGet, 0, kExprTableGet, 0, kExprLocalGet, 0, kExprTableGet, 0,
kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefAsData,
kGCPrefix, kExprRefCastStatic, struct, kGCPrefix, kExprRefCast, struct,
kGCPrefix, kExprStructGet, struct, 0, kGCPrefix, kExprStructGet, struct, 0,
]) ])
.exportFunc(); .exportFunc();
...@@ -83,7 +83,7 @@ for (let [typeName, type] of Object.entries(tableTypes)) { ...@@ -83,7 +83,7 @@ for (let [typeName, type] of Object.entries(tableTypes)) {
.addBody([ .addBody([
kExprLocalGet, 0, kExprTableGet, 0, kExprLocalGet, 0, kExprTableGet, 0,
kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefAsData,
kGCPrefix, kExprRefCastStatic, array, kGCPrefix, kExprRefCast, array,
kExprI32Const, 0, kExprI32Const, 0,
kGCPrefix, kExprArrayGet, array, kGCPrefix, kExprArrayGet, array,
]) ])
......
...@@ -166,7 +166,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js'); ...@@ -166,7 +166,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([ .addBody([
kExprI32Const, 0, kExprTableGet, 0, kExprI32Const, 0, kExprTableGet, 0,
kGCPrefix, kExprRefAsArray, kGCPrefix, kExprRefAsArray,
kGCPrefix, kExprRefCastStatic, array_type, kGCPrefix, kExprRefCast, array_type,
kExprLocalSet, 0, kExprLocalSet, 0,
kExprLocalGet, 0, kExprLocalGet, 0,
...wasmI32Const(0), kGCPrefix, kExprArrayGet, array_type, ...wasmI32Const(0), kGCPrefix, kExprArrayGet, array_type,
...@@ -186,7 +186,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js'); ...@@ -186,7 +186,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
builder.addFunction("struct_getter", kSig_i_v) builder.addFunction("struct_getter", kSig_i_v)
.addBody([ .addBody([
kExprI32Const, 2, kExprTableGet, 0, kExprI32Const, 2, kExprTableGet, 0,
kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefCastStatic, struct_type, kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefCast, struct_type,
kGCPrefix, kExprStructGet, struct_type, 0]) kGCPrefix, kExprStructGet, struct_type, 0])
.exportFunc(); .exportFunc();
...@@ -230,7 +230,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js'); ...@@ -230,7 +230,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([ .addBody([
kExprI32Const, 0, kExprTableGet, 0, kExprI32Const, 0, kExprTableGet, 0,
kGCPrefix, kExprRefAsArray, kGCPrefix, kExprRefAsArray,
kGCPrefix, kExprRefCastStatic, array_type, kGCPrefix, kExprRefCast, array_type,
kExprLocalSet, 0, kExprLocalSet, 0,
kExprLocalGet, 0, kExprLocalGet, 0,
...wasmI32Const(0), kGCPrefix, kExprArrayGet, array_type, ...wasmI32Const(0), kGCPrefix, kExprArrayGet, array_type,
...@@ -250,7 +250,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js'); ...@@ -250,7 +250,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
builder.addFunction("struct_getter", kSig_i_i) builder.addFunction("struct_getter", kSig_i_i)
.addBody([ .addBody([
kExprLocalGet, 0, kExprTableGet, 0, kExprLocalGet, 0, kExprTableGet, 0,
kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefCastStatic, struct_type, kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefCast, struct_type,
kGCPrefix, kExprStructGet, struct_type, 0]) kGCPrefix, kExprStructGet, struct_type, 0])
.exportFunc(); .exportFunc();
......
...@@ -20,12 +20,12 @@ let struct_init = builder.addFunction("struct_init", ...@@ -20,12 +20,12 @@ let struct_init = builder.addFunction("struct_init",
let test_pass = builder.addFunction("test_pass", let test_pass = builder.addFunction("test_pass",
makeSig([kWasmDataRef], [kWasmI32])) makeSig([kWasmDataRef], [kWasmI32]))
.addBody([kExprLocalGet, 0, .addBody([kExprLocalGet, 0,
kGCPrefix, kExprRefTestStatic, identical_struct_index]) kGCPrefix, kExprRefTest, identical_struct_index])
.exportFunc(); .exportFunc();
let test_fail = builder.addFunction("test_fail", let test_fail = builder.addFunction("test_fail",
makeSig([kWasmDataRef], [kWasmI32])) makeSig([kWasmDataRef], [kWasmI32]))
.addBody([kExprLocalGet, 0, .addBody([kExprLocalGet, 0,
kGCPrefix, kExprRefTestStatic, distinct_struct_index]) kGCPrefix, kExprRefTest, distinct_struct_index])
.exportFunc(); .exportFunc();
(function TestCanonicalizationSameInstance() { (function TestCanonicalizationSameInstance() {
......
...@@ -111,7 +111,7 @@ function makeWtf8TestDataSegment() { ...@@ -111,7 +111,7 @@ function makeWtf8TestDataSegment() {
.addBody([ .addBody([
...wasmI32Const(0), ...wasmI32Const(0),
...wasmI32Const(data.data.length), ...wasmI32Const(data.data.length),
kGCPrefix, kExprArrayNewDataStatic, i8_array, data_index kGCPrefix, kExprArrayNewData, i8_array, data_index
]).index; ]).index;
for (let [policy, name] of [[kWtf8PolicyAccept, "new_wtf8"], for (let [policy, name] of [[kWtf8PolicyAccept, "new_wtf8"],
...@@ -131,7 +131,7 @@ function makeWtf8TestDataSegment() { ...@@ -131,7 +131,7 @@ function makeWtf8TestDataSegment() {
.addBody([ .addBody([
...wasmI32Const(0), ...wasmI32Const(0),
...wasmI32Const("ascii".length), ...wasmI32Const("ascii".length),
kGCPrefix, kExprArrayNewDataStatic, i8_array, ascii_data_index, kGCPrefix, kExprArrayNewData, i8_array, ascii_data_index,
kExprLocalGet, 0, kExprLocalGet, 1, kExprLocalGet, 0, kExprLocalGet, 1,
...GCInstr(kExprStringNewWtf8Array), kWtf8PolicyAccept ...GCInstr(kExprStringNewWtf8Array), kWtf8PolicyAccept
]); ]);
...@@ -220,7 +220,7 @@ function makeWtf16TestDataSegment() { ...@@ -220,7 +220,7 @@ function makeWtf16TestDataSegment() {
.addBody([ .addBody([
...wasmI32Const(0), ...wasmI32Const(0),
...wasmI32Const(data.data.length / 2), ...wasmI32Const(data.data.length / 2),
kGCPrefix, kExprArrayNewDataStatic, i16_array, data_index kGCPrefix, kExprArrayNewData, i16_array, data_index
]).index; ]).index;
builder.addFunction("new_wtf16", kSig_w_ii) builder.addFunction("new_wtf16", kSig_w_ii)
...@@ -236,7 +236,7 @@ function makeWtf16TestDataSegment() { ...@@ -236,7 +236,7 @@ function makeWtf16TestDataSegment() {
.addBody([ .addBody([
...wasmI32Const(0), ...wasmI32Const(0),
...wasmI32Const("ascii".length), ...wasmI32Const("ascii".length),
kGCPrefix, kExprArrayNewDataStatic, i16_array, ascii_data_index, kGCPrefix, kExprArrayNewData, i16_array, ascii_data_index,
kExprLocalGet, 0, kExprLocalGet, 1, kExprLocalGet, 0, kExprLocalGet, 1,
...GCInstr(kExprStringNewWtf16Array) ...GCInstr(kExprStringNewWtf16Array)
]); ]);
......
...@@ -33,12 +33,12 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -33,12 +33,12 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
// while (true) { // while (true) {
kExprLoop, kWasmVoid, kExprLoop, kWasmVoid,
// if (ref.test temp bottom1) { // if (ref.test temp bottom1) {
kExprLocalGet, 2, kGCPrefix, kExprRefTestStatic, bottom1, kExprLocalGet, 2, kGCPrefix, kExprRefTest, bottom1,
kExprIf, kWasmVoid, kExprIf, kWasmVoid,
// counter += ((bottom1) temp).field_2; // counter += ((bottom1) temp).field_2;
// TODO(manoskouk): Implement path-based type tracking so we can // TODO(manoskouk): Implement path-based type tracking so we can
// eliminate this check. // eliminate this check.
kExprLocalGet, 2, kGCPrefix, kExprRefCastStatic, bottom1, kExprLocalGet, 2, kGCPrefix, kExprRefCast, bottom1,
kGCPrefix, kExprStructGet, bottom1, 2, kGCPrefix, kExprStructGet, bottom1, 2,
kExprLocalGet, 3, kExprI32Add, kExprLocalSet, 3, kExprLocalGet, 3, kExprI32Add, kExprLocalSet, 3,
// temp = x1; // temp = x1;
...@@ -48,7 +48,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -48,7 +48,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
// counter += (i32) ((middle) temp).field_1 // counter += (i32) ((middle) temp).field_1
// Note: This cast should get optimized away, as temp only gets // Note: This cast should get optimized away, as temp only gets
// assigned to {bottom1} and {bottom2}. // assigned to {bottom1} and {bottom2}.
kExprLocalGet, 2, kGCPrefix, kExprRefCastStatic, middle, kExprLocalGet, 2, kGCPrefix, kExprRefCast, middle,
kGCPrefix, kExprStructGet, middle, 1, kExprI32ConvertI64, kGCPrefix, kExprStructGet, middle, 1, kExprI32ConvertI64,
kExprLocalGet, 3, kExprI32Add, kExprLocalSet, 3, kExprLocalGet, 3, kExprI32Add, kExprLocalSet, 3,
// temp = x0; // temp = x0;
......
...@@ -27,19 +27,19 @@ function createArray_i() { ...@@ -27,19 +27,19 @@ function createArray_i() {
builder.addFunction("array_get", sig_i_ai) builder.addFunction("array_get", sig_i_ai)
.addBody([ .addBody([
kExprLocalGet, 0, // -- kExprLocalGet, 0, // --
kGCPrefix, kExprRefCastStatic, type_index, // -- kGCPrefix, kExprRefCast, type_index, // --
kExprLocalGet, 1, // -- kExprLocalGet, 1, // --
kGCPrefix, kExprArrayGet, type_index]) // -- kGCPrefix, kExprArrayGet, type_index]) // --
.exportAs("array_get"); .exportAs("array_get");
builder.addFunction("array_set", sig_v_aii) builder.addFunction("array_set", sig_v_aii)
.addBody([ .addBody([
kExprLocalGet, 0, // -- kExprLocalGet, 0, // --
kGCPrefix, kExprRefCastStatic, type_index, // -- kGCPrefix, kExprRefCast, type_index, // --
kExprLocalGet, 1, // -- kExprLocalGet, 1, // --
kExprLocalGet, 2, // -- kExprLocalGet, 2, // --
kGCPrefix, kExprArraySet, type_index]) // -- kGCPrefix, kExprArraySet, type_index]) // --
.exportAs("array_set"); .exportAs("array_set");
let instance = builder.instantiate(); let instance = builder.instantiate();
......
...@@ -44,7 +44,7 @@ let instance = (() => { ...@@ -44,7 +44,7 @@ let instance = (() => {
kExprLocalGet, 0, kExprLocalGet, 0,
kExprBrOnNull, 0, kExprBrOnNull, 0,
kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefAsData,
kGCPrefix, kExprRefCastStatic, struct, kGCPrefix, kExprRefCast, struct,
kGCPrefix, kExprStructGet, struct, 0, // value kGCPrefix, kExprStructGet, struct, 0, // value
kExprI32Const, 0, // isNull kExprI32Const, 0, // isNull
kExprReturn, kExprReturn,
...@@ -65,7 +65,7 @@ let instance = (() => { ...@@ -65,7 +65,7 @@ let instance = (() => {
kGCPrefix, kExprExternInternalize, kGCPrefix, kExprExternInternalize,
kExprBrOnNull, 0, kExprBrOnNull, 0,
kGCPrefix, kExprRefAsData, kGCPrefix, kExprRefAsData,
kGCPrefix, kExprRefCastStatic, struct, kGCPrefix, kExprRefCast, struct,
kGCPrefix, kExprStructGet, struct, 0, // value kGCPrefix, kExprStructGet, struct, 0, // value
kExprI32Const, 0, // isNull kExprI32Const, 0, // isNull
kExprReturn, kExprReturn,
...@@ -156,7 +156,7 @@ let instance = (() => { ...@@ -156,7 +156,7 @@ let instance = (() => {
kExprLocalGet, 0, kExprLocalGet, 0,
kExprBrOnNull, 0, kExprBrOnNull, 0,
kGCPrefix, kExprRefAsArray, kGCPrefix, kExprRefAsArray,
kGCPrefix, kExprRefCastStatic, array, kGCPrefix, kExprRefCast, array,
kExprI32Const, 0, kExprI32Const, 0,
kGCPrefix, kExprArrayGet, array, // value kGCPrefix, kExprArrayGet, array, // value
kExprI32Const, 0, // isNull kExprI32Const, 0, // isNull
...@@ -178,7 +178,7 @@ let instance = (() => { ...@@ -178,7 +178,7 @@ let instance = (() => {
kGCPrefix, kExprExternInternalize, kGCPrefix, kExprExternInternalize,
kExprBrOnNull, 0, kExprBrOnNull, 0,
kGCPrefix, kExprRefAsArray, kGCPrefix, kExprRefAsArray,
kGCPrefix, kExprRefCastStatic, array, kGCPrefix, kExprRefCast, array,
kExprI32Const, 0, kExprI32Const, 0,
kGCPrefix, kExprArrayGet, array, // value kGCPrefix, kExprArrayGet, array, // value
kExprI32Const, 0, // isNull kExprI32Const, 0, // isNull
......
...@@ -502,16 +502,16 @@ let kExprArrayLen = 0x19; ...@@ -502,16 +502,16 @@ let kExprArrayLen = 0x19;
let kExprArrayNewFixed = 0x1a; let kExprArrayNewFixed = 0x1a;
let kExprArrayNew = 0x1b; let kExprArrayNew = 0x1b;
let kExprArrayNewDefault = 0x1c; let kExprArrayNewDefault = 0x1c;
let kExprArrayNewDataStatic = 0x1d; let kExprArrayNewData = 0x1d;
let kExprArrayNewElemStatic = 0x1f; let kExprArrayNewElem = 0x1f;
let kExprI31New = 0x20; let kExprI31New = 0x20;
let kExprI31GetS = 0x21; let kExprI31GetS = 0x21;
let kExprI31GetU = 0x22; let kExprI31GetU = 0x22;
let kExprRefTestStatic = 0x44; let kExprRefTest = 0x44;
let kExprRefCastStatic = 0x45; let kExprRefCast = 0x45;
let kExprBrOnCastStatic = 0x46; let kExprBrOnCast = 0x46;
let kExprBrOnCastStaticFail = 0x47; let kExprBrOnCastFail = 0x47;
let kExprRefCastNopStatic = 0x48; let kExprRefCastNop = 0x48;
let kExprRefIsData = 0x51; let kExprRefIsData = 0x51;
let kExprRefIsI31 = 0x52; let kExprRefIsI31 = 0x52;
let kExprRefIsArray = 0x53; let kExprRefIsArray = 0x53;
......
...@@ -1153,12 +1153,12 @@ TEST_F(FunctionBodyDecoderTest, UnreachableRefTypes) { ...@@ -1153,12 +1153,12 @@ TEST_F(FunctionBodyDecoderTest, UnreachableRefTypes) {
{WASM_UNREACHABLE, WASM_GC_OP(kExprArrayNewDefault), {WASM_UNREACHABLE, WASM_GC_OP(kExprArrayNewDefault),
array_index, kExprDrop}); array_index, kExprDrop});
ExpectValidates(sigs.i_v(), {WASM_UNREACHABLE, WASM_GC_OP(kExprRefTestStatic), ExpectValidates(sigs.i_v(),
struct_index}); {WASM_UNREACHABLE, WASM_GC_OP(kExprRefTest), struct_index});
ExpectValidates(sigs.v_v(), {WASM_UNREACHABLE, WASM_GC_OP(kExprRefCastStatic), ExpectValidates(sigs.v_v(), {WASM_UNREACHABLE, WASM_GC_OP(kExprRefCast),
struct_index, kExprDrop}); struct_index, kExprDrop});
ExpectValidates(sigs.v_v(), {WASM_UNREACHABLE, WASM_GC_OP(kExprRefCastStatic), ExpectValidates(sigs.v_v(), {WASM_UNREACHABLE, WASM_GC_OP(kExprRefCast),
struct_index, kExprDrop}); struct_index, kExprDrop});
ExpectValidates(sigs.v_v(), {WASM_UNREACHABLE, kExprBrOnNull, 0, WASM_DROP}); ExpectValidates(sigs.v_v(), {WASM_UNREACHABLE, kExprBrOnNull, 0, WASM_DROP});
...@@ -1166,9 +1166,8 @@ TEST_F(FunctionBodyDecoderTest, UnreachableRefTypes) { ...@@ -1166,9 +1166,8 @@ TEST_F(FunctionBodyDecoderTest, UnreachableRefTypes) {
ExpectValidates(&sig_v_s, {WASM_UNREACHABLE, WASM_LOCAL_GET(0), kExprBrOnNull, ExpectValidates(&sig_v_s, {WASM_UNREACHABLE, WASM_LOCAL_GET(0), kExprBrOnNull,
0, kExprCallFunction, struct_consumer}); 0, kExprCallFunction, struct_consumer});
ExpectValidates( ExpectValidates(FunctionSig::Build(zone(), {struct_type}, {}),
FunctionSig::Build(zone(), {struct_type}, {}), {WASM_UNREACHABLE, WASM_GC_OP(kExprRefCast), struct_index});
{WASM_UNREACHABLE, WASM_GC_OP(kExprRefCastStatic), struct_index});
ExpectValidates(FunctionSig::Build(zone(), {kWasmDataRef}, {}), ExpectValidates(FunctionSig::Build(zone(), {kWasmDataRef}, {}),
{WASM_UNREACHABLE, WASM_GC_OP(kExprRefAsData)}); {WASM_UNREACHABLE, WASM_GC_OP(kExprRefAsData)});
...@@ -4333,38 +4332,34 @@ TEST_F(FunctionBodyDecoderTest, RefTestCast) { ...@@ -4333,38 +4332,34 @@ TEST_F(FunctionBodyDecoderTest, RefTestCast) {
FunctionSig cast_sig(1, 1, cast_reps); FunctionSig cast_sig(1, 1, cast_reps);
if (should_pass) { if (should_pass) {
ExpectValidates( ExpectValidates(&test_sig, {WASM_REF_TEST(WASM_LOCAL_GET(0),
&test_sig, WASM_HEAP_TYPE(to_heap))});
{WASM_REF_TEST_STATIC(WASM_LOCAL_GET(0), WASM_HEAP_TYPE(to_heap))}); ExpectValidates(&cast_sig, {WASM_REF_CAST(WASM_LOCAL_GET(0),
ExpectValidates( WASM_HEAP_TYPE(to_heap))});
&cast_sig,
{WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), WASM_HEAP_TYPE(to_heap))});
} else { } else {
std::string error_message = std::string error_message =
"[0] expected subtype of (ref null func) or (ref null data), found " "[0] expected subtype of (ref null func) or (ref null data), found "
"local.get of type " + "local.get of type " +
test_reps[1].name(); test_reps[1].name();
ExpectFailure( ExpectFailure(&test_sig,
&test_sig, {WASM_REF_TEST(WASM_LOCAL_GET(0), WASM_HEAP_TYPE(to_heap))},
{WASM_REF_TEST_STATIC(WASM_LOCAL_GET(0), WASM_HEAP_TYPE(to_heap))}, kAppendEnd, ("ref.test" + error_message).c_str());
kAppendEnd, ("ref.test_static" + error_message).c_str()); ExpectFailure(&cast_sig,
ExpectFailure( {WASM_REF_CAST(WASM_LOCAL_GET(0), WASM_HEAP_TYPE(to_heap))},
&cast_sig, kAppendEnd, ("ref.cast" + error_message).c_str());
{WASM_REF_CAST_STATIC(WASM_LOCAL_GET(0), WASM_HEAP_TYPE(to_heap))},
kAppendEnd, ("ref.cast_static" + error_message).c_str());
} }
} }
// Trivial type error. // Trivial type error.
ExpectFailure(sigs.v_v(), ExpectFailure(sigs.v_v(),
{WASM_REF_TEST_STATIC(WASM_I32V(1), array_heap), kExprDrop}, {WASM_REF_TEST(WASM_I32V(1), array_heap), kExprDrop},
kAppendEnd, kAppendEnd,
"ref.test_static[0] expected subtype of (ref null func) or " "ref.test[0] expected subtype of (ref null func) or "
"(ref null data), found i32.const of type i32"); "(ref null data), found i32.const of type i32");
ExpectFailure(sigs.v_v(), ExpectFailure(sigs.v_v(),
{WASM_REF_CAST_STATIC(WASM_I32V(1), array_heap), kExprDrop}, {WASM_REF_CAST(WASM_I32V(1), array_heap), kExprDrop},
kAppendEnd, kAppendEnd,
"ref.cast_static[0] expected subtype of (ref null func) or " "ref.cast[0] expected subtype of (ref null func) or "
"(ref null data), found i32.const of type i32"); "(ref null data), found i32.const of type i32");
} }
...@@ -4382,48 +4377,44 @@ TEST_F(FunctionBodyDecoderTest, BrOnCastOrCastFail) { ...@@ -4382,48 +4377,44 @@ TEST_F(FunctionBodyDecoderTest, BrOnCastOrCastFail) {
ExpectValidates( ExpectValidates(
FunctionSig::Build(this->zone(), {kWasmI32, subtype}, {supertype}), FunctionSig::Build(this->zone(), {kWasmI32, subtype}, {supertype}),
{WASM_I32V(42), WASM_LOCAL_GET(0), WASM_BR_ON_CAST_STATIC(0, sub_struct), {WASM_I32V(42), WASM_LOCAL_GET(0), WASM_BR_ON_CAST(0, sub_struct),
WASM_GC_OP(kExprRefCastStatic), sub_struct}); WASM_GC_OP(kExprRefCast), sub_struct});
ExpectValidates( ExpectValidates(
FunctionSig::Build(this->zone(), {kWasmI32, supertype}, {supertype}), FunctionSig::Build(this->zone(), {kWasmI32, supertype}, {supertype}),
{WASM_I32V(42), WASM_LOCAL_GET(0), {WASM_I32V(42), WASM_LOCAL_GET(0), WASM_BR_ON_CAST_FAIL(0, sub_struct)});
WASM_BR_ON_CAST_STATIC_FAIL(0, sub_struct)});
// Wrong branch type. // Wrong branch type.
ExpectFailure(FunctionSig::Build(this->zone(), {}, {supertype}), ExpectFailure(
{WASM_LOCAL_GET(0), WASM_BR_ON_CAST_STATIC(0, sub_struct), FunctionSig::Build(this->zone(), {}, {supertype}),
WASM_UNREACHABLE}, {WASM_LOCAL_GET(0), WASM_BR_ON_CAST(0, sub_struct), WASM_UNREACHABLE},
kAppendEnd, kAppendEnd, "br_on_cast must target a branch of arity at least 1");
"br_on_cast must target a branch of arity at least 1");
ExpectFailure( ExpectFailure(
FunctionSig::Build(this->zone(), {subtype}, {supertype}), FunctionSig::Build(this->zone(), {subtype}, {supertype}),
{WASM_I32V(42), WASM_LOCAL_GET(0), {WASM_I32V(42), WASM_LOCAL_GET(0), WASM_BR_ON_CAST_FAIL(0, sub_struct)},
WASM_BR_ON_CAST_STATIC_FAIL(0, sub_struct)},
kAppendEnd, kAppendEnd,
"type error in branch[0] (expected (ref null 1), got (ref null 0))"); "type error in branch[0] (expected (ref null 1), got (ref null 0))");
// Wrong fallthrough type. // Wrong fallthrough type.
ExpectFailure( ExpectFailure(
FunctionSig::Build(this->zone(), {subtype}, {supertype}), FunctionSig::Build(this->zone(), {subtype}, {supertype}),
{WASM_LOCAL_GET(0), WASM_BR_ON_CAST_STATIC(0, sub_struct)}, kAppendEnd, {WASM_LOCAL_GET(0), WASM_BR_ON_CAST(0, sub_struct)}, kAppendEnd,
"type error in fallthru[0] (expected (ref null 1), got (ref null 0))"); "type error in fallthru[0] (expected (ref null 1), got (ref null 0))");
ExpectFailure(FunctionSig::Build(this->zone(), {supertype}, {supertype}), ExpectFailure(
{WASM_BLOCK_I(WASM_LOCAL_GET(0), FunctionSig::Build(this->zone(), {supertype}, {supertype}),
WASM_BR_ON_CAST_STATIC_FAIL(0, sub_struct))}, {WASM_BLOCK_I(WASM_LOCAL_GET(0), WASM_BR_ON_CAST_FAIL(0, sub_struct))},
kAppendEnd, kAppendEnd, "type error in branch[0] (expected i32, got (ref null 0))");
"type error in branch[0] (expected i32, got (ref null 0))");
// Argument type error. // Argument type error.
ExpectFailure(FunctionSig::Build(this->zone(), {subtype}, {kWasmExternRef}), ExpectFailure(FunctionSig::Build(this->zone(), {subtype}, {kWasmExternRef}),
{WASM_LOCAL_GET(0), WASM_BR_ON_CAST_STATIC(0, sub_struct), {WASM_LOCAL_GET(0), WASM_BR_ON_CAST(0, sub_struct),
WASM_GC_OP(kExprRefCastStatic), sub_struct}, WASM_GC_OP(kExprRefCast), sub_struct},
kAppendEnd, kAppendEnd,
"br_on_cast_static[0] expected subtype of (ref null func) or " "br_on_cast[0] expected subtype of (ref null func) or "
"(ref null data), found local.get of type externref"); "(ref null data), found local.get of type externref");
ExpectFailure(FunctionSig::Build(this->zone(), {supertype}, {kWasmExternRef}), ExpectFailure(FunctionSig::Build(this->zone(), {supertype}, {kWasmExternRef}),
{WASM_LOCAL_GET(0), WASM_BR_ON_CAST_STATIC_FAIL(0, sub_struct)}, {WASM_LOCAL_GET(0), WASM_BR_ON_CAST_FAIL(0, sub_struct)},
kAppendEnd, kAppendEnd,
"br_on_cast_static_fail[0] expected subtype of (ref null func) " "br_on_cast_fail[0] expected subtype of (ref null func) "
"or (ref null data), found local.get of type externref"); "or (ref null data), found local.get of type externref");
} }
...@@ -4865,9 +4856,9 @@ TEST_F(WasmOpcodeLengthTest, IllegalRefIndices) { ...@@ -4865,9 +4856,9 @@ TEST_F(WasmOpcodeLengthTest, IllegalRefIndices) {
} }
TEST_F(WasmOpcodeLengthTest, GCOpcodes) { TEST_F(WasmOpcodeLengthTest, GCOpcodes) {
// br_on_cast_static{,_fail}: prefix + opcode + br_depth + type_index // br_on_cast{,_fail}: prefix + opcode + br_depth + type_index
ExpectLength(4, 0xfb, kExprBrOnCastStatic & 0xFF); ExpectLength(4, 0xfb, kExprBrOnCast & 0xFF);
ExpectLength(4, 0xfb, kExprBrOnCastStaticFail & 0xFF); ExpectLength(4, 0xfb, kExprBrOnCastFail & 0xFF);
// struct.new, with leb immediate operand. // struct.new, with leb immediate operand.
ExpectLength(3, 0xfb, 0x07, 0x42); ExpectLength(3, 0xfb, 0x07, 0x42);
......
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