21 for (
auto &Iter : AllocationSites) {
22 auto &AllocSite = Iter.second;
23 for (
auto &
Alloc : AllocSite.Allocations) {
32 AllocationSites.clear();
36 size_t NumElements,
unsigned EvalID,
41 allocateDescriptor(Source,
nullptr,
T, NumElements,
false,
45 return allocate(D, EvalID, AllocForm);
49 size_t NumElements,
unsigned EvalID,
55 ElementDesc->
asExpr(),
nullptr, ElementDesc, NumElements,
57 return allocate(D, EvalID, AllocForm);
67 llvm::erase_if(DeadAllocations, [](Allocation &
Alloc) ->
bool {
68 return !
Alloc.block()->hasPointers();
74 B->invokeCtorNoMemset();
83 if (
auto It = AllocationSites.find(D->
asExpr());
84 It != AllocationSites.end()) {
85 It->second.Allocations.emplace_back(std::move(
Memory));
86 B->setDynAllocId(It->second.NumAllocs);
87 ++It->second.NumAllocs;
89 AllocationSites.insert(
90 {D->
asExpr(), AllocationSite(std::move(
Memory), AllocForm)});
93 assert(B->isDynamic());
98 const Block *BlockToDelete) {
99 auto It = AllocationSites.find(Source);
100 if (It == AllocationSites.end())
103 auto &Site = It->second;
104 assert(!Site.empty());
107 auto *AllocIt = llvm::find_if(Site.Allocations, [&](
const Allocation &A) {
108 return BlockToDelete == A.block();
113 if (AllocIt == Site.Allocations.end())
116 Block *B = AllocIt->block();
129 DeadAllocations.push_back(std::move(*AllocIt));
130 Site.Allocations.erase(AllocIt);
132 if (Site.size() == 0)
133 AllocationSites.erase(It);
138 Site.Allocations.erase(AllocIt);
140 AllocationSites.erase(It);
This represents one expression.
A memory block, either on the stack or in the heap.
static unsigned allocSize(const Descriptor *D, BlockKind K)
Number of bytes needed to allocate the block.
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)
Top level wrappers for InstallAPI frontend operations.
const FunctionProtoType * T
Describes a memory block created by an allocation site.
bool isCompositeArray() const
Checks if the descriptor is of an array of composites.
const Expr * asExpr() const
void setLifetime(Lifetime L)