summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-09-09 03:40:09 +0200
committerGitHub <noreply@github.com>2020-09-09 03:40:09 +0200
commit916ce6f1a9f7c85102a8c69f593b301c8df5d19d (patch)
tree93b22be9f2c0718248528d140b05221cb6878600 /src/tools
parent0fdcf5b51a0c8c379b2d3ad8262aa22bb234f0e9 (diff)
downloadbinaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.tar.gz
binaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.tar.bz2
binaryen-916ce6f1a9f7c85102a8c69f593b301c8df5d19d.zip
Update reference types (#3084)
Align with the current state of the reference types proposal: * Remove `nullref` * Remove `externref` and `funcref` subtyping * A `Literal` of a nullable reference type can now represent `null` (previously was type `nullref`) * Update the tests and temporarily comment out those tests relying on subtyping
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/execution-results.h2
-rw-r--r--src/tools/fuzzing.h45
-rw-r--r--src/tools/spec-wrapper.h7
-rw-r--r--src/tools/wasm-reduce.cpp9
4 files changed, 16 insertions, 47 deletions
diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h
index 38989aedf..c41b0c208 100644
--- a/src/tools/execution-results.h
+++ b/src/tools/execution-results.h
@@ -74,7 +74,7 @@ struct ExecutionResults {
// while the function contents are still the same
for (Literal& val : ret) {
if (val.type == Type::funcref) {
- val = Literal::makeFuncref(Name("funcref"));
+ val = Literal::makeFunc(Name("funcref"));
}
}
results[exp->name] = ret;
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index b3c1212d4..ef7844c60 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -315,21 +315,7 @@ private:
}
SmallVector<Type, 2> options;
options.push_back(type); // includes itself
- TODO_SINGLE_COMPOUND(type);
- switch (type.getBasic()) {
- case Type::externref:
- if (wasm.features.hasExceptionHandling()) {
- options.push_back(Type::exnref);
- }
- options.push_back(Type::funcref);
- // falls through
- case Type::funcref:
- case Type::exnref:
- options.push_back(Type::nullref);
- break;
- default:
- break;
- }
+ // TODO (GC): subtyping
return pick(options);
}
@@ -1362,7 +1348,6 @@ private:
}
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -1466,7 +1451,6 @@ private:
}
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -1595,7 +1579,6 @@ private:
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -1640,7 +1623,6 @@ private:
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -1708,7 +1690,6 @@ private:
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -1735,7 +1716,6 @@ private:
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -1763,7 +1743,7 @@ private:
}
return builder.makeRefFunc(target->name);
}
- return builder.makeRefNull();
+ return builder.makeRefNull(type);
}
if (type.isTuple()) {
std::vector<Expression*> operands;
@@ -1845,7 +1825,6 @@ private:
}
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
return makeTrivial(type);
case Type::none:
@@ -1990,7 +1969,6 @@ private:
}
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -2227,7 +2205,6 @@ private:
}
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -2434,7 +2411,6 @@ private:
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
case Type::none:
case Type::unreachable:
@@ -2610,14 +2586,13 @@ private:
Expression* makeRefIsNull(Type type) {
assert(type == Type::i32);
assert(wasm.features.hasReferenceTypes());
- Type refType;
+ SmallVector<Type, 2> options;
+ options.push_back(Type::externref);
+ options.push_back(Type::funcref);
if (wasm.features.hasExceptionHandling()) {
- refType =
- pick(Type::funcref, Type::externref, Type::nullref, Type::exnref);
- } else {
- refType = pick(Type::funcref, Type::externref, Type::nullref);
+ options.push_back(Type::exnref);
}
- return builder.makeRefIsNull(make(refType));
+ return builder.makeRefIsNull(make(pick(options)));
}
Expression* makeMemoryInit() {
@@ -2680,10 +2655,7 @@ private:
FeatureOptions<Type>()
.add(FeatureSet::MVP, Type::i32, Type::i64, Type::f32, Type::f64)
.add(FeatureSet::SIMD, Type::v128)
- .add(FeatureSet::ReferenceTypes,
- Type::funcref,
- Type::externref,
- Type::nullref)
+ .add(FeatureSet::ReferenceTypes, Type::funcref, Type::externref)
.add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling,
Type::exnref));
}
@@ -2732,7 +2704,6 @@ private:
FeatureOptions<Type>()
.add(FeatureSet::MVP, Type::i32, Type::i64, Type::f32, Type::f64)
.add(FeatureSet::SIMD, Type::v128)
- .add(FeatureSet::ReferenceTypes, Type::nullref)
.add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling,
Type::exnref));
}
diff --git a/src/tools/spec-wrapper.h b/src/tools/spec-wrapper.h
index 44f92b56d..c073a994c 100644
--- a/src/tools/spec-wrapper.h
+++ b/src/tools/spec-wrapper.h
@@ -50,10 +50,13 @@ static std::string generateSpecWrapper(Module& wasm) {
ret += "(v128.const i32x4 0 0 0 0)";
break;
case Type::funcref:
+ ret += "(ref.null func)";
+ break;
case Type::externref:
- case Type::nullref:
+ ret += "(ref.null extern)";
+ break;
case Type::exnref:
- ret += "(ref.null)";
+ ret += "(ref.null exn)";
break;
case Type::none:
case Type::unreachable:
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp
index 9c9978b63..1a7c3544d 100644
--- a/src/tools/wasm-reduce.cpp
+++ b/src/tools/wasm-reduce.cpp
@@ -597,7 +597,6 @@ struct Reducer
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
continue; // not implemented yet
case Type::none:
@@ -623,7 +622,6 @@ struct Reducer
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
continue; // not implemented yet
case Type::none:
@@ -649,7 +647,6 @@ struct Reducer
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
continue; // not implemented yet
case Type::none:
@@ -675,7 +672,6 @@ struct Reducer
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
continue; // not implemented yet
case Type::none:
@@ -687,7 +683,6 @@ struct Reducer
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::nullref:
case Type::exnref:
continue; // not implemented yet
case Type::none:
@@ -1015,8 +1010,8 @@ struct Reducer
return false;
}
// try to replace with a trivial value
- if (curr->type.isRef()) {
- RefNull* n = builder->makeRefNull();
+ if (curr->type.isNullable()) {
+ RefNull* n = builder->makeRefNull(curr->type);
return tryToReplaceCurrent(n);
}
if (curr->type.isTuple()) {