diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-09-09 03:40:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 03:40:09 +0200 |
commit | 916ce6f1a9f7c85102a8c69f593b301c8df5d19d (patch) | |
tree | 93b22be9f2c0718248528d140b05221cb6878600 /src/ir | |
parent | 0fdcf5b51a0c8c379b2d3ad8262aa22bb234f0e9 (diff) | |
download | binaryen-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/ir')
-rw-r--r-- | src/ir/ExpressionManipulator.cpp | 4 | ||||
-rw-r--r-- | src/ir/abstract.h | 2 | ||||
-rw-r--r-- | src/ir/manipulation.h | 5 | ||||
-rw-r--r-- | src/ir/properties.h | 8 |
4 files changed, 10 insertions, 9 deletions
diff --git a/src/ir/ExpressionManipulator.cpp b/src/ir/ExpressionManipulator.cpp index 57048b9bd..6f64ec77b 100644 --- a/src/ir/ExpressionManipulator.cpp +++ b/src/ir/ExpressionManipulator.cpp @@ -227,7 +227,9 @@ flexibleCopy(Expression* original, Module& wasm, CustomCopier custom) { builder.makeHost(curr->op, curr->nameOperand, std::move(operands)); return ret; } - Expression* visitRefNull(RefNull* curr) { return builder.makeRefNull(); } + Expression* visitRefNull(RefNull* curr) { + return builder.makeRefNull(curr->type); + } Expression* visitRefIsNull(RefIsNull* curr) { return builder.makeRefIsNull(copy(curr->value)); } diff --git a/src/ir/abstract.h b/src/ir/abstract.h index f706e9972..b00537bf5 100644 --- a/src/ir/abstract.h +++ b/src/ir/abstract.h @@ -103,7 +103,6 @@ inline UnaryOp getUnary(Type type, Op op) { } case Type::funcref: case Type::externref: - case Type::nullref: case Type::exnref: case Type::none: case Type::unreachable: { @@ -268,7 +267,6 @@ inline BinaryOp getBinary(Type type, Op op) { } case Type::funcref: case Type::externref: - case Type::nullref: case Type::exnref: case Type::none: case Type::unreachable: { diff --git a/src/ir/manipulation.h b/src/ir/manipulation.h index 49ed7e11e..fb1f0181e 100644 --- a/src/ir/manipulation.h +++ b/src/ir/manipulation.h @@ -40,9 +40,10 @@ template<typename InputType> inline Nop* nop(InputType* target) { return ret; } -template<typename InputType> inline RefNull* refNull(InputType* target) { +template<typename InputType> +inline RefNull* refNull(InputType* target, Type type) { auto* ret = convert<InputType, RefNull>(target); - ret->finalize(); + ret->finalize(type); return ret; } diff --git a/src/ir/properties.h b/src/ir/properties.h index 0c6824e4a..ac61f787e 100644 --- a/src/ir/properties.h +++ b/src/ir/properties.h @@ -93,10 +93,10 @@ inline bool isConstantExpression(const Expression* curr) { inline Literal getSingleLiteral(const Expression* curr) { if (auto* c = curr->dynCast<Const>()) { return c->value; - } else if (curr->is<RefNull>()) { - return Literal(Type::nullref); - } else if (auto* c = curr->dynCast<RefFunc>()) { - return Literal(c->func); + } else if (auto* n = curr->dynCast<RefNull>()) { + return Literal(n->type); + } else if (auto* r = curr->dynCast<RefFunc>()) { + return Literal(r->func); } else { WASM_UNREACHABLE("non-constant expression"); } |