mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-15 19:28:43 +12:00
Use g_fxo for spu_cache
This commit is contained in:
parent
5f9c5e8765
commit
a6edcca6e6
3 changed files with 15 additions and 18 deletions
|
@ -40,7 +40,6 @@ void spu_recompiler::init()
|
||||||
// Initialize if necessary
|
// Initialize if necessary
|
||||||
if (!m_spurt)
|
if (!m_spurt)
|
||||||
{
|
{
|
||||||
m_cache = fxm::get<spu_cache>();
|
|
||||||
m_spurt = g_fxo->get<spu_runtime>();
|
m_spurt = g_fxo->get<spu_runtime>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,9 +58,9 @@ spu_function_t spu_recompiler::compile(u64 last_reset_count, const std::vector<u
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cache && g_cfg.core.spu_cache)
|
if (auto cache = g_fxo->get<spu_cache>(); cache && g_cfg.core.spu_cache)
|
||||||
{
|
{
|
||||||
m_cache->add(func);
|
cache->add(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace asmjit;
|
using namespace asmjit;
|
||||||
|
|
|
@ -313,16 +313,16 @@ void spu_cache::initialize()
|
||||||
// SPU cache file (version + block size type)
|
// SPU cache file (version + block size type)
|
||||||
const std::string loc = ppu_cache + "spu-" + fmt::to_lower(g_cfg.core.spu_block_size.to_string()) + "-v1-tane.dat";
|
const std::string loc = ppu_cache + "spu-" + fmt::to_lower(g_cfg.core.spu_block_size.to_string()) + "-v1-tane.dat";
|
||||||
|
|
||||||
auto cache = std::make_shared<spu_cache>(loc);
|
spu_cache cache(loc);
|
||||||
|
|
||||||
if (!*cache)
|
if (!cache)
|
||||||
{
|
{
|
||||||
LOG_ERROR(SPU, "Failed to initialize SPU cache at: %s", loc);
|
LOG_ERROR(SPU, "Failed to initialize SPU cache at: %s", loc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read cache
|
// Read cache
|
||||||
auto func_list = cache->get();
|
auto func_list = cache.get();
|
||||||
atomic_t<std::size_t> fnext{};
|
atomic_t<std::size_t> fnext{};
|
||||||
atomic_t<u8> fail_flag{0};
|
atomic_t<u8> fail_flag{0};
|
||||||
|
|
||||||
|
@ -469,11 +469,8 @@ void spu_cache::initialize()
|
||||||
LOG_SUCCESS(SPU, "SPU Runtime: Built %u functions.", func_list.size());
|
LOG_SUCCESS(SPU, "SPU Runtime: Built %u functions.", func_list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register cache instance
|
// Initialize global cache instance
|
||||||
fxm::import<spu_cache>([&]() -> std::shared_ptr<spu_cache>&&
|
g_fxo->init<spu_cache>(std::move(cache));
|
||||||
{
|
|
||||||
return std::move(cache);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool spu_runtime::func_compare::operator()(const std::vector<u32>& lhs, const std::vector<u32>& rhs) const
|
bool spu_runtime::func_compare::operator()(const std::vector<u32>& lhs, const std::vector<u32>& rhs) const
|
||||||
|
@ -571,7 +568,7 @@ bool spu_runtime::add(u64 last_reset_count, void* _where, spu_function_t compile
|
||||||
// Register function in PIC map
|
// Register function in PIC map
|
||||||
m_pic_map[{func.data() + _off, func.size() - _off}] = compiled;
|
m_pic_map[{func.data() + _off, func.size() - _off}] = compiled;
|
||||||
|
|
||||||
if (fxm::check_unlocked<spu_cache>())
|
if (g_fxo->get<spu_cache>())
|
||||||
{
|
{
|
||||||
// Rebuild trampolines if necessary
|
// Rebuild trampolines if necessary
|
||||||
if (const auto new_tr = rebuild_ubertrampoline())
|
if (const auto new_tr = rebuild_ubertrampoline())
|
||||||
|
@ -4168,7 +4165,6 @@ public:
|
||||||
// Initialize if necessary
|
// Initialize if necessary
|
||||||
if (!m_spurt)
|
if (!m_spurt)
|
||||||
{
|
{
|
||||||
m_cache = fxm::get<spu_cache>();
|
|
||||||
m_spurt = g_fxo->get<spu_runtime>();
|
m_spurt = g_fxo->get<spu_runtime>();
|
||||||
cpu_translator::initialize(m_jit.get_context(), m_jit.get_engine());
|
cpu_translator::initialize(m_jit.get_context(), m_jit.get_engine());
|
||||||
|
|
||||||
|
@ -4203,9 +4199,9 @@ public:
|
||||||
|
|
||||||
std::string log;
|
std::string log;
|
||||||
|
|
||||||
if (m_cache && g_cfg.core.spu_cache)
|
if (auto cache = g_fxo->get<spu_cache>(); cache && g_cfg.core.spu_cache)
|
||||||
{
|
{
|
||||||
m_cache->add(func);
|
cache->add(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -4220,7 +4216,7 @@ public:
|
||||||
fmt::append(m_hash, "spu-0x%05x-%s", func[0], fmt::base57(output));
|
fmt::append(m_hash, "spu-0x%05x-%s", func[0], fmt::base57(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cache)
|
if (g_fxo->get<spu_cache>())
|
||||||
{
|
{
|
||||||
LOG_SUCCESS(SPU, "LLVM: Building %s (size %u)...", m_hash, func.size() - 1);
|
LOG_SUCCESS(SPU, "LLVM: Building %s (size %u)...", m_hash, func.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@ class spu_cache
|
||||||
public:
|
public:
|
||||||
spu_cache(const std::string& loc);
|
spu_cache(const std::string& loc);
|
||||||
|
|
||||||
|
spu_cache(spu_cache&&) noexcept = default;
|
||||||
|
|
||||||
|
spu_cache& operator=(spu_cache&&) noexcept = default;
|
||||||
|
|
||||||
~spu_cache();
|
~spu_cache();
|
||||||
|
|
||||||
operator bool() const
|
operator bool() const
|
||||||
|
@ -337,8 +341,6 @@ protected:
|
||||||
// Sorted function info
|
// Sorted function info
|
||||||
std::map<u32, func_info> m_funcs;
|
std::map<u32, func_info> m_funcs;
|
||||||
|
|
||||||
std::shared_ptr<spu_cache> m_cache;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// For private use
|
// For private use
|
||||||
std::bitset<0x10000> m_bits;
|
std::bitset<0x10000> m_bits;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue