mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
LibJS: Switch to array-calls in the bytecode vm
This will make it easier to implement spreading arguments.
This commit is contained in:
parent
ab763a56f6
commit
4235b2020f
3 changed files with 67 additions and 65 deletions
|
@ -585,59 +585,39 @@ public:
|
|||
Construct,
|
||||
};
|
||||
|
||||
Call(CallType type, Register callee, Register this_value, Vector<Register> const& arguments)
|
||||
Call(CallType type, Register callee, Register this_value)
|
||||
: Instruction(Type::Call)
|
||||
, m_callee(callee)
|
||||
, m_this_value(this_value)
|
||||
, m_type(type)
|
||||
, m_argument_count(arguments.size())
|
||||
{
|
||||
for (size_t i = 0; i < m_argument_count; ++i)
|
||||
m_arguments[i] = arguments[i];
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
|
||||
|
||||
size_t length_impl() const
|
||||
{
|
||||
return sizeof(*this) + sizeof(Register) * m_argument_count;
|
||||
}
|
||||
|
||||
private:
|
||||
Register m_callee;
|
||||
Register m_this_value;
|
||||
CallType m_type;
|
||||
size_t m_argument_count { 0 };
|
||||
Register m_arguments[];
|
||||
};
|
||||
|
||||
// NOTE: This instruction is variable-width depending on the number of arguments!
|
||||
class SuperCall : public Instruction {
|
||||
public:
|
||||
explicit SuperCall(bool is_synthetic, Vector<Register> const& arguments)
|
||||
explicit SuperCall(bool is_synthetic)
|
||||
: Instruction(Type::SuperCall)
|
||||
, m_is_synthetic(is_synthetic)
|
||||
, m_argument_count(arguments.size())
|
||||
{
|
||||
for (size_t i = 0; i < m_argument_count; ++i)
|
||||
m_arguments[i] = arguments[i];
|
||||
}
|
||||
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
|
||||
String to_string_impl(Bytecode::Executable const&) const;
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
|
||||
|
||||
size_t length_impl() const
|
||||
{
|
||||
return sizeof(*this) + sizeof(Register) * m_argument_count;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_is_synthetic;
|
||||
size_t m_argument_count { 0 };
|
||||
Register m_arguments[];
|
||||
};
|
||||
|
||||
class NewClass final : public Instruction {
|
||||
|
@ -991,10 +971,6 @@ ALWAYS_INLINE void Instruction::replace_references(BasicBlock const& from, Basic
|
|||
|
||||
ALWAYS_INLINE size_t Instruction::length() const
|
||||
{
|
||||
if (type() == Type::Call)
|
||||
return static_cast<Op::Call const&>(*this).length_impl();
|
||||
if (type() == Type::SuperCall)
|
||||
return static_cast<Op::SuperCall const&>(*this).length_impl();
|
||||
if (type() == Type::NewArray)
|
||||
return static_cast<Op::NewArray const&>(*this).length_impl();
|
||||
if (type() == Type::CopyObjectExcludingProperties)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue