diff options
author | Hendiadyoin1 <leon.a@serenityos.org> | 2022-11-13 18:38:15 +0100 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-12-06 16:09:24 +0330 |
commit | 133faa0accb99efe87c58d33eb3cb1d632a72826 (patch) | |
tree | b037ac2e5e61e04c981e4945f699751ae1970cca /Userland/Libraries | |
parent | fc332be2e56aff54d42338c7a1c082f789f84be8 (diff) | |
download | serenity-133faa0accb99efe87c58d33eb3cb1d632a72826.zip |
LibJS: Remove FinishUnwind instruction
This is essentially a LeaveUnwind+Jump, so lets just do that, that will
make it easier to optimize it, or see unwind state transitions
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Instruction.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Op.cpp | 18 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Op.h | 21 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Pass/GenerateCFG.cpp | 5 |
5 files changed, 2 insertions, 46 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 6950d6d632..4da233a48f 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -1987,7 +1987,8 @@ Bytecode::CodeGenerationErrorOr<void> TryStatement::generate_bytecode(Bytecode:: generator.emit<Bytecode::Op::Jump>(finalizer_target); } else { auto& block = generator.make_block(); - generator.emit<Bytecode::Op::FinishUnwind>(Bytecode::Label { block }); + generator.emit<Bytecode::Op::LeaveUnwindContext>(); + generator.emit<Bytecode::Op::Jump>(Bytecode::Label { block }); next_block = █ } } diff --git a/Userland/Libraries/LibJS/Bytecode/Instruction.h b/Userland/Libraries/LibJS/Bytecode/Instruction.h index bf4c624b65..524ea8dc3c 100644 --- a/Userland/Libraries/LibJS/Bytecode/Instruction.h +++ b/Userland/Libraries/LibJS/Bytecode/Instruction.h @@ -31,7 +31,6 @@ O(EnterUnwindContext) \ O(EnterObjectEnvironment) \ O(Exp) \ - O(FinishUnwind) \ O(GetById) \ O(GetByValue) \ O(GetIterator) \ diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index c4d1007b5d..7cec9665a4 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -744,19 +744,6 @@ void EnterUnwindContext::replace_references_impl(BasicBlock const& from, BasicBl m_finalizer_target = Label { to }; } -ThrowCompletionOr<void> FinishUnwind::execute_impl(Bytecode::Interpreter& interpreter) const -{ - interpreter.leave_unwind_context(); - interpreter.jump(m_next_target); - return {}; -} - -void FinishUnwind::replace_references_impl(BasicBlock const& from, BasicBlock const& to) -{ - if (&m_next_target.block() == &from) - m_next_target = Label { to }; -} - void CopyObjectExcludingProperties::replace_references_impl(Register from, Register to) { if (m_from_object == from) @@ -1229,11 +1216,6 @@ DeprecatedString EnterUnwindContext::to_deprecated_string_impl(Bytecode::Executa return DeprecatedString::formatted("EnterUnwindContext handler:{} finalizer:{} entry:{}", handler_string, finalizer_string, m_entry_point); } -DeprecatedString FinishUnwind::to_deprecated_string_impl(Bytecode::Executable const&) const -{ - return DeprecatedString::formatted("FinishUnwind next:{}", m_next_target); -} - DeprecatedString LeaveEnvironment::to_deprecated_string_impl(Bytecode::Executable const&) const { auto mode_string = m_mode == EnvironmentMode::Lexical diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 0ec5498884..c0de8fb4e7 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -876,27 +876,6 @@ public: void replace_references_impl(Register, Register) { } }; -class FinishUnwind final : public Instruction { -public: - constexpr static bool IsTerminator = true; - - FinishUnwind(Label next) - : Instruction(Type::FinishUnwind) - , m_next_target(move(next)) - { - } - - ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; - DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; - void replace_references_impl(BasicBlock const&, BasicBlock const&); - void replace_references_impl(Register, Register) { } - - Label next_target() const { return m_next_target; } - -private: - Label m_next_target; -}; - class ContinuePendingUnwind final : public Instruction { public: constexpr static bool IsTerminator = true; diff --git a/Userland/Libraries/LibJS/Bytecode/Pass/GenerateCFG.cpp b/Userland/Libraries/LibJS/Bytecode/Pass/GenerateCFG.cpp index d4be4b7148..476cc937b7 100644 --- a/Userland/Libraries/LibJS/Bytecode/Pass/GenerateCFG.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Pass/GenerateCFG.cpp @@ -90,11 +90,6 @@ void GenerateCFG::perform(PassPipelineExecutable& executable) enter_label(&resume_target, current_block); continue; } - case FinishUnwind: { - auto const& next_target = static_cast<Op::FinishUnwind const&>(instruction).next_target(); - enter_label(&next_target, current_block); - continue; - } default: // Otherwise, pop the current block off, it doesn't jump anywhere. iterators.take_last(); |