1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:17:44 +00:00

LibJS: Add LoadArgument bytecode instruction for fast argument access

This is generated for Identifier nodes that represent a function
argument variable. It loads a given argument index from the current
call frame into the accumulator.
This commit is contained in:
Andreas Kling 2021-06-14 09:37:35 +02:00
parent 848944113c
commit 91fbeeab72
4 changed files with 31 additions and 1 deletions

View file

@ -529,6 +529,22 @@ public:
private:
HashMap<u32, Variable> m_variables;
};
class LoadArgument final : public Instruction {
public:
explicit LoadArgument(size_t index)
: Instruction(Type::LoadArgument)
, m_index(index)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string(Bytecode::Executable const&) const;
private:
size_t m_index { 0 };
};
}
namespace JS::Bytecode {