1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-01-31 12:31:45 +01:00

SPU: fix excessive cache size regression

This commit is contained in:
Nekotekina 2019-05-01 14:56:41 +03:00
parent bc42719c48
commit a4c4ee9cb2
4 changed files with 26 additions and 21 deletions

View File

@ -46,18 +46,23 @@ void spu_recompiler::init()
} }
} }
bool spu_recompiler::compile(u64 last_reset_count, const std::vector<u32>& func) spu_function_t spu_recompiler::compile(u64 last_reset_count, const std::vector<u32>& func)
{ {
const auto fn_location = m_spurt->find(last_reset_count, func); const auto fn_location = m_spurt->find(last_reset_count, func);
if (fn_location == spu_runtime::g_dispatcher) if (fn_location == spu_runtime::g_dispatcher)
{ {
return true; return &dispatch;
} }
if (!fn_location) if (!fn_location)
{ {
return false; return nullptr;
}
if (m_cache && g_cfg.core.spu_cache)
{
m_cache->add(func);
} }
using namespace asmjit; using namespace asmjit;
@ -836,7 +841,7 @@ bool spu_recompiler::compile(u64 last_reset_count, const std::vector<u32>& func)
{ {
if (err == asmjit::ErrorCode::kErrorNoVirtualMemory) if (err == asmjit::ErrorCode::kErrorNoVirtualMemory)
{ {
return false; return nullptr;
} }
LOG_FATAL(SPU, "Failed to build a function"); LOG_FATAL(SPU, "Failed to build a function");
@ -844,7 +849,7 @@ bool spu_recompiler::compile(u64 last_reset_count, const std::vector<u32>& func)
if (!m_spurt->add(last_reset_count, fn_location, fn)) if (!m_spurt->add(last_reset_count, fn_location, fn))
{ {
return false; return nullptr;
} }
if (g_cfg.core.spu_debug) if (g_cfg.core.spu_debug)
@ -858,7 +863,7 @@ bool spu_recompiler::compile(u64 last_reset_count, const std::vector<u32>& func)
fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log); fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log);
} }
return true; return fn;
} }
spu_recompiler::XmmLink spu_recompiler::XmmAlloc() // get empty xmm register spu_recompiler::XmmLink spu_recompiler::XmmAlloc() // get empty xmm register

View File

@ -13,7 +13,7 @@ public:
virtual void init() override; virtual void init() override;
virtual bool compile(u64 last_reset_count, const std::vector<u32>&) override; virtual spu_function_t compile(u64 last_reset_count, const std::vector<u32>&) override;
private: private:
// ASMJIT runtime // ASMJIT runtime

View File

@ -786,11 +786,6 @@ spu_recompiler_base::~spu_recompiler_base()
void spu_recompiler_base::make_function(const std::vector<u32>& data) void spu_recompiler_base::make_function(const std::vector<u32>& data)
{ {
if (m_cache && g_cfg.core.spu_cache)
{
m_cache->add(data);
}
for (u64 reset_count = m_spurt->get_reset_count();;) for (u64 reset_count = m_spurt->get_reset_count();;)
{ {
if (LIKELY(compile(reset_count, data))) if (LIKELY(compile(reset_count, data)))
@ -3104,7 +3099,7 @@ public:
} }
} }
virtual bool compile(u64 last_reset_count, const std::vector<u32>& func) override virtual spu_function_t compile(u64 last_reset_count, const std::vector<u32>& func) override
{ {
if (func.empty() && last_reset_count == 0 && m_interp_magn) if (func.empty() && last_reset_count == 0 && m_interp_magn)
{ {
@ -3115,12 +3110,17 @@ public:
if (fn_location == spu_runtime::g_dispatcher) if (fn_location == spu_runtime::g_dispatcher)
{ {
return true; return &dispatch;
} }
if (!fn_location) if (!fn_location)
{ {
return false; return nullptr;
}
if (m_cache && g_cfg.core.spu_cache)
{
m_cache->add(func);
} }
std::string hash; std::string hash;
@ -3684,7 +3684,7 @@ public:
if (!m_spurt->add(last_reset_count, fn_location, fn)) if (!m_spurt->add(last_reset_count, fn_location, fn))
{ {
return false; return nullptr;
} }
if (g_cfg.core.spu_debug) if (g_cfg.core.spu_debug)
@ -3693,7 +3693,7 @@ public:
fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log); fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log);
} }
return true; return fn;
} }
static void interp_check(spu_thread* _spu, bool after) static void interp_check(spu_thread* _spu, bool after)
@ -3730,7 +3730,7 @@ public:
} }
} }
bool compile_interpreter() spu_function_t compile_interpreter()
{ {
using namespace llvm; using namespace llvm;
@ -4044,7 +4044,7 @@ public:
if (!spu_runtime::g_interpreter) if (!spu_runtime::g_interpreter)
{ {
return false; return nullptr;
} }
if (g_cfg.core.spu_debug) if (g_cfg.core.spu_debug)
@ -4053,7 +4053,7 @@ public:
fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log); fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log);
} }
return true; return spu_runtime::g_interpreter;
} }
static bool exec_check_state(spu_thread* _spu) static bool exec_check_state(spu_thread* _spu)

View File

@ -283,7 +283,7 @@ public:
virtual void init() = 0; virtual void init() = 0;
// Compile function (may fail) // Compile function (may fail)
virtual bool compile(u64 last_reset_count, const std::vector<u32>&) = 0; virtual spu_function_t compile(u64 last_reset_count, const std::vector<u32>&) = 0;
// Compile function, handle failure // Compile function, handle failure
void make_function(const std::vector<u32>&); void make_function(const std::vector<u32>&);