PPU LLVM: Reduce size of JIT-transition treampolines to 16

This commit is contained in:
Elad 2025-01-22 11:15:55 +02:00
parent 6fc643f483
commit 4c0832e6e6
3 changed files with 153 additions and 4 deletions

View file

@ -93,6 +93,10 @@ struct jit_runtime final : jit_runtime_base
// Allocate memory
static u8* alloc(usz size, usz align, bool exec = true) noexcept;
// Allocate 0 bytes, observe memory location
// Same as alloc(0, 1, exec)
static u8* peek(bool exec = true) noexcept;
// Should be called at least once after global initialization
static void initialize();

View file

@ -147,6 +147,12 @@ static u8* add_jit_memory(usz size, usz align)
return pointer;
}
if (!size && align == 1)
{
// Return memory top address
return pointer + (Ctr.load() & 0xffff'ffff);
}
u64 olda, newa;
// Simple allocation by incrementing pointer to the next free data
@ -273,6 +279,18 @@ u8* jit_runtime::alloc(usz size, usz align, bool exec) noexcept
}
}
u8* jit_runtime::peek(bool exec) noexcept
{
if (exec)
{
return add_jit_memory<s_code_pos, 0x0, utils::protection::wx>(0, 1);
}
else
{
return add_jit_memory<s_data_pos, 0x40000000, utils::protection::rw>(0, 1);
}
}
void jit_runtime::initialize()
{
if (!s_code_init.empty() || !s_data_init.empty())