Skip to content

Commit 6be04ad

Browse files
committed
Remove ref.is_null type parameter
See WebAssembly/reference-types#99. This can't land currently, since the testsuite hasn't been updated with these changes (looks like merge failure).
1 parent 017b8bd commit 6be04ad

20 files changed

+43
-50
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

src/shared-validator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class SharedValidator {
150150
Result OnMemorySize(const Location&);
151151
Result OnNop(const Location&);
152152
Result OnRefFunc(const Location&, Var func_var);
153-
Result OnRefIsNull(const Location&, Type type);
153+
Result OnRefIsNull(const Location&);
154154
Result OnRefNull(const Location&, Type type);
155155
Result OnRethrow(const Location&);
156156
Result OnReturnCall(const Location&, Var func_var);

src/type-checker.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,10 @@ Result TypeChecker::OnRefNullExpr(Type type) {
680680
return Result::Ok;
681681
}
682682

683-
Result TypeChecker::OnRefIsNullExpr(Type type) {
684-
Result result = PopAndCheck1Type(type, "ref.is_null");
683+
Result TypeChecker::OnRefIsNullExpr() {
684+
Type type;
685+
Result result = PeekType(0, &type);
686+
result |= PopAndCheck1Type(type, "ref.is_null");
685687
PushType(Type::I32);
686688
return result;
687689
}

src/type-checker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class TypeChecker {
110110
Result OnTableFill(Type elem_type);
111111
Result OnRefFuncExpr(Index func_index);
112112
Result OnRefNullExpr(Type type);
113-
Result OnRefIsNullExpr(Type type);
113+
Result OnRefIsNullExpr();
114114
Result OnRethrow();
115115
Result OnReturn();
116116
Result OnSelect(Type expected);

src/validator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ Result Validator::OnRefNullExpr(RefNullExpr* expr) {
438438
}
439439

440440
Result Validator::OnRefIsNullExpr(RefIsNullExpr* expr) {
441-
result_ |= validator_.OnRefIsNull(expr->loc, expr->type);
441+
result_ |= validator_.OnRefIsNull(expr->loc);
442442
return Result::Ok;
443443
}
444444

src/wast-parser.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,13 +1996,10 @@ Result WastParser::ParsePlainInstr(std::unique_ptr<Expr>* out_expr) {
19961996
break;
19971997
}
19981998

1999-
case TokenType::RefIsNull: {
1999+
case TokenType::RefIsNull:
20002000
ErrorUnlessOpcodeEnabled(Consume());
2001-
Type type;
2002-
CHECK_RESULT(ParseRefKind(&type));
2003-
out_expr->reset(new RefIsNullExpr(type, loc));
2001+
out_expr->reset(new RefIsNullExpr(loc));
20042002
break;
2005-
}
20062003

20072004
case TokenType::Throw:
20082005
ErrorUnlessOpcodeEnabled(Consume());

src/wat-writer.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ Result WatWriter::ExprVisitorDelegate::OnRefNullExpr(RefNullExpr* expr) {
824824

825825
Result WatWriter::ExprVisitorDelegate::OnRefIsNullExpr(RefIsNullExpr* expr) {
826826
writer_->WritePutsSpace(Opcode::RefIsNull_Opcode.GetName());
827-
writer_->WriteRefKind(expr->type, NextChar::Newline);
828827
return Result::Ok;
829828
}
830829

test/decompile/basic.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
set_local 0
9797
nop
9898
ref.null func
99-
ref.is_null func
99+
ref.is_null
100100
drop
101101
i32.const 0 ;; fi
102102
call_indirect

test/dump/reference-types.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
(func (param externref) (result i32)
4444
local.get 0
45-
ref.is_null extern
45+
ref.is_null
4646
)
4747

4848

@@ -94,7 +94,7 @@ Code[10]:
9494
- func[3] size=8
9595
- func[4] size=9
9696
- func[5] size=9
97-
- func[6] size=6
97+
- func[6] size=5
9898
- func[7] size=5
9999
- func[8] size=5
100100
- func[9] size=5
@@ -131,15 +131,15 @@ Code Disassembly:
131131
00007c: 0b | end
132132
00007e func[6]:
133133
00007f: 20 00 | local.get 0
134-
000081: d1 6f | ref.is_null extern
135-
000083: 0b | end
136-
000085 func[7]:
137-
000086: fc 10 00 | table.size 0
138-
000089: 0b | end
139-
00008b func[8]:
140-
00008c: fc 10 01 | table.size 1
141-
00008f: 0b | end
142-
000091 func[9]:
143-
000092: fc 10 02 | table.size 2
144-
000095: 0b | end
134+
000081: d1 | ref.is_null
135+
000082: 0b | end
136+
000084 func[7]:
137+
000085: fc 10 00 | table.size 0
138+
000088: 0b | end
139+
00008a func[8]:
140+
00008b: fc 10 01 | table.size 1
141+
00008e: 0b | end
142+
000090 func[9]:
143+
000091: fc 10 02 | table.size 2
144+
000094: 0b | end
145145
;;; STDOUT ;;)

test/interp/reference-types.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
(func $ref_is_null_func (export "ref_is_null_func") (result i32)
2020
global.get $g
21-
ref.is_null func
21+
ref.is_null
2222
)
2323

2424
(func $ref_func (export "ref_func") (result funcref)
@@ -35,7 +35,7 @@
3535
call $table_set
3636
i32.const 0
3737
table.get $t_func
38-
ref.is_null func
38+
ref.is_null
3939
)
4040

4141
(func $global_set (export "global_set") (result funcref)

test/parse/expr/reference-types.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
(func (param externref) (result i32)
4242
local.get 0
43-
ref.is_null extern
43+
ref.is_null
4444
)
4545

4646
(func (result funcref)

0 commit comments

Comments
 (0)