From 73fdd31124543775602942b2c6636fdb8c0c0b9b Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Sun, 12 May 2024 10:47:52 +0200 Subject: [PATCH] LibJS: Avoid returning Completions from more Bytecode instructions --- .../Libraries/LibJS/Bytecode/Interpreter.cpp | 18 +++++++----------- Userland/Libraries/LibJS/Bytecode/Op.h | 6 +++--- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 3381d1e87e9..6a0a9e62bcc 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -529,7 +529,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point) handle_##name: \ { \ auto& instruction = *reinterpret_cast(&bytecode[program_counter]); \ - (void)instruction.execute_impl(*this); \ + instruction.execute_impl(*this); \ DISPATCH_NEXT(name); \ } @@ -638,20 +638,20 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point) handle_Await: { auto& instruction = *reinterpret_cast(&bytecode[program_counter]); - (void)instruction.execute_impl(*this); + instruction.execute_impl(*this); will_yield = true; goto run_finalizer_and_return; } handle_Return: { auto& instruction = *reinterpret_cast(&bytecode[program_counter]); - (void)instruction.execute_impl(*this); + instruction.execute_impl(*this); goto run_finalizer_and_return; } handle_Yield: { auto& instruction = *reinterpret_cast(&bytecode[program_counter]); - (void)instruction.execute_impl(*this); + instruction.execute_impl(*this); // Note: A `yield` statement will not go through a finally statement, // hence we need to set a flag to not do so, // but we generate a Yield Operation in the case of returns in @@ -1300,14 +1300,13 @@ void CreatePrivateEnvironment::execute_impl(Bytecode::Interpreter& interpreter) running_execution_context.private_environment = new_private_environment(interpreter.vm(), outer_private_environment); } -ThrowCompletionOr CreateVariableEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const +void CreateVariableEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const { auto& running_execution_context = interpreter.running_execution_context(); auto var_environment = new_declarative_environment(*running_execution_context.lexical_environment); var_environment->ensure_capacity(m_capacity); running_execution_context.variable_environment = var_environment; running_execution_context.lexical_environment = var_environment; - return {}; } ThrowCompletionOr EnterObjectEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const @@ -1768,7 +1767,7 @@ void LeaveUnwindContext::execute_impl(Bytecode::Interpreter& interpreter) const interpreter.leave_unwind_context(); } -ThrowCompletionOr Yield::execute_impl(Bytecode::Interpreter& interpreter) const +void Yield::execute_impl(Bytecode::Interpreter& interpreter) const { auto yielded_value = interpreter.get(m_value).value_or(js_undefined()); @@ -1784,11 +1783,9 @@ ThrowCompletionOr Yield::execute_impl(Bytecode::Interpreter& interpreter) object->define_direct_property("isAwait", Value(false), JS::default_attributes); interpreter.do_return(object); - - return {}; } -ThrowCompletionOr Await::execute_impl(Bytecode::Interpreter& interpreter) const +void Await::execute_impl(Bytecode::Interpreter& interpreter) const { auto yielded_value = interpreter.get(m_argument).value_or(js_undefined()); auto object = Object::create(interpreter.realm(), nullptr); @@ -1798,7 +1795,6 @@ ThrowCompletionOr Await::execute_impl(Bytecode::Interpreter& interpreter) object->define_direct_property("continuation", Value(m_continuation_label.address()), JS::default_attributes); object->define_direct_property("isAwait", Value(true), JS::default_attributes); interpreter.do_return(object); - return {}; } ThrowCompletionOr GetByValue::execute_impl(Bytecode::Interpreter& interpreter) const diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 5e5e06df949..4080c9d8eb3 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -555,7 +555,7 @@ public: { } - ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; + void execute_impl(Bytecode::Interpreter&) const; ByteString to_byte_string_impl(Bytecode::Executable const&) const; private: @@ -2194,7 +2194,7 @@ public: { } - ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; + void execute_impl(Bytecode::Interpreter&) const; ByteString to_byte_string_impl(Bytecode::Executable const&) const; void visit_labels_impl(Function visitor) { @@ -2225,7 +2225,7 @@ public: { } - ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; + void execute_impl(Bytecode::Interpreter&) const; ByteString to_byte_string_impl(Bytecode::Executable const&) const; void visit_labels_impl(Function visitor) {