Skip to content

Commit

Permalink
PPU LLVM: Improve precompilation time
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jul 14, 2023
1 parent a828c21 commit c441469
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rpcs3/Emu/Cell/PPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3890,6 +3890,10 @@ bool ppu_initialize(const ppu_module& info, bool check_only)

bool has_mfvscr = false;

const bool is_being_used_in_emulation = vm::base(info.segs[0].addr) == info.segs[0].ptr;

const cpu_thread* cpu = cpu_thread::get_current();

for (auto& func : info.funcs)
{
if (func.size == 0)
Expand Down Expand Up @@ -3931,7 +3935,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
while (!jit_mod.init && fpos < info.funcs.size())
{
// Initialize compiler instance
if (!jit && get_current_cpu_thread())
if (!jit && is_being_used_in_emulation)
{
jit = std::make_shared<jit_compiler>(s_link_table, g_cfg.core.llvm_cpu);
}
Expand Down Expand Up @@ -4267,7 +4271,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)

g_watchdog_hold_ctr--;

if (Emu.IsStopped() || !get_current_cpu_thread())
if (!is_being_used_in_emulation || (cpu ? cpu->state.all_of(cpu_flag::exit) : Emu.IsStopped()))
{
return compiled_new;
}
Expand All @@ -4280,7 +4284,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)

for (auto [obj_name, is_compiled] : link_workload)
{
if (Emu.IsStopped())
if (cpu ? cpu->state.all_of(cpu_flag::exit) : Emu.IsStopped())
{
break;
}
Expand All @@ -4295,7 +4299,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
}
}

if (Emu.IsStopped() || !get_current_cpu_thread())
if (!is_being_used_in_emulation || (cpu ? cpu->state.all_of(cpu_flag::exit) : Emu.IsStopped()))
{
return compiled_new;
}
Expand Down

0 comments on commit c441469

Please sign in to comment.