Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEXCore: Moves CodeLoader to frontend #3526

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion FEXCore/Source/Interface/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ desc: Glues Frontend, OpDispatcher and IR Opts & Compilation, LookupCache, Dispa
#include "Utils/Allocator/HostAllocator.h"

#include <FEXCore/Config/Config.h>
#include <FEXCore/Core/CodeLoader.h>
#include <FEXCore/Core/Context.h>
#include <FEXCore/Core/CoreState.h>
#include <FEXCore/Core/CPUBackend.h>
Expand Down
5 changes: 0 additions & 5 deletions FEXCore/include/FEXCore/HLE/SyscallHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

#include <FEXCore/IR/IR.h>

namespace FEXCore {
class CodeLoader;
}

namespace FEXCore::IR {
struct AOTIRCacheEntry;
}
Expand Down Expand Up @@ -74,7 +70,6 @@ namespace FEXCore::HLE {
virtual FEXCore::IR::SyscallFlags GetSyscallFlags(uint64_t Syscall) const { return FEXCore::IR::SyscallFlags::DEFAULT; }

SyscallOSABI GetOSABI() const { return OSABI; }
virtual FEXCore::CodeLoader *GetCodeLoader() const { return nullptr; }
virtual void MarkGuestExecutableRange(FEXCore::Core::InternalThreadState *Thread, uint64_t Start, uint64_t Length) { }
virtual AOTIRCacheEntryLookupResult LookupAOTIRCacheEntry(FEXCore::Core::InternalThreadState *Thread, uint64_t GuestAddr) = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#include <cstdint>
#include <functional>

namespace FEXCore {
namespace IR {
namespace FEXCore::IR {
class IREmitter;
}

namespace FEX {

/**
* @brief Code loader class so the CPU backend can load code in a generic fashion
*
Expand Down Expand Up @@ -46,5 +47,4 @@ class CodeLoader {
virtual uint64_t GetBaseOffset() const { return 0; }
};


}
4 changes: 2 additions & 2 deletions Source/Tools/CommonTools/HarnessHelpers.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
#pragma once

#include "CodeLoader.h"
#include "Common/Config.h"

#include <array>
Expand All @@ -9,7 +10,6 @@
#include <cstring>
#include <fcntl.h>

#include <FEXCore/Core/CodeLoader.h>
#include <FEXCore/Core/CoreState.h>
#include <FEXCore/Core/X86Enums.h>
#include <FEXCore/Utils/Allocator.h>
Expand Down Expand Up @@ -369,7 +369,7 @@ namespace FEX::HarnessHelper {
ConfigStructBase BaseConfig;
};

class HarnessCodeLoader final : public FEXCore::CodeLoader {
class HarnessCodeLoader final : public FEX::CodeLoader {
public:

HarnessCodeLoader(fextl::string const &Filename, fextl::string const &ConfigFilename) {
Expand Down
4 changes: 2 additions & 2 deletions Source/Tools/FEXLoader/ELFCodeLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#pragma once

#include "ArchHelpers/UContext.h"
#include "CodeLoader.h"
#include "Common/Config.h"
#include "Common/FDUtils.h"
#include "FEXCore/Utils/Allocator.h"
Expand All @@ -17,7 +18,6 @@
#include <cstring>
#include <random>

#include <FEXCore/Core/CodeLoader.h>
#include <FEXCore/Core/CoreState.h>
#include <FEXCore/Utils/MathUtils.h>
#include <FEXCore/Core/X86Enums.h>
Expand All @@ -41,7 +41,7 @@
#define PAGE_OFFSET(x) ((x) & 4095)
#define PAGE_ALIGN(x) (((x) + 4095) & ~(uintptr_t)(4095))

class ELFCodeLoader final : public FEXCore::CodeLoader {
class ELFCodeLoader final : public FEX::CodeLoader {
ELFParser MainElf;
ELFParser InterpElf;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ desc: Emulated /proc/cpuinfo, version, osrelease, etc
$end_info$
*/

#include "CodeLoader.h"

#include "Common/FDUtils.h"
#include "LinuxSyscalls/Syscalls.h"
#include "LinuxSyscalls/EmulatedFiles/EmulatedFiles.h"

#include <FEXCore/Config/Config.h>
#include <FEXCore/Core/CodeLoader.h>
#include <FEXCore/Core/Context.h>
#include <FEXCore/Core/CPUID.h>
#include <FEXCore/Utils/CPUInfo.h>
Expand Down
3 changes: 2 additions & 1 deletion Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ desc: Provides a gdb interface to the guest state
$end_info$
*/

#include "CodeLoader.h"

#include "LinuxSyscalls/NetStream.h"

#include <cstdlib>
Expand All @@ -16,7 +18,6 @@ desc: Provides a gdb interface to the guest state

#include <Common/FEXServerClient.h>
#include <FEXCore/Config/Config.h>
#include <FEXCore/Core/CodeLoader.h>
#include <FEXCore/Core/Context.h>
#include <FEXCore/Core/CoreState.h>
#include <FEXCore/Core/SignalDelegator.h>
Expand Down
3 changes: 2 additions & 1 deletion Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ desc: Glue logic, brk allocations
$end_info$
*/

#include "CodeLoader.h"

#include "Linux/Utils/ELFContainer.h"
#include "Linux/Utils/ELFParser.h"

Expand All @@ -23,7 +25,6 @@ desc: Glue logic, brk allocations
#include <FEXCore/Config/Config.h>
#include <FEXCore/Core/Context.h>
#include <FEXCore/Core/CoreState.h>
#include <FEXCore/Core/CodeLoader.h>
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/HLE/Linux/ThreadManagement.h>
#include <FEXCore/HLE/SyscallHandler.h>
Expand Down
11 changes: 7 additions & 4 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ desc: Glue logic, STRACE magic

// #define DEBUG_STRACE

namespace FEXCore {
namespace FEX {
class CodeLoader;
}

namespace FEXCore {
namespace Context {
class Context;
}
Expand Down Expand Up @@ -243,8 +246,8 @@ class SyscallHandler : public FEXCore::HLE::SyscallHandler, FEXCore::HLE::Source
uint64_t HandleBRK(FEXCore::Core::CpuStateFrame *Frame, void *Addr);

FEX::HLE::FileManager FM;
FEXCore::CodeLoader *GetCodeLoader() const override { return LocalLoader; }
void SetCodeLoader(FEXCore::CodeLoader *Loader) { LocalLoader = Loader; }
FEX::CodeLoader *GetCodeLoader() const { return LocalLoader; }
void SetCodeLoader(FEX::CodeLoader *Loader) { LocalLoader = Loader; }
FEX::HLE::SignalDelegator *GetSignalDelegator() { return SignalDelegation; }

FEX_CONFIG_OPT(IsInterpreter, IS_INTERPRETER);
Expand Down Expand Up @@ -334,7 +337,7 @@ class SyscallHandler : public FEXCore::HLE::SyscallHandler, FEXCore::HLE::Source

std::mutex FutexMutex;
std::mutex SyscallMutex;
FEXCore::CodeLoader *LocalLoader{};
FEX::CodeLoader *LocalLoader{};
bool NeedToCheckXID{true};

#ifdef DEBUG_STRACE
Expand Down
4 changes: 2 additions & 2 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ tags: LinuxSyscalls|syscalls-shared
$end_info$
*/

#include "FEXCore/IR/IR.h"
#include "CodeLoader.h"

#include "LinuxSyscalls/SignalDelegator.h"
#include "LinuxSyscalls/Syscalls.h"
#include "LinuxSyscalls/Syscalls/Thread.h"
Expand All @@ -15,7 +16,6 @@ tags: LinuxSyscalls|syscalls-shared
#include "LinuxSyscalls/x32/Thread.h"

#include <FEXCore/Core/Context.h>
#include <FEXCore/Core/CodeLoader.h>
#include <FEXCore/Core/X86Enums.h>
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/IR/IR.h>
Expand Down
Loading