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.
This commit is contained in:
Andreas Kling 2025-04-06 22:50:55 +02:00 committed by Andreas Kling
commit 5cdbb8b140
Notes: github-actions[bot] 2025-04-08 16:54:36 +00:00
3 changed files with 4 additions and 10 deletions

View file

@ -1806,7 +1806,6 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> CallExpression::generat
argument_operands.size(), argument_operands.size(),
dst, dst,
callee, callee,
this_value,
argument_operands, argument_operands,
expression_string_index); expression_string_index);
} else if (call_type == Op::CallType::DirectEval) { } else if (call_type == Op::CallType::DirectEval) {

View file

@ -2630,7 +2630,7 @@ ThrowCompletionOr<void> CallConstruct::execute_impl(Bytecode::Interpreter& inter
auto argument_values = interpreter.allocate_argument_values(m_argument_count); auto argument_values = interpreter.allocate_argument_values(m_argument_count);
for (size_t i = 0; i < m_argument_count; ++i) for (size_t i = 0; i < m_argument_count; ++i)
argument_values[i] = interpreter.get(m_arguments[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 {}; 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 ByteString CallConstruct::to_byte_string_impl(Bytecode::Executable const& executable) const
{ {
StringBuilder builder; StringBuilder builder;
builder.appendff("CallConstruct {}, {}, {}, "sv, builder.appendff("CallConstruct {}, {}, "sv,
format_operand("dst"sv, m_dst, executable), format_operand("dst"sv, m_dst, executable),
format_operand("callee"sv, m_callee, executable), format_operand("callee"sv, m_callee, executable));
format_operand("this"sv, m_this_value, executable));
builder.append(format_operand_list("args"sv, { m_arguments, m_argument_count }, executable)); builder.append(format_operand_list("args"sv, { m_arguments, m_argument_count }, executable));

View file

@ -1900,11 +1900,10 @@ class CallConstruct final : public Instruction {
public: public:
static constexpr bool IsVariableLength = true; static constexpr bool IsVariableLength = true;
CallConstruct(Operand dst, Operand callee, Operand this_value, ReadonlySpan<ScopedOperand> arguments, Optional<StringTableIndex> expression_string = {}) CallConstruct(Operand dst, Operand callee, ReadonlySpan<ScopedOperand> arguments, Optional<StringTableIndex> expression_string = {})
: Instruction(Type::CallConstruct) : Instruction(Type::CallConstruct)
, m_dst(dst) , m_dst(dst)
, m_callee(callee) , m_callee(callee)
, m_this_value(this_value)
, m_argument_count(arguments.size()) , m_argument_count(arguments.size())
, m_expression_string(expression_string) , m_expression_string(expression_string)
{ {
@ -1919,7 +1918,6 @@ public:
Operand dst() const { return m_dst; } Operand dst() const { return m_dst; }
Operand callee() const { return m_callee; } Operand callee() const { return m_callee; }
Operand this_value() const { return m_this_value; }
Optional<StringTableIndex> const& expression_string() const { return m_expression_string; } Optional<StringTableIndex> const& expression_string() const { return m_expression_string; }
u32 argument_count() const { return m_argument_count; } u32 argument_count() const { return m_argument_count; }
@ -1930,7 +1928,6 @@ public:
{ {
visitor(m_dst); visitor(m_dst);
visitor(m_callee); visitor(m_callee);
visitor(m_this_value);
for (size_t i = 0; i < m_argument_count; i++) for (size_t i = 0; i < m_argument_count; i++)
visitor(m_arguments[i]); visitor(m_arguments[i]);
} }
@ -1938,7 +1935,6 @@ public:
private: private:
Operand m_dst; Operand m_dst;
Operand m_callee; Operand m_callee;
Operand m_this_value;
u32 m_argument_count { 0 }; u32 m_argument_count { 0 };
Optional<StringTableIndex> m_expression_string; Optional<StringTableIndex> m_expression_string;
Operand m_arguments[]; Operand m_arguments[];