mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
LLVM: Add explicit resource-freeing at emulation stop
This commit is contained in:
parent
a24e747e16
commit
81d0dd686b
4 changed files with 44 additions and 0 deletions
|
@ -498,6 +498,8 @@ namespace llvm
|
||||||
class StringRef;
|
class StringRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class thread_state : u32;
|
||||||
|
|
||||||
// Temporary compiler interface
|
// Temporary compiler interface
|
||||||
class jit_compiler final
|
class jit_compiler final
|
||||||
{
|
{
|
||||||
|
@ -515,6 +517,7 @@ class jit_compiler final
|
||||||
|
|
||||||
public:
|
public:
|
||||||
jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags = 0, std::function<u64(const std::string&)> symbols_cement = {}) noexcept;
|
jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags = 0, std::function<u64(const std::string&)> symbols_cement = {}) noexcept;
|
||||||
|
jit_compiler& operator=(thread_state) noexcept;
|
||||||
~jit_compiler() noexcept;
|
~jit_compiler() noexcept;
|
||||||
|
|
||||||
// Get LLVM context
|
// Get LLVM context
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "util/types.hpp"
|
#include "util/types.hpp"
|
||||||
#include "util/sysinfo.hpp"
|
#include "util/sysinfo.hpp"
|
||||||
|
#include "Utilities/Thread.h"
|
||||||
#include "JIT.h"
|
#include "JIT.h"
|
||||||
#include "StrFmt.h"
|
#include "StrFmt.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
|
@ -718,6 +719,18 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jit_compiler& jit_compiler::operator=(thread_state s) noexcept
|
||||||
|
{
|
||||||
|
if (s == thread_state::destroying_context)
|
||||||
|
{
|
||||||
|
// Release resources explicitly
|
||||||
|
m_engine.reset();
|
||||||
|
m_context.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
jit_compiler::~jit_compiler() noexcept
|
jit_compiler::~jit_compiler() noexcept
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -3736,6 +3736,25 @@ namespace
|
||||||
|
|
||||||
bucket.map.erase(found);
|
bucket.map.erase(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jit_module_manager& operator=(thread_state s) noexcept
|
||||||
|
{
|
||||||
|
if (s == thread_state::destroying_context)
|
||||||
|
{
|
||||||
|
for (auto& buck : buckets)
|
||||||
|
{
|
||||||
|
for (auto& mod : buck.map)
|
||||||
|
{
|
||||||
|
for (auto& jit : mod.second.pjit)
|
||||||
|
{
|
||||||
|
*jit = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3337,6 +3337,15 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s
|
||||||
|
|
||||||
static_cast<void>(init_mtx->init());
|
static_cast<void>(init_mtx->init());
|
||||||
|
|
||||||
|
// Call explcit semi-destructors (free memory before savestate)
|
||||||
|
for (const auto& [type, data] : *g_fxo)
|
||||||
|
{
|
||||||
|
if (type.thread_op)
|
||||||
|
{
|
||||||
|
type.thread_op(data, thread_state::destroying_context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto set_progress_message = [&](std::string_view text)
|
auto set_progress_message = [&](std::string_view text)
|
||||||
{
|
{
|
||||||
*verbose_message = stx::make_single<std::string>(text);
|
*verbose_message = stx::make_single<std::string>(text);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue