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
parent 6b883c5ccb
commit 0991847d4a
3 changed files with 4 additions and 10 deletions

View file

@ -1806,7 +1806,6 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> CallExpression::generat
argument_operands.size(),
dst,
callee,
this_value,
argument_operands,
expression_string_index);
} 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);
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));

View file

@ -1900,11 +1900,10 @@ class CallConstruct final : public Instruction {
public:
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)
, 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<StringTableIndex> 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<StringTableIndex> m_expression_string;
Operand m_arguments[];