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,
42 allocateDescriptor(Source,
nullptr,
T, NumElements,
false,
46 return allocate(D, EvalID, AllocForm);
50 size_t NumElements,
unsigned EvalID,
56 ElementDesc->
asExpr(),
nullptr, ElementDesc, NumElements,
58 return allocate(D, EvalID, AllocForm);
68 llvm::erase_if(DeadAllocations, [](Allocation &
Alloc) ->
bool {
69 return !
Alloc.block()->hasPointers();
72 auto Memory = std::make_unique<std::byte[]>(
76 B->invokeCtorNoMemset();
82 ID->IsFieldMutable =
false;
84 ID->IsInitialized =
false;
85 ID->IsVolatile =
false;
93 if (
auto It = AllocationSites.find(D->
asExpr());
94 It != AllocationSites.end()) {
95 It->second.Allocations.emplace_back(std::move(Memory));
96 B->setDynAllocId(It->second.NumAllocs);
97 ++It->second.NumAllocs;
99 AllocationSites.insert(
100 {D->
asExpr(), AllocationSite(std::move(Memory), AllocForm)});
103 assert(B->isDynamic());
108 const Block *BlockToDelete) {
109 auto It = AllocationSites.find(Source);
110 if (It == AllocationSites.end())
113 auto &Site = It->second;
114 assert(!Site.empty());
117 auto *AllocIt = llvm::find_if(Site.Allocations, [&](
const Allocation &A) {
118 return BlockToDelete == A.block();
123 if (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.
static constexpr uint8_t InlineDescMD
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.
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.
const Expr * asExpr() const
Inline descriptor embedded in structures and arrays.