[wasm-gc] Remove ref.is_func & ref.as_func op
Preparation step to remove the subtype relationship between funcref and anyref. Bug: v8:7748 Change-Id: Ic2d3467addff16dc0df466234cb7ce6e573ba666 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3797829 Auto-Submit: Matthias Liedtke <mliedtke@chromium.org> Commit-Queue: Matthias Liedtke <mliedtke@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/main@{#82111}
This commit is contained in:
parent
32217caa20
commit
fb9504f31e
@ -5541,26 +5541,6 @@ void WasmGraphBuilder::BrOnData(Node* object, Node* /*rtt*/,
|
||||
});
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::RefIsFunc(Node* object, bool object_can_be_null) {
|
||||
auto done = gasm_->MakeLabel(MachineRepresentation::kWord32);
|
||||
ManagedObjectInstanceCheck(object, object_can_be_null,
|
||||
WASM_INTERNAL_FUNCTION_TYPE, TestCallbacks(&done));
|
||||
gasm_->Goto(&done, Int32Constant(1));
|
||||
gasm_->Bind(&done);
|
||||
return done.PhiAt(0);
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::RefAsFunc(Node* object, bool object_can_be_null,
|
||||
wasm::WasmCodePosition position) {
|
||||
auto done = gasm_->MakeLabel();
|
||||
ManagedObjectInstanceCheck(object, object_can_be_null,
|
||||
WASM_INTERNAL_FUNCTION_TYPE,
|
||||
CastCallbacks(&done, position));
|
||||
gasm_->Goto(&done);
|
||||
gasm_->Bind(&done);
|
||||
return object;
|
||||
}
|
||||
|
||||
void WasmGraphBuilder::BrOnFunc(Node* object, Node* /*rtt*/,
|
||||
WasmTypeCheckConfig config,
|
||||
Node** match_control, Node** match_effect,
|
||||
|
@ -520,9 +520,6 @@ class WasmGraphBuilder {
|
||||
void BrOnData(Node* object, Node* rtt, WasmTypeCheckConfig config,
|
||||
Node** match_control, Node** match_effect,
|
||||
Node** no_match_control, Node** no_match_effect);
|
||||
Node* RefIsFunc(Node* object, bool object_can_be_null);
|
||||
Node* RefAsFunc(Node* object, bool object_can_be_null,
|
||||
wasm::WasmCodePosition position);
|
||||
void BrOnFunc(Node* object, Node* rtt, WasmTypeCheckConfig config,
|
||||
Node** match_control, Node** match_effect,
|
||||
Node** no_match_control, Node** no_match_effect);
|
||||
|
@ -6067,11 +6067,6 @@ class LiftoffCompiler {
|
||||
AbstractTypeCheck<&LiftoffCompiler::DataCheck>(object);
|
||||
}
|
||||
|
||||
void RefIsFunc(FullDecoder* /* decoder */, const Value& object,
|
||||
Value* /* result_val */) {
|
||||
AbstractTypeCheck<&LiftoffCompiler::FuncCheck>(object);
|
||||
}
|
||||
|
||||
void RefIsArray(FullDecoder* /* decoder */, const Value& object,
|
||||
Value* /* result_val */) {
|
||||
AbstractTypeCheck<&LiftoffCompiler::ArrayCheck>(object);
|
||||
@ -6098,11 +6093,6 @@ class LiftoffCompiler {
|
||||
AbstractTypeCast<&LiftoffCompiler::DataCheck>(object, decoder, kRef);
|
||||
}
|
||||
|
||||
void RefAsFunc(FullDecoder* decoder, const Value& object,
|
||||
Value* /* result */) {
|
||||
AbstractTypeCast<&LiftoffCompiler::FuncCheck>(object, decoder, kRef);
|
||||
}
|
||||
|
||||
void RefAsI31(FullDecoder* decoder, const Value& object, Value* result) {
|
||||
AbstractTypeCast<&LiftoffCompiler::I31Check>(object, decoder, kRef);
|
||||
}
|
||||
|
@ -1089,11 +1089,9 @@ struct ControlBase : public PcForErrors<validate> {
|
||||
uint32_t depth) \
|
||||
F(BrOnCastFail, const Value& obj, const Value& rtt, \
|
||||
Value* result_on_fallthrough, uint32_t depth) \
|
||||
F(RefIsFunc, const Value& object, Value* result) \
|
||||
F(RefIsData, const Value& object, Value* result) \
|
||||
F(RefIsI31, const Value& object, Value* result) \
|
||||
F(RefIsArray, const Value& object, Value* result) \
|
||||
F(RefAsFunc, const Value& object, Value* result) \
|
||||
F(RefAsData, const Value& object, Value* result) \
|
||||
F(RefAsI31, const Value& object, Value* result) \
|
||||
F(RefAsArray, const Value& object, Value* result) \
|
||||
@ -2068,11 +2066,9 @@ class WasmDecoder : public Decoder {
|
||||
case kExprI31GetU:
|
||||
case kExprRefAsArray:
|
||||
case kExprRefAsData:
|
||||
case kExprRefAsFunc:
|
||||
case kExprRefAsI31:
|
||||
case kExprRefIsArray:
|
||||
case kExprRefIsData:
|
||||
case kExprRefIsFunc:
|
||||
case kExprRefIsI31:
|
||||
return length;
|
||||
case kExprStringNewWtf16:
|
||||
@ -4952,7 +4948,6 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
return opcode_length; \
|
||||
}
|
||||
ABSTRACT_TYPE_CHECK(Data)
|
||||
ABSTRACT_TYPE_CHECK(Func)
|
||||
ABSTRACT_TYPE_CHECK(I31)
|
||||
ABSTRACT_TYPE_CHECK(Array)
|
||||
#undef ABSTRACT_TYPE_CHECK
|
||||
@ -4987,7 +4982,6 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
return opcode_length; \
|
||||
}
|
||||
ABSTRACT_TYPE_CAST(Data)
|
||||
ABSTRACT_TYPE_CAST(Func)
|
||||
ABSTRACT_TYPE_CAST(I31)
|
||||
ABSTRACT_TYPE_CAST(Array)
|
||||
#undef ABSTRACT_TYPE_CAST
|
||||
|
@ -1308,18 +1308,6 @@ class WasmGraphBuildingInterface {
|
||||
br_depth, false);
|
||||
}
|
||||
|
||||
void RefIsFunc(FullDecoder* decoder, const Value& object, Value* result) {
|
||||
SetAndTypeNode(result,
|
||||
builder_->RefIsFunc(object.node, object.type.is_nullable()));
|
||||
}
|
||||
|
||||
void RefAsFunc(FullDecoder* decoder, const Value& object, Value* result) {
|
||||
TFNode* cast_object = builder_->RefAsFunc(
|
||||
object.node, object.type.is_nullable(), decoder->position());
|
||||
TFNode* rename = builder_->TypeGuard(cast_object, result->type);
|
||||
SetAndTypeNode(result, rename);
|
||||
}
|
||||
|
||||
void BrOnFunc(FullDecoder* decoder, const Value& object,
|
||||
Value* value_on_branch, uint32_t br_depth) {
|
||||
BrOnCastAbs<&compiler::WasmGraphBuilder::BrOnFunc>(
|
||||
|
@ -710,11 +710,9 @@ bool V8_EXPORT_PRIVATE IsJSCompatibleSignature(const FunctionSig* sig,
|
||||
V(BrOnCastStatic, 0xfb46, _, "br_on_cast_static") \
|
||||
V(BrOnCastStaticFail, 0xfb47, _, "br_on_cast_static_fail") \
|
||||
V(RefCastNopStatic, 0xfb48, _, "ref.cast_nop_static") \
|
||||
V(RefIsFunc, 0xfb50, _, "ref.is_func") \
|
||||
V(RefIsData, 0xfb51, _, "ref.is_data") \
|
||||
V(RefIsI31, 0xfb52, _, "ref.is_i31") \
|
||||
V(RefIsArray, 0xfb53, _, "ref.is_array") \
|
||||
V(RefAsFunc, 0xfb58, _, "ref.as_func") \
|
||||
V(RefAsData, 0xfb59, _, "ref.as_data") \
|
||||
V(RefAsI31, 0xfb5a, _, "ref.as_i31") \
|
||||
V(RefAsArray, 0xfb5b, _, "ref.as_array") \
|
||||
|
@ -1574,9 +1574,6 @@ WASM_COMPILED_EXEC_TEST(CallNullRefImplicitConversion) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(CastNullRef) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
byte to_func = tester.DefineFunction(
|
||||
tester.sigs.i_v(), {},
|
||||
{WASM_REF_IS_NULL(WASM_REF_AS_FUNC(WASM_REF_NULL(kNoneCode))), kExprEnd});
|
||||
byte to_non_null = tester.DefineFunction(
|
||||
tester.sigs.i_v(), {},
|
||||
{WASM_REF_IS_NULL(WASM_REF_AS_NON_NULL(WASM_REF_NULL(kNoneCode))),
|
||||
@ -1599,7 +1596,6 @@ WASM_COMPILED_EXEC_TEST(CastNullRef) {
|
||||
kExprEnd});
|
||||
tester.CompileModule();
|
||||
// Generic casts trap on null.
|
||||
tester.CheckHasThrown(to_func);
|
||||
tester.CheckHasThrown(to_non_null);
|
||||
tester.CheckHasThrown(to_array);
|
||||
tester.CheckHasThrown(to_data);
|
||||
@ -1664,9 +1660,6 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
byte kArrayCheckNull = tester.DefineFunction(
|
||||
tester.sigs.i_v(), {},
|
||||
{WASM_REF_IS_ARRAY(WASM_REF_NULL(kAnyRefCode)), kExprEnd});
|
||||
byte kFuncCheckNull = tester.DefineFunction(
|
||||
tester.sigs.i_v(), {},
|
||||
{WASM_REF_IS_FUNC(WASM_REF_NULL(kAnyRefCode)), kExprEnd});
|
||||
byte kI31CheckNull = tester.DefineFunction(
|
||||
tester.sigs.i_v(), {},
|
||||
{WASM_REF_IS_I31(WASM_REF_NULL(kAnyRefCode)), kExprEnd});
|
||||
@ -1679,10 +1672,6 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
tester.DefineFunction(tester.sigs.i_v(), {},
|
||||
{WASM_REF_AS_ARRAY(WASM_REF_NULL(kAnyRefCode)),
|
||||
WASM_DROP, WASM_I32V(1), kExprEnd});
|
||||
byte kFuncCastNull =
|
||||
tester.DefineFunction(tester.sigs.i_v(), {},
|
||||
{WASM_REF_AS_FUNC(WASM_REF_NULL(kAnyRefCode)),
|
||||
WASM_DROP, WASM_I32V(1), kExprEnd});
|
||||
byte kI31CastNull =
|
||||
tester.DefineFunction(tester.sigs.i_v(), {},
|
||||
{WASM_REF_AS_I31(WASM_REF_NULL(kAnyRefCode)),
|
||||
@ -1700,9 +1689,6 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
TYPE_CHECK(ARRAY, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
byte kArrayCheckFailure =
|
||||
TYPE_CHECK(ARRAY, WASM_STRUCT_NEW_DEFAULT(struct_index));
|
||||
byte kFuncCheckSuccess = TYPE_CHECK(FUNC, WASM_REF_FUNC(function_index));
|
||||
byte kFuncCheckFailure =
|
||||
TYPE_CHECK(FUNC, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
byte kI31CheckSuccess = TYPE_CHECK(I31, WASM_I31_NEW(WASM_I32V(42)));
|
||||
byte kI31CheckFailure =
|
||||
TYPE_CHECK(I31, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
@ -1720,9 +1706,6 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
byte kArrayCastSuccess =
|
||||
TYPE_CAST(DATA, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
byte kArrayCastFailure = TYPE_CAST(DATA, WASM_I31_NEW(WASM_I32V(42)));
|
||||
byte kFuncCastSuccess = TYPE_CAST(FUNC, WASM_REF_FUNC(function_index));
|
||||
byte kFuncCastFailure =
|
||||
TYPE_CAST(FUNC, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
byte kI31CastSuccess = TYPE_CAST(I31, WASM_I31_NEW(WASM_I32V(42)));
|
||||
byte kI31CastFailure =
|
||||
TYPE_CAST(I31, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
@ -1742,8 +1725,6 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
byte kBrOnDataTaken =
|
||||
BR_ON(DATA, Data, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
byte kBrOnDataNotTaken = BR_ON(DATA, Data, WASM_REF_FUNC(function_index));
|
||||
byte kBrOnFuncTaken = BR_ON(FUNC, Func, WASM_REF_FUNC(function_index));
|
||||
byte kBrOnFuncNotTaken = BR_ON(FUNC, Func, WASM_I31_NEW(WASM_I32V(42)));
|
||||
byte kBrOnArrayTaken =
|
||||
BR_ON(ARRAY, Array, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
byte kBrOnArrayNotTaken = BR_ON(ARRAY, Array, WASM_I31_NEW(WASM_I32V(42)));
|
||||
@ -1766,9 +1747,6 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
byte kBrOnNonDataNotTaken =
|
||||
BR_ON_NON(DATA, Data, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
byte kBrOnNonDataTaken = BR_ON_NON(DATA, Data, WASM_REF_FUNC(function_index));
|
||||
byte kBrOnNonFuncNotTaken =
|
||||
BR_ON_NON(FUNC, Func, WASM_REF_FUNC(function_index));
|
||||
byte kBrOnNonFuncTaken = BR_ON_NON(FUNC, Func, WASM_I31_NEW(WASM_I32V(42)));
|
||||
byte kBrOnNonArrayNotTaken = BR_ON_NON(
|
||||
ARRAY, Array, WASM_ARRAY_NEW_DEFAULT(array_index, WASM_I32V(10)));
|
||||
byte kBrOnNonArrayTaken =
|
||||
@ -1782,38 +1760,30 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
|
||||
tester.CheckResult(kDataCheckNull, 0);
|
||||
tester.CheckResult(kArrayCheckNull, 0);
|
||||
tester.CheckResult(kFuncCheckNull, 0);
|
||||
tester.CheckResult(kI31CheckNull, 0);
|
||||
|
||||
tester.CheckHasThrown(kDataCastNull);
|
||||
tester.CheckHasThrown(kArrayCastNull);
|
||||
tester.CheckHasThrown(kFuncCastNull);
|
||||
tester.CheckHasThrown(kI31CastNull);
|
||||
|
||||
tester.CheckResult(kDataCheckSuccess, 1);
|
||||
tester.CheckResult(kArrayCheckSuccess, 1);
|
||||
tester.CheckResult(kFuncCheckSuccess, 1);
|
||||
tester.CheckResult(kI31CheckSuccess, 1);
|
||||
|
||||
tester.CheckResult(kDataCheckFailure, 0);
|
||||
tester.CheckResult(kArrayCheckFailure, 0);
|
||||
tester.CheckResult(kFuncCheckFailure, 0);
|
||||
tester.CheckResult(kI31CheckFailure, 0);
|
||||
|
||||
tester.CheckResult(kDataCastSuccess, 1);
|
||||
tester.CheckResult(kArrayCastSuccess, 1);
|
||||
tester.CheckResult(kFuncCastSuccess, 1);
|
||||
tester.CheckResult(kI31CastSuccess, 1);
|
||||
|
||||
tester.CheckHasThrown(kDataCastFailure);
|
||||
tester.CheckHasThrown(kArrayCastFailure);
|
||||
tester.CheckHasThrown(kFuncCastFailure);
|
||||
tester.CheckHasThrown(kI31CastFailure);
|
||||
|
||||
tester.CheckResult(kBrOnDataTaken, 1);
|
||||
tester.CheckResult(kBrOnDataNotTaken, 0);
|
||||
tester.CheckResult(kBrOnFuncTaken, 1);
|
||||
tester.CheckResult(kBrOnFuncNotTaken, 0);
|
||||
tester.CheckResult(kBrOnArrayTaken, 1);
|
||||
tester.CheckResult(kBrOnArrayNotTaken, 0);
|
||||
tester.CheckResult(kBrOnI31Taken, 1);
|
||||
@ -1821,8 +1791,6 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
|
||||
tester.CheckResult(kBrOnNonDataTaken, 0);
|
||||
tester.CheckResult(kBrOnNonDataNotTaken, 1);
|
||||
tester.CheckResult(kBrOnNonFuncTaken, 0);
|
||||
tester.CheckResult(kBrOnNonFuncNotTaken, 1);
|
||||
tester.CheckResult(kBrOnNonArrayTaken, 0);
|
||||
tester.CheckResult(kBrOnNonArrayNotTaken, 1);
|
||||
tester.CheckResult(kBrOnNonI31Taken, 0);
|
||||
|
@ -534,11 +534,9 @@ inline uint16_t ExtractPrefixedOpcodeBytes(WasmOpcode opcode) {
|
||||
WASM_GC_OP(kExprBrOnCastStaticFail), static_cast<byte>(depth), \
|
||||
static_cast<byte>(typeidx)
|
||||
|
||||
#define WASM_REF_IS_FUNC(ref) ref, WASM_GC_OP(kExprRefIsFunc)
|
||||
#define WASM_REF_IS_DATA(ref) ref, WASM_GC_OP(kExprRefIsData)
|
||||
#define WASM_REF_IS_ARRAY(ref) ref, WASM_GC_OP(kExprRefIsArray)
|
||||
#define WASM_REF_IS_I31(ref) ref, WASM_GC_OP(kExprRefIsI31)
|
||||
#define WASM_REF_AS_FUNC(ref) ref, WASM_GC_OP(kExprRefAsFunc)
|
||||
#define WASM_REF_AS_DATA(ref) ref, WASM_GC_OP(kExprRefAsData)
|
||||
#define WASM_REF_AS_ARRAY(ref) ref, WASM_GC_OP(kExprRefAsArray)
|
||||
#define WASM_REF_AS_I31(ref) ref, WASM_GC_OP(kExprRefAsI31)
|
||||
|
@ -495,11 +495,9 @@ let kExprRefCastStatic = 0x45;
|
||||
let kExprBrOnCastStatic = 0x46;
|
||||
let kExprBrOnCastStaticFail = 0x47;
|
||||
let kExprRefCastNopStatic = 0x48;
|
||||
let kExprRefIsFunc = 0x50;
|
||||
let kExprRefIsData = 0x51;
|
||||
let kExprRefIsI31 = 0x52;
|
||||
let kExprRefIsArray = 0x53;
|
||||
let kExprRefAsFunc = 0x58;
|
||||
let kExprRefAsData = 0x59;
|
||||
let kExprRefAsI31 = 0x5a;
|
||||
let kExprRefAsArray = 0x5b;
|
||||
|
@ -4387,9 +4387,6 @@ TEST_F(FunctionBodyDecoderTest, BrOnAbstractType) {
|
||||
|
||||
ValueType kNonNullableFunc = ValueType::Ref(HeapType::kFunc);
|
||||
|
||||
ExpectValidates(
|
||||
FunctionSig::Build(this->zone(), {kNonNullableFunc}, {kWasmAnyRef}),
|
||||
{WASM_LOCAL_GET(0), WASM_BR_ON_FUNC(0), WASM_GC_OP(kExprRefAsFunc)});
|
||||
ExpectValidates(
|
||||
FunctionSig::Build(this->zone(), {kWasmAnyRef}, {kWasmAnyRef}),
|
||||
{WASM_LOCAL_GET(0), WASM_BR_ON_NON_FUNC(0)});
|
||||
@ -4405,10 +4402,6 @@ TEST_F(FunctionBodyDecoderTest, BrOnAbstractType) {
|
||||
ExpectValidates(
|
||||
FunctionSig::Build(this->zone(), {kWasmAnyRef}, {kWasmAnyRef}),
|
||||
{WASM_LOCAL_GET(0), WASM_BR_ON_NON_I31(0)});
|
||||
// Unrelated types are OK.
|
||||
ExpectValidates(
|
||||
FunctionSig::Build(this->zone(), {kNonNullableFunc}, {kWasmDataRef}),
|
||||
{WASM_LOCAL_GET(0), WASM_BR_ON_FUNC(0), WASM_GC_OP(kExprRefAsFunc)});
|
||||
|
||||
// Wrong branch type.
|
||||
ExpectFailure(FunctionSig::Build(this->zone(), {}, {kWasmAnyRef}),
|
||||
|
Loading…
Reference in New Issue
Block a user