mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +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:
parent
814b07a9c2
commit
71e41418f6
2 changed files with 12 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -179,6 +179,8 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable const& bytecode_
|
|||
|
||||
Compiler compiler;
|
||||
|
||||
compiler.m_assembler.enter();
|
||||
|
||||
compiler.m_assembler.mov(
|
||||
Assembler::Operand::Register(REGISTER_ARRAY_BASE),
|
||||
Assembler::Operand::Register(ARG1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue