diff --git a/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp b/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp index ea13ac7702..82d3d77f12 100644 --- a/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp +++ b/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp @@ -353,8 +353,10 @@ Arm64Emitter::Arm64Emitter(FEXCore::Context::ContextImpl *ctx, void* EmissionPtr // Only setup the disassembler if enabled. // vixl's decoder is expensive to setup. if (Disassemble()) { + DisasmBuffer = static_cast(FEXCore::Allocator::malloc(DISASM_BUFFER_SIZE)); + Disasm = fextl::make_unique(DisasmBuffer, DISASM_BUFFER_SIZE); DisasmDecoder = fextl::make_unique(); - DisasmDecoder->AppendVisitor(&Disasm); + DisasmDecoder->AppendVisitor(Disasm.get()); } #endif diff --git a/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h b/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h index 859a3f192f..6f297058d0 100644 --- a/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h +++ b/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h @@ -63,6 +63,14 @@ class Arm64Emitter : public FEXCore::ARMEmitter::Emitter { protected: Arm64Emitter(FEXCore::Context::ContextImpl *ctx, void* EmissionPtr = nullptr, size_t size = 0); + virtual ~Arm64Emitter() { +#ifdef VIXL_DISASSEMBLER + if (DisasmBuffer) { + FEXCore::Allocator::free(DisasmBuffer); + } +#endif + } + FEXCore::Context::ContextImpl *EmitterCTX; vixl::aarch64::CPU CPU; @@ -233,7 +241,9 @@ class Arm64Emitter : public FEXCore::ARMEmitter::Emitter { #endif #ifdef VIXL_DISASSEMBLER - vixl::aarch64::Disassembler Disasm; + char *DisasmBuffer{}; + constexpr static int DISASM_BUFFER_SIZE {256}; + fextl::unique_ptr Disasm; fextl::unique_ptr DisasmDecoder; FEX_CONFIG_OPT(Disassemble, DISASSEMBLE); diff --git a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp index 0372df3cde..140e86d077 100644 --- a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp +++ b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp @@ -526,7 +526,7 @@ void Dispatcher::EmitDispatcher() { const auto DisasmEnd = GetCursorAddress(); for (auto PCToDecode = DisasmBegin; PCToDecode < DisasmEnd; PCToDecode += 4) { DisasmDecoder->Decode(PCToDecode); - auto Output = Disasm.GetOutput(); + auto Output = Disasm->GetOutput(); LogMan::Msg::IFmt("{}", Output); } } diff --git a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h index 542347fb27..8713873130 100644 --- a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h +++ b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h @@ -43,7 +43,7 @@ class Dispatcher final : public Arm64Emitter { static fextl::unique_ptr Create(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config); Dispatcher(FEXCore::Context::ContextImpl *ctx, const DispatcherConfig &Config); - ~Dispatcher(); + virtual ~Dispatcher(); /** * @name Dispatch Helper functions diff --git a/FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp b/FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp index 980a931e8b..58fa1b73b1 100644 --- a/FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp +++ b/FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp @@ -881,7 +881,7 @@ CPUBackend::CompiledCode Arm64JITCore::CompileCode(uint64_t Entry, LogMan::Msg::IFmt("Disassemble Begin"); for (auto PCToDecode = DisasmBegin; PCToDecode < DisasmEnd; PCToDecode += 4) { DisasmDecoder->Decode(PCToDecode); - auto Output = Disasm.GetOutput(); + auto Output = Disasm->GetOutput(); LogMan::Msg::IFmt("{}", Output); } LogMan::Msg::IFmt("Disassemble End"); diff --git a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp index 978197368c..21e7f3d6c7 100644 --- a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp +++ b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp @@ -362,7 +362,7 @@ namespace FEX::VDSO { } void LoadHostVDSO() { - + FEXCore::Allocator::YesIKnowImNotSupposedToUseTheGlibcAllocator glibc; void *vdso = dlopen("linux-vdso.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); if (!vdso) { vdso = dlopen("linux-gate.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);