mirror of
https://github.com/RGBCube/serenity
synced 2025-06-15 10:02:08 +00:00
LibJS/JIT: Save and restore callee-saved registers in jitted code
This commit is contained in:
parent
3974ce2069
commit
decc221109
1 changed files with 27 additions and 0 deletions
|
@ -311,6 +311,8 @@ struct Assembler {
|
||||||
|
|
||||||
void enter()
|
void enter()
|
||||||
{
|
{
|
||||||
|
push_callee_saved_registers();
|
||||||
|
|
||||||
push(Operand::Register(Reg::RBP));
|
push(Operand::Register(Reg::RBP));
|
||||||
mov(Operand::Register(Reg::RBP), Operand::Register(Reg::RSP));
|
mov(Operand::Register(Reg::RBP), Operand::Register(Reg::RSP));
|
||||||
sub(Operand::Register(Reg::RSP), Operand::Imm8(8));
|
sub(Operand::Register(Reg::RSP), Operand::Imm8(8));
|
||||||
|
@ -321,10 +323,35 @@ struct Assembler {
|
||||||
// leave
|
// leave
|
||||||
emit8(0xc9);
|
emit8(0xc9);
|
||||||
|
|
||||||
|
pop_callee_saved_registers();
|
||||||
|
|
||||||
// ret
|
// ret
|
||||||
emit8(0xc3);
|
emit8(0xc3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void push_callee_saved_registers()
|
||||||
|
{
|
||||||
|
// FIXME: Don't push RBX twice :^)
|
||||||
|
push(Operand::Register(Reg::RBX));
|
||||||
|
push(Operand::Register(Reg::RBX));
|
||||||
|
push(Operand::Register(Reg::R12));
|
||||||
|
push(Operand::Register(Reg::R13));
|
||||||
|
push(Operand::Register(Reg::R14));
|
||||||
|
push(Operand::Register(Reg::R15));
|
||||||
|
}
|
||||||
|
|
||||||
|
void pop_callee_saved_registers()
|
||||||
|
{
|
||||||
|
pop(Operand::Register(Reg::R15));
|
||||||
|
pop(Operand::Register(Reg::R14));
|
||||||
|
pop(Operand::Register(Reg::R13));
|
||||||
|
pop(Operand::Register(Reg::R12));
|
||||||
|
|
||||||
|
// FIXME: Don't pop RBX twice :^)
|
||||||
|
pop(Operand::Register(Reg::RBX));
|
||||||
|
pop(Operand::Register(Reg::RBX));
|
||||||
|
}
|
||||||
|
|
||||||
void push(Operand op)
|
void push(Operand op)
|
||||||
{
|
{
|
||||||
if (op.type == Operand::Type::Reg) {
|
if (op.type == Operand::Type::Reg) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue