1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 16:25:07 +00:00

LibJS: Handle Calls argument range during EliminateLoads pass

Otherwise we could forget to emit stores those registers, thinking that
they are only directly accessed.
This commit is contained in:
Hendiadyoin1 2023-07-03 15:15:24 +02:00 committed by Andreas Kling
parent f52e3e540f
commit b26dad3d62
2 changed files with 7 additions and 0 deletions

View file

@ -794,6 +794,9 @@ public:
Register this_value() const { return m_this_value; } Register 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; }
Register first_argument() const { return m_first_argument; }
u32 argument_count() const { return m_argument_count; }
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { } void replace_references_impl(BasicBlock const&, BasicBlock const&) { }

View file

@ -20,6 +20,10 @@ static NonnullOwnPtr<BasicBlock> eliminate_loads(BasicBlock const& block, size_t
Op::NewArray const& array_instruction = static_cast<Op::NewArray const&>(*it); Op::NewArray const& array_instruction = static_cast<Op::NewArray const&>(*it);
if (size_t element_count = array_instruction.element_count()) if (size_t element_count = array_instruction.element_count())
array_ranges.set_range<true, false>(array_instruction.start().index(), element_count); array_ranges.set_range<true, false>(array_instruction.start().index(), element_count);
} else if ((*it).type() == Instruction::Type::Call) {
auto const& call_instruction = static_cast<Op::Call const&>(*it);
if (size_t element_count = call_instruction.argument_count())
array_ranges.set_range<true, false>(call_instruction.first_argument().index(), element_count);
} }
} }