Skip to content

Commit

Permalink
Fixes some new glibc allocations that cropped up
Browse files Browse the repository at this point in the history
I guess this was handled by brk things before.
  • Loading branch information
Sonicadvance1 committed Dec 28, 2023
1 parent fc73700 commit 5b26499
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 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 @@ -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<char*>(FEXCore::Allocator::malloc(DISASM_BUFFER_SIZE));
Disasm = fextl::make_unique<vixl::aarch64::Disassembler>(DisasmBuffer, DISASM_BUFFER_SIZE);
DisasmDecoder = fextl::make_unique<vixl::aarch64::Decoder>();
DisasmDecoder->AppendVisitor(&Disasm);
DisasmDecoder->AppendVisitor(Disasm.get());
}
#endif

Expand Down
12 changes: 11 additions & 1 deletion FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<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 @@ -526,7 +526,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/Dispatcher/Dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Dispatcher final : public Arm64Emitter {
static fextl::unique_ptr<Dispatcher> Create(FEXCore::Context::ContextImpl *CTX, const DispatcherConfig &Config);

Dispatcher(FEXCore::Context::ContextImpl *ctx, const DispatcherConfig &Config);
~Dispatcher();
virtual ~Dispatcher();

/**
* @name Dispatch Helper functions
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 @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion Source/Tools/LinuxEmulation/VDSO_Emulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5b26499

Please sign in to comment.