From 0991847d4a38552eebe0f56744406d2c7f3854cb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 6 Apr 2025 22:50:55 +0200 Subject: [PATCH] LibJS: Remove unused `this` value from CallConstruct instruction There's no `this` value prior in the caller context, and this was never actually used by CallConstruct. --- Libraries/LibJS/Bytecode/ASTCodegen.cpp | 1 - Libraries/LibJS/Bytecode/Interpreter.cpp | 7 +++---- Libraries/LibJS/Bytecode/Op.h | 6 +----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 85d9f61f2e2..1f1ef6717fd 100644 --- a/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -1806,7 +1806,6 @@ Bytecode::CodeGenerationErrorOr> CallExpression::generat argument_operands.size(), dst, callee, - this_value, argument_operands, expression_string_index); } else if (call_type == Op::CallType::DirectEval) { diff --git a/Libraries/LibJS/Bytecode/Interpreter.cpp b/Libraries/LibJS/Bytecode/Interpreter.cpp index 5c2b622106b..d4b48fb04f7 100644 --- a/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -2630,7 +2630,7 @@ ThrowCompletionOr CallConstruct::execute_impl(Bytecode::Interpreter& inter auto argument_values = interpreter.allocate_argument_values(m_argument_count); for (size_t i = 0; i < m_argument_count; ++i) argument_values[i] = interpreter.get(m_arguments[i]); - interpreter.set(dst(), TRY(perform_call(interpreter, interpreter.get(m_this_value), CallType::Construct, callee, argument_values))); + interpreter.set(dst(), TRY(perform_call(interpreter, Value(), CallType::Construct, callee, argument_values))); return {}; } @@ -3424,10 +3424,9 @@ ByteString Call::to_byte_string_impl(Bytecode::Executable const& executable) con ByteString CallConstruct::to_byte_string_impl(Bytecode::Executable const& executable) const { StringBuilder builder; - builder.appendff("CallConstruct {}, {}, {}, "sv, + builder.appendff("CallConstruct {}, {}, "sv, format_operand("dst"sv, m_dst, executable), - format_operand("callee"sv, m_callee, executable), - format_operand("this"sv, m_this_value, executable)); + format_operand("callee"sv, m_callee, executable)); builder.append(format_operand_list("args"sv, { m_arguments, m_argument_count }, executable)); diff --git a/Libraries/LibJS/Bytecode/Op.h b/Libraries/LibJS/Bytecode/Op.h index 834a884be93..83bdeeecbf1 100644 --- a/Libraries/LibJS/Bytecode/Op.h +++ b/Libraries/LibJS/Bytecode/Op.h @@ -1900,11 +1900,10 @@ class CallConstruct final : public Instruction { public: static constexpr bool IsVariableLength = true; - CallConstruct(Operand dst, Operand callee, Operand this_value, ReadonlySpan arguments, Optional expression_string = {}) + CallConstruct(Operand dst, Operand callee, ReadonlySpan arguments, Optional expression_string = {}) : Instruction(Type::CallConstruct) , m_dst(dst) , m_callee(callee) - , m_this_value(this_value) , m_argument_count(arguments.size()) , m_expression_string(expression_string) { @@ -1919,7 +1918,6 @@ public: Operand dst() const { return m_dst; } Operand callee() const { return m_callee; } - Operand this_value() const { return m_this_value; } Optional const& expression_string() const { return m_expression_string; } u32 argument_count() const { return m_argument_count; } @@ -1930,7 +1928,6 @@ public: { visitor(m_dst); visitor(m_callee); - visitor(m_this_value); for (size_t i = 0; i < m_argument_count; i++) visitor(m_arguments[i]); } @@ -1938,7 +1935,6 @@ public: private: Operand m_dst; Operand m_callee; - Operand m_this_value; u32 m_argument_count { 0 }; Optional m_expression_string; Operand m_arguments[];