22 for (
auto &Iter : AllocationSites) {
23 auto &AllocSite = Iter.second;
24 for (
auto &
Alloc : AllocSite.Allocations) {
33 AllocationSites.clear();
37 size_t NumElements,
unsigned EvalID,
47 return allocate(D, EvalID, AllocForm);
51 size_t NumElements,
unsigned EvalID,
61 return allocate(D, EvalID, AllocForm);
71 llvm::erase_if(DeadAllocations, [](Allocation &
Alloc) ->
bool {
72 return !
Alloc.block()->hasPointers();
77 auto *B =
new (Memory.get())
Block(EvalID, D,
false);
78 B->invokeCtorNoMemset();
86 ID->IsFieldMutable =
false;
88 ID->IsInitialized =
false;
89 ID->IsVolatile =
false;
97 if (
auto It = AllocationSites.find(D->
asExpr());
98 It != AllocationSites.end()) {
99 It->second.Allocations.emplace_back(std::move(Memory));
100 B->setDynAllocId(It->second.NumAllocs);
101 ++It->second.NumAllocs;
103 AllocationSites.insert(
104 {D->
asExpr(), AllocationSite(std::move(Memory), AllocForm)});
107 assert(B->isDynamic());
112 const Block *BlockToDelete) {
113 auto It = AllocationSites.find(Source);
114 if (It == AllocationSites.end())
117 auto &Site = It->second;
118 assert(!Site.empty());
121 auto *AllocIt = llvm::find_if(Site.Allocations, [&](
const Allocation &A) {
122 return BlockToDelete == A.block();
127 if (AllocIt == Site.Allocations.end())
130 Block *B = AllocIt->block();
142 B->AccessFlags |= Block::DeadFlag;
143 DeadAllocations.push_back(std::move(*AllocIt));
144 Site.Allocations.erase(AllocIt);
146 if (Site.size() == 0)
147 AllocationSites.erase(It);
152 Site.Allocations.erase(AllocIt);
154 AllocationSites.erase(It);
This represents one expression.
A memory block, either on the stack or in the heap.
void invokeDtor()
Invokes the Destructor.
bool isInitialized() const
Returns whether the data of this block has been initialized via invoking the Ctor func.
bool hasPointers() const
Checks if the block has any live pointers.
void removePointers()
Make all pointers that currently point to this block point to nullptr.
Block * allocate(const Descriptor *D, unsigned EvalID, Form AllocForm)
Allocate ONE element of the given descriptor.
bool deallocate(const Expr *Source, const Block *BlockToDelete)
Deallocate the given source+block combination.
PrimType
Enumeration of the primitive types of the VM.
bool Alloc(InterpState &S, CodePtr OpPC, const Descriptor *Desc)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
Describes a memory block created by an allocation site.
const bool IsConst
Flag indicating if the block is mutable.
unsigned getAllocSize() const
Returns the allocated size, including metadata.
bool isCompositeArray() const
Checks if the descriptor is of an array of composites.
unsigned getMetadataSize() const
Returns the size of the metadata.
static constexpr MetadataSize InlineDescMD
const Expr * asExpr() const
Inline descriptor embedded in structures and arrays.