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