1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:28:11 +00:00

LibJS+LibJIT: Make Assembler::native_call accept preserved_registers

This makes JS::JIT::Compiler less architecture-specific
and unifies aligning the stack into a single operation,
where previously we were doing it separately for preserved registers
and for stack arguments.
This commit is contained in:
Nikodem Rabuliński 2023-10-29 13:39:19 +01:00 committed by Andreas Kling
parent ecbb1df01b
commit 9f5450527f
2 changed files with 15 additions and 18 deletions

View file

@ -1917,21 +1917,9 @@ void Compiler::jump_to_exit()
void Compiler::native_call(void* function_address, Vector<Assembler::Operand> const& stack_arguments)
{
// Make sure we don't clobber the VM&.
m_assembler.push(Assembler::Operand::Register(ARG0));
// Align the stack pointer.
m_assembler.sub(Assembler::Operand::Register(STACK_POINTER), Assembler::Operand::Imm(8));
// NOTE: We don't preserve caller-saved registers when making a native call.
// This means that they may have changed after we return from the call.
m_assembler.native_call(function_address, stack_arguments);
// Restore the stack pointer.
m_assembler.add(Assembler::Operand::Register(STACK_POINTER), Assembler::Operand::Imm(8));
// Restore our VM&.
m_assembler.pop(Assembler::Operand::Register(ARG0));
m_assembler.native_call(function_address, { Assembler::Operand::Register(ARG0) }, stack_arguments);
}
OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_executable)