Skip to content

Commit

Permalink
Merge pull request #3362 from Sonicadvance1/glibc_alloc
Browse files Browse the repository at this point in the history
Fixes some new glibc allocations that cropped up
  • Loading branch information
Sonicadvance1 committed Jan 10, 2024
2 parents d488592 + 3d5f876 commit dae16aa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<vixl::aarch64::Disassembler>(DisasmBuffer.data(), DISASM_BUFFER_SIZE);
DisasmDecoder = fextl::make_unique<vixl::aarch64::Decoder>();
DisasmDecoder->AppendVisitor(&Disasm);
DisasmDecoder->AppendVisitor(Disasm.get());
}
#endif

Expand Down
5 changes: 4 additions & 1 deletion FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#endif

#include <FEXCore/Config/Config.h>
#include <FEXCore/fextl/vector.h>

#include <array>
#include <cstddef>
Expand Down Expand Up @@ -233,7 +234,9 @@ class Arm64Emitter : public FEXCore::ARMEmitter::Emitter {
#endif

#ifdef VIXL_DISASSEMBLER
vixl::aarch64::Disassembler Disasm;
fextl::vector<char> DisasmBuffer;
constexpr static int DISASM_BUFFER_SIZE {256};
fextl::unique_ptr<vixl::aarch64::Disassembler> Disasm;
fextl::unique_ptr<vixl::aarch64::Decoder> DisasmDecoder;

FEX_CONFIG_OPT(Disassemble, DISASSEMBLE);
Expand Down
2 changes: 1 addition & 1 deletion FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void Dispatcher::EmitDispatcher() {
const auto DisasmEnd = GetCursorAddress<const vixl::aarch64::Instruction*>();
for (auto PCToDecode = DisasmBegin; PCToDecode < DisasmEnd; PCToDecode += 4) {
DisasmDecoder->Decode(PCToDecode);
auto Output = Disasm.GetOutput();
auto Output = Disasm->GetOutput();
LogMan::Msg::IFmt("{}", Output);
}
}
Expand Down
2 changes: 1 addition & 1 deletion FEXCore/Source/Interface/Core/JIT/Arm64/JIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 3 additions & 1 deletion Source/Tools/LinuxEmulation/VDSO_Emulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit dae16aa

Please sign in to comment.