|
clang 22.0.0git
|
Manages dynamic memory allocations done during bytecode interpretation. More...
Public Types | |
| enum class | Form : uint8_t { NonArray , Array , Operator } |
| using | const_virtual_iter |
| Allocation site iterator. | |
Public Member Functions | |
| DynamicAllocator ()=default | |
| DynamicAllocator (DynamicAllocator &)=delete | |
| DynamicAllocator (DynamicAllocator &&)=delete | |
| ~DynamicAllocator () | |
| void | cleanup () |
| Block * | allocate (const Descriptor *D, unsigned EvalID, Form AllocForm) |
| Allocate ONE element of the given descriptor. | |
| Block * | allocate (const Expr *Source, PrimType T, size_t NumElements, unsigned EvalID, Form AllocForm) |
Allocate NumElements primitive elements of the given type. | |
| Block * | allocate (const Descriptor *D, size_t NumElements, unsigned EvalID, Form AllocForm) |
Allocate NumElements elements of the given descriptor. | |
| bool | deallocate (const Expr *Source, const Block *BlockToDelete, InterpState &S) |
| Deallocate the given source+block combination. | |
| std::optional< Form > | getAllocationForm (const Expr *Source) const |
| Checks whether the allocation done at the given source is an array allocation. | |
| llvm::iterator_range< const_virtual_iter > | allocation_sites () const |
| bool | hasAllocations () const |
Manages dynamic memory allocations done during bytecode interpretation.
We manage allocations as a map from their new-expression to a list of allocations. This is called an AllocationSite. For each site, we record whether it was allocated using new or new[], the IsArrayAllocation flag.
For all array allocations, we need to allocate new Descriptor instances, so the DynamicAllocator has a llvm::BumpPtrAllocator similar to Program.
Definition at line 33 of file DynamicAllocator.h.
Allocation site iterator.
Definition at line 95 of file DynamicAllocator.h.
|
strong |
| Enumerator | |
|---|---|
| NonArray | |
| Array | |
| Operator | |
Definition at line 35 of file DynamicAllocator.h.
|
default |
Referenced by DynamicAllocator(), and DynamicAllocator().
|
delete |
References DynamicAllocator().
|
delete |
References DynamicAllocator(), and clang::T.
| DynamicAllocator::~DynamicAllocator | ( | ) |
Definition at line 16 of file DynamicAllocator.cpp.
References cleanup().
| Block * DynamicAllocator::allocate | ( | const Descriptor * | D, |
| size_t | NumElements, | ||
| unsigned | EvalID, | ||
| Form | AllocForm ) |
Allocate NumElements elements of the given descriptor.
Definition at line 57 of file DynamicAllocator.cpp.
References allocate(), clang::interp::Descriptor::asExpr(), clang::interp::Descriptor::getMetadataSize(), and clang::interp::Descriptor::InlineDescMD.
| Block * DynamicAllocator::allocate | ( | const Descriptor * | D, |
| unsigned | EvalID, | ||
| Form | AllocForm ) |
Allocate ONE element of the given descriptor.
Definition at line 71 of file DynamicAllocator.cpp.
References clang::interp::Alloc(), clang::interp::Descriptor::asExpr(), clang::interp::Block, clang::interp::InlineDescriptor::Desc, clang::interp::Ended, clang::interp::Descriptor::getAllocSize(), clang::interp::Descriptor::getMetadataSize(), clang::interp::Descriptor::isCompositeArray(), clang::interp::Descriptor::IsConst, Operator, and clang::interp::Started.
Referenced by clang::interp::Alloc(), allocate(), allocate(), clang::interp::AllocCN(), clang::interp::AllocN(), and clang::interp::interp__builtin_operator_new().
| Block * DynamicAllocator::allocate | ( | const Expr * | Source, |
| PrimType | T, | ||
| size_t | NumElements, | ||
| unsigned | EvalID, | ||
| Form | AllocForm ) |
Allocate NumElements primitive elements of the given type.
Definition at line 45 of file DynamicAllocator.cpp.
References allocate(), clang::interp::Descriptor::InlineDescMD, and clang::T.
|
inline |
Definition at line 97 of file DynamicAllocator.h.
| void DynamicAllocator::cleanup | ( | ) |
Definition at line 18 of file DynamicAllocator.cpp.
References clang::interp::Alloc(), clang::interp::Pointer::asBlockPointer(), clang::interp::Pointer::BS, clang::interp::Block::hasPointers(), clang::interp::Block::invokeDtor(), clang::interp::Block::isDead(), clang::interp::Block::isInitialized(), clang::interp::BlockPointer::Next, Next, and clang::interp::BlockPointer::Pointee.
Referenced by ~DynamicAllocator().
| bool DynamicAllocator::deallocate | ( | const Expr * | Source, |
| const Block * | BlockToDelete, | ||
| InterpState & | S ) |
Deallocate the given source+block combination.
Returns true if anything has been deallocatd, false otherwise.
Definition at line 118 of file DynamicAllocator.cpp.
References clang::interp::Block::hasPointers(), clang::interp::Block::invokeDtor(), clang::interp::Block::isDead(), and clang::interp::Block::isInitialized().
Referenced by clang::interp::Free(), and clang::interp::interp__builtin_operator_delete().
|
inline |
Checks whether the allocation done at the given source is an array allocation.
Definition at line 88 of file DynamicAllocator.h.
Referenced by clang::interp::Free(), and clang::interp::interp__builtin_operator_delete().
|
inline |
Definition at line 101 of file DynamicAllocator.h.