From 533607ccdf0bc2a8b7934a5f78c39147bbee50a8 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Fri, 25 Jun 2021 23:19:36 -0700 Subject: [PATCH] Remove `unwind` `unwind` was removed. See WebAssembly/exception-handling#156. --- src/binary-reader-ir.cc | 28 +-------- src/binary-reader-logging.cc | 1 - src/binary-reader-logging.h | 1 - src/binary-reader-nop.h | 1 - src/binary-reader-objdump.cc | 1 - src/binary-reader.cc | 6 -- src/binary-reader.h | 1 - src/binary-writer.cc | 5 -- src/common.h | 3 +- src/expr-visitor.cc | 16 ----- src/expr-visitor.h | 3 - src/interp/interp.cc | 1 - src/interp/istream.cc | 1 - src/ir.h | 2 - src/lexer-keywords.txt | 1 - src/opcode.cc | 1 - src/opcode.def | 1 - src/prebuilt/lexer-keywords.cc | 5 +- src/shared-validator.cc | 7 --- src/shared-validator.h | 1 - src/token.def | 3 +- src/type-checker.cc | 26 +------- src/type-checker.h | 1 - src/validator.cc | 6 -- src/wast-parser.cc | 14 +---- src/wat-writer.cc | 17 ------ test/dump/try-unwind.txt | 90 ---------------------------- test/parse/expr/bad-try-no-catch.txt | 2 +- test/parse/expr/bad-try-unwind.txt | 38 ------------ test/parse/expr/try-unwind.txt | 15 ----- test/roundtrip/fold-try-unwind.txt | 25 -------- test/spec/unwind.txt | 13 ---- test/typecheck/bad-rethrow-depth.txt | 9 --- test/wasm2c/spec/unwind.txt | 5 -- 34 files changed, 11 insertions(+), 339 deletions(-) delete mode 100644 test/dump/try-unwind.txt delete mode 100644 test/parse/expr/bad-try-unwind.txt delete mode 100644 test/parse/expr/try-unwind.txt delete mode 100644 test/roundtrip/fold-try-unwind.txt delete mode 100644 test/spec/unwind.txt delete mode 100644 test/wasm2c/spec/unwind.txt diff --git a/src/binary-reader-ir.cc b/src/binary-reader-ir.cc index 1251c0af2..19fec5c9a 100644 --- a/src/binary-reader-ir.cc +++ b/src/binary-reader-ir.cc @@ -199,7 +199,6 @@ class BinaryReaderIR : public BinaryReaderNop { Result OnUnaryExpr(Opcode opcode) override; Result OnTernaryExpr(Opcode opcode) override; Result OnUnreachableExpr() override; - Result OnUnwindExpr() override; Result EndFunctionBody(Index index) override; Result OnSimdLaneOpExpr(Opcode opcode, uint64_t value) override; Result OnSimdLoadLaneExpr(Opcode opcode, @@ -813,7 +812,6 @@ Result BinaryReaderIR::OnEndExpr() { case LabelType::Func: case LabelType::Catch: - case LabelType::Unwind: break; } @@ -1015,7 +1013,7 @@ Result BinaryReaderIR::AppendCatch(Catch&& catch_) { if (try_->kind == TryKind::Invalid) { try_->kind = TryKind::Catch; } else if (try_->kind != TryKind::Catch) { - PrintError("catch not allowed in try-unwind or try-delegate"); + PrintError("catch not allowed in try-delegate"); return Result::Error; } @@ -1032,28 +1030,6 @@ Result BinaryReaderIR::OnCatchAllExpr() { return AppendCatch(Catch(GetLocation())); } -Result BinaryReaderIR::OnUnwindExpr() { - LabelNode* label = nullptr; - CHECK_RESULT(TopLabel(&label)); - - if (label->label_type != LabelType::Try) { - PrintError("unwind not inside try block"); - return Result::Error; - } - - auto* try_ = cast(label->context); - - if (try_->kind == TryKind::Invalid) { - try_->kind = TryKind::Unwind; - } else if (try_->kind != TryKind::Unwind) { - PrintError("unwind not allowed in try-catch or try-delegate"); - return Result::Error; - } - - label->exprs = &try_->unwind; - return Result::Ok; -} - Result BinaryReaderIR::OnDelegateExpr(Index depth) { LabelNode* label = nullptr; CHECK_RESULT(TopLabel(&label)); @@ -1068,7 +1044,7 @@ Result BinaryReaderIR::OnDelegateExpr(Index depth) { if (try_->kind == TryKind::Invalid) { try_->kind = TryKind::Delegate; } else if (try_->kind != TryKind::Delegate) { - PrintError("delegate not allowed in try-catch or try-unwind"); + PrintError("delegate not allowed in try-catch"); return Result::Error; } diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc index 71e438643..d67bb5cbc 100644 --- a/src/binary-reader-logging.cc +++ b/src/binary-reader-logging.cc @@ -844,7 +844,6 @@ DEFINE_LOAD_STORE_OPCODE(OnLoadZeroExpr); DEFINE_LOAD_STORE_OPCODE(OnStoreExpr); DEFINE_INDEX_DESC(OnThrowExpr, "tag_index") DEFINE0(OnUnreachableExpr) -DEFINE0(OnUnwindExpr) DEFINE_OPCODE(OnUnaryExpr) DEFINE_OPCODE(OnTernaryExpr) DEFINE_SIMD_LOAD_STORE_LANE_OPCODE(OnSimdLoadLaneExpr); diff --git a/src/binary-reader-logging.h b/src/binary-reader-logging.h index 9b7eb8623..5e385748a 100644 --- a/src/binary-reader-logging.h +++ b/src/binary-reader-logging.h @@ -222,7 +222,6 @@ class BinaryReaderLogging : public BinaryReaderDelegate { Result OnUnaryExpr(Opcode opcode) override; Result OnTernaryExpr(Opcode opcode) override; Result OnUnreachableExpr() override; - Result OnUnwindExpr() override; Result OnAtomicWaitExpr(Opcode opcode, Address alignment_log2, Address offset) override; diff --git a/src/binary-reader-nop.h b/src/binary-reader-nop.h index c069914fb..1ae01e537 100644 --- a/src/binary-reader-nop.h +++ b/src/binary-reader-nop.h @@ -303,7 +303,6 @@ class BinaryReaderNop : public BinaryReaderDelegate { Result OnUnaryExpr(Opcode opcode) override { return Result::Ok; } Result OnTernaryExpr(Opcode opcode) override { return Result::Ok; } Result OnUnreachableExpr() override { return Result::Ok; } - Result OnUnwindExpr() override { return Result::Ok; } Result EndFunctionBody(Index index) override { return Result::Ok; } Result EndCodeSection() override { return Result::Ok; } Result OnSimdLaneOpExpr(Opcode opcode, uint64_t value) override { diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 20f82c869..1f02d3352 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -598,7 +598,6 @@ void BinaryReaderObjdumpDisassemble::LogOpcode(size_t data_size, case Opcode::Else: case Opcode::Catch: case Opcode::CatchAll: - case Opcode::Unwind: indent_level--; default: break; diff --git a/src/binary-reader.cc b/src/binary-reader.cc index c66a96393..f457f238f 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -1435,12 +1435,6 @@ Result BinaryReader::ReadFunctionBody(Offset end_offset) { break; } - case Opcode::Unwind: { - CALLBACK0(OnUnwindExpr); - CALLBACK0(OnOpcodeBare); - break; - } - case Opcode::Delegate: { Index index; CHECK_RESULT(ReadIndex(&index, "depth")); diff --git a/src/binary-reader.h b/src/binary-reader.h index a9463ce53..a688eadad 100644 --- a/src/binary-reader.h +++ b/src/binary-reader.h @@ -290,7 +290,6 @@ class BinaryReaderDelegate { virtual Result OnUnaryExpr(Opcode opcode) = 0; virtual Result OnTernaryExpr(Opcode opcode) = 0; virtual Result OnUnreachableExpr() = 0; - virtual Result OnUnwindExpr() = 0; virtual Result EndFunctionBody(Index index) = 0; virtual Result EndCodeSection() = 0; diff --git a/src/binary-writer.cc b/src/binary-writer.cc index 9ad314ec1..14f51cb7f 100644 --- a/src/binary-writer.cc +++ b/src/binary-writer.cc @@ -1006,11 +1006,6 @@ void BinaryWriter::WriteExpr(const Func* func, const Expr* expr) { } WriteOpcode(stream_, Opcode::End); break; - case TryKind::Unwind: - WriteOpcode(stream_, Opcode::Unwind); - WriteExprList(func, try_expr->unwind); - WriteOpcode(stream_, Opcode::End); - break; case TryKind::Delegate: WriteOpcode(stream_, Opcode::Delegate); WriteU32Leb128(stream_, diff --git a/src/common.h b/src/common.h index c48f22de5..d90ba45b8 100644 --- a/src/common.h +++ b/src/common.h @@ -230,10 +230,9 @@ enum class LabelType { Else, Try, Catch, - Unwind, First = Func, - Last = Unwind, + Last = Catch, }; static const int kLabelTypeCount = WABT_ENUM_COUNT(LabelType); diff --git a/src/expr-visitor.cc b/src/expr-visitor.cc index 5ef2b473d..fa572285c 100644 --- a/src/expr-visitor.cc +++ b/src/expr-visitor.cc @@ -107,10 +107,6 @@ Result ExprVisitor::VisitExpr(Expr* root_expr) { CHECK_RESULT(delegate_->EndTryExpr(try_expr)); } break; - case TryKind::Unwind: - CHECK_RESULT(delegate_->OnUnwindExpr(try_expr)); - PushExprlist(State::Unwind, expr, try_expr->unwind); - break; case TryKind::Delegate: CHECK_RESULT(delegate_->OnDelegateExpr(try_expr)); break; @@ -141,18 +137,6 @@ Result ExprVisitor::VisitExpr(Expr* root_expr) { } break; } - - case State::Unwind: { - auto try_expr = cast(expr); - auto& iter = expr_iter_stack_.back(); - if (iter != try_expr->unwind.end()) { - PushDefault(&*iter++); - } else { - CHECK_RESULT(delegate_->EndTryExpr(try_expr)); - PopExprlist(); - } - break; - } } } diff --git a/src/expr-visitor.h b/src/expr-visitor.h index 19277d562..eda287f04 100644 --- a/src/expr-visitor.h +++ b/src/expr-visitor.h @@ -42,7 +42,6 @@ class ExprVisitor { Loop, Try, Catch, - Unwind, }; Result HandleDefaultState(Expr*); @@ -118,7 +117,6 @@ class ExprVisitor::Delegate { virtual Result OnUnreachableExpr(UnreachableExpr*) = 0; virtual Result BeginTryExpr(TryExpr*) = 0; virtual Result OnCatchExpr(TryExpr*, Catch*) = 0; - virtual Result OnUnwindExpr(TryExpr*) = 0; virtual Result OnDelegateExpr(TryExpr*) = 0; virtual Result EndTryExpr(TryExpr*) = 0; virtual Result OnThrowExpr(ThrowExpr*) = 0; @@ -193,7 +191,6 @@ class ExprVisitor::DelegateNop : public ExprVisitor::Delegate { Result OnUnreachableExpr(UnreachableExpr*) override { return Result::Ok; } Result BeginTryExpr(TryExpr*) override { return Result::Ok; } Result OnCatchExpr(TryExpr*, Catch*) override { return Result::Ok; } - Result OnUnwindExpr(TryExpr*) override { return Result::Ok; } Result OnDelegateExpr(TryExpr*) override { return Result::Ok; } Result EndTryExpr(TryExpr*) override { return Result::Ok; } Result OnThrowExpr(ThrowExpr*) override { return Result::Ok; } diff --git a/src/interp/interp.cc b/src/interp/interp.cc index 6a7fd2fe8..44fa5b66f 100644 --- a/src/interp/interp.cc +++ b/src/interp/interp.cc @@ -1794,7 +1794,6 @@ RunResult Thread::StepInternal(Trap::Ptr* out_trap) { case O::Try: case O::Catch: case O::CatchAll: - case O::Unwind: case O::Delegate: case O::Throw: case O::Rethrow: diff --git a/src/interp/istream.cc b/src/interp/istream.cc index cc8ec5479..609c69230 100644 --- a/src/interp/istream.cc +++ b/src/interp/istream.cc @@ -764,7 +764,6 @@ Instr Istream::Read(Offset* offset) const { case Opcode::Rethrow: case Opcode::Throw: case Opcode::Try: - case Opcode::Unwind: case Opcode::ReturnCall: // Not used. break; diff --git a/src/ir.h b/src/ir.h index ca2d6c2f7..d68cd1411 100644 --- a/src/ir.h +++ b/src/ir.h @@ -380,7 +380,6 @@ typedef std::vector CatchVector; enum class TryKind { Invalid, Catch, - Unwind, Delegate }; @@ -609,7 +608,6 @@ class TryExpr : public ExprMixin { TryKind kind; Block block; CatchVector catches; - ExprList unwind; Var delegate_target; }; diff --git a/src/lexer-keywords.txt b/src/lexer-keywords.txt index 67eb7fad7..9f23590e7 100644 --- a/src/lexer-keywords.txt +++ b/src/lexer-keywords.txt @@ -628,4 +628,3 @@ i64.trunc_u:sat/f64, TokenType::Convert, Opcode::I64TruncSatF64U set_global, TokenType::GlobalSet, Opcode::GlobalSet set_local, TokenType::LocalSet, Opcode::LocalSet tee_local, TokenType::LocalTee, Opcode::LocalTee -unwind, TokenType::Unwind, Opcode::Unwind diff --git a/src/opcode.cc b/src/opcode.cc index 1883aa86e..d4ffcdc12 100644 --- a/src/opcode.cc +++ b/src/opcode.cc @@ -65,7 +65,6 @@ bool Opcode::IsEnabled(const Features& features) const { switch (enum_) { case Opcode::Try: case Opcode::Catch: - case Opcode::Unwind: case Opcode::Delegate: case Opcode::Throw: case Opcode::Rethrow: diff --git a/src/opcode.def b/src/opcode.def index 18c415ca7..846841d1c 100644 --- a/src/opcode.def +++ b/src/opcode.def @@ -45,7 +45,6 @@ WABT_OPCODE(___, ___, ___, ___, 0, 0, 0x06, Try, "try", "") WABT_OPCODE(___, ___, ___, ___, 0, 0, 0x07, Catch, "catch", "") WABT_OPCODE(___, ___, ___, ___, 0, 0, 0x08, Throw, "throw", "") WABT_OPCODE(___, ___, ___, ___, 0, 0, 0x09, Rethrow, "rethrow", "") -WABT_OPCODE(___, ___, ___, ___, 0, 0, 0x0a, Unwind, "unwind", "") WABT_OPCODE(___, ___, ___, ___, 0, 0, 0x0b, End, "end", "") WABT_OPCODE(___, ___, ___, ___, 0, 0, 0x0c, Br, "br", "") WABT_OPCODE(___, I32, ___, ___, 0, 0, 0x0d, BrIf, "br_if", "") diff --git a/src/prebuilt/lexer-keywords.cc b/src/prebuilt/lexer-keywords.cc index 3e74f5824..0c2d8df84 100644 --- a/src/prebuilt/lexer-keywords.cc +++ b/src/prebuilt/lexer-keywords.cc @@ -158,7 +158,7 @@ Perfect_Hash::InWordSet (const char *str, size_t len) { enum { - TOTAL_KEYWORDS = 611, + TOTAL_KEYWORDS = 610, MIN_WORD_LENGTH = 2, MAX_WORD_LENGTH = 29, MIN_HASH_VALUE = 19, @@ -457,8 +457,7 @@ Perfect_Hash::InWordSet (const char *str, size_t len) {"i64x2.bitmask", TokenType::Unary, Opcode::I64X2Bitmask}, #line 383 "src/lexer-keywords.txt" {"i64.atomic.store32", TokenType::AtomicStore, Opcode::I64AtomicStore32}, -#line 631 "src/lexer-keywords.txt" - {"unwind", TokenType::Unwind, Opcode::Unwind}, + {""}, #line 407 "src/lexer-keywords.txt" {"i64.load32_u", TokenType::Load, Opcode::I64Load32U}, {""}, diff --git a/src/shared-validator.cc b/src/shared-validator.cc index 0071d2f26..214c4204b 100644 --- a/src/shared-validator.cc +++ b/src/shared-validator.cc @@ -1241,11 +1241,4 @@ Result SharedValidator::OnUnreachable(const Location& loc) { return result; } -Result SharedValidator::OnUnwind(const Location& loc) { - Result result = Result::Ok; - expr_loc_ = &loc; - result |= typechecker_.OnUnwind(); - return result; -} - } // namespace wabt diff --git a/src/shared-validator.h b/src/shared-validator.h index f5b8ce9a4..da49e4e07 100644 --- a/src/shared-validator.h +++ b/src/shared-validator.h @@ -175,7 +175,6 @@ class SharedValidator { Result OnTry(const Location&, Type sig_type); Result OnUnary(const Location&, Opcode); Result OnUnreachable(const Location&); - Result OnUnwind(const Location&); private: struct FuncType { diff --git a/src/token.def b/src/token.def index a54e37ace..4c5824912 100644 --- a/src/token.def +++ b/src/token.def @@ -145,9 +145,8 @@ WABT_TOKEN(Throw, "throw") WABT_TOKEN(Try, "try") WABT_TOKEN(Unary, "UNARY") WABT_TOKEN(Unreachable, "unreachable") -WABT_TOKEN(Unwind, "unwind") WABT_TOKEN_FIRST(Opcode, AtomicFence) -WABT_TOKEN_LAST(Opcode, Unwind) +WABT_TOKEN_LAST(Opcode, Unreachable) /* Tokens with string data. */ WABT_TOKEN(AlignEqNat, "align=") diff --git a/src/type-checker.cc b/src/type-checker.cc index 1826e1d2c..be0c69e93 100644 --- a/src/type-checker.cc +++ b/src/type-checker.cc @@ -604,8 +604,7 @@ Result TypeChecker::OnEnd(Label* label, Result TypeChecker::OnEnd() { Result result = Result::Ok; static const char* s_label_type_name[] = { - "function", "block", "loop", "if", "if false branch", "try", - "try catch", "try unwind"}; + "function", "block", "loop", "if", "if false branch", "try", "try catch"}; WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(s_label_type_name) == kLabelTypeCount); Label* label; CHECK_RESULT(TopLabel(&label)); @@ -618,15 +617,7 @@ Result TypeChecker::OnEnd() { } const char* desc = s_label_type_name[static_cast(label->label_type)]; - if (label->label_type == LabelType::Unwind) { - // Unwind is unusual in that it always unwinds the control stack at the end, - // and therefore the return type of the unwind expressions are not the same - // as the block return type. - TypeVector empty; - result |= OnEnd(label, empty, desc, desc); - } else { - result |= OnEnd(label, label->result_types, desc, desc); - } + result |= OnEnd(label, label->result_types, desc, desc); return result; } @@ -914,19 +905,6 @@ Result TypeChecker::OnUnreachable() { return SetUnreachable(); } -Result TypeChecker::OnUnwind() { - Result result = Result::Ok; - Label* label; - CHECK_RESULT(TopLabel(&label)); - result |= CheckLabelType(label, LabelType::Try); - result |= PopAndCheckSignature(label->result_types, "try block"); - result |= CheckTypeStackEnd("try block"); - ResetTypeStackToLabel(label); - label->label_type = LabelType::Unwind; - label->unreachable = false; - return result; -} - Result TypeChecker::EndFunction() { Result result = Result::Ok; Label* label; diff --git a/src/type-checker.h b/src/type-checker.h index b183ee071..be596d375 100644 --- a/src/type-checker.h +++ b/src/type-checker.h @@ -125,7 +125,6 @@ class TypeChecker { Result OnTry(const TypeVector& param_types, const TypeVector& result_types); Result OnUnary(Opcode); Result OnUnreachable(); - Result OnUnwind(); Result EndFunction(); static Result CheckType(Type actual, Type expected); diff --git a/src/validator.cc b/src/validator.cc index e192ff98c..b98121d4c 100644 --- a/src/validator.cc +++ b/src/validator.cc @@ -135,7 +135,6 @@ class Validator : public ExprVisitor::Delegate { Result OnUnreachableExpr(UnreachableExpr*) override; Result BeginTryExpr(TryExpr*) override; Result OnCatchExpr(TryExpr*, Catch*) override; - Result OnUnwindExpr(TryExpr*) override; Result OnDelegateExpr(TryExpr*) override; Result EndTryExpr(TryExpr*) override; Result OnThrowExpr(ThrowExpr*) override; @@ -499,11 +498,6 @@ Result Validator::OnCatchExpr(TryExpr*, Catch* catch_) { return Result::Ok; } -Result Validator::OnUnwindExpr(TryExpr* expr) { - result_ |= validator_.OnUnwind(expr->loc); - return Result::Ok; -} - Result Validator::OnDelegateExpr(TryExpr* expr) { result_ |= validator_.OnDelegate(expr->loc, expr->delegate_target); return Result::Ok; diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 955b6a3d4..22dd53226 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -2591,10 +2591,6 @@ Result WastParser::ParseBlockInstr(std::unique_ptr* out_expr) { if (IsCatch(Peek())) { CHECK_RESULT(ParseCatchInstrList(&expr->catches)); expr->kind = TryKind::Catch; - } else if (PeekMatch(TokenType::Unwind)) { - Consume(); - CHECK_RESULT(ParseInstrList(&expr->unwind)); - expr->kind = TryKind::Unwind; } else if (PeekMatch(TokenType::Delegate)) { Consume(); Var var; @@ -2602,7 +2598,7 @@ Result WastParser::ParseBlockInstr(std::unique_ptr* out_expr) { expr->delegate_target = var; expr->kind = TryKind::Delegate; } else { - return ErrorExpected({"catch", "catch_all", "unwind", "delegate"}); + return ErrorExpected({"catch", "catch_all", "delegate"}); } CHECK_RESULT(ErrorIfLpar({"a valid try clause"})); expr->block.end_loc = GetLocation(); @@ -2779,12 +2775,6 @@ Result WastParser::ParseExpr(ExprList* exprs) { CHECK_RESULT(ParseCatchExprList(&expr->catches)); expr->kind = TryKind::Catch; break; - case TokenType::Unwind: - Consume(); - CHECK_RESULT(ParseTerminatingInstrList(&expr->unwind)); - expr->kind = TryKind::Unwind; - EXPECT(Rpar); - break; case TokenType::Delegate: { Consume(); Var var; @@ -2795,7 +2785,7 @@ Result WastParser::ParseExpr(ExprList* exprs) { break; } default: - ErrorExpected({"catch", "catch_all", "unwind", "delegate"}); + ErrorExpected({"catch", "catch_all", "delegate"}); break; } CHECK_RESULT(ErrorIfLpar({"a valid try clause"})); diff --git a/src/wat-writer.cc b/src/wat-writer.cc index 3d2fa56b9..c09b89914 100644 --- a/src/wat-writer.cc +++ b/src/wat-writer.cc @@ -558,7 +558,6 @@ class WatWriter::ExprVisitorDelegate : public ExprVisitor::Delegate { Result OnUnreachableExpr(UnreachableExpr*) override; Result BeginTryExpr(TryExpr*) override; Result OnCatchExpr(TryExpr*, Catch*) override; - Result OnUnwindExpr(TryExpr*) override; Result OnDelegateExpr(TryExpr*) override; Result EndTryExpr(TryExpr*) override; Result OnThrowExpr(ThrowExpr*) override; @@ -894,14 +893,6 @@ Result WatWriter::ExprVisitorDelegate::OnCatchExpr( return Result::Ok; } -Result WatWriter::ExprVisitorDelegate::OnUnwindExpr(TryExpr* expr) { - writer_->Dedent(); - writer_->WritePutsNewline(Opcode::Unwind_Opcode.GetName()); - writer_->Indent(); - writer_->SetTopLabelType(LabelType::Unwind); - return Result::Ok; -} - Result WatWriter::ExprVisitorDelegate::OnDelegateExpr(TryExpr* expr) { writer_->Dedent(); writer_->WritePutsSpace(Opcode::Delegate_Opcode.GetName()); @@ -1173,14 +1164,6 @@ void WatWriter::FlushExprTree(const ExprTree& expr_tree) { WriteCloseNewline(); } break; - case TryKind::Unwind: - WritePuts("(", NextChar::None); - WritePutsNewline(Opcode::Unwind_Opcode.GetName()); - Indent(); - WriteFoldedExprList(try_expr->unwind); - FlushExprTreeStack(); - WriteCloseNewline(); - break; case TryKind::Delegate: WritePuts("(", NextChar::None); WritePutsSpace(Opcode::Delegate_Opcode.GetName()); diff --git a/test/dump/try-unwind.txt b/test/dump/try-unwind.txt deleted file mode 100644 index 50d3af2a2..000000000 --- a/test/dump/try-unwind.txt +++ /dev/null @@ -1,90 +0,0 @@ -;;; TOOL: run-objdump -;;; ARGS0: -v --enable-exceptions -(module - (tag $e (param i32)) - (func - try $try1 (result i32) - nop - i32.const 7 - unwind - i32.const 8 - drop - end - drop)) -(;; STDERR ;;; -0000000: 0061 736d ; WASM_BINARY_MAGIC -0000004: 0100 0000 ; WASM_BINARY_VERSION -; section "Type" (1) -0000008: 01 ; section code -0000009: 00 ; section size (guess) -000000a: 02 ; num types -; func type 0 -000000b: 60 ; func -000000c: 01 ; num params -000000d: 7f ; i32 -000000e: 00 ; num results -; func type 1 -000000f: 60 ; func -0000010: 00 ; num params -0000011: 00 ; num results -0000009: 08 ; FIXUP section size -; section "Function" (3) -0000012: 03 ; section code -0000013: 00 ; section size (guess) -0000014: 01 ; num functions -0000015: 01 ; function 0 signature index -0000013: 02 ; FIXUP section size -; section "Tag" (13) -0000016: 0d ; section code -0000017: 00 ; section size (guess) -0000018: 01 ; tag count -; tag 0 -0000019: 00 ; tag attribute -000001a: 00 ; tag signature index -0000017: 03 ; FIXUP section size -; section "DataCount" (12) -000001b: 0c ; section code -000001c: 00 ; section size (guess) -000001d: 00 ; data count -000001c: 01 ; FIXUP section size -; section "Code" (10) -000001e: 0a ; section code -000001f: 00 ; section size (guess) -0000020: 01 ; num functions -; function body 0 -0000021: 00 ; func body size (guess) -0000022: 00 ; local decl count -0000023: 06 ; try -0000024: 7f ; i32 -0000025: 01 ; nop -0000026: 41 ; i32.const -0000027: 07 ; i32 literal -0000028: 0a ; unwind -0000029: 41 ; i32.const -000002a: 08 ; i32 literal -000002b: 1a ; drop -000002c: 0b ; end -000002d: 1a ; drop -000002e: 0b ; end -0000021: 0d ; FIXUP func body size -000001f: 0f ; FIXUP section size -; move data: [1e, 2f) -> [1b, 2c) -; truncate to 44 (0x2c) -;;; STDERR ;;) -(;; STDOUT ;;; - -try-unwind.wasm: file format wasm 0x1 - -Code Disassembly: - -00001f func[0]: - 000020: 06 7f | try i32 - 000022: 01 | nop - 000023: 41 07 | i32.const 7 - 000025: 0a | unwind - 000026: 41 08 | i32.const 8 - 000028: 1a | drop - 000029: 0b | end - 00002a: 1a | drop - 00002b: 0b | end -;;; STDOUT ;;) diff --git a/test/parse/expr/bad-try-no-catch.txt b/test/parse/expr/bad-try-no-catch.txt index a1e5ebdec..c85756fba 100644 --- a/test/parse/expr/bad-try-no-catch.txt +++ b/test/parse/expr/bad-try-no-catch.txt @@ -5,7 +5,7 @@ (func try nop end) (func (try (do nop)))) (;; STDERR ;;; -out/test/parse/expr/bad-try-no-catch.txt:5:17: error: unexpected token "end", expected catch, catch_all, unwind or delegate. +out/test/parse/expr/bad-try-no-catch.txt:5:17: error: unexpected token "end", expected catch, catch_all or delegate. (func try nop end) ^^^ out/test/parse/expr/bad-try-no-catch.txt:6:22: error: unexpected token ), expected (. diff --git a/test/parse/expr/bad-try-unwind.txt b/test/parse/expr/bad-try-unwind.txt deleted file mode 100644 index 7790c6eb7..000000000 --- a/test/parse/expr/bad-try-unwind.txt +++ /dev/null @@ -1,38 +0,0 @@ -;;; TOOL: wat2wasm -;;; ARGS: --enable-exceptions -;;; ERROR: 1 -(module - (func try nop unwind) - - (func - try - nop - unwind - nop - catch 0 - nop - end) - - ;; folded - (func - (try - (do - (nop)) - (unwind - (nop)) - (catch 0 - (nop))) -(;; STDERR ;;; -out/test/parse/expr/bad-try-unwind.txt:5:23: error: unexpected token ), expected end. - (func try nop unwind) - ^ -out/test/parse/expr/bad-try-unwind.txt:12:5: error: unexpected token catch, expected end. - catch 0 - ^^^^^ -out/test/parse/expr/bad-try-unwind.txt:14:5: error: unexpected token end, expected ). - end) - ^^^ -out/test/parse/expr/bad-try-unwind.txt:23:8: error: unexpected token "catch", expected a valid try clause. - (catch 0 - ^^^^^ -;;; STDERR ;;) diff --git a/test/parse/expr/try-unwind.txt b/test/parse/expr/try-unwind.txt deleted file mode 100644 index 4eb9f5e1b..000000000 --- a/test/parse/expr/try-unwind.txt +++ /dev/null @@ -1,15 +0,0 @@ -;;; TOOL: wat2wasm -;;; ARGS: --enable-exceptions -(module - (func - try - nop - unwind - end) - - (func - try (result i32) - (i32.const 1) - unwind - end - drop)) diff --git a/test/roundtrip/fold-try-unwind.txt b/test/roundtrip/fold-try-unwind.txt deleted file mode 100644 index fbfb625aa..000000000 --- a/test/roundtrip/fold-try-unwind.txt +++ /dev/null @@ -1,25 +0,0 @@ -;;; TOOL: run-roundtrip -;;; ARGS: --stdout --fold-exprs --enable-exceptions --debug-names -(module - (func (result i32) - try (result i32) - nop - i32.const 7 - unwind - i32.const 8 - drop - end - ) -) -(;; STDOUT ;;; -(module - (type (;0;) (func (result i32))) - (func (;0;) (type 0) (result i32) - (try (result i32) ;; label = @1 - (do - (nop) - (i32.const 7)) - (unwind - (drop - (i32.const 8)))))) -;;; STDOUT ;;) diff --git a/test/spec/unwind.txt b/test/spec/unwind.txt deleted file mode 100644 index 42cf3f025..000000000 --- a/test/spec/unwind.txt +++ /dev/null @@ -1,13 +0,0 @@ -;;; TOOL: run-interp-spec -;;; STDIN_FILE: third_party/testsuite/unwind.wast -(;; STDOUT ;;; -out/test/spec/unwind.wast:212: assert_trap passed: unreachable executed -out/test/spec/unwind.wast:221: assert_trap passed: unreachable executed -out/test/spec/unwind.wast:230: assert_trap passed: unreachable executed -out/test/spec/unwind.wast:239: assert_trap passed: unreachable executed -out/test/spec/unwind.wast:245: assert_trap passed: unreachable executed -out/test/spec/unwind.wast:251: assert_trap passed: unreachable executed -out/test/spec/unwind.wast:257: assert_trap passed: unreachable executed -out/test/spec/unwind.wast:263: assert_trap passed: unreachable executed -49/49 tests passed. -;;; STDOUT ;;) diff --git a/test/typecheck/bad-rethrow-depth.txt b/test/typecheck/bad-rethrow-depth.txt index 571ae130e..2b4bc8907 100644 --- a/test/typecheck/bad-rethrow-depth.txt +++ b/test/typecheck/bad-rethrow-depth.txt @@ -23,12 +23,6 @@ end end end) - - (func - try - unwind - rethrow 0 - end) ) (;; STDERR ;;; out/test/typecheck/bad-rethrow-depth.txt:15:13: error: invalid rethrow depth: 0 (catches: 1, 3) @@ -49,7 +43,4 @@ out/test/typecheck/bad-rethrow-depth.txt:20:13: error: invalid rethrow depth: 2 out/test/typecheck/bad-rethrow-depth.txt:21:13: error: invalid rethrow depth: 2 (catches: 0, 1, 3) rethrow 2 ^^^^^^^ -out/test/typecheck/bad-rethrow-depth.txt:30:7: error: rethrow not in try catch block - rethrow 0 - ^^^^^^^ ;;; STDERR ;;) diff --git a/test/wasm2c/spec/unwind.txt b/test/wasm2c/spec/unwind.txt deleted file mode 100644 index 79aa336e8..000000000 --- a/test/wasm2c/spec/unwind.txt +++ /dev/null @@ -1,5 +0,0 @@ -;;; TOOL: run-spec-wasm2c -;;; STDIN_FILE: third_party/testsuite/unwind.wast -(;; STDOUT ;;; -49/49 tests passed. -;;; STDOUT ;;)