23 for (
auto &Iter : AllocationSites) {
24 auto &AllocSite = Iter.second;
25 for (
auto &
Alloc : AllocSite.Allocations) {
34 AllocationSites.clear();
38 size_t NumElements,
unsigned EvalID,
46 return allocate(D, EvalID, AllocForm);
50 size_t NumElements,
unsigned EvalID,
60 return allocate(D, EvalID, AllocForm);
70 llvm::erase_if(DeadAllocations, [](Allocation &
Alloc) ->
bool {
71 return !
Alloc.block()->hasPointers();
76 auto *B =
new (Memory.get())
Block(EvalID, D,
false);
85 ID->IsFieldMutable =
false;
87 ID->IsInitialized =
false;
88 ID->IsVolatile =
false;
96 if (
auto It = AllocationSites.find(D->
asExpr());
97 It != AllocationSites.end()) {
98 It->second.Allocations.emplace_back(std::move(Memory));
99 B->setDynAllocId(It->second.NumAllocs);
100 ++It->second.NumAllocs;
102 AllocationSites.insert(
103 {D->
asExpr(), AllocationSite(std::move(Memory), AllocForm)});
106 assert(B->isDynamic());
112 auto It = AllocationSites.find(Source);
113 if (It == AllocationSites.end())
116 auto &Site = It->second;
117 assert(!Site.empty());
120 auto *AllocIt = llvm::find_if(Site.Allocations, [&](
const Allocation &A) {
121 return BlockToDelete == A.block();
124 assert(AllocIt != Site.Allocations.end());
126 Block *B = AllocIt->block();
138 B->AccessFlags |= Block::DeadFlag;
139 DeadAllocations.push_back(std::move(*AllocIt));
140 Site.Allocations.erase(AllocIt);
142 if (Site.size() == 0)
143 AllocationSites.erase(It);
148 Site.Allocations.erase(AllocIt);
150 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.
bool deallocate(const Expr *Source, const Block *BlockToDelete, InterpState &S)
Deallocate the given source+block combination.
Block * allocate(const Descriptor *D, unsigned EvalID, Form AllocForm)
Allocate ONE element of the given descriptor.
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.
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.