Skip to content

Commit bd52b88

Browse files
authored
Remove ref.is_null type parameter (#1474)
See WebAssembly/reference-types#99. This change also updates the testsuite, so the spec tests pass too. In addition, the behavior of `br_table` is no longer different from MVP, and has a text to confirm this. That is now fixed in `type-checker.cc` too.
1 parent 3041d94 commit bd52b88

26 files changed

+94
-90
lines changed

src/binary-reader-ir.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class BinaryReaderIR : public BinaryReaderNop {
185185
Result OnTableFillExpr(Index table_index) override;
186186
Result OnRefFuncExpr(Index func_index) override;
187187
Result OnRefNullExpr(Type type) override;
188-
Result OnRefIsNullExpr(Type type) override;
188+
Result OnRefIsNullExpr() override;
189189
Result OnNopExpr() override;
190190
Result OnRethrowExpr() override;
191191
Result OnReturnExpr() override;
@@ -919,8 +919,8 @@ Result BinaryReaderIR::OnRefNullExpr(Type type) {
919919
return AppendExpr(MakeUnique<RefNullExpr>(type));
920920
}
921921

922-
Result BinaryReaderIR::OnRefIsNullExpr(Type type) {
923-
return AppendExpr(MakeUnique<RefIsNullExpr>(type));
922+
Result BinaryReaderIR::OnRefIsNullExpr() {
923+
return AppendExpr(MakeUnique<RefIsNullExpr>());
924924
}
925925

926926
Result BinaryReaderIR::OnNopExpr() {

src/binary-reader-logging.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ DEFINE_INDEX(OnTableSizeExpr)
790790
DEFINE_INDEX_DESC(OnTableFillExpr, "table index")
791791
DEFINE_INDEX(OnRefFuncExpr)
792792
DEFINE_TYPE(OnRefNullExpr)
793-
DEFINE_TYPE(OnRefIsNullExpr)
793+
DEFINE0(OnRefIsNullExpr)
794794
DEFINE0(OnNopExpr)
795795
DEFINE0(OnRethrowExpr);
796796
DEFINE_INDEX_DESC(OnReturnCallExpr, "func_index")

src/binary-reader-logging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
201201
Result OnTableFillExpr(Index table) override;
202202
Result OnRefFuncExpr(Index index) override;
203203
Result OnRefNullExpr(Type type) override;
204-
Result OnRefIsNullExpr(Type type) override;
204+
Result OnRefIsNullExpr() override;
205205
Result OnNopExpr() override;
206206
Result OnRethrowExpr() override;
207207
Result OnReturnCallExpr(Index func_index) override;

src/binary-reader-nop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class BinaryReaderNop : public BinaryReaderDelegate {
278278
Result OnTableFillExpr(Index table_index) override { return Result::Ok; }
279279
Result OnRefFuncExpr(Index func_index) override { return Result::Ok; }
280280
Result OnRefNullExpr(Type type) override { return Result::Ok; }
281-
Result OnRefIsNullExpr(Type type) override { return Result::Ok; }
281+
Result OnRefIsNullExpr() override { return Result::Ok; }
282282
Result OnNopExpr() override { return Result::Ok; }
283283
Result OnRethrowExpr() override { return Result::Ok; }
284284
Result OnReturnCallExpr(Index sig_index) override { return Result::Ok; }

src/binary-reader.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,13 +1573,10 @@ Result BinaryReader::ReadFunctionBody(Offset end_offset) {
15731573
break;
15741574
}
15751575

1576-
case Opcode::RefIsNull: {
1577-
Type type;
1578-
CHECK_RESULT(ReadRefType(&type, "ref.is_null type"));
1579-
CALLBACK(OnRefIsNullExpr, type);
1580-
CALLBACK(OnOpcodeType, type);
1576+
case Opcode::RefIsNull:
1577+
CALLBACK(OnRefIsNullExpr);
1578+
CALLBACK(OnOpcodeBare);
15811579
break;
1582-
}
15831580

15841581
default:
15851582
return ReportUnexpectedOpcode(opcode);

src/binary-reader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class BinaryReaderDelegate {
267267
virtual Result OnTableFillExpr(Index table_index) = 0;
268268
virtual Result OnRefFuncExpr(Index func_index) = 0;
269269
virtual Result OnRefNullExpr(Type type) = 0;
270-
virtual Result OnRefIsNullExpr(Type type) = 0;
270+
virtual Result OnRefIsNullExpr() = 0;
271271
virtual Result OnNopExpr() = 0;
272272
virtual Result OnRethrowExpr() = 0;
273273
virtual Result OnReturnExpr() = 0;

src/binary-writer.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,9 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) {
684684
WriteType(stream_, cast<RefNullExpr>(expr)->type, "ref.null type");
685685
break;
686686
}
687-
case ExprType::RefIsNull: {
687+
case ExprType::RefIsNull:
688688
WriteOpcode(stream_, Opcode::RefIsNull);
689-
WriteType(stream_, cast<RefIsNullExpr>(expr)->type, "ref.is_null type");
690689
break;
691-
}
692690
case ExprType::Nop:
693691
WriteOpcode(stream_, Opcode::Nop);
694692
break;

src/interp/binary-reader-interp.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class BinaryReaderInterp : public BinaryReaderNop {
192192
Result OnMemorySizeExpr() override;
193193
Result OnRefFuncExpr(Index func_index) override;
194194
Result OnRefNullExpr(Type type) override;
195-
Result OnRefIsNullExpr(Type type) override;
195+
Result OnRefIsNullExpr() override;
196196
Result OnNopExpr() override;
197197
Result OnReturnExpr() override;
198198
Result OnSelectExpr(Type result_type) override;
@@ -1240,8 +1240,8 @@ Result BinaryReaderInterp::OnRefNullExpr(Type type) {
12401240
return Result::Ok;
12411241
}
12421242

1243-
Result BinaryReaderInterp::OnRefIsNullExpr(Type type) {
1244-
CHECK_RESULT(validator_.OnRefIsNull(loc, type));
1243+
Result BinaryReaderInterp::OnRefIsNullExpr() {
1244+
CHECK_RESULT(validator_.OnRefIsNull(loc));
12451245
istream_.Emit(Opcode::RefIsNull);
12461246
return Result::Ok;
12471247
}

src/ir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class RefTypeExpr : public ExprMixin<TypeEnum> {
409409
};
410410

411411
typedef RefTypeExpr<ExprType::RefNull> RefNullExpr;
412-
typedef RefTypeExpr<ExprType::RefIsNull> RefIsNullExpr;
412+
typedef ExprMixin<ExprType::RefIsNull> RefIsNullExpr;
413413

414414
template <ExprType TypeEnum>
415415
class OpcodeExpr : public ExprMixin<TypeEnum> {

src/shared-validator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,10 +968,10 @@ Result SharedValidator::OnRefFunc(const Location& loc, Var func_var) {
968968
return result;
969969
}
970970

971-
Result SharedValidator::OnRefIsNull(const Location& loc, Type type) {
971+
Result SharedValidator::OnRefIsNull(const Location& loc) {
972972
Result result = Result::Ok;
973973
expr_loc_ = &loc;
974-
result |= typechecker_.OnRefIsNullExpr(type);
974+
result |= typechecker_.OnRefIsNullExpr();
975975
return result;
976976
}
977977

0 commit comments

Comments
 (0)