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,
48 return allocate(D, EvalID, AllocForm);
52 size_t NumElements,
unsigned EvalID,
62 return allocate(D, EvalID, AllocForm);
72 llvm::erase_if(DeadAllocations, [](Allocation &
Alloc) ->
bool {
73 return !
Alloc.block()->hasPointers();
78 auto *B =
new (Memory.get())
Block(EvalID, D,
false);
87 ID->IsFieldMutable =
false;
89 ID->IsInitialized =
false;
90 ID->IsVolatile =
false;
98 if (
auto It = AllocationSites.find(D->
asExpr());
99 It != AllocationSites.end()) {
100 It->second.Allocations.emplace_back(std::move(Memory));
101 B->setDynAllocId(It->second.NumAllocs);
102 ++It->second.NumAllocs;
104 AllocationSites.insert(
105 {D->
asExpr(), AllocationSite(std::move(Memory), AllocForm)});
108 assert(B->isDynamic());
114 auto It = AllocationSites.find(Source);
115 if (It == AllocationSites.end())
118 auto &Site = It->second;
119 assert(!Site.empty());
122 auto *AllocIt = llvm::find_if(Site.Allocations, [&](
const Allocation &A) {
123 return BlockToDelete == A.block();
126 assert(AllocIt != Site.Allocations.end());
128 Block *B = AllocIt->block();
140 B->AccessFlags |= Block::DeadFlag;
141 DeadAllocations.push_back(std::move(*AllocIt));
142 Site.Allocations.erase(AllocIt);
144 if (Site.size() == 0)
145 AllocationSites.erase(It);
150 Site.Allocations.erase(AllocIt);
152 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.