diff options
Diffstat (limited to 'src')
46 files changed, 14 insertions, 557 deletions
diff --git a/src/asmjs/asm_v_wasm.cpp b/src/asmjs/asm_v_wasm.cpp index b07ef8534..f5e4b7815 100644 --- a/src/asmjs/asm_v_wasm.cpp +++ b/src/asmjs/asm_v_wasm.cpp @@ -34,7 +34,6 @@ AsmType wasmToAsmType(Type type) { assert(false && "v128 not implemented yet"); case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -65,8 +64,6 @@ char getSig(Type type) { return 'F'; case Type::externref: return 'X'; - case Type::exnref: - return 'E'; case Type::anyref: return 'A'; case Type::eqref: diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 64813436e..93c8693c6 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -71,7 +71,6 @@ BinaryenLiteral toBinaryenLiteral(Literal x) { ret.func = x.isNull() ? nullptr : x.getFunc().c_str(); break; case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: assert(x.isNull() && "unexpected non-null reference type literal"); @@ -102,7 +101,6 @@ Literal fromBinaryenLiteral(BinaryenLiteral x) { case Type::funcref: return Literal::makeFunc(x.func); case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: return Literal::makeNull(Type(x.type)); @@ -143,7 +141,6 @@ BinaryenType BinaryenTypeFloat64(void) { return Type::f64; } BinaryenType BinaryenTypeVec128(void) { return Type::v128; } BinaryenType BinaryenTypeFuncref(void) { return Type::funcref; } BinaryenType BinaryenTypeExternref(void) { return Type::externref; } -BinaryenType BinaryenTypeExnref(void) { return Type::exnref; } BinaryenType BinaryenTypeAnyref(void) { return Type::anyref; } BinaryenType BinaryenTypeEqref(void) { return Type::eqref; } BinaryenType BinaryenTypeI31ref(void) { return Type::i31ref; } @@ -1237,17 +1234,6 @@ BinaryenExpressionRef BinaryenRethrow(BinaryenModuleRef module, return static_cast<Expression*>(Builder(*(Module*)module).makeRethrow(depth)); } -BinaryenExpressionRef BinaryenBrOnExn(BinaryenModuleRef module, - const char* name, - const char* eventName, - BinaryenExpressionRef exnref) { - auto* wasm = (Module*)module; - auto* event = wasm->getEventOrNull(eventName); - assert(event && "br_on_exn's event must exist"); - return static_cast<Expression*>( - Builder(*wasm).makeBrOnExn(name, event, (Expression*)exnref)); -} - BinaryenExpressionRef BinaryenI31New(BinaryenModuleRef module, BinaryenExpressionRef value) { return static_cast<Expression*>( @@ -2932,40 +2918,6 @@ void BinaryenRethrowSetDepth(BinaryenExpressionRef expr, BinaryenIndex depth) { assert(expression->is<Rethrow>()); static_cast<Rethrow*>(expression)->depth = depth; } -// BrOnExn -const char* BinaryenBrOnExnGetEvent(BinaryenExpressionRef expr) { - auto* expression = (Expression*)expr; - assert(expression->is<BrOnExn>()); - return static_cast<BrOnExn*>(expression)->event.c_str(); -} -void BinaryenBrOnExnSetEvent(BinaryenExpressionRef expr, - const char* eventName) { - auto* expression = (Expression*)expr; - assert(expression->is<BrOnExn>()); - static_cast<BrOnExn*>(expression)->event = eventName; -} -const char* BinaryenBrOnExnGetName(BinaryenExpressionRef expr) { - auto* expression = (Expression*)expr; - assert(expression->is<BrOnExn>()); - return static_cast<BrOnExn*>(expression)->name.c_str(); -} -void BinaryenBrOnExnSetName(BinaryenExpressionRef expr, const char* name) { - auto* expression = (Expression*)expr; - assert(expression->is<BrOnExn>()); - static_cast<BrOnExn*>(expression)->name = name; -} -BinaryenExpressionRef BinaryenBrOnExnGetExnref(BinaryenExpressionRef expr) { - auto* expression = (Expression*)expr; - assert(expression->is<BrOnExn>()); - return static_cast<BrOnExn*>(expression)->exnref; -} -void BinaryenBrOnExnSetExnref(BinaryenExpressionRef expr, - BinaryenExpressionRef exnrefExpr) { - auto* expression = (Expression*)expr; - assert(expression->is<BrOnExn>()); - assert(exnrefExpr); - static_cast<BrOnExn*>(expression)->exnref = (Expression*)exnrefExpr; -} // TupleMake BinaryenIndex BinaryenTupleMakeGetNumOperands(BinaryenExpressionRef expr) { auto* expression = (Expression*)expr; diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 8d991343d..6337fadd8 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -100,7 +100,6 @@ BINARYEN_API BinaryenType BinaryenTypeFloat64(void); BINARYEN_API BinaryenType BinaryenTypeVec128(void); BINARYEN_API BinaryenType BinaryenTypeFuncref(void); BINARYEN_API BinaryenType BinaryenTypeExternref(void); -BINARYEN_API BinaryenType BinaryenTypeExnref(void); BINARYEN_API BinaryenType BinaryenTypeAnyref(void); BINARYEN_API BinaryenType BinaryenTypeEqref(void); BINARYEN_API BinaryenType BinaryenTypeI31ref(void); @@ -192,7 +191,6 @@ struct BinaryenLiteral { double f64; uint8_t v128[16]; const char* func; - // TODO: exn }; }; @@ -811,11 +809,6 @@ BinaryenThrow(BinaryenModuleRef module, BINARYEN_API BinaryenExpressionRef BinaryenRethrow(BinaryenModuleRef module, BinaryenIndex depth); BINARYEN_API BinaryenExpressionRef -BinaryenBrOnExn(BinaryenModuleRef module, - const char* name, - const char* eventName, - BinaryenExpressionRef exnref); -BINARYEN_API BinaryenExpressionRef BinaryenTupleMake(BinaryenModuleRef module, BinaryenExpressionRef* operands, BinaryenIndex numOperands); @@ -1812,25 +1805,6 @@ BINARYEN_API BinaryenIndex BinaryenRethrowGetDepth(BinaryenExpressionRef expr); BINARYEN_API void BinaryenRethrowSetDepth(BinaryenExpressionRef expr, BinaryenIndex depth); -// BrOnExn - -// Gets the name of the event triggering a `br_on_exn` expression. -BINARYEN_API const char* BinaryenBrOnExnGetEvent(BinaryenExpressionRef expr); -// Sets the name of the event triggering a `br_on_exn` expression. -BINARYEN_API void BinaryenBrOnExnSetEvent(BinaryenExpressionRef expr, - const char* eventName); -// Gets the name (target label) of a `br_on_exn` expression. -BINARYEN_API const char* BinaryenBrOnExnGetName(BinaryenExpressionRef expr); -// Sets the name (target label) of a `br_on_exn` expression. -BINARYEN_API void BinaryenBrOnExnSetName(BinaryenExpressionRef expr, - const char* name); -// Gets the expression reference expression of a `br_on_exn` expression. -BINARYEN_API BinaryenExpressionRef -BinaryenBrOnExnGetExnref(BinaryenExpressionRef expr); -// Sets the expression reference expression of a `br_on_exn` expression. -BINARYEN_API void BinaryenBrOnExnSetExnref(BinaryenExpressionRef expr, - BinaryenExpressionRef exnrefExpr); - // TupleMake // Gets the number of operands of a `tuple.make` expression. diff --git a/src/cfg/cfg-traversal.h b/src/cfg/cfg-traversal.h index 267fb9589..fe85f0b9f 100644 --- a/src/cfg/cfg-traversal.h +++ b/src/cfg/cfg-traversal.h @@ -317,14 +317,6 @@ struct CFGWalker : public ControlFlowWalker<SubType, VisitorType> { self->startUnreachableBlock(); } - static void doEndBrOnExn(SubType* self, Expression** currp) { - auto* curr = (*currp)->cast<BrOnExn>(); - self->branches[self->findBreakTarget(curr->name)].push_back( - self->currBasicBlock); // branch to the target - auto* last = self->currBasicBlock; - self->link(last, self->startBasicBlock()); // we might fall through - } - static void scan(SubType* self, Expression** currp) { Expression* curr = *currp; @@ -395,10 +387,6 @@ struct CFGWalker : public ControlFlowWalker<SubType, VisitorType> { self->pushTask(SubType::doEndThrow, currp); break; } - case Expression::Id::BrOnExnId: { - self->pushTask(SubType::doEndBrOnExn, currp); - break; - } default: {} } diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h index 4cf5022e3..6256c4c1e 100644 --- a/src/dataflow/graph.h +++ b/src/dataflow/graph.h @@ -228,8 +228,7 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { return doVisitUnreachable(unreachable); } else if (auto* drop = curr->dynCast<Drop>()) { return doVisitDrop(drop); - } else if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>() || - curr->is<BrOnExn>()) { + } else if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>()) { Fatal() << "DataFlow does not support EH instructions yet"; } else { return doVisitGeneric(curr); diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 1b48eca24..93f064c89 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -71,17 +71,9 @@ switch (op[0]) { case 'i': if (strcmp(op, "br_if") == 0) { return makeBreak(s); } goto parse_error; - case 'o': { - switch (op[6]) { - case 'c': - if (strcmp(op, "br_on_cast") == 0) { return makeBrOnCast(s); } - goto parse_error; - case 'e': - if (strcmp(op, "br_on_exn") == 0) { return makeBrOnExn(s); } - goto parse_error; - default: goto parse_error; - } - } + case 'o': + if (strcmp(op, "br_on_cast") == 0) { return makeBrOnCast(s); } + goto parse_error; case 't': if (strcmp(op, "br_table") == 0) { return makeBreakTable(s); } goto parse_error; diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp index 32b38325d..014ee184e 100644 --- a/src/ir/ReFinalize.cpp +++ b/src/ir/ReFinalize.cpp @@ -136,14 +136,6 @@ void ReFinalize::visitRefEq(RefEq* curr) { curr->finalize(); } void ReFinalize::visitTry(Try* curr) { curr->finalize(); } void ReFinalize::visitThrow(Throw* curr) { curr->finalize(); } void ReFinalize::visitRethrow(Rethrow* curr) { curr->finalize(); } -void ReFinalize::visitBrOnExn(BrOnExn* curr) { - curr->finalize(); - if (curr->exnref->type == Type::unreachable) { - replaceUntaken(curr->exnref, nullptr); - } else { - updateBreakValueType(curr->name, curr->sent); - } -} void ReFinalize::visitNop(Nop* curr) { curr->finalize(); } void ReFinalize::visitUnreachable(Unreachable* curr) { curr->finalize(); } void ReFinalize::visitPop(Pop* curr) { curr->finalize(); } diff --git a/src/ir/abstract.h b/src/ir/abstract.h index d4a93b011..4c8d556cb 100644 --- a/src/ir/abstract.h +++ b/src/ir/abstract.h @@ -115,7 +115,6 @@ inline UnaryOp getUnary(Type type, Op op) { case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::dataref: @@ -289,7 +288,6 @@ inline BinaryOp getBinary(Type type, Op op) { 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/ir/branch-utils.h b/src/ir/branch-utils.h index 2e7ef470d..5e2cc5184 100644 --- a/src/ir/branch-utils.h +++ b/src/ir/branch-utils.h @@ -80,8 +80,6 @@ void operateOnScopeNameUsesAndSentTypes(Expression* expr, T func) { func(name, br->value ? br->value->type : Type::none); } else if (auto* sw = expr->dynCast<Switch>()) { func(name, sw->value ? sw->value->type : Type::none); - } else if (auto* br = expr->dynCast<BrOnExn>()) { - func(name, br->sent); } else if (auto* br = expr->dynCast<BrOnCast>()) { func(name, br->getCastType()); } else { diff --git a/src/ir/cost.h b/src/ir/cost.h index 7f8e39e1b..46213880b 100644 --- a/src/ir/cost.h +++ b/src/ir/cost.h @@ -562,9 +562,6 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, Index> { return ret; } Index visitRethrow(Rethrow* curr) { return 100; } - Index visitBrOnExn(BrOnExn* curr) { - return 1 + visit(curr->exnref) + curr->sent.size(); - } Index visitTupleMake(TupleMake* curr) { Index ret = 0; for (auto* child : curr->operands) { diff --git a/src/ir/effects.h b/src/ir/effects.h index 22fab593d..e9e8d0f6c 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -538,11 +538,6 @@ private: // traps when the arg is null parent.implicitTrap = true; } - void visitBrOnExn(BrOnExn* curr) { - parent.breakTargets.insert(curr->name); - // traps when the arg is null - parent.implicitTrap = true; - } void visitNop(Nop* curr) {} void visitUnreachable(Unreachable* curr) { parent.trap = true; } void visitPop(Pop* curr) { diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 6055ba5c6..1ae7b11b2 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -35,7 +35,6 @@ function initializeConstants() { ['v128', 'Vec128'], ['funcref', 'Funcref'], ['externref', 'Externref'], - ['exnref', 'Exnref'], ['anyref', 'Anyref'], ['eqref', 'Eqref'], ['i31ref', 'I31ref'], @@ -93,7 +92,6 @@ function initializeConstants() { 'Try', 'Throw', 'Rethrow', - 'BrOnExn', 'TupleMake', 'TupleExtract', 'Pop', @@ -2074,12 +2072,6 @@ function wrapModule(module, self = {}) { } }; - self['exnref'] = { - 'pop'() { - return Module['_BinaryenPop'](module, Module['exnref']); - } - }; - self['anyref'] = { 'pop'() { return Module['_BinaryenPop'](module, Module['anyref']); @@ -2145,9 +2137,6 @@ function wrapModule(module, self = {}) { self['rethrow'] = function(depth) { return Module['_BinaryenRethrow'](module, depth); }; - self['br_on_exn'] = function(label, event_, exnref) { - return preserveStack(() => Module['_BinaryenBrOnExn'](module, strToStack(label), strToStack(event_), exnref)); - }; self['tuple'] = { 'make'(elements) { @@ -2885,14 +2874,6 @@ Module['getExpressionInfo'] = function(expr) { 'type': type, 'depth': Module['_BinaryenRethrowGetDepth'](expr) }; - case Module['BrOnExnId']: - return { - 'id': id, - 'type': type, - 'name': UTF8ToString(Module['_BinaryenBrOnExnGetName'](expr)), - 'event': UTF8ToString(Module['_BinaryenBrOnExnGetEvent'](expr)), - 'exnref': Module['_BinaryenBrOnExnGetExnref'](expr) - }; case Module['TupleMakeId']: return { 'id': id, @@ -4230,27 +4211,6 @@ Module['Rethrow'] = makeExpressionWrapper({ } }); -Module['BrOnExn'] = makeExpressionWrapper({ - 'getEvent'(expr) { - return UTF8ToString(Module['_BinaryenBrOnExnGetEvent'](expr)); - }, - 'setEvent'(expr, eventName) { - preserveStack(() => { Module['_BinaryenBrOnExnSetEvent'](expr, strToStack(eventName)) }); - }, - 'getName'(expr) { - return UTF8ToString(Module['_BinaryenBrOnExnGetName'](expr)); - }, - 'setName'(expr, name) { - preserveStack(() => { Module['_BinaryenBrOnExnSetName'](expr, strToStack(name)) }); - }, - 'getExnref'(expr) { - return Module['_BinaryenBrOnExnGetExnref'](expr); - }, - 'setExnref'(expr, exnrefExpr) { - Module['_BinaryenBrOnExnSetExnref'](expr, exnrefExpr); - } -}); - Module['TupleMake'] = makeExpressionWrapper({ 'getNumOperands'(expr) { return Module['_BinaryenTupleMakeGetNumOperands'](expr); diff --git a/src/literal.h b/src/literal.h index a6727681b..c85701a48 100644 --- a/src/literal.h +++ b/src/literal.h @@ -30,7 +30,6 @@ namespace wasm { class Literals; -struct ExceptionPackage; struct GCData; // Subclass the vector type so that this is not easily confused with a vector of // types (which could be confusing on the Literal constructor). @@ -45,8 +44,6 @@ class Literal { uint8_t v128[16]; // funcref function name. `isNull()` indicates a `null` value. Name func; - // exnref package. `nullptr` indicates a `null` value. - std::unique_ptr<ExceptionPackage> exn; // A reference to GC data, either a Struct or an Array. For both of those // we store the referred data as a Literals object (which is natural for an // Array, and for a Struct, is just the fields in order). The type is used @@ -94,8 +91,6 @@ public: explicit Literal(const std::array<Literal, 4>&); explicit Literal(const std::array<Literal, 2>&); explicit Literal(Name func, Type type) : func(func), type(type) {} - explicit Literal(std::unique_ptr<ExceptionPackage>&& exn) - : exn(std::move(exn)), type(Type::exnref) {} explicit Literal(std::shared_ptr<GCData> gcData, Type type); explicit Literal(std::unique_ptr<RttSupers>&& rttSupers, Type type); Literal(const Literal& other); @@ -109,9 +104,6 @@ public: if (type.isFunction()) { return func.isNull(); } - if (type.isException()) { - return !exn; - } if (isGCData()) { return !gcData; } @@ -260,9 +252,6 @@ public: static Literal makeFunc(Name func, Type type = Type::funcref) { return Literal(func, type); } - static Literal makeExn(std::unique_ptr<ExceptionPackage>&& exn) { - return Literal(std::move(exn)); - } static Literal makeI31(int32_t value) { auto lit = Literal(Type::i31ref); lit.i32 = value & 0x7fffffff; @@ -299,7 +288,6 @@ public: assert(type.isFunction() && !func.isNull()); return func; } - ExceptionPackage getExceptionPackage() const; std::shared_ptr<GCData> getGCData() const; const RttSupers& getRttSupers() const; @@ -683,22 +671,8 @@ public: bool isConcrete() { return size() != 0; } }; -// A struct for a thrown exception, which includes a tag (event) and thrown -// values -struct ExceptionPackage { - Name event; - Literals values; - bool operator==(const ExceptionPackage& other) const { - return event == other.event && values == other.values; - } - bool operator!=(const ExceptionPackage& other) const { - return !(*this == other); - } -}; - std::ostream& operator<<(std::ostream& o, wasm::Literal literal); std::ostream& operator<<(std::ostream& o, wasm::Literals literals); -std::ostream& operator<<(std::ostream& o, const ExceptionPackage& exn); // A GC Struct or Array is a set of values with a run-time type saying what it // is. @@ -723,12 +697,6 @@ template<> struct hash<wasm::Literal> { wasm::rehash(digest, a.getFunc()); return digest; } - if (a.type.isException()) { - auto exn = a.getExceptionPackage(); - wasm::rehash(digest, exn.event); - wasm::rehash(digest, exn.values); - return digest; - } // other non-null reference type literals cannot represent concrete // values, i.e. there is no concrete externref, anyref or eqref other than // null. @@ -756,7 +724,6 @@ template<> struct hash<wasm::Literal> { return digest; case wasm::Type::funcref: case wasm::Type::externref: - case wasm::Type::exnref: case wasm::Type::anyref: case wasm::Type::eqref: case wasm::Type::dataref: @@ -812,7 +779,6 @@ template<> struct less<wasm::Literal> { return memcmp(a.getv128Ptr(), b.getv128Ptr(), 16) < 0; case wasm::Type::funcref: case wasm::Type::externref: - case wasm::Type::exnref: case wasm::Type::anyref: case wasm::Type::eqref: case wasm::Type::dataref: diff --git a/src/parsing.h b/src/parsing.h index 68c94c4a6..68647901a 100644 --- a/src/parsing.h +++ b/src/parsing.h @@ -264,7 +264,6 @@ parseConst(cashew::IString s, Type type, MixedArena& allocator) { case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -376,9 +375,6 @@ struct UniqueNameMapper { void visitBreak(Break* curr) { curr->name = mapper.sourceToUnique(curr->name); } - void visitBrOnExn(BrOnExn* curr) { - curr->name = mapper.sourceToUnique(curr->name); - } void visitSwitch(Switch* curr) { for (auto& target : curr->targets) { target = mapper.sourceToUnique(target); diff --git a/src/passes/CodeFolding.cpp b/src/passes/CodeFolding.cpp index a0fc11c83..5362e310d 100644 --- a/src/passes/CodeFolding.cpp +++ b/src/passes/CodeFolding.cpp @@ -155,8 +155,6 @@ struct CodeFolding : public WalkerPass<ControlFlowWalker<CodeFolding>> { unoptimizables.insert(curr->default_); } - void visitBrOnExn(BrOnExn* curr) { unoptimizables.insert(curr->name); } - void visitUnreachable(Unreachable* curr) { // we can only optimize if we are at the end of the parent block if (!controlFlowStack.empty()) { diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp index 55c955539..c43028399 100644 --- a/src/passes/CodePushing.cpp +++ b/src/passes/CodePushing.cpp @@ -141,7 +141,7 @@ private: if (auto* drop = curr->dynCast<Drop>()) { curr = drop->value; } - if (curr->is<If>() || curr->is<BrOnExn>()) { + if (curr->is<If>()) { return true; } if (auto* br = curr->dynCast<Break>()) { diff --git a/src/passes/ConstHoisting.cpp b/src/passes/ConstHoisting.cpp index 6552cfec0..8349e7234 100644 --- a/src/passes/ConstHoisting.cpp +++ b/src/passes/ConstHoisting.cpp @@ -96,7 +96,6 @@ private: case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp index ebd0f3ba8..94544ae25 100644 --- a/src/passes/Flatten.cpp +++ b/src/passes/Flatten.cpp @@ -69,8 +69,7 @@ struct Flatten return; } - if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>() || - curr->is<BrOnExn>()) { + if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>()) { Fatal() << "Flatten does not support EH instructions yet"; } @@ -277,7 +276,6 @@ struct Flatten } } } - // TODO Handle br_on_exn // continue for general handling of everything, control flow or otherwise curr = getCurrent(); // we may have replaced it diff --git a/src/passes/FuncCastEmulation.cpp b/src/passes/FuncCastEmulation.cpp index de21cbb7a..7f7721706 100644 --- a/src/passes/FuncCastEmulation.cpp +++ b/src/passes/FuncCastEmulation.cpp @@ -63,7 +63,6 @@ static Expression* toABI(Expression* value, Module* module) { } case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::dataref: @@ -110,7 +109,6 @@ static Expression* fromABI(Expression* value, Type type, Module* module) { } case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::dataref: diff --git a/src/passes/InstrumentLocals.cpp b/src/passes/InstrumentLocals.cpp index 99a93af69..cc1234fc5 100644 --- a/src/passes/InstrumentLocals.cpp +++ b/src/passes/InstrumentLocals.cpp @@ -57,7 +57,6 @@ Name get_f32("get_f32"); Name get_f64("get_f64"); Name get_funcref("get_funcref"); Name get_externref("get_externref"); -Name get_exnref("get_exnref"); Name get_anyref("get_anyref"); Name get_eqref("get_eqref"); Name get_dataref("get_dataref"); @@ -70,7 +69,6 @@ Name set_f32("set_f32"); Name set_f64("set_f64"); Name set_funcref("set_funcref"); Name set_externref("set_externref"); -Name set_exnref("set_exnref"); Name set_anyref("set_anyref"); Name set_eqref("set_eqref"); Name set_dataref("set_dataref"); @@ -103,9 +101,6 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { case Type::externref: import = get_externref; break; - case Type::exnref: - import = get_exnref; - break; case Type::anyref: import = get_anyref; break; @@ -166,9 +161,6 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { case Type::externref: import = set_externref; break; - case Type::exnref: - import = set_exnref; - break; case Type::anyref: import = set_anyref; break; @@ -220,12 +212,6 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> { set_externref, {Type::i32, Type::i32, Type::externref}, Type::externref); - if (curr->features.hasExceptionHandling()) { - addImport( - curr, get_exnref, {Type::i32, Type::i32, Type::exnref}, Type::exnref); - addImport( - curr, set_exnref, {Type::i32, Type::i32, Type::exnref}, Type::exnref); - } if (curr->features.hasGC()) { addImport( curr, get_anyref, {Type::i32, Type::i32, Type::anyref}, Type::anyref); diff --git a/src/passes/MergeBlocks.cpp b/src/passes/MergeBlocks.cpp index 0ce776524..ef0ead133 100644 --- a/src/passes/MergeBlocks.cpp +++ b/src/passes/MergeBlocks.cpp @@ -129,11 +129,6 @@ struct ProblemFinder : public ControlFlowWalker<ProblemFinder> { } } - void visitBrOnExn(BrOnExn* curr) { - // We should not take exnref value out of br_on_exn - foundProblem = true; - } - bool found() { assert(brIfs >= droppedBrIfs); return foundProblem || brIfs > droppedBrIfs; @@ -596,8 +591,6 @@ struct MergeBlocks : public WalkerPass<PostWalker<MergeBlocks>> { outer = optimize(curr, curr->operands[i], outer); } } - - void visitBrOnExn(BrOnExn* curr) { optimize(curr, curr->exnref); } }; Pass* createMergeBlocksPass() { return new MergeBlocks(); } diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 0696ea4ec..53049943a 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1732,12 +1732,6 @@ struct PrintExpressionContents printMedium(o, "rethrow "); o << curr->depth; } - void visitBrOnExn(BrOnExn* curr) { - printMedium(o, "br_on_exn "); - printName(curr->name, o); - o << " "; - printName(curr->event, o); - } void visitNop(Nop* curr) { printMinor(o, "nop"); } void visitUnreachable(Unreachable* curr) { printMinor(o, "unreachable"); } void visitPop(Pop* curr) { @@ -2420,13 +2414,6 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> { PrintExpressionContents(currFunction, o).visit(curr); o << ')'; } - void visitBrOnExn(BrOnExn* curr) { - o << '('; - PrintExpressionContents(currFunction, o).visit(curr); - incIndent(); - printFullLine(curr->exnref); - decIndent(); - } void visitNop(Nop* curr) { o << '('; PrintExpressionContents(currFunction, o).visit(curr); diff --git a/src/passes/ReReloop.cpp b/src/passes/ReReloop.cpp index 374a54bb8..f70a8afd4 100644 --- a/src/passes/ReReloop.cpp +++ b/src/passes/ReReloop.cpp @@ -278,8 +278,7 @@ struct ReReloop final : public Pass { ReturnTask::handle(*this, ret); } else if (auto* un = curr->dynCast<Unreachable>()) { UnreachableTask::handle(*this, un); - } else if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>() || - curr->is<BrOnExn>()) { + } else if (curr->is<Try>() || curr->is<Throw>() || curr->is<Rethrow>()) { Fatal() << "ReReloop does not support EH instructions yet"; } else { // not control flow, so just a simple element diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp index 8c4523724..70a326799 100644 --- a/src/passes/RemoveUnusedModuleElements.cpp +++ b/src/passes/RemoveUnusedModuleElements.cpp @@ -124,12 +124,6 @@ struct ReachabilityAnalyzer : public PostWalker<ReachabilityAnalyzer> { queue.emplace_back(ModuleElementKind::Event, curr->event); } } - void visitBrOnExn(BrOnExn* curr) { - if (reachable.count(ModuleElement(ModuleElementKind::Event, curr->event)) == - 0) { - queue.emplace_back(ModuleElementKind::Event, curr->event); - } - } }; struct RemoveUnusedModuleElements : public Pass { diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index 9f164ae92..0649b39c4 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -146,10 +146,6 @@ struct SimplifyLocals self->unoptimizableBlocks.insert(target); } // TODO: we could use this info to stop gathering data on these blocks - } else if (auto* br = curr->dynCast<BrOnExn>()) { - // We cannot optimize the block this targets to have a return value, as - // the br_on_exn doesn't support a change to the block's type - self->unoptimizableBlocks.insert(br->name); } self->sinkables.clear(); } diff --git a/src/shell-interface.h b/src/shell-interface.h index dc72eff5b..aeb9cc2a9 100644 --- a/src/shell-interface.h +++ b/src/shell-interface.h @@ -117,7 +117,6 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { assert(false && "v128 not implemented yet"); case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: globals[import->name] = {Literal::makeNull(import->type)}; diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h index 749e6c31f..7e5a56ab1 100644 --- a/src/tools/fuzzing.h +++ b/src/tools/fuzzing.h @@ -335,9 +335,6 @@ private: if (wasm.features.hasReferenceTypes()) { options.push_back(Type::funcref); options.push_back(Type::externref); - if (wasm.features.hasExceptionHandling()) { - options.push_back(Type::exnref); - } if (wasm.features.hasGC()) { options.push_back(Type::eqref); options.push_back(Type::i31ref); @@ -871,8 +868,6 @@ private: void visitBreak(Break* curr) { replaceIfInvalid(curr->name); } - void visitBrOnExn(BrOnExn* curr) { replaceIfInvalid(curr->name); } - bool replaceIfInvalid(Name target) { if (!hasBreakTarget(target)) { // There is no valid parent, replace with something trivially safe. @@ -1648,7 +1643,6 @@ private: } case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -1755,7 +1749,6 @@ private: } case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -1892,7 +1885,6 @@ private: case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -1940,7 +1932,6 @@ private: case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -2013,7 +2004,6 @@ private: case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -2043,7 +2033,6 @@ private: case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -2182,7 +2171,6 @@ private: } case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -2331,7 +2319,6 @@ private: } case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -2574,7 +2561,6 @@ private: } case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -2782,7 +2768,6 @@ private: case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -3047,8 +3032,6 @@ private: .add(FeatureSet::MVP, Type::i32, Type::i64, Type::f32, Type::f64) .add(FeatureSet::SIMD, Type::v128) .add(FeatureSet::ReferenceTypes, Type::funcref, Type::externref) - .add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling, - Type::exnref) .add(FeatureSet::ReferenceTypes | FeatureSet::GC, Type::anyref, Type::eqref, @@ -3063,8 +3046,6 @@ private: return items( FeatureOptions<Type>() .add(FeatureSet::ReferenceTypes, Type::funcref, Type::externref) - .add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling, - Type::exnref) .add(FeatureSet::ReferenceTypes | FeatureSet::GC, Type::anyref, Type::eqref, @@ -3137,9 +3118,7 @@ private: loggableTypes = items( FeatureOptions<Type>() .add(FeatureSet::MVP, Type::i32, Type::i64, Type::f32, Type::f64) - .add(FeatureSet::SIMD, Type::v128) - .add(FeatureSet::ReferenceTypes | FeatureSet::ExceptionHandling, - Type::exnref)); + .add(FeatureSet::SIMD, Type::v128)); } return loggableTypes; } diff --git a/src/tools/spec-wrapper.h b/src/tools/spec-wrapper.h index 6947c499e..f8081a33d 100644 --- a/src/tools/spec-wrapper.h +++ b/src/tools/spec-wrapper.h @@ -55,9 +55,6 @@ static std::string generateSpecWrapper(Module& wasm) { case Type::externref: ret += "(ref.null extern)"; break; - case Type::exnref: - ret += "(ref.null exn)"; - break; case Type::anyref: ret += "(ref.null any)"; break; diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp index a9b3e3068..3860630af 100644 --- a/src/tools/wasm-reduce.cpp +++ b/src/tools/wasm-reduce.cpp @@ -608,7 +608,6 @@ struct Reducer case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -637,7 +636,6 @@ struct Reducer case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -666,7 +664,6 @@ struct Reducer case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -695,7 +692,6 @@ struct Reducer case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: @@ -710,7 +706,6 @@ struct Reducer case Type::v128: case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::i31ref: diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 06a294c6d..8f4946786 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -359,8 +359,6 @@ enum EncodedType { // run-time type info type, without depth index n rtt = -0x18, // 0x68 dataref = -0x19, // 0x67 - // exception reference type TODO remove; the code for now is incorrect - exnref = -0x1a, // 0x66 // func_type form Func = -0x20, // 0x60 Struct = -0x21, // 0x5f @@ -375,7 +373,6 @@ enum EncodedHeapType { any = -0x12, // 0x6e eq = -0x13, // 0x6d i31 = -0x16, // 0x6a - exn = -0x18, // 0x68 data = -0x19, // 0x67 }; @@ -1007,7 +1004,6 @@ enum ASTNodes { CatchAll = 0x05, Throw = 0x08, Rethrow = 0x09, - BrOnExn = 0x0a, // typed function references opcodes @@ -1472,8 +1468,6 @@ public: void readNextDebugLocation(); void readSourceMapHeader(); - void handleBrOnExnNotTaken(Expression* curr); - // AST reading int depth = 0; // only for debugging @@ -1554,7 +1548,6 @@ public: void visitTryOrTryInBlock(Expression*& out); void visitThrow(Throw* curr); void visitRethrow(Rethrow* curr); - void visitBrOnExn(BrOnExn* curr); void visitCallRef(CallRef* curr); // Let is lowered into a block. void visitLet(Block* curr); diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 7f0029e9e..0bfa317d3 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -661,20 +661,6 @@ public: ret->finalize(); return ret; } - BrOnExn* makeBrOnExn(Name name, Event* event, Expression* exnref) { - return makeBrOnExn(name, event->name, exnref, event->sig.params); - } - BrOnExn* makeBrOnExn(Name name, Name event, Expression* exnref, Type sent) { - auto* ret = wasm.allocator.alloc<BrOnExn>(); - ret->name = name; - ret->event = event; - ret->exnref = exnref; - // Copy params info into BrOnExn, because it is necessary when BrOnExn is - // refinalized without the module. - ret->sent = sent; - ret->finalize(); - return ret; - } Unreachable* makeUnreachable() { return wasm.allocator.alloc<Unreachable>(); } Pop* makePop(Type type) { auto* ret = wasm.allocator.alloc<Pop>(); @@ -835,7 +821,6 @@ public: TODO_SINGLE_COMPOUND(type); switch (type.getBasic()) { case Type::externref: - case Type::exnref: // TODO: ExceptionPackage? case Type::anyref: case Type::eqref: assert(value.isNull() && "unexpected non-null reference type literal"); @@ -1040,7 +1025,6 @@ public: case Type::funcref: WASM_UNREACHABLE("handled above"); case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: return ExpressionManipulator::refNull(curr, curr->type); diff --git a/src/wasm-delegations-fields.h b/src/wasm-delegations-fields.h index b5d80b86a..60e14d0c5 100644 --- a/src/wasm-delegations-fields.h +++ b/src/wasm-delegations-fields.h @@ -524,15 +524,6 @@ switch (DELEGATE_ID) { DELEGATE_END(Rethrow); break; } - case Expression::Id::BrOnExnId: { - DELEGATE_START(BrOnExn); - DELEGATE_FIELD_CHILD(BrOnExn, exnref); - DELEGATE_FIELD_SCOPE_NAME_USE(BrOnExn, name); - DELEGATE_FIELD_NAME(BrOnExn, event); - DELEGATE_FIELD_TYPE(BrOnExn, sent); - DELEGATE_END(BrOnExn); - break; - } case Expression::Id::NopId: { DELEGATE_START(Nop); DELEGATE_END(Nop); diff --git a/src/wasm-delegations.h b/src/wasm-delegations.h index f46f5cbb2..f9e163286 100644 --- a/src/wasm-delegations.h +++ b/src/wasm-delegations.h @@ -62,7 +62,6 @@ DELEGATE(RefEq); DELEGATE(Try); DELEGATE(Throw); DELEGATE(Rethrow); -DELEGATE(BrOnExn); DELEGATE(TupleMake); DELEGATE(TupleExtract); DELEGATE(I31New); diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index a825f99ef..1336a8d10 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -1354,25 +1354,6 @@ public: WASM_UNREACHABLE("throw"); } Flow visitRethrow(Rethrow* curr) { WASM_UNREACHABLE("unimp"); } - Flow visitBrOnExn(BrOnExn* curr) { - NOTE_ENTER("BrOnExn"); - Flow flow = this->visit(curr->exnref); - if (flow.breaking()) { - return flow; - } - const auto& value = flow.getSingleValue(); - if (value.isNull()) { - trap("br_on_exn: argument is null"); - } - auto ex = value.getExceptionPackage(); - if (curr->event != ex.event) { // Not taken - return flow; - } - // Taken - flow.values = ex.values; - flow.breakTo = curr->name; - return flow; - } Flow visitI31New(I31New* curr) { NOTE_ENTER("I31New"); Flow flow = visit(curr->value); @@ -2033,7 +2014,6 @@ public: return Literal(load128(addr).data()); case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::dataref: @@ -2093,7 +2073,6 @@ public: break; case Type::funcref: case Type::externref: - case Type::exnref: case Type::anyref: case Type::eqref: case Type::dataref: diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 074e9dbe7..b6db598ec 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -251,7 +251,6 @@ private: Expression* makeTryOrCatchBody(Element& s, Type type, bool isTry); Expression* makeThrow(Element& s); Expression* makeRethrow(Element& s); - Expression* makeBrOnExn(Element& s); Expression* makeTupleMake(Element& s); Expression* makeTupleExtract(Element& s); Expression* makeCallRef(Element& s, bool isReturn); diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h index 53c0e4ac7..4d69eaee3 100644 --- a/src/wasm-traversal.h +++ b/src/wasm-traversal.h @@ -589,12 +589,6 @@ struct LinearExecutionWalker : public PostWalker<SubType, VisitorType> { self->pushTask(SubType::doNoteNonLinear, currp); break; } - case Expression::Id::BrOnExnId: { - self->pushTask(SubType::doVisitBrOnExn, currp); - self->pushTask(SubType::doNoteNonLinear, currp); - self->pushTask(SubType::scan, &curr->cast<BrOnExn>()->exnref); - break; - } case Expression::Id::UnreachableId: { self->pushTask(SubType::doVisitUnreachable, currp); self->pushTask(SubType::doNoteNonLinear, currp); diff --git a/src/wasm-type.h b/src/wasm-type.h index b85855f0b..6b3fdb08f 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -72,7 +72,6 @@ public: v128, funcref, externref, - exnref, anyref, eqref, dataref, @@ -117,8 +116,7 @@ public: // ├─ Aliases ───╫───┼───┼───┼───┤───────┤ // │ funcref ║ x │ │ x │ x │ f n │ ┐ Ref // │ externref ║ x │ │ x │ x │ f? n │ │ f_unc - // │ exnref ║ x │ │ x │ x │ n │ │ n_ullable - // │ anyref ║ x │ │ x │ x │ f? n │ │ + // │ anyref ║ x │ │ x │ x │ f? n │ │ n_ullable // │ eqref ║ x │ │ x │ x │ n │ │ ┐ TODO (GC) // │ i31ref ║ x │ │ x │ x │ │ │ │ // │ dataref ║ x │ │ x │ x │ │ │ ┘ @@ -295,7 +293,6 @@ public: enum BasicHeapType : uint32_t { func, ext, - exn, any, eq, data, diff --git a/src/wasm.h b/src/wasm.h index dd15ea7ad..0b7a09a3c 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -615,7 +615,6 @@ public: TryId, ThrowId, RethrowId, - BrOnExnId, TupleMakeId, TupleExtractId, I31NewId, @@ -1292,21 +1291,6 @@ public: void finalize(); }; -class BrOnExn : public SpecificExpression<Expression::BrOnExnId> { -public: - BrOnExn() { type = Type::unreachable; } - BrOnExn(MixedArena& allocator) : BrOnExn() {} - - Name name; - Name event; - Expression* exnref; - // This is duplicate info of param types stored in Event, but this is required - // for us to know the type of the value sent to the target block. - Type sent; - - void finalize(); -}; - class TupleMake : public SpecificExpression<Expression::TupleMakeId> { public: TupleMake(MixedArena& allocator) : operands(allocator) {} 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) { diff --git a/src/wasm2js.h b/src/wasm2js.h index a9b57b185..745a56d59 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -2175,10 +2175,6 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, unimplemented(curr); WASM_UNREACHABLE("unimp"); } - Ref visitBrOnExn(BrOnExn* curr) { - unimplemented(curr); - WASM_UNREACHABLE("unimp"); - } Ref visitPop(Pop* curr) { unimplemented(curr); WASM_UNREACHABLE("unimp"); |