#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
-#include "llvm/ExecutionEngine/JITLink/MemoryFlags.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
friend class LinkGraph;
private:
- Section(StringRef Name, MemProt Prot, SectionOrdinal SecOrdinal)
+ Section(StringRef Name, orc::MemProt Prot, SectionOrdinal SecOrdinal)
: Name(Name), Prot(Prot), SecOrdinal(SecOrdinal) {}
using SymbolSet = DenseSet<Symbol *>;
StringRef getName() const { return Name; }
/// Returns the protection flags for this section.
- MemProt getMemProt() const { return Prot; }
+ orc::MemProt getMemProt() const { return Prot; }
/// Set the protection flags for this section.
- void setMemProt(MemProt Prot) { this->Prot = Prot; }
+ void setMemProt(orc::MemProt Prot) { this->Prot = Prot; }
/// Get the deallocation policy for this section.
- MemDeallocPolicy getMemDeallocPolicy() const { return MDP; }
+ orc::MemDeallocPolicy getMemDeallocPolicy() const { return MDP; }
/// Set the deallocation policy for this section.
- void setMemDeallocPolicy(MemDeallocPolicy MDP) { this->MDP = MDP; }
+ void setMemDeallocPolicy(orc::MemDeallocPolicy MDP) { this->MDP = MDP; }
/// Returns the ordinal for this section.
SectionOrdinal getOrdinal() const { return SecOrdinal; }
}
StringRef Name;
- MemProt Prot;
- MemDeallocPolicy MDP = MemDeallocPolicy::Standard;
+ orc::MemProt Prot;
+ orc::MemDeallocPolicy MDP = orc::MemDeallocPolicy::Standard;
SectionOrdinal SecOrdinal = 0;
BlockSet Blocks;
SymbolSet Symbols;
}
/// Create a section with the given name, protection flags, and alignment.
- Section &createSection(StringRef Name, MemProt Prot) {
+ Section &createSection(StringRef Name, orc::MemProt Prot) {
assert(llvm::none_of(Sections,
[&](std::unique_ptr<Section> &Sec) {
return Sec->getName() == Name;
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ExecutionEngine/JITLink/JITLinkDylib.h"
-#include "llvm/ExecutionEngine/JITLink/MemoryFlags.h"
#include "llvm/ExecutionEngine/Orc/Shared/AllocationActions.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
+#include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MSVCErrorWorkarounds.h"
};
private:
- using SegmentMap = AllocGroupSmallMap<Segment>;
+ using SegmentMap = orc::AllocGroupSmallMap<Segment>;
public:
BasicLayout(LinkGraph &G);
MutableArrayRef<char> WorkingMem;
};
- using SegmentMap = AllocGroupSmallMap<Segment>;
+ using SegmentMap = orc::AllocGroupSmallMap<Segment>;
using OnCreatedFunction = unique_function<void(Expected<SimpleSegmentAlloc>)>;
~SimpleSegmentAlloc();
/// Returns the SegmentInfo for the given group.
- SegmentInfo getSegInfo(AllocGroup AG);
+ SegmentInfo getSegInfo(orc::AllocGroup AG);
/// Finalize all groups (async version).
void finalize(OnFinalizedFunction OnFinalized) {
private:
SimpleSegmentAlloc(
- std::unique_ptr<LinkGraph> G, AllocGroupSmallMap<Block *> ContentBlocks,
+ std::unique_ptr<LinkGraph> G,
+ orc::AllocGroupSmallMap<Block *> ContentBlocks,
std::unique_ptr<JITLinkMemoryManager::InFlightAlloc> Alloc);
std::unique_ptr<LinkGraph> G;
- AllocGroupSmallMap<Block *> ContentBlocks;
+ orc::AllocGroupSmallMap<Block *> ContentBlocks;
std::unique_ptr<JITLinkMemoryManager::InFlightAlloc> Alloc;
};
#include "TableManager.h"
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
-#include "llvm/ExecutionEngine/JITLink/MemoryFlags.h"
+#include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
namespace llvm {
namespace jitlink {
private:
Section &getGOTSection(LinkGraph &G) {
if (!GOTSection)
- GOTSection =
- &G.createSection(getSectionName(), MemProt::Read | MemProt::Exec);
+ GOTSection = &G.createSection(getSectionName(),
+ orc::MemProt::Read | orc::MemProt::Exec);
return *GOTSection;
}
public:
Section &getStubsSection(LinkGraph &G) {
if (!StubsSection)
- StubsSection =
- &G.createSection(getSectionName(), MemProt::Read | MemProt::Exec);
+ StubsSection = &G.createSection(getSectionName(),
+ orc::MemProt::Read | orc::MemProt::Exec);
return *StubsSection;
}
private:
Section &getGOTSection(LinkGraph &G) {
if (!GOTSection)
- GOTSection = &G.createSection(getSectionName(), MemProt::Read);
+ GOTSection = &G.createSection(getSectionName(), orc::MemProt::Read);
return *GOTSection;
}
public:
Section &getStubsSection(LinkGraph &G) {
if (!PLTSection)
- PLTSection =
- &G.createSection(getSectionName(), MemProt::Read | MemProt::Exec);
+ PLTSection = &G.createSection(getSectionName(),
+ orc::MemProt::Read | orc::MemProt::Exec);
return *PLTSection;
}
bool finalizeMemory(std::string *ErrMsg = nullptr) override;
private:
- struct Alloc {
+ struct SectionAlloc {
public:
- Alloc(uint64_t Size, unsigned Align)
+ SectionAlloc(uint64_t Size, unsigned Align)
: Size(Size), Align(Align),
Contents(std::make_unique<uint8_t[]>(Size + Align - 1)) {}
// Group of section allocations to be allocated together in the executor. The
// RemoteCodeAddr will stand in as the id of the group for deallocation
// purposes.
- struct AllocGroup {
- AllocGroup() = default;
- AllocGroup(const AllocGroup &) = delete;
- AllocGroup &operator=(const AllocGroup &) = delete;
- AllocGroup(AllocGroup &&) = default;
- AllocGroup &operator=(AllocGroup &&) = default;
+ struct SectionAllocGroup {
+ SectionAllocGroup() = default;
+ SectionAllocGroup(const SectionAllocGroup &) = delete;
+ SectionAllocGroup &operator=(const SectionAllocGroup &) = delete;
+ SectionAllocGroup(SectionAllocGroup &&) = default;
+ SectionAllocGroup &operator=(SectionAllocGroup &&) = default;
ExecutorAddrRange RemoteCode;
ExecutorAddrRange RemoteROData;
ExecutorAddrRange RemoteRWData;
std::vector<ExecutorAddrRange> UnfinalizedEHFrames;
- std::vector<Alloc> CodeAllocs, RODataAllocs, RWDataAllocs;
+ std::vector<SectionAlloc> CodeAllocs, RODataAllocs, RWDataAllocs;
};
- // Maps all allocations in Allocs to aligned blocks
- void mapAllocsToRemoteAddrs(RuntimeDyld &Dyld, std::vector<Alloc> &Allocs,
+ // Maps all allocations in SectionAllocs to aligned blocks
+ void mapAllocsToRemoteAddrs(RuntimeDyld &Dyld,
+ std::vector<SectionAlloc> &SecAllocs,
ExecutorAddr NextAddr);
ExecutorProcessControl &EPC;
SymbolAddrs SAs;
std::mutex M;
- std::vector<AllocGroup> Unmapped;
- std::vector<AllocGroup> Unfinalized;
+ std::vector<SectionAllocGroup> Unmapped;
+ std::vector<SectionAllocGroup> Unfinalized;
std::vector<ExecutorAddr> FinalizedAllocs;
std::string ErrMsg;
};
#define LLVM_EXECUTIONENGINE_ORC_MEMORYMAPPER_H
#include "llvm/ExecutionEngine/Orc/Core.h"
+#include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
#include "llvm/Support/Process.h"
#include <mutex>
const char *WorkingMem;
size_t ContentSize;
size_t ZeroFillSize;
- unsigned Prot;
+ AllocGroup AG;
};
ExecutorAddr MappingBase;
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_EXECUTIONENGINE_JITLINK_MEMORYFLAGS_H
-#define LLVM_EXECUTIONENGINE_JITLINK_MEMORYFLAGS_H
+#ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_MEMORYFLAGS_H
+#define LLVM_EXECUTIONENGINE_ORC_SHARED_MEMORYFLAGS_H
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
-namespace jitlink {
+namespace orc {
/// Describes Read/Write/Exec permissions for memory.
enum class MemProt {
};
/// Print a MemProt as an RWX triple.
-raw_ostream &operator<<(raw_ostream &OS, MemProt MP);
+inline raw_ostream &operator<<(raw_ostream &OS, MemProt MP) {
+ return OS << (((MP & MemProt::Read) != MemProt::None) ? 'R' : '-')
+ << (((MP & MemProt::Write) != MemProt::None) ? 'W' : '-')
+ << (((MP & MemProt::Exec) != MemProt::None) ? 'X' : '-');
+}
/// Convert a MemProt value to a corresponding sys::Memory::ProtectionFlags
/// value.
};
/// Print a MemDeallocPolicy.
-raw_ostream &operator<<(raw_ostream &OS, MemDeallocPolicy MDP);
+inline raw_ostream &operator<<(raw_ostream &OS, MemDeallocPolicy MDP) {
+ return OS << (MDP == MemDeallocPolicy::Standard ? "standard" : "finalize");
+}
/// A pair of memory protections and allocation policies.
///
};
/// Print an AllocGroup.
-raw_ostream &operator<<(raw_ostream &OS, AllocGroup AG);
+inline raw_ostream &operator<<(raw_ostream &OS, AllocGroup AG) {
+ return OS << '(' << AG.getMemProt() << ", " << AG.getMemDeallocPolicy()
+ << ')';
+}
-} // end namespace jitlink
+} // end namespace orc
-template <> struct DenseMapInfo<jitlink::MemProt> {
- static inline jitlink::MemProt getEmptyKey() {
- return jitlink::MemProt(~uint8_t(0));
- }
- static inline jitlink::MemProt getTombstoneKey() {
- return jitlink::MemProt(~uint8_t(0) - 1);
+template <> struct DenseMapInfo<orc::MemProt> {
+ static inline orc::MemProt getEmptyKey() { return orc::MemProt(~uint8_t(0)); }
+ static inline orc::MemProt getTombstoneKey() {
+ return orc::MemProt(~uint8_t(0) - 1);
}
- static unsigned getHashValue(const jitlink::MemProt &Val) {
- using UT = std::underlying_type_t<jitlink::MemProt>;
+ static unsigned getHashValue(const orc::MemProt &Val) {
+ using UT = std::underlying_type_t<orc::MemProt>;
return DenseMapInfo<UT>::getHashValue(static_cast<UT>(Val));
}
- static bool isEqual(const jitlink::MemProt &LHS,
- const jitlink::MemProt &RHS) {
+ static bool isEqual(const orc::MemProt &LHS, const orc::MemProt &RHS) {
return LHS == RHS;
}
};
-template <> struct DenseMapInfo<jitlink::AllocGroup> {
- static inline jitlink::AllocGroup getEmptyKey() {
- return jitlink::AllocGroup(~uint8_t(0));
+template <> struct DenseMapInfo<orc::AllocGroup> {
+ static inline orc::AllocGroup getEmptyKey() {
+ return orc::AllocGroup(~uint8_t(0));
}
- static inline jitlink::AllocGroup getTombstoneKey() {
- return jitlink::AllocGroup(~uint8_t(0) - 1);
+ static inline orc::AllocGroup getTombstoneKey() {
+ return orc::AllocGroup(~uint8_t(0) - 1);
}
- static unsigned getHashValue(const jitlink::AllocGroup &Val) {
- return DenseMapInfo<jitlink::AllocGroup::underlying_type>::getHashValue(
- Val.Id);
+ static unsigned getHashValue(const orc::AllocGroup &Val) {
+ return DenseMapInfo<orc::AllocGroup::underlying_type>::getHashValue(Val.Id);
}
- static bool isEqual(const jitlink::AllocGroup &LHS,
- const jitlink::AllocGroup &RHS) {
+ static bool isEqual(const orc::AllocGroup &LHS, const orc::AllocGroup &RHS) {
return LHS == RHS;
}
};
} // end namespace llvm
-#endif // LLVM_EXECUTIONENGINE_JITLINK_MEMORYFLAGS_H
+#endif // LLVM_EXECUTIONENGINE_ORC_SHARED_MEMORYFLAGS_H
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/Shared/AllocationActions.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
+#include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h"
#include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"
#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
#include "llvm/Support/Memory.h"
namespace orc {
namespace tpctypes {
-enum WireProtectionFlags : uint8_t {
- WPF_None = 0,
- WPF_Read = 1U << 0,
- WPF_Write = 1U << 1,
- WPF_Exec = 1U << 2,
- LLVM_MARK_AS_BITMASK_ENUM(WPF_Exec)
-};
-
-/// Convert from sys::Memory::ProtectionFlags
-inline WireProtectionFlags
-toWireProtectionFlags(sys::Memory::ProtectionFlags PF) {
- WireProtectionFlags WPF = WPF_None;
- if (PF & sys::Memory::MF_READ)
- WPF |= WPF_Read;
- if (PF & sys::Memory::MF_WRITE)
- WPF |= WPF_Write;
- if (PF & sys::Memory::MF_EXEC)
- WPF |= WPF_Exec;
- return WPF;
-}
-
-inline sys::Memory::ProtectionFlags
-fromWireProtectionFlags(WireProtectionFlags WPF) {
- int PF = 0;
- if (WPF & WPF_Read)
- PF |= sys::Memory::MF_READ;
- if (WPF & WPF_Write)
- PF |= sys::Memory::MF_WRITE;
- if (WPF & WPF_Exec)
- PF |= sys::Memory::MF_EXEC;
- return static_cast<sys::Memory::ProtectionFlags>(PF);
-}
-
-inline std::string getWireProtectionFlagsStr(WireProtectionFlags WPF) {
- std::string Result;
- Result += (WPF & WPF_Read) ? 'R' : '-';
- Result += (WPF & WPF_Write) ? 'W' : '-';
- Result += (WPF & WPF_Exec) ? 'X' : '-';
- return Result;
-}
-
struct SegFinalizeRequest {
- WireProtectionFlags Prot;
+ AllocGroup AG;
ExecutorAddr Addr;
uint64_t Size;
ArrayRef<char> Content;
};
struct SharedMemorySegFinalizeRequest {
- WireProtectionFlags Prot;
+ AllocGroup AG;
ExecutorAddr Addr;
uint64_t Size;
};
namespace shared {
-class SPSMemoryProtectionFlags {};
+class SPSAllocGroup {};
using SPSSegFinalizeRequest =
- SPSTuple<SPSMemoryProtectionFlags, SPSExecutorAddr, uint64_t,
- SPSSequence<char>>;
+ SPSTuple<SPSAllocGroup, SPSExecutorAddr, uint64_t, SPSSequence<char>>;
using SPSFinalizeRequest = SPSTuple<SPSSequence<SPSSegFinalizeRequest>,
SPSSequence<SPSAllocActionCallPair>>;
using SPSSharedMemorySegFinalizeRequest =
- SPSTuple<SPSMemoryProtectionFlags, SPSExecutorAddr, uint64_t>;
+ SPSTuple<SPSAllocGroup, SPSExecutorAddr, uint64_t>;
using SPSSharedMemoryFinalizeRequest =
SPSTuple<SPSSequence<SPSSharedMemorySegFinalizeRequest>,
using SPSMemoryAccessBufferWrite = SPSTuple<SPSExecutorAddr, SPSSequence<char>>;
-template <>
-class SPSSerializationTraits<SPSMemoryProtectionFlags,
- tpctypes::WireProtectionFlags> {
+template <> class SPSSerializationTraits<SPSAllocGroup, AllocGroup> {
+ enum WireBits {
+ ReadBit = 1 << 0,
+ WriteBit = 1 << 1,
+ ExecBit = 1 << 2,
+ FinalizeBit = 1 << 3
+ };
+
public:
- static size_t size(const tpctypes::WireProtectionFlags &WPF) {
- return SPSArgList<uint8_t>::size(static_cast<uint8_t>(WPF));
+ static size_t size(const AllocGroup &AG) {
+ // All AllocGroup values encode to the same size.
+ return SPSArgList<uint8_t>::size(uint8_t(0));
}
- static bool serialize(SPSOutputBuffer &OB,
- const tpctypes::WireProtectionFlags &WPF) {
- return SPSArgList<uint8_t>::serialize(OB, static_cast<uint8_t>(WPF));
+ static bool serialize(SPSOutputBuffer &OB, const AllocGroup &AG) {
+ uint8_t WireValue = 0;
+ if ((AG.getMemProt() & MemProt::Read) != MemProt::None)
+ WireValue |= ReadBit;
+ if ((AG.getMemProt() & MemProt::Write) != MemProt::None)
+ WireValue |= WriteBit;
+ if ((AG.getMemProt() & MemProt::Exec) != MemProt::None)
+ WireValue |= ExecBit;
+ if (AG.getMemDeallocPolicy() == MemDeallocPolicy::Finalize)
+ WireValue |= FinalizeBit;
+ return SPSArgList<uint8_t>::serialize(OB, WireValue);
}
- static bool deserialize(SPSInputBuffer &IB,
- tpctypes::WireProtectionFlags &WPF) {
+ static bool deserialize(SPSInputBuffer &IB, AllocGroup &AG) {
uint8_t Val;
if (!SPSArgList<uint8_t>::deserialize(IB, Val))
return false;
- WPF = static_cast<tpctypes::WireProtectionFlags>(Val);
+ MemProt MP = MemProt::None;
+ if (Val & ReadBit)
+ MP |= MemProt::Read;
+ if (Val & WriteBit)
+ MP |= MemProt::Write;
+ if (Val & ExecBit)
+ MP |= MemProt::Exec;
+ MemDeallocPolicy MDP = (Val & FinalizeBit) ? MemDeallocPolicy::Finalize
+ : MemDeallocPolicy::Standard;
+ AG = AllocGroup(MP, MDP);
return true;
}
};
public:
static size_t size(const tpctypes::SegFinalizeRequest &SFR) {
- return SFRAL::size(SFR.Prot, SFR.Addr, SFR.Size, SFR.Content);
+ return SFRAL::size(SFR.AG, SFR.Addr, SFR.Size, SFR.Content);
}
static bool serialize(SPSOutputBuffer &OB,
const tpctypes::SegFinalizeRequest &SFR) {
- return SFRAL::serialize(OB, SFR.Prot, SFR.Addr, SFR.Size, SFR.Content);
+ return SFRAL::serialize(OB, SFR.AG, SFR.Addr, SFR.Size, SFR.Content);
}
static bool deserialize(SPSInputBuffer &IB,
tpctypes::SegFinalizeRequest &SFR) {
- return SFRAL::deserialize(IB, SFR.Prot, SFR.Addr, SFR.Size, SFR.Content);
+ return SFRAL::deserialize(IB, SFR.AG, SFR.Addr, SFR.Size, SFR.Content);
}
};
public:
static size_t size(const tpctypes::SharedMemorySegFinalizeRequest &SFR) {
- return SFRAL::size(SFR.Prot, SFR.Addr, SFR.Size);
+ return SFRAL::size(SFR.AG, SFR.Addr, SFR.Size);
}
static bool serialize(SPSOutputBuffer &OB,
const tpctypes::SharedMemorySegFinalizeRequest &SFR) {
- return SFRAL::serialize(OB, SFR.Prot, SFR.Addr, SFR.Size);
+ return SFRAL::serialize(OB, SFR.AG, SFR.Addr, SFR.Size);
}
static bool deserialize(SPSInputBuffer &IB,
tpctypes::SharedMemorySegFinalizeRequest &SFR) {
- return SFRAL::deserialize(IB, SFR.Prot, SFR.Addr, SFR.Size);
+ return SFRAL::deserialize(IB, SFR.AG, SFR.Addr, SFR.Size);
}
};
JITLink.cpp
JITLinkGeneric.cpp
JITLinkMemoryManager.cpp
- MemoryFlags.cpp
# Formats:
Section &COFFLinkGraphBuilder::getCommonSection() {
if (!CommonSection)
- CommonSection =
- &G->createSection(CommonSectionName, MemProt::Read | MemProt::Write);
+ CommonSection = &G->createSection(CommonSectionName,
+ orc::MemProt::Read | orc::MemProt::Write);
return *CommonSection;
}
});
// Get the section's memory protection flags.
- MemProt Prot = MemProt::Read;
+ orc::MemProt Prot = orc::MemProt::Read;
if ((*Sec)->Characteristics & COFF::IMAGE_SCN_MEM_EXECUTE)
- Prot |= MemProt::Exec;
+ Prot |= orc::MemProt::Exec;
if ((*Sec)->Characteristics & COFF::IMAGE_SCN_MEM_READ)
- Prot |= MemProt::Read;
+ Prot |= orc::MemProt::Read;
if ((*Sec)->Characteristics & COFF::IMAGE_SCN_MEM_WRITE)
- Prot |= MemProt::Write;
+ Prot |= orc::MemProt::Write;
// Look for existing sections first.
auto *GraphSec = G->findSectionByName(SectionName);
Section &getCommonSection() {
if (!CommonSection)
- CommonSection =
- &G->createSection(CommonSectionName, MemProt::Read | MemProt::Write);
+ CommonSection = &G->createSection(
+ CommonSectionName, orc::MemProt::Read | orc::MemProt::Write);
return *CommonSection;
}
});
// Get the section's memory protection flags.
- MemProt Prot;
+ orc::MemProt Prot;
if (Sec.sh_flags & ELF::SHF_EXECINSTR)
- Prot = MemProt::Read | MemProt::Exec;
+ Prot = orc::MemProt::Read | orc::MemProt::Exec;
else
- Prot = MemProt::Read | MemProt::Write;
+ Prot = orc::MemProt::Read | orc::MemProt::Write;
// Look for existing sections first.
auto *GraphSec = G->findSectionByName(*Name);
private:
Section &getTLSInfoSection(LinkGraph &G) {
if (!TLSInfoTable)
- TLSInfoTable = &G.createSection(getSectionName(), MemProt::Read);
+ TLSInfoTable = &G.createSection(getSectionName(), orc::MemProt::Read);
return *TLSInfoTable;
}
private:
Section &getTLSDescSection(LinkGraph &G) {
if (!GOTSection)
- GOTSection = &G.createSection(getSectionName(), MemProt::Read);
+ GOTSection = &G.createSection(getSectionName(), orc::MemProt::Read);
return *GOTSection;
}
private:
Section &getGOTSection() const {
if (!GOTSection)
- GOTSection = &G.createSection("$__GOT", MemProt::Read);
+ GOTSection = &G.createSection("$__GOT", orc::MemProt::Read);
return *GOTSection;
}
Section &getStubsSection() const {
if (!StubsSection)
StubsSection =
- &G.createSection("$__STUBS", MemProt::Read | MemProt::Exec);
+ &G.createSection("$__STUBS", orc::MemProt::Read | orc::MemProt::Exec);
return *StubsSection;
}
private:
Section &getTLSInfoSection(LinkGraph &G) {
if (!TLSInfoTable)
- TLSInfoTable = &G.createSection(ELFTLSInfoSectionName, MemProt::Read);
+ TLSInfoTable =
+ &G.createSection(ELFTLSInfoSectionName, orc::MemProt::Read);
return *TLSInfoTable;
}
inconvertibleErrorCode());
uint64_t SegSize = alignTo(Seg.ContentSize + Seg.ZeroFillSize, PageSize);
- if (AG.getMemDeallocPolicy() == MemDeallocPolicy::Standard)
+ if (AG.getMemDeallocPolicy() == orc::MemDeallocPolicy::Standard)
SegsSizes.StandardSegs += SegSize;
else
SegsSizes.FinalizeSegs += SegSize;
const JITLinkDylib *JD, SegmentMap Segments,
OnCreatedFunction OnCreated) {
- static_assert(AllocGroup::NumGroups == 16,
+ static_assert(orc::AllocGroup::NumGroups == 16,
"AllocGroup has changed. Section names below must be updated");
StringRef AGSectionNames[] = {
"__---.standard", "__R--.standard", "__-W-.standard", "__RW-.standard",
auto G =
std::make_unique<LinkGraph>("", Triple(), 0, support::native, nullptr);
- AllocGroupSmallMap<Block *> ContentBlocks;
+ orc::AllocGroupSmallMap<Block *> ContentBlocks;
orc::ExecutorAddr NextAddr(0x100000);
for (auto &KV : Segments) {
SimpleSegmentAlloc::operator=(SimpleSegmentAlloc &&) = default;
SimpleSegmentAlloc::~SimpleSegmentAlloc() = default;
-SimpleSegmentAlloc::SegmentInfo SimpleSegmentAlloc::getSegInfo(AllocGroup AG) {
+SimpleSegmentAlloc::SegmentInfo
+SimpleSegmentAlloc::getSegInfo(orc::AllocGroup AG) {
auto I = ContentBlocks.find(AG);
if (I != ContentBlocks.end()) {
auto &B = *I->second;
}
SimpleSegmentAlloc::SimpleSegmentAlloc(
- std::unique_ptr<LinkGraph> G, AllocGroupSmallMap<Block *> ContentBlocks,
+ std::unique_ptr<LinkGraph> G,
+ orc::AllocGroupSmallMap<Block *> ContentBlocks,
std::unique_ptr<JITLinkMemoryManager::InFlightAlloc> Alloc)
: G(std::move(G)), ContentBlocks(std::move(ContentBlocks)),
Alloc(std::move(Alloc)) {}
auto &AG = KV.first;
auto &Seg = KV.second;
- auto &SegAddr = (AG.getMemDeallocPolicy() == MemDeallocPolicy::Standard)
- ? NextStandardSegAddr
- : NextFinalizeSegAddr;
+ auto &SegAddr =
+ (AG.getMemDeallocPolicy() == orc::MemDeallocPolicy::Standard)
+ ? NextStandardSegAddr
+ : NextFinalizeSegAddr;
Seg.WorkingMem = SegAddr.toPtr<char *>();
Seg.Addr = SegAddr;
Section &MachOLinkGraphBuilder::getCommonSection() {
if (!CommonSection)
- CommonSection =
- &G->createSection(CommonSectionName, MemProt::Read | MemProt::Write);
+ CommonSection = &G->createSection(CommonSectionName,
+ orc::MemProt::Read | orc::MemProt::Write);
return *CommonSection;
}
// Get prot flags.
// FIXME: Make sure this test is correct (it's probably missing cases
// as-is).
- MemProt Prot;
+ orc::MemProt Prot;
if (NSec.Flags & MachO::S_ATTR_PURE_INSTRUCTIONS)
- Prot = MemProt::Read | MemProt::Exec;
+ Prot = orc::MemProt::Read | orc::MemProt::Exec;
else
- Prot = MemProt::Read | MemProt::Write;
+ Prot = orc::MemProt::Read | orc::MemProt::Write;
auto FullyQualifiedName =
G->allocateString(StringRef(NSec.SegName) + "," + NSec.SectName);
+++ /dev/null
-//===------------- MemoryFlags.cpp - Memory allocation flags --------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ExecutionEngine/JITLink/MemoryFlags.h"
-
-#define DEBUG_TYPE "jitlink"
-
-namespace llvm {
-namespace jitlink {
-
-raw_ostream &operator<<(raw_ostream &OS, MemProt MP) {
- return OS << (((MP & MemProt::Read) != MemProt::None) ? 'R' : '-')
- << (((MP & MemProt::Write) != MemProt::None) ? 'W' : '-')
- << (((MP & MemProt::Exec) != MemProt::None) ? 'X' : '-');
-}
-
-raw_ostream &operator<<(raw_ostream &OS, MemDeallocPolicy MDP) {
- return OS << (MDP == MemDeallocPolicy::Standard ? "standard" : "finalize");
-}
-
-raw_ostream &operator<<(raw_ostream &OS, AllocGroup AG) {
- return OS << '(' << AG.getMemProt() << ", " << AG.getMemDeallocPolicy()
- << ')';
-}
-
-} // end namespace jitlink
-} // end namespace llvm
auto G = std::make_unique<jitlink::LinkGraph>(
"<COFFHeaderMU>", TT, PointerSize, Endianness,
jitlink::getGenericEdgeKindName);
- auto &HeaderSection = G->createSection("__header", jitlink::MemProt::Read);
+ auto &HeaderSection = G->createSection("__header", MemProt::Read);
auto &HeaderBlock = createHeaderBlock(*G, HeaderSection);
// Init symbol is __ImageBase symbol.
"<DSOHandleMU>", TT, PointerSize, Endianness,
jitlink::getGenericEdgeKindName);
auto &DSOHandleSection =
- G->createSection(".data.__dso_handle", jitlink::MemProt::Read);
+ G->createSection(".data.__dso_handle", MemProt::Read);
auto &DSOHandleBlock = G->createContentBlock(
DSOHandleSection, getDSOHandleContent(PointerSize), orc::ExecutorAddr(),
8, 0);
for (auto &KV : Segs) {
assert(KV.second.ContentSize <= std::numeric_limits<size_t>::max());
FR.Segments.push_back(tpctypes::SegFinalizeRequest{
- tpctypes::toWireProtectionFlags(
- toSysMemoryProtectionFlags(KV.first.getMemProt())),
+ KV.first,
KV.second.Addr,
alignTo(KV.second.ContentSize + KV.second.ZeroFillSize,
Parent.EPC.getPageSize()),
}
std::lock_guard<std::mutex> Lock(M);
- Unmapped.push_back(AllocGroup());
+ Unmapped.push_back(SectionAllocGroup());
Unmapped.back().RemoteCode = {
*TargetAllocAddr, ExecutorAddrDiff(alignTo(CodeSize, EPC.getPageSize()))};
Unmapped.back().RemoteROData = {
return;
ExecutorAddr LA(LoadAddr);
- for (auto &Alloc : llvm::reverse(Unfinalized)) {
- if (Alloc.RemoteCode.contains(LA) || Alloc.RemoteROData.contains(LA) ||
- Alloc.RemoteRWData.contains(LA)) {
- Alloc.UnfinalizedEHFrames.push_back({LA, Size});
+ for (auto &SecAllocGroup : llvm::reverse(Unfinalized)) {
+ if (SecAllocGroup.RemoteCode.contains(LA) ||
+ SecAllocGroup.RemoteROData.contains(LA) ||
+ SecAllocGroup.RemoteRWData.contains(LA)) {
+ SecAllocGroup.UnfinalizedEHFrames.push_back({LA, Size});
return;
}
}
LLVM_DEBUG(dbgs() << "Allocator " << (void *)this << " finalizing:\n");
// If there's an error then bail out here.
- std::vector<AllocGroup> Allocs;
+ std::vector<SectionAllocGroup> SecAllocGroups;
{
std::lock_guard<std::mutex> Lock(M);
if (ErrMsg && !this->ErrMsg.empty()) {
*ErrMsg = std::move(this->ErrMsg);
return true;
}
- std::swap(Allocs, Unfinalized);
+ std::swap(SecAllocGroups, Unfinalized);
}
// Loop over unfinalized objects to make finalization requests.
- for (auto &ObjAllocs : Allocs) {
+ for (auto &SecAllocGroup : SecAllocGroups) {
- tpctypes::WireProtectionFlags SegProts[3] = {
- tpctypes::toWireProtectionFlags(
- static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ |
- sys::Memory::MF_EXEC)),
- tpctypes::toWireProtectionFlags(sys::Memory::MF_READ),
- tpctypes::toWireProtectionFlags(
- static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ |
- sys::Memory::MF_WRITE))};
+ MemProt SegMemProts[3] = {MemProt::Read | MemProt::Exec, MemProt::Read,
+ MemProt::Read | MemProt::Write};
- ExecutorAddrRange *RemoteAddrs[3] = {&ObjAllocs.RemoteCode,
- &ObjAllocs.RemoteROData,
- &ObjAllocs.RemoteRWData};
+ ExecutorAddrRange *RemoteAddrs[3] = {&SecAllocGroup.RemoteCode,
+ &SecAllocGroup.RemoteROData,
+ &SecAllocGroup.RemoteRWData};
- std::vector<Alloc> *SegSections[3] = {&ObjAllocs.CodeAllocs,
- &ObjAllocs.RODataAllocs,
- &ObjAllocs.RWDataAllocs};
+ std::vector<SectionAlloc> *SegSections[3] = {&SecAllocGroup.CodeAllocs,
+ &SecAllocGroup.RODataAllocs,
+ &SecAllocGroup.RWDataAllocs};
tpctypes::FinalizeRequest FR;
std::unique_ptr<char[]> AggregateContents[3];
for (unsigned I = 0; I != 3; ++I) {
FR.Segments.push_back({});
auto &Seg = FR.Segments.back();
- Seg.Prot = SegProts[I];
+ Seg.AG = SegMemProts[I];
Seg.Addr = RemoteAddrs[I]->Start;
for (auto &SecAlloc : *SegSections[I]) {
Seg.Size = alignTo(Seg.Size, SecAlloc.Align);
Seg.Content = {AggregateContents[I].get(), SecOffset};
}
- for (auto &Frame : ObjAllocs.UnfinalizedEHFrames)
+ for (auto &Frame : SecAllocGroup.UnfinalizedEHFrames)
FR.Actions.push_back(
{cantFail(
WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddrRange>>(
}
void EPCGenericRTDyldMemoryManager::mapAllocsToRemoteAddrs(
- RuntimeDyld &Dyld, std::vector<Alloc> &Allocs, ExecutorAddr NextAddr) {
+ RuntimeDyld &Dyld, std::vector<SectionAlloc> &Allocs,
+ ExecutorAddr NextAddr) {
for (auto &Alloc : Allocs) {
NextAddr.setValue(alignTo(NextAddr.getValue(), Alloc.Align));
LLVM_DEBUG({
auto G = std::make_unique<jitlink::LinkGraph>(
"<DLLIMPORT_STUBS>", TT, *PointerSize, *Endianness,
jitlink::getGenericEdgeKindName);
- jitlink::Section &Sec = G->createSection(
- getSectionName(), jitlink::MemProt::Read | jitlink::MemProt::Exec);
+ jitlink::Section &Sec =
+ G->createSection(getSectionName(), MemProt::Read | MemProt::Exec);
for (auto &KV : Resolved) {
jitlink::Symbol &Target = G->addAbsoluteSymbol(
auto G = std::make_unique<jitlink::LinkGraph>(
"<MachOHeaderMU>", TT, PointerSize, Endianness,
jitlink::getGenericEdgeKindName);
- auto &HeaderSection = G->createSection("__header", jitlink::MemProt::Read);
+ auto &HeaderSection = G->createSection("__header", MemProt::Read);
auto &HeaderBlock = createHeaderBlock(*G, HeaderSection);
// Init symbol is header-start symbol.
SI.Offset = Seg.Addr - Result->Start;
SI.ContentSize = Seg.ContentSize;
SI.ZeroFillSize = Seg.ZeroFillSize;
- SI.Prot = toSysMemoryProtectionFlags(AG.getMemProt());
+ SI.AG = AG;
SI.WorkingMem = Seg.WorkingMem;
SegInfos.push_back(SI);
ExecutorAddr MinAddr(~0ULL);
ExecutorAddr MaxAddr(0);
+ // FIXME: Release finalize lifetime segments.
for (auto &Segment : AI.Segments) {
auto Base = AI.MappingBase + Segment.Offset;
auto Size = Segment.ContentSize + Segment.ZeroFillSize;
std::memset((Base + Segment.ContentSize).toPtr<void *>(), 0,
Segment.ZeroFillSize);
- if (auto EC = sys::Memory::protectMappedMemory({Base.toPtr<void *>(), Size},
- Segment.Prot)) {
+ if (auto EC = sys::Memory::protectMappedMemory(
+ {Base.toPtr<void *>(), Size},
+ toSysMemoryProtectionFlags(Segment.AG.getMemProt()))) {
return OnInitialized(errorCodeToError(EC));
}
- if (Segment.Prot & sys::Memory::MF_EXEC)
+ if ((Segment.AG.getMemProt() & MemProt::Exec) == MemProt::Exec)
sys::Memory::InvalidateInstructionCache(Base.toPtr<void *>(), Size);
}
std::memset(Base + Segment.ContentSize, 0, Segment.ZeroFillSize);
tpctypes::SharedMemorySegFinalizeRequest SegReq;
- SegReq.Prot = tpctypes::toWireProtectionFlags(
- static_cast<sys::Memory::ProtectionFlags>(Segment.Prot));
+ SegReq.AG = Segment.AG;
SegReq.Addr = AI.MappingBase + Segment.Offset;
SegReq.Size = Segment.ContentSize + Segment.ZeroFillSize;
#if defined(LLVM_ON_UNIX)
int NativeProt = 0;
- if (Segment.Prot & tpctypes::WPF_Read)
+ if ((Segment.AG.getMemProt() & MemProt::Read) == MemProt::Read)
NativeProt |= PROT_READ;
- if (Segment.Prot & tpctypes::WPF_Write)
+ if ((Segment.AG.getMemProt() & MemProt::Write) == MemProt::Write)
NativeProt |= PROT_WRITE;
- if (Segment.Prot & tpctypes::WPF_Exec)
+ if ((Segment.AG.getMemProt() & MemProt::Exec) == MemProt::Exec)
NativeProt |= PROT_EXEC;
if (mprotect(Segment.Addr.toPtr<void *>(), Segment.Size, NativeProt))
#endif
- if (Segment.Prot & tpctypes::WPF_Exec)
+ if ((Segment.AG.getMemProt() & MemProt::Exec) == MemProt::Exec)
sys::Memory::InvalidateInstructionCache(Segment.Addr.toPtr<void *>(),
Segment.Size);
}
assert(Seg.Size <= std::numeric_limits<size_t>::max());
if (auto EC = sys::Memory::protectMappedMemory(
{Mem, static_cast<size_t>(Seg.Size)},
- tpctypes::fromWireProtectionFlags(Seg.Prot)))
+ toSysMemoryProtectionFlags(Seg.AG.getMemProt())))
return BailOut(errorCodeToError(EC));
- if (Seg.Prot & tpctypes::WPF_Exec)
+ if ((Seg.AG.getMemProt() & MemProt::Exec) == MemProt::Exec)
sys::Memory::InvalidateInstructionCache(Mem, Seg.Size);
}
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec1 = G.createSection("__data.1", MemProt::Read | MemProt::Write);
+ auto &Sec1 =
+ G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
orc::ExecutorAddr B1Addr(0x1000);
auto &B1 = G.createContentBlock(Sec1, BlockContent, B1Addr, 8, 0);
auto &S1 = G.addDefinedSymbol(B1, 4, "S1", 4, Linkage::Strong, Scope::Default,
// Check that we can iterate over blocks within Sections and across sections.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec1 = G.createSection("__data.1", MemProt::Read | MemProt::Write);
+ auto &Sec1 =
+ G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
orc::ExecutorAddr B1Addr(0x1000);
auto &B1 = G.createContentBlock(Sec1, BlockContent, B1Addr, 8, 0);
orc::ExecutorAddr B2Addr(0x2000);
auto &S2 = G.addDefinedSymbol(B2, 4, "S2", 4, Linkage::Strong, Scope::Default,
false, false);
- auto &Sec2 = G.createSection("__data.2", MemProt::Read | MemProt::Write);
+ auto &Sec2 =
+ G.createSection("__data.2", orc::MemProt::Read | orc::MemProt::Write);
orc::ExecutorAddr B3Addr(0x3000);
auto &B3 = G.createContentBlock(Sec2, BlockContent, B3Addr, 8, 0);
orc::ExecutorAddr B4Addr(0x4000);
// Check that we can make a defined symbol external.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec = G.createSection("__data", MemProt::Read | MemProt::Write);
+ auto &Sec =
+ G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
// Create an initial block.
orc::ExecutorAddr BAddr(0x1000);
// Check that we can make defined and absolute symbols external.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec = G.createSection("__data", MemProt::Read | MemProt::Write);
+ auto &Sec =
+ G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
// Create an initial block.
auto &B1 =
// Check that we can make defined and external symbols absolute.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec = G.createSection("__data", MemProt::Read | MemProt::Write);
+ auto &Sec =
+ G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
// Create an initial block.
auto &B1 =
// Check that we can make an external symbol defined.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec = G.createSection("__data", MemProt::Read | MemProt::Write);
+ auto &Sec =
+ G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
// Create an initial block.
orc::ExecutorAddr B1Addr(0x1000);
// Check that we can transfer a defined symbol from one block to another.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec = G.createSection("__data", MemProt::Read | MemProt::Write);
+ auto &Sec =
+ G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
// Create initial blocks.
orc::ExecutorAddr B1Addr(0x1000);
// section to another.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec1 = G.createSection("__data.1", MemProt::Read | MemProt::Write);
- auto &Sec2 = G.createSection("__data.2", MemProt::Read | MemProt::Write);
+ auto &Sec1 =
+ G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
+ auto &Sec2 =
+ G.createSection("__data.2", orc::MemProt::Read | orc::MemProt::Write);
// Create blocks in each section.
orc::ExecutorAddr B1Addr(0x1000);
// section to another.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec1 = G.createSection("__data.1", MemProt::Read | MemProt::Write);
- auto &Sec2 = G.createSection("__data.2", MemProt::Read | MemProt::Write);
+ auto &Sec1 =
+ G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
+ auto &Sec2 =
+ G.createSection("__data.2", orc::MemProt::Read | orc::MemProt::Write);
// Create an initial block.
orc::ExecutorAddr B1Addr(0x1000);
// section to another.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec1 = G.createSection("__data.1", MemProt::Read | MemProt::Write);
- auto &Sec2 = G.createSection("__data.2", MemProt::Read | MemProt::Write);
- auto &Sec3 = G.createSection("__data.3", MemProt::Read | MemProt::Write);
+ auto &Sec1 =
+ G.createSection("__data.1", orc::MemProt::Read | orc::MemProt::Write);
+ auto &Sec2 =
+ G.createSection("__data.2", orc::MemProt::Read | orc::MemProt::Write);
+ auto &Sec3 =
+ G.createSection("__data.3", orc::MemProt::Read | orc::MemProt::Write);
// Create an initial block.
orc::ExecutorAddr B1Addr(0x1000);
// Check that the LinkGraph::splitBlock test works as expected.
LinkGraph G("foo", Triple("x86_64-apple-darwin"), 8, support::little,
getGenericEdgeKindName);
- auto &Sec = G.createSection("__data", MemProt::Read | MemProt::Write);
+ auto &Sec =
+ G.createSection("__data", orc::MemProt::Read | orc::MemProt::Write);
// Create the block to split.
orc::ExecutorAddr B1Addr(0x1000);
assert(Seg.Size <= std::numeric_limits<size_t>::max());
if (auto EC = sys::Memory::protectMappedMemory(
{Mem, static_cast<size_t>(Seg.Size)},
- tpctypes::fromWireProtectionFlags(Seg.Prot)))
+ toSysMemoryProtectionFlags(Seg.AG.getMemProt())))
return errorCodeToError(EC);
- if (Seg.Prot & tpctypes::WPF_Exec)
+ if ((Seg.AG.getMemProt() & MemProt::Exec) != MemProt::Exec)
sys::Memory::InvalidateInstructionCache(Mem, Seg.Size);
}
return Error::success();
StringRef Hello = "hello";
auto SSA = jitlink::SimpleSegmentAlloc::Create(
- *MemMgr, nullptr, {{jitlink::MemProt::Read, {Hello.size(), Align(1)}}});
+ *MemMgr, nullptr, {{MemProt::Read, {Hello.size(), Align(1)}}});
EXPECT_THAT_EXPECTED(SSA, Succeeded());
- auto SegInfo = SSA->getSegInfo(jitlink::MemProt::Read);
+ auto SegInfo = SSA->getSegInfo(MemProt::Read);
memcpy(SegInfo.WorkingMem.data(), Hello.data(), Hello.size());
auto FA = SSA->finalize();
StringRef Hello = "hello";
auto SSA1 = jitlink::SimpleSegmentAlloc::Create(
- *MemMgr, nullptr, {{jitlink::MemProt::Read, {Hello.size(), Align(1)}}});
+ *MemMgr, nullptr, {{MemProt::Read, {Hello.size(), Align(1)}}});
EXPECT_THAT_EXPECTED(SSA1, Succeeded());
EXPECT_EQ(Counter->ReserveCount, 1);
EXPECT_EQ(Counter->InitCount, 0);
- auto SegInfo1 = SSA1->getSegInfo(jitlink::MemProt::Read);
+ auto SegInfo1 = SSA1->getSegInfo(MemProt::Read);
memcpy(SegInfo1.WorkingMem.data(), Hello.data(), Hello.size());
auto FA1 = SSA1->finalize();
EXPECT_EQ(Counter->InitCount, 1);
auto SSA2 = jitlink::SimpleSegmentAlloc::Create(
- *MemMgr, nullptr, {{jitlink::MemProt::Read, {Hello.size(), Align(1)}}});
+ *MemMgr, nullptr, {{MemProt::Read, {Hello.size(), Align(1)}}});
EXPECT_THAT_EXPECTED(SSA2, Succeeded());
// last reservation should be reused
EXPECT_EQ(Counter->ReserveCount, 1);
EXPECT_EQ(Counter->InitCount, 1);
- auto SegInfo2 = SSA2->getSegInfo(jitlink::MemProt::Read);
+ auto SegInfo2 = SSA2->getSegInfo(MemProt::Read);
memcpy(SegInfo2.WorkingMem.data(), Hello.data(), Hello.size());
auto FA2 = SSA2->finalize();
EXPECT_THAT_EXPECTED(FA2, Succeeded());
std::move(Mapper));
auto SSA1 = jitlink::SimpleSegmentAlloc::Create(
- *MemMgr, nullptr, {{jitlink::MemProt::Read, {1024, Align(1)}}});
+ *MemMgr, nullptr, {{MemProt::Read, {1024, Align(1)}}});
EXPECT_THAT_EXPECTED(SSA1, Succeeded());
- auto SegInfo1 = SSA1->getSegInfo(jitlink::MemProt::Read);
+ auto SegInfo1 = SSA1->getSegInfo(MemProt::Read);
ExecutorAddr TargetAddr1(SegInfo1.Addr);
auto FA1 = SSA1->finalize();
EXPECT_THAT_EXPECTED(FA1, Succeeded());
auto SSA2 = jitlink::SimpleSegmentAlloc::Create(
- *MemMgr, nullptr, {{jitlink::MemProt::Read, {1024, Align(1)}}});
+ *MemMgr, nullptr, {{MemProt::Read, {1024, Align(1)}}});
EXPECT_THAT_EXPECTED(SSA2, Succeeded());
auto FA2 = SSA2->finalize();
EXPECT_THAT_EXPECTED(FA2, Succeeded());
EXPECT_THAT_ERROR(std::move(Err3), Succeeded());
auto SSA3 = jitlink::SimpleSegmentAlloc::Create(
- *MemMgr, nullptr, {{jitlink::MemProt::Read, {2048, Align(1)}}});
+ *MemMgr, nullptr, {{MemProt::Read, {2048, Align(1)}}});
EXPECT_THAT_EXPECTED(SSA3, Succeeded());
- auto SegInfo3 = SSA3->getSegInfo(jitlink::MemProt::Read);
+ auto SegInfo3 = SSA3->getSegInfo(MemProt::Read);
ExecutorAddr TargetAddr3(SegInfo3.Addr);
auto FA3 = SSA3->finalize();
Seg1.Offset = 0;
Seg1.ContentSize = HW.size();
Seg1.ZeroFillSize = PageSize - Seg1.ContentSize;
- Seg1.Prot = sys::Memory::MF_READ | sys::Memory::MF_WRITE;
+ Seg1.AG = MemProt::Read | MemProt::Write;
Alloc1.MappingBase = Mem1->Start;
Alloc1.Segments.push_back(Seg1);
Seg2.Offset = PageSize;
Seg2.ContentSize = HW.size();
Seg2.ZeroFillSize = PageSize - Seg2.ContentSize;
- Seg2.Prot = sys::Memory::MF_READ | sys::Memory::MF_WRITE;
+ Seg2.AG = MemProt::Read | MemProt::Write;
Alloc2.MappingBase = Mem1->Start;
Alloc2.Segments.push_back(Seg2);
Seg3.Offset = 0;
Seg3.ContentSize = HW.size();
Seg3.ZeroFillSize = PageSize - Seg3.ContentSize;
- Seg3.Prot = sys::Memory::MF_READ | sys::Memory::MF_WRITE;
+ Seg3.AG = MemProt::Read | MemProt::Write;
Alloc3.MappingBase = Mem2->Start;
Alloc3.Segments.push_back(Seg3);
SI.Offset = 0;
SI.ContentSize = TestString.size() + 1;
SI.ZeroFillSize = PageSize - SI.ContentSize;
- SI.Prot = sys::Memory::MF_READ | sys::Memory::MF_WRITE;
+ SI.AG = MemProt::Read | MemProt::Write;
AI.MappingBase = Reservation.Start;
AI.Segments.push_back(SI);
tpctypes::FinalizeRequest FR;
FR.Segments.push_back(
- tpctypes::SegFinalizeRequest{tpctypes::WPF_Read | tpctypes::WPF_Write,
+ tpctypes::SegFinalizeRequest{MemProt::Read | MemProt::Write,
*Mem,
AllocSize,
{HW.data(), HW.size() + 1}});