13
13
#ifndef LLVM_EXECUTIONENGINE_JITLINK_JITLINK_H
14
14
#define LLVM_EXECUTIONENGINE_JITLINK_JITLINK_H
15
15
16
+ #include " JITLinkMemoryManager.h"
16
17
#include " llvm/ADT/DenseMap.h"
17
18
#include " llvm/ADT/DenseSet.h"
18
19
#include " llvm/ADT/Optional.h"
19
20
#include " llvm/ADT/STLExtras.h"
20
21
#include " llvm/ADT/Triple.h"
21
- #include " llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
22
- #include " llvm/ExecutionEngine/JITLink/MemoryFlags.h"
23
22
#include " llvm/ExecutionEngine/JITSymbol.h"
24
23
#include " llvm/Support/Allocator.h"
25
24
#include " llvm/Support/Endian.h"
26
25
#include " llvm/Support/Error.h"
27
26
#include " llvm/Support/FormatVariadic.h"
28
27
#include " llvm/Support/MathExtras.h"
28
+ #include " llvm/Support/Memory.h"
29
29
#include " llvm/Support/MemoryBuffer.h"
30
30
31
31
#include < map>
@@ -225,15 +225,14 @@ class Block : public Addressable {
225
225
226
226
// / Get the content for this block. Block must not be a zero-fill block.
227
227
ArrayRef<char > getContent () const {
228
- assert (Data && " Block does not contain content" );
228
+ assert (Data && " Section does not contain content" );
229
229
return ArrayRef<char >(Data, Size);
230
230
}
231
231
232
232
// / Set the content for this block.
233
233
// / Caller is responsible for ensuring the underlying bytes are not
234
234
// / deallocated while pointed to by this block.
235
235
void setContent (ArrayRef<char > Content) {
236
- assert (Content.data () && " Setting null content" );
237
236
Data = Content.data ();
238
237
Size = Content.size ();
239
238
ContentMutable = false ;
@@ -252,7 +251,6 @@ class Block : public Addressable {
252
251
// / to call this on a block with immutable content -- consider using
253
252
// / getMutableContent instead.
254
253
MutableArrayRef<char > getAlreadyMutableContent () {
255
- assert (Data && " Block does not contain content" );
256
254
assert (ContentMutable && " Content is not mutable" );
257
255
return MutableArrayRef<char >(const_cast <char *>(Data), Size);
258
256
}
@@ -262,7 +260,6 @@ class Block : public Addressable {
262
260
// / The caller is responsible for ensuring that the memory pointed to by
263
261
// / MutableContent is not deallocated while pointed to by this block.
264
262
void setMutableContent (MutableArrayRef<char > MutableContent) {
265
- assert (MutableContent.data () && " Setting null content" );
266
263
Data = MutableContent.data ();
267
264
Size = MutableContent.size ();
268
265
ContentMutable = true ;
@@ -298,7 +295,6 @@ class Block : public Addressable {
298
295
// / Add an edge to this block.
299
296
void addEdge (Edge::Kind K, Edge::OffsetT Offset, Symbol &Target,
300
297
Edge::AddendT Addend) {
301
- assert (!isZeroFill () && " Adding edge to zero-fill block?" );
302
298
Edges.push_back (Edge (K, Offset, Target, Addend));
303
299
}
304
300
@@ -644,7 +640,8 @@ class Section {
644
640
friend class LinkGraph ;
645
641
646
642
private:
647
- Section (StringRef Name, MemProt Prot, SectionOrdinal SecOrdinal)
643
+ Section (StringRef Name, sys::Memory::ProtectionFlags Prot,
644
+ SectionOrdinal SecOrdinal)
648
645
: Name(Name), Prot(Prot), SecOrdinal(SecOrdinal) {}
649
646
650
647
using SymbolSet = DenseSet<Symbol *>;
@@ -669,16 +666,12 @@ class Section {
669
666
StringRef getName () const { return Name; }
670
667
671
668
// / Returns the protection flags for this section.
672
- MemProt getMemProt () const { return Prot; }
669
+ sys::Memory::ProtectionFlags getProtectionFlags () const { return Prot; }
673
670
674
671
// / Set the protection flags for this section.
675
- void setMemProt (MemProt Prot) { this ->Prot = Prot; }
676
-
677
- // / Get the deallocation policy for this section.
678
- MemDeallocPolicy getMemDeallocPolicy () const { return MDP; }
679
-
680
- // / Set the deallocation policy for this section.
681
- void setMemDeallocPolicy (MemDeallocPolicy MDP) { this ->MDP = MDP; }
672
+ void setProtectionFlags (sys::Memory::ProtectionFlags Prot) {
673
+ this ->Prot = Prot;
674
+ }
682
675
683
676
// / Returns the ordinal for this section.
684
677
SectionOrdinal getOrdinal () const { return SecOrdinal; }
@@ -693,7 +686,6 @@ class Section {
693
686
return make_range (Blocks.begin (), Blocks.end ());
694
687
}
695
688
696
- // / Returns the number of blocks in this section.
697
689
BlockSet::size_type blocks_size () const { return Blocks.size (); }
698
690
699
691
// / Returns an iterator over the symbols defined in this section.
@@ -742,8 +734,7 @@ class Section {
742
734
}
743
735
744
736
StringRef Name;
745
- MemProt Prot;
746
- MemDeallocPolicy MDP = MemDeallocPolicy::Standard;
737
+ sys::Memory::ProtectionFlags Prot;
747
738
SectionOrdinal SecOrdinal = 0 ;
748
739
BlockSet Blocks;
749
740
SymbolSet Symbols;
@@ -925,11 +916,6 @@ class LinkGraph {
925
916
: Name(std::move(Name)), TT(TT), PointerSize(PointerSize),
926
917
Endianness (Endianness), GetEdgeKindName(std::move(GetEdgeKindName)) {}
927
918
928
- LinkGraph (const LinkGraph &) = delete;
929
- LinkGraph &operator =(const LinkGraph &) = delete ;
930
- LinkGraph (LinkGraph &&) = delete;
931
- LinkGraph &operator =(LinkGraph &&) = delete ;
932
-
933
919
// / Returns the name of this graph (usually the name of the original
934
920
// / underlying MemoryBuffer).
935
921
const std::string &getName () const { return Name; }
@@ -976,7 +962,7 @@ class LinkGraph {
976
962
}
977
963
978
964
// / Create a section with the given name, protection flags, and alignment.
979
- Section &createSection (StringRef Name, MemProt Prot) {
965
+ Section &createSection (StringRef Name, sys::Memory::ProtectionFlags Prot) {
980
966
assert (llvm::find_if (Sections,
981
967
[&](std::unique_ptr<Section> &Sec) {
982
968
return Sec->getName () == Name;
@@ -1364,13 +1350,6 @@ class LinkGraph {
1364
1350
Sections.erase (I);
1365
1351
}
1366
1352
1367
- // / Accessor for the AllocActions object for this graph. This can be used to
1368
- // / register allocation action calls prior to finalization.
1369
- // /
1370
- // / Accessing this object after finalization will result in undefined
1371
- // / behavior.
1372
- JITLinkMemoryManager::AllocActions &allocActions () { return AAs; }
1373
-
1374
1353
// / Dump the graph.
1375
1354
void dump (raw_ostream &OS);
1376
1355
@@ -1387,7 +1366,6 @@ class LinkGraph {
1387
1366
SectionList Sections;
1388
1367
ExternalSymbolSet ExternalSymbols;
1389
1368
ExternalSymbolSet AbsoluteSymbols;
1390
- JITLinkMemoryManager::AllocActions AAs;
1391
1369
};
1392
1370
1393
1371
inline MutableArrayRef<char > Block::getMutableContent (LinkGraph &G) {
@@ -1677,7 +1655,8 @@ class JITLinkContext {
1677
1655
// / finalized (i.e. emitted to memory and memory permissions set). If all of
1678
1656
// / this objects dependencies have also been finalized then the code is ready
1679
1657
// / to run.
1680
- virtual void notifyFinalized (JITLinkMemoryManager::FinalizedAlloc Alloc) = 0;
1658
+ virtual void
1659
+ notifyFinalized (std::unique_ptr<JITLinkMemoryManager::Allocation> A) = 0 ;
1681
1660
1682
1661
// / Called by JITLink prior to linking to determine whether default passes for
1683
1662
// / the target should be added. The default implementation returns true.
0 commit comments