mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
LibJS/Bytecode: Put arguments directly in the Call instruction
Instead of having Call refer to a range of VM registers, it now has a trailing list of argument operands as part of the instruction. This means we no longer have to shuffle every argument value into a register before making a call, making bytecode smaller & faster. :^)
This commit is contained in:
parent
da107ec9fb
commit
9a0a5a79f4
3 changed files with 70 additions and 53 deletions
|
@ -1152,17 +1152,23 @@ enum class CallType {
|
|||
|
||||
class Call final : public Instruction {
|
||||
public:
|
||||
Call(CallType type, Operand dst, Operand callee, Operand this_value, Register first_argument, u32 argument_count, Optional<StringTableIndex> expression_string = {}, Optional<Builtin> builtin = {})
|
||||
: Instruction(Type::Call, sizeof(*this))
|
||||
Call(CallType type, Operand dst, Operand callee, Operand this_value, ReadonlySpan<Operand> arguments, Optional<StringTableIndex> expression_string = {}, Optional<Builtin> builtin = {})
|
||||
: Instruction(Type::Call, length_impl(arguments.size()))
|
||||
, m_dst(dst)
|
||||
, m_callee(callee)
|
||||
, m_this_value(this_value)
|
||||
, m_first_argument(first_argument)
|
||||
, m_argument_count(argument_count)
|
||||
, m_argument_count(arguments.size())
|
||||
, m_type(type)
|
||||
, m_expression_string(expression_string)
|
||||
, m_builtin(builtin)
|
||||
{
|
||||
for (size_t i = 0; i < arguments.size(); ++i)
|
||||
m_arguments[i] = arguments[i];
|
||||
}
|
||||
|
||||
size_t length_impl(size_t argument_count) const
|
||||
{
|
||||
return round_up_to_power_of_two(alignof(void*), sizeof(*this) + sizeof(Operand) * argument_count);
|
||||
}
|
||||
|
||||
CallType call_type() const { return m_type; }
|
||||
|
@ -1171,7 +1177,6 @@ public:
|
|||
Operand this_value() const { return m_this_value; }
|
||||
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; }
|
||||
|
||||
Optional<Builtin> const& builtin() const { return m_builtin; }
|
||||
|
@ -1183,11 +1188,11 @@ private:
|
|||
Operand m_dst;
|
||||
Operand m_callee;
|
||||
Operand m_this_value;
|
||||
Register m_first_argument;
|
||||
u32 m_argument_count { 0 };
|
||||
CallType m_type;
|
||||
Optional<StringTableIndex> m_expression_string;
|
||||
Optional<Builtin> m_builtin;
|
||||
Operand m_arguments[];
|
||||
};
|
||||
|
||||
class CallWithArgumentArray final : public Instruction {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue