diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index bb1f8bd5fc..b9c800bfd8 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -223,7 +223,7 @@ void spu_cache::initialize() } // Call analyser - std::vector func2 = compiler->block(ls.data(), func[0]); + const std::vector& func2 = compiler->analyse(ls.data(), func[0]); if (func2.size() != size0) { @@ -758,6 +758,7 @@ void spu_runtime::handle_return(spu_thread* _spu) spu_recompiler_base::spu_recompiler_base() { + result.reserve(8192); } spu_recompiler_base::~spu_recompiler_base() @@ -808,7 +809,7 @@ void spu_recompiler_base::dispatch(spu_thread& spu, void*, u8* rip) } // Compile - spu.jit->make_function(spu.jit->block(spu._ptr(0), spu.pc)); + spu.jit->make_function(spu.jit->analyse(spu._ptr(0), spu.pc)); // Diagnostic if (g_cfg.core.spu_block_size == spu_block_size_type::giga) @@ -870,11 +871,10 @@ void spu_recompiler_base::branch(spu_thread& spu, void*, u8* rip) atomic_storage::release(*reinterpret_cast(rip), result); } -std::vector spu_recompiler_base::block(const be_t* ls, u32 entry_point) +const std::vector& spu_recompiler_base::analyse(const be_t* ls, u32 entry_point) { // Result: addr + raw instruction data - std::vector result; - result.reserve(256); + result.clear(); result.push_back(entry_point); // Initialize block entries diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index 503d0ecffd..518bb58f2c 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -209,6 +209,9 @@ private: // For private use std::bitset<0x10000> m_bits; + // Result of analyse(), to avoid copying and allocation + std::vector result; + public: spu_recompiler_base(); @@ -229,8 +232,8 @@ public: // Target for the unresolved patch point (second arg is unused) static void branch(spu_thread&, void*, u8* rip); - // Get the block at specified address - std::vector block(const be_t* ls, u32 lsa); + // Get the function data at specified address + const std::vector& analyse(const be_t* ls, u32 lsa); // Print analyser internal state void dump(std::string& out);