summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/literal.cpp50
-rw-r--r--src/wasm/wasm-binary.cpp33
-rw-r--r--src/wasm/wasm-s-parser.cpp33
-rw-r--r--src/wasm/wasm-stack.cpp8
-rw-r--r--src/wasm/wasm-type.cpp20
-rw-r--r--src/wasm/wasm-validator.cpp37
-rw-r--r--src/wasm/wasm.cpp10
7 files changed, 5 insertions, 186 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index e22088d9c..6d870ec55 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -35,9 +35,7 @@ Literal::Literal(Type type) : type(type) {
i32 = 0;
} else {
assert(type != Type::unreachable && (!type.isRef() || type.isNullable()));
- if (type.isException()) {
- new (&exn) std::unique_ptr<ExceptionPackage>();
- } else if (isGCData()) {
+ if (isGCData()) {
new (&gcData) std::shared_ptr<GCData>();
} else if (type.isRtt()) {
// Allocate a new RttSupers (with no data).
@@ -66,15 +64,6 @@ Literal::Literal(std::unique_ptr<RttSupers>&& rttSupers, Type type)
}
Literal::Literal(const Literal& other) : type(other.type) {
- if (type.isException()) {
- // Avoid calling the destructor on an uninitialized value
- if (other.exn != nullptr) {
- new (&exn) auto(std::make_unique<ExceptionPackage>(*other.exn));
- } else {
- new (&exn) std::unique_ptr<ExceptionPackage>();
- }
- return;
- }
if (other.isGCData()) {
new (&gcData) std::shared_ptr<GCData>(other.gcData);
return;
@@ -101,7 +90,6 @@ Literal::Literal(const Literal& other) : type(other.type) {
return;
case HeapType::func:
case HeapType::data:
- case HeapType::exn:
WASM_UNREACHABLE("invalid type");
}
}
@@ -124,7 +112,6 @@ Literal::Literal(const Literal& other) : type(other.type) {
case Type::unreachable:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -134,9 +121,7 @@ Literal::Literal(const Literal& other) : type(other.type) {
}
Literal::~Literal() {
- if (type.isException()) {
- exn.~unique_ptr();
- } else if (isGCData()) {
+ if (isGCData()) {
gcData.~shared_ptr();
} else if (type.isRtt()) {
rttSupers.~unique_ptr();
@@ -255,11 +240,6 @@ std::array<uint8_t, 16> Literal::getv128() const {
return ret;
}
-ExceptionPackage Literal::getExceptionPackage() const {
- assert(type.isException() && exn != nullptr);
- return *exn;
-}
-
std::shared_ptr<GCData> Literal::getGCData() const {
assert(isGCData());
return gcData;
@@ -349,7 +329,6 @@ void Literal::getBits(uint8_t (&buf)[16]) const {
case Type::unreachable:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -371,10 +350,6 @@ bool Literal::operator==(const Literal& other) const {
assert(func.is() && other.func.is());
return func == other.func;
}
- if (type.isException()) {
- assert(exn != nullptr && other.exn != nullptr);
- return *exn == *other.exn;
- }
// other non-null reference type literals cannot represent concrete values,
// i.e. there is no concrete externref, anyref or eqref other than null.
WASM_UNREACHABLE("unexpected type");
@@ -394,7 +369,6 @@ bool Literal::operator==(const Literal& other) const {
return memcmp(v128, other.v128, 16) == 0;
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::dataref:
case Type::eqref:
@@ -525,13 +499,6 @@ std::ostream& operator<<(std::ostream& o, Literal literal) {
assert(literal.isNull() && "unexpected non-null externref literal");
o << "externref(null)";
break;
- case HeapType::exn:
- if (literal.isNull()) {
- o << "exnref(null)";
- } else {
- o << "exnref(" << literal.getExceptionPackage() << ")";
- }
- break;
case HeapType::any:
assert(literal.isNull() && "unexpected non-null anyref literal");
o << "anyref(null)";
@@ -578,7 +545,6 @@ std::ostream& operator<<(std::ostream& o, Literal literal) {
break;
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -606,10 +572,6 @@ std::ostream& operator<<(std::ostream& o, wasm::Literals literals) {
}
}
-std::ostream& operator<<(std::ostream& o, const ExceptionPackage& exn) {
- return o << exn.event << " " << exn.values;
-}
-
Literal Literal::countLeadingZeroes() const {
if (type == Type::i32) {
return Literal((int32_t)Bits::countLeadingZeroes(i32));
@@ -807,7 +769,6 @@ Literal Literal::eqz() const {
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -832,7 +793,6 @@ Literal Literal::neg() const {
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -857,7 +817,6 @@ Literal Literal::abs() const {
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -999,7 +958,6 @@ Literal Literal::add(const Literal& other) const {
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -1024,7 +982,6 @@ Literal Literal::sub(const Literal& other) const {
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -1120,7 +1077,6 @@ Literal Literal::mul(const Literal& other) const {
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -1357,7 +1313,6 @@ Literal Literal::eq(const Literal& other) const {
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -1382,7 +1337,6 @@ Literal Literal::ne(const Literal& other) const {
case Type::v128:
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 62c8a6cb3..a61d47102 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -1045,9 +1045,6 @@ void WasmBinaryWriter::writeType(Type type) {
case Type::externref:
ret = BinaryConsts::EncodedType::externref;
break;
- case Type::exnref:
- ret = BinaryConsts::EncodedType::exnref;
- break;
case Type::anyref:
ret = BinaryConsts::EncodedType::anyref;
break;
@@ -1080,9 +1077,6 @@ void WasmBinaryWriter::writeHeapType(HeapType type) {
case HeapType::ext:
ret = BinaryConsts::EncodedHeapType::extern_;
break;
- case HeapType::exn:
- ret = BinaryConsts::EncodedHeapType::exn;
- break;
case HeapType::any:
ret = BinaryConsts::EncodedHeapType::any;
break;
@@ -1410,8 +1404,6 @@ Type WasmBinaryBuilder::getType(int initial) {
return Type::funcref;
case BinaryConsts::EncodedType::externref:
return Type::externref;
- case BinaryConsts::EncodedType::exnref:
- return Type::exnref;
case BinaryConsts::EncodedType::anyref:
return Type::anyref;
case BinaryConsts::EncodedType::eqref:
@@ -1457,8 +1449,6 @@ HeapType WasmBinaryBuilder::getHeapType() {
return HeapType::func;
case BinaryConsts::EncodedHeapType::extern_:
return HeapType::ext;
- case BinaryConsts::EncodedHeapType::exn:
- return HeapType::exn;
case BinaryConsts::EncodedHeapType::any:
return HeapType::any;
case BinaryConsts::EncodedHeapType::eq:
@@ -2874,9 +2864,6 @@ BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) {
case BinaryConsts::Rethrow:
visitRethrow((curr = allocator.alloc<Rethrow>())->cast<Rethrow>());
break;
- case BinaryConsts::BrOnExn:
- visitBrOnExn((curr = allocator.alloc<BrOnExn>())->cast<BrOnExn>());
- break;
case BinaryConsts::MemorySize: {
auto size = allocator.alloc<MemorySize>();
if (wasm.memory.is64()) {
@@ -5699,26 +5686,6 @@ void WasmBinaryBuilder::visitRethrow(Rethrow* curr) {
curr->finalize();
}
-void WasmBinaryBuilder::visitBrOnExn(BrOnExn* curr) {
- BYN_TRACE("zz node: BrOnExn\n");
- BreakTarget target = getBreakTarget(getU32LEB());
- curr->name = target.name;
- auto index = getU32LEB();
- if (index >= wasm.events.size()) {
- throwError("bad event index");
- }
- curr->event = wasm.events[index]->name;
- curr->exnref = popNonVoidExpression();
-
- Event* event = wasm.getEventOrNull(curr->event);
- assert(event && "br_on_exn's event must exist");
-
- // Copy params info into BrOnExn, because it is necessary when BrOnExn is
- // refinalized without the module.
- curr->sent = event->sig.params;
- curr->finalize();
-}
-
void WasmBinaryBuilder::visitCallRef(CallRef* curr) {
BYN_TRACE("zz node: CallRef\n");
curr->target = popNonVoidExpression();
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 0356db235..d34698131 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -858,9 +858,6 @@ Type SExpressionWasmBuilder::stringToType(const char* str,
if (strncmp(str, "externref", 9) == 0 && (prefix || str[9] == 0)) {
return Type::externref;
}
- if (strncmp(str, "exnref", 6) == 0 && (prefix || str[6] == 0)) {
- return Type::exnref;
- }
if (strncmp(str, "anyref", 6) == 0 && (prefix || str[6] == 0)) {
return Type::anyref;
}
@@ -892,14 +889,9 @@ HeapType SExpressionWasmBuilder::stringToHeapType(const char* str,
if (str[1] == 'q' && (prefix || str[2] == 0)) {
return HeapType::eq;
}
- if (str[1] == 'x') {
- if (str[2] == 'n' && (prefix || str[3] == 0)) {
- return HeapType::exn;
- }
- if (str[2] == 't' && str[3] == 'e' && str[4] == 'r' && str[5] == 'n' &&
- (prefix || str[6] == 0)) {
- return HeapType::ext;
- }
+ if (str[1] == 'x' && str[2] == 't' && str[3] == 'e' && str[4] == 'r' &&
+ str[5] == 'n' && (prefix || str[6] == 0)) {
+ return HeapType::ext;
}
}
if (str[0] == 'i') {
@@ -2073,25 +2065,6 @@ Expression* SExpressionWasmBuilder::makeRethrow(Element& s) {
return ret;
}
-Expression* SExpressionWasmBuilder::makeBrOnExn(Element& s) {
- auto ret = allocator.alloc<BrOnExn>();
- size_t i = 1;
- ret->name = getLabel(*s[i++]);
- ret->event = getEventName(*s[i++]);
- if (!wasm.getEventOrNull(ret->event)) {
- throw ParseException("bad event name", s[1]->line, s[1]->col);
- }
- ret->exnref = parseExpression(s[i]);
-
- Event* event = wasm.getEventOrNull(ret->event);
- assert(event && "br_on_exn's event must exist");
- // Copy params info into BrOnExn, because it is necessary when BrOnExn is
- // refinalized without the module.
- ret->sent = event->sig.params;
- ret->finalize();
- return ret;
-}
-
Expression* SExpressionWasmBuilder::makeTupleMake(Element& s) {
auto ret = allocator.alloc<TupleMake>();
parseCallOperands(s, 1, s.size(), ret);
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 8fc6c02c6..81858d003 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -192,7 +192,6 @@ void BinaryInstWriter::visitLoad(Load* curr) {
return;
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
@@ -297,7 +296,6 @@ void BinaryInstWriter::visitStore(Store* curr) {
break;
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
@@ -762,7 +760,6 @@ void BinaryInstWriter::visitConst(Const* curr) {
}
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
@@ -1914,11 +1911,6 @@ void BinaryInstWriter::visitRethrow(Rethrow* curr) {
o << int8_t(BinaryConsts::Rethrow) << U32LEB(curr->depth);
}
-void BinaryInstWriter::visitBrOnExn(BrOnExn* curr) {
- o << int8_t(BinaryConsts::BrOnExn) << U32LEB(getBreakIndex(curr->name))
- << U32LEB(parent.getEventIndex(curr->event));
-}
-
void BinaryInstWriter::visitNop(Nop* curr) { o << int8_t(BinaryConsts::Nop); }
void BinaryInstWriter::visitUnreachable(Unreachable* curr) {
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index 862a95223..fc8f84f6f 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -302,8 +302,6 @@ struct TypeStore : Store<TypeInfo> {
return Type::funcref;
case HeapType::ext:
return Type::externref;
- case HeapType::exn:
- return Type::exnref;
case HeapType::any:
return Type::anyref;
case HeapType::eq:
@@ -386,15 +384,6 @@ bool Type::isFunction() const {
}
}
-bool Type::isException() const {
- if (isBasic()) {
- return id == exnref;
- } else {
- auto* info = getTypeInfo(*this);
- return info->isRef() && info->ref.heapType == HeapType::exn;
- }
-}
-
bool Type::isNullable() const {
if (isBasic()) {
return id >= funcref && id <= eqref; // except i31ref
@@ -452,7 +441,6 @@ unsigned Type::getByteSize() const {
return 16;
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -501,8 +489,6 @@ FeatureSet Type::getFeatures() const {
}
if (heapType.isBasic()) {
switch (heapType.getBasic()) {
- case HeapType::BasicHeapType::exn:
- return FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling;
case HeapType::BasicHeapType::any:
case HeapType::BasicHeapType::eq:
case HeapType::BasicHeapType::data:
@@ -554,8 +540,6 @@ HeapType Type::getHeapType() const {
return HeapType::func;
case Type::externref:
return HeapType::ext;
- case Type::exnref:
- return HeapType::exn;
case Type::anyref:
return HeapType::any;
case Type::eqref:
@@ -894,8 +878,6 @@ std::ostream& operator<<(std::ostream& os, Type type) {
return os << "funcref";
case Type::externref:
return os << "externref";
- case Type::exnref:
- return os << "exnref";
case Type::anyref:
return os << "anyref";
case Type::eqref:
@@ -988,8 +970,6 @@ std::ostream& operator<<(std::ostream& os, HeapType heapType) {
return os << "func";
case HeapType::ext:
return os << "extern";
- case HeapType::exn:
- return os << "exn";
case HeapType::any:
return os << "any";
case HeapType::eq:
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index cc8a2bb56..e4a70a347 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -337,7 +337,6 @@ public:
void visitTry(Try* curr);
void visitThrow(Throw* curr);
void visitRethrow(Rethrow* curr);
- void visitBrOnExn(BrOnExn* curr);
void visitTupleMake(TupleMake* curr);
void visitTupleExtract(TupleExtract* curr);
void visitCallRef(CallRef* curr);
@@ -1395,7 +1394,6 @@ void FunctionValidator::validateMemBytes(uint8_t bytes,
break;
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -2102,34 +2100,6 @@ void FunctionValidator::visitRethrow(Rethrow* curr) {
// depth 0 for C++ support.
}
-void FunctionValidator::visitBrOnExn(BrOnExn* curr) {
- shouldBeTrue(getModule()->features.hasExceptionHandling(),
- curr,
- "br_on_exn requires exception-handling to be enabled");
- Event* event = getModule()->getEventOrNull(curr->event);
- shouldBeTrue(event != nullptr, curr, "br_on_exn's event must exist");
- shouldBeTrue(event->sig.params == curr->sent,
- curr,
- "br_on_exn's event params and event's params are different");
- noteBreak(curr->name, curr->sent, curr);
- shouldBeSubTypeOrFirstIsUnreachable(
- curr->exnref->type,
- Type::exnref,
- curr,
- "br_on_exn's argument must be unreachable or exnref type or its subtype");
- if (curr->exnref->type == Type::unreachable) {
- shouldBeTrue(curr->type == Type::unreachable,
- curr,
- "If exnref argument's type is unreachable, br_on_exn should "
- "be unreachable too");
- } else {
- shouldBeTrue(curr->type == Type::exnref,
- curr,
- "br_on_exn's type should be exnref unless its exnref argument "
- "is unreachable");
- }
-}
-
void FunctionValidator::visitTupleMake(TupleMake* curr) {
shouldBeTrue(getModule()->features.hasMultivalue(),
curr,
@@ -2542,7 +2512,6 @@ void FunctionValidator::validateAlignment(
break;
case Type::funcref:
case Type::externref:
- case Type::exnref:
case Type::anyref:
case Type::eqref:
case Type::dataref:
@@ -2859,12 +2828,6 @@ static void validateFeatures(Module& module, ValidationInfo& info) {
module.features,
"--enable-gc requires --enable-reference-types");
}
- if (module.features.hasExceptionHandling()) { // implies exnref
- info.shouldBeTrue(
- module.features.hasReferenceTypes(),
- module.features,
- "--enable-exception-handling requires --enable-reference-types");
- }
}
// TODO: If we want the validator to be part of libwasm rather than libpasses,
diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp
index 52d2af0c6..13085ca17 100644
--- a/src/wasm/wasm.cpp
+++ b/src/wasm/wasm.cpp
@@ -200,8 +200,6 @@ const char* getExpressionName(Expression* curr) {
return "throw";
case Expression::Id::RethrowId:
return "rethrow";
- case Expression::Id::BrOnExnId:
- return "br_on_exn";
case Expression::Id::TupleMakeId:
return "tuple.make";
case Expression::Id::TupleExtractId:
@@ -976,14 +974,6 @@ void Throw::finalize() { type = Type::unreachable; }
void Rethrow::finalize() { type = Type::unreachable; }
-void BrOnExn::finalize() {
- if (exnref->type == Type::unreachable) {
- type = Type::unreachable;
- } else {
- type = Type::exnref;
- }
-}
-
void TupleMake::finalize() {
std::vector<Type> types;
for (auto* op : operands) {