Skip to content

Commit 1cd89d5

Browse files
committed
Implement changes in reference types proposal
This updates reference types proposal up-to-date, per WebAssembly/reference-types#87. Only maybe half of tests have been updated, so CI will not pass. I was in the process of updating them fully, but then I noticed WebAssembly#3084, so I'm not sure if I should continue to do this anymore. I asked him if he wanted to do it himself to prevent this situation but apparently my questions weren't answered and I didn't know that he was working on this at the same time. I'm uploading this anyway in case this is necessary for discussions.
1 parent fecfa92 commit 1cd89d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+219
-427
lines changed

check.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,7 @@ def check_expected(actual, expected):
240240
# some wast files cannot be split:
241241
# * comments.wast: contains characters that are not valid utf-8,
242242
# so our string splitting code fails there
243-
244-
# FIXME Remove reference type tests from this list after nullref is
245-
# implemented in V8
246-
if base not in ['comments.wast', 'ref_null.wast', 'ref_is_null.wast', 'ref_func.wast', 'old_select.wast']:
243+
if base not in ['comments.wast', 'old_select.wast']:
247244
split_num = 0
248245
actual = ''
249246
for module, asserts in support.split_wast(wast):

scripts/gen-s-parser.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
("v128.pop", "makePop(Type::v128)"),
5151
("funcref.pop", "makePop(Type::funcref)"),
5252
("externref.pop", "makePop(Type::externref)"),
53-
("nullref.pop", "makePop(Type::nullref)"),
5453
("exnref.pop", "makePop(Type::exnref)"),
5554
("i32.load", "makeLoad(s, Type::i32, /*isAtomic=*/false)"),
5655
("i64.load", "makeLoad(s, Type::i64, /*isAtomic=*/false)"),

scripts/test/wasm_opt.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ def check():
113113

114114
shared.fail_if_not_identical_to_file(actual, f)
115115

116-
# FIXME Remove this condition after nullref is implemented in V8
117-
if 'reference-types.wast' not in t:
118-
shared.binary_format_check(t, wasm_as_args=['-g']) # test with debuginfo
119-
shared.binary_format_check(t, wasm_as_args=[], binary_suffix='.fromBinary.noDebugInfo') # test without debuginfo
116+
shared.binary_format_check(t, wasm_as_args=['-g']) # test with debuginfo
117+
shared.binary_format_check(t, wasm_as_args=[], binary_suffix='.fromBinary.noDebugInfo') # test without debuginfo
120118

121119
shared.minify_check(t)
122120

