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

LibJS/JIT: Do "enter & leave" sequence in x86_64 machine code

This ensures that the stack pointer is restored before we return from
the jitted code.
This commit is contained in:
Andreas Kling 2023-10-17 18:03:39 +02:00
parent 814b07a9c2
commit 71e41418f6
2 changed files with 12 additions and 0 deletions

View file

@ -290,8 +290,18 @@ struct Assembler {
}
}
void enter()
{
push(Operand::Register(Reg::RBP));
mov(Operand::Register(Reg::RBP), Operand::Register(Reg::RSP));
sub(Operand::Register(Reg::RSP), Operand::Imm8(8));
}
void exit()
{
// leave
emit8(0xc9);
// ret
emit8(0xc3);
}