SPU: fixup for duplicates in recompilers

Fixup for the edge case.
This commit is contained in:
Nekotekina 2019-10-27 12:57:02 +03:00
parent 37dbbce194
commit 5f00b32867
2 changed files with 26 additions and 0 deletions

View file

@ -47,6 +47,8 @@ void spu_recompiler::init()
spu_function_t spu_recompiler::compile(std::vector<u32>&& _func)
{
const u32 start0 = _func[0];
const auto add_loc = m_spurt->add_empty(std::move(_func));
if (!add_loc)
@ -61,6 +63,17 @@ spu_function_t spu_recompiler::compile(std::vector<u32>&& _func)
const std::vector<u32>& func = add_loc->data;
if (func[0] != start0)
{
// Wait for the duplicate
while (!add_loc->compiled)
{
add_loc->compiled.wait(nullptr);
}
return add_loc->compiled;
}
if (auto cache = g_fxo->get<spu_cache>(); cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1))
{
cache->add(func);

View file

@ -4161,6 +4161,8 @@ public:
return compile_interpreter();
}
const u32 start0 = _func[0];
const auto add_loc = m_spurt->add_empty(std::move(_func));
if (!add_loc)
@ -4170,6 +4172,17 @@ public:
const std::vector<u32>& func = add_loc->data;
if (func[0] != start0)
{
// Wait for the duplicate
while (!add_loc->compiled)
{
add_loc->compiled.wait(nullptr);
}
return add_loc->compiled;
}
std::string log;
if (auto cache = g_fxo->get<spu_cache>(); cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1))