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

LibJS/JIT: Support alternative entry point blocks

If Interpreter::run_and_return_frame is called with a specific entry
point we now map that to a native instruction address, which the JIT
code jumps to after the function prologue.
This commit is contained in:
Simon Wanner 2023-11-02 21:52:20 +01:00 committed by Andreas Kling
parent 38f3b78a1d
commit e400682fb1
4 changed files with 46 additions and 5 deletions

View file

@ -1736,11 +1736,32 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
compiler.reload_cached_accumulator();
Assembler::Label normal_entry {};
compiler.m_assembler.jump_if(
Assembler::Operand::Register(ARG3),
Assembler::Condition::EqualTo,
Assembler::Operand::Imm(0),
normal_entry);
compiler.m_assembler.jump(Assembler::Operand::Register(ARG3));
normal_entry.link(compiler.m_assembler);
for (size_t block_index = 0; block_index < bytecode_executable.basic_blocks.size(); block_index++) {
auto& block = bytecode_executable.basic_blocks[block_index];
compiler.block_data_for(*block).start_offset = compiler.m_output.size();
compiler.set_current_block(*block);
auto it = Bytecode::InstructionStreamIterator(block->instruction_stream());
if (it.at_end()) {
mapping.append({
.native_offset = compiler.m_output.size(),
.block_index = block_index,
.bytecode_offset = 0,
});
}
while (!it.at_end()) {
auto const& op = *it;