From 3d5f876585125c16d5afb4cf7c88765a912f87e2 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Wed, 27 Dec 2023 17:47:44 -0800 Subject: [PATCH] Fixes some new glibc allocations that cropped up I guess this was handled by brk things before. --- FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp | 4 +++- FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h | 5 ++++- FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp | 2 +- FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp | 2 +- Source/Tools/LinuxEmulation/VDSO_Emulation.cpp | 4 +++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp b/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp index 8990eb78a7..bffa3c6fbe 100644 --- a/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp +++ b/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp @@ -354,8 +354,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.resize(DISASM_BUFFER_SIZE); + Disasm = fextl::make_unique(DisasmBuffer.data(), 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 70b9bd92e5..21ce5adf58 100644 --- a/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h +++ b/FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h @@ -21,6 +21,7 @@ #endif #include +#include #include #include @@ -233,7 +234,9 @@ class Arm64Emitter : public FEXCore::ARMEmitter::Emitter { #endif #ifdef VIXL_DISASSEMBLER - vixl::aarch64::Disassembler Disasm; + fextl::vector 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 0b7ed0468c..8e4c9b3c90 100644 --- a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp +++ b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp @@ -513,7 +513,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/JIT/Arm64/JIT.cpp b/FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp index 390e9ab571..3d524276c5 100644 --- a/FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp +++ b/FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp @@ -876,7 +876,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..086ac6e31e 100644 --- a/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp +++ b/Source/Tools/LinuxEmulation/VDSO_Emulation.cpp @@ -362,7 +362,9 @@ namespace FEX::VDSO { } void LoadHostVDSO() { - + // dlopen does allocations that FEX can't track. + // Ensure we don't run afoul of the glibc fault allocator. + 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);