src/asmjs/asm_v_wasm.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ AsmType wasmToAsmType(Type type) {
5656
assert(false && "v128 not implemented yet");
5757
case Type::funcref:
5858
case Type::externref:
59-
case Type::nullref:
6059
case Type::exnref:
6160
assert(false && "reference types are not supported by asm2wasm");
6261
case Type::none:
@@ -84,8 +83,6 @@ char getSig(Type type) {
8483
return 'F';
8584
case Type::externref:
8685
return 'X';
87-
case Type::nullref:
88-
return 'N';
8986
case Type::exnref:
9087
return 'E';
9188
case Type::none:

src/binaryen-c.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ BinaryenLiteral toBinaryenLiteral(Literal x) {
7171
case Type::funcref:
7272
ret.func = x.getFunc().c_str();
7373
break;
74-
case Type::nullref:
75-
break;
7674
case Type::externref:
7775
case Type::exnref:
7876
case Type::none:
@@ -96,8 +94,6 @@ Literal fromBinaryenLiteral(BinaryenLiteral x) {
9694
return Literal(x.v128);
9795
case Type::funcref:
9896
return Literal::makeFuncref(x.func);
99-
case Type::nullref:
100-
return Literal::makeNullref();
10197
case Type::externref:
10298
case Type::exnref:
10399
case Type::none:
@@ -133,7 +129,6 @@ BinaryenType BinaryenTypeFloat64(void) { return Type::f64; }
133129
BinaryenType BinaryenTypeVec128(void) { return Type::v128; }
134130
BinaryenType BinaryenTypeFuncref(void) { return Type::funcref; }
135131
BinaryenType BinaryenTypeExternref(void) { return Type::externref; }
136-
BinaryenType BinaryenTypeNullref(void) { return Type::nullref; }
137132
BinaryenType BinaryenTypeExnref(void) { return Type::exnref; }
138133
BinaryenType BinaryenTypeUnreachable(void) { return Type::unreachable; }
139134
BinaryenType BinaryenTypeAuto(void) { return uintptr_t(-1); }
@@ -1264,8 +1259,10 @@ BinaryenExpressionRef BinaryenPop(BinaryenModuleRef module, BinaryenType type) {
12641259
Builder(*(Module*)module).makePop(Type(type)));
12651260
}
12661261

1267-
BinaryenExpressionRef BinaryenRefNull(BinaryenModuleRef module) {
1268-
return static_cast<Expression*>(Builder(*(Module*)module).makeRefNull());
1262+
BinaryenExpressionRef BinaryenRefNull(BinaryenModuleRef module,
1263+
BinaryenType type) {
1264+
return static_cast<Expression*>(
1265+
Builder(*(Module*)module).makeRefNull(Type(type)));
12691266
}
12701267

12711268
BinaryenExpressionRef BinaryenRefIsNull(BinaryenModuleRef module,

src/binaryen-c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ BINARYEN_API BinaryenType BinaryenTypeFloat64(void);
100100
BINARYEN_API BinaryenType BinaryenTypeVec128(void);
101101
BINARYEN_API BinaryenType BinaryenTypeFuncref(void);
102102
BINARYEN_API BinaryenType BinaryenTypeExternref(void);
103-
BINARYEN_API BinaryenType BinaryenTypeNullref(void);
104103
BINARYEN_API BinaryenType BinaryenTypeExnref(void);
105104
BINARYEN_API BinaryenType BinaryenTypeUnreachable(void);
106105
// Not a real type. Used as the last parameter to BinaryenBlock to let
@@ -826,7 +825,8 @@ BinaryenMemoryFill(BinaryenModuleRef module,
826825
BinaryenExpressionRef dest,
827826
BinaryenExpressionRef value,
828827
BinaryenExpressionRef size);
829-
BINARYEN_API BinaryenExpressionRef BinaryenRefNull(BinaryenModuleRef module);
828+
BINARYEN_API BinaryenExpressionRef BinaryenRefNull(BinaryenModuleRef module,
829+
BinaryenType type);
830830
BINARYEN_API BinaryenExpressionRef
831831
BinaryenRefIsNull(BinaryenModuleRef module, BinaryenExpressionRef value);
832832
BINARYEN_API BinaryenExpressionRef BinaryenRefFunc(BinaryenModuleRef module,

src/gen-s-parser.inc

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,17 +2560,9 @@ switch (op[0]) {
25602560
default: goto parse_error;
25612561
}
25622562
}
2563-
case 'n': {
2564-
switch (op[1]) {
2565-
case 'o':
2566-
if (strcmp(op, "nop") == 0) { return makeNop(); }
2567-
goto parse_error;
2568-
case 'u':
2569-
if (strcmp(op, "nullref.pop") == 0) { return makePop(Type::nullref); }
2570-
goto parse_error;
2571-
default: goto parse_error;
2572-
}
2573-
}
2563+
case 'n':
2564+
if (strcmp(op, "nop") == 0) { return makeNop(); }
2565+
goto parse_error;
25742566
case 'r': {
25752567
switch (op[2]) {
25762568
case 'f': {

src/ir/ExpressionManipulator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) {
227227
builder.makeHost(curr->op, curr->nameOperand, std::move(operands));
228228
return ret;
229229
}
230-
Expression* visitRefNull(RefNull* curr) { return builder.makeRefNull(); }
230+
Expression* visitRefNull(RefNull* curr) {
231+
return builder.makeRefNull(curr->type);
232+
}
231233
Expression* visitRefIsNull(RefIsNull* curr) {
232234
return builder.makeRefIsNull(copy(curr->value));
233235
}

src/ir/abstract.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ inline UnaryOp getUnary(Type type, Op op) {
103103
}
104104
case Type::funcref:
105105
case Type::externref:
106-
case Type::nullref:
107106
case Type::exnref:
108107
case Type::none:
109108
case Type::unreachable: {
@@ -268,7 +267,6 @@ inline BinaryOp getBinary(Type type, Op op) {
268267
}
269268
case Type::funcref:
270269
case Type::externref:
271-
case Type::nullref:
272270
case Type::exnref:
273271
case Type::none:
274272
case Type::unreachable: {

src/ir/properties.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ inline Literal getSingleLiteral(const Expression* curr) {
9494
if (auto* c = curr->dynCast<Const>()) {
9595
return c->value;
9696
} else if (curr->is<RefNull>()) {
97-
return Literal(Type::nullref);
97+
return Literal::makeNull(curr->type);
9898
} else if (auto* c = curr->dynCast<RefFunc>()) {
9999
return Literal(c->func);
100100
} else {

0 commit comments

Comments
 (0)