mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- delete JIT data when shutting down.
This commit is contained in:
parent
c164b3c3b0
commit
34a1c8e545
2 changed files with 21 additions and 0 deletions
|
@ -9,6 +9,7 @@ extern PStruct *TypeVector3;
|
|||
static void OutputJitLog(const asmjit::StringLogger &logger);
|
||||
|
||||
static TArray<uint8_t*> JitBlocks;
|
||||
static TArray<uint8_t*> JitFrames;
|
||||
static size_t JitBlockPos = 0;
|
||||
static size_t JitBlockSize = 0;
|
||||
|
||||
|
@ -61,6 +62,21 @@ static void *AllocJitMemory(size_t size)
|
|||
#define UWOP_SAVE_XMM128_FAR 9
|
||||
#define UWOP_PUSH_MACHFRAME 10
|
||||
|
||||
|
||||
void JitRelease()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
for (auto p : JitFrames)
|
||||
{
|
||||
RtlDeleteFunctionTable((PRUNTIME_FUNCTION)p);
|
||||
}
|
||||
#endif
|
||||
for (auto p : JitBlocks)
|
||||
{
|
||||
asmjit::OSUtils::releaseVirtualMemory(p, 1024 * 1024);
|
||||
}
|
||||
}
|
||||
|
||||
static TArray<uint16_t> CreateUnwindInfo(asmjit::CCFunc *func)
|
||||
{
|
||||
using namespace asmjit;
|
||||
|
@ -276,6 +292,7 @@ static void *AddJitFunction(asmjit::CodeHolder* code, asmjit::CCFunc *func)
|
|||
table[0].EndAddress = (DWORD)(ptrdiff_t)(endaddr - baseaddr);
|
||||
table[0].UnwindInfoAddress = (DWORD)(ptrdiff_t)(unwindptr - baseaddr);
|
||||
BOOLEAN result = RtlAddFunctionTable(table, 1, (DWORD64)baseaddr);
|
||||
JitFrames.Push((uint8_t*)table);
|
||||
if (result == 0)
|
||||
I_FatalError("RtlAddFunctionTable failed");
|
||||
#endif
|
||||
|
|
|
@ -53,6 +53,8 @@ extern FMemArena ClassDataAllocator;
|
|||
#define MAX_RETURNS 8 // Maximum number of results a function called by script code can return
|
||||
#define MAX_TRY_DEPTH 8 // Maximum number of nested TRYs in a single function
|
||||
|
||||
void JitRelease();
|
||||
|
||||
|
||||
typedef unsigned char VM_UBYTE;
|
||||
typedef signed char VM_SBYTE;
|
||||
|
@ -426,6 +428,8 @@ public:
|
|||
f->~VMFunction();
|
||||
}
|
||||
AllFunctions.Clear();
|
||||
// also release any JIT data
|
||||
JitRelease();
|
||||
}
|
||||
static void CreateRegUseInfo()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue