clang  20.0.0git
Classes | Public Types | Public Member Functions | List of all members
clang::interp::DynamicAllocator Class Referencefinal

Manages dynamic memory allocations done during bytecode interpretation. More...

#include "/home/runner/work/llvm/llvm/repo/clang/lib/AST/ByteCode/DynamicAllocator.h"

Public Types

using const_virtual_iter = llvm::DenseMap< const Expr *, AllocationSite >::const_iterator
 Allocation site iterator. More...
 

Public Member Functions

 DynamicAllocator ()=default
 
 ~DynamicAllocator ()
 
void cleanup ()
 
unsigned getNumAllocations () const
 
Blockallocate (const Descriptor *D, unsigned EvalID)
 Allocate ONE element of the given descriptor. More...
 
Blockallocate (const Expr *Source, PrimType T, size_t NumElements, unsigned EvalID)
 Allocate NumElements primitive elements of the given type. More...
 
Blockallocate (const Descriptor *D, size_t NumElements, unsigned EvalID)
 Allocate NumElements elements of the given descriptor. More...
 
bool deallocate (const Expr *Source, const Block *BlockToDelete, InterpState &S)
 Deallocate the given source+block combination. More...
 
bool isArrayAllocation (const Expr *Source) const
 Checks whether the allocation done at the given source is an array allocation. More...
 
llvm::iterator_range< const_virtual_iterallocation_sites () const
 

Detailed Description

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.

Member Typedef Documentation

◆ const_virtual_iter

using clang::interp::DynamicAllocator::const_virtual_iter = llvm::DenseMap<const Expr *, AllocationSite>::const_iterator

Allocation site iterator.

Definition at line 82 of file DynamicAllocator.h.

Constructor & Destructor Documentation

◆ DynamicAllocator()

clang::interp::DynamicAllocator::DynamicAllocator ( )
default

◆ ~DynamicAllocator()

DynamicAllocator::~DynamicAllocator ( )

Definition at line 16 of file DynamicAllocator.cpp.

References cleanup().

Member Function Documentation

◆ allocate() [1/3]

Block * DynamicAllocator::allocate ( const Descriptor D,
size_t  NumElements,
unsigned  EvalID 
)

Allocate NumElements elements of the given descriptor.

Definition at line 53 of file DynamicAllocator.cpp.

References allocate(), clang::interp::Descriptor::asExpr(), D, and clang::interp::Descriptor::InlineDescMD.

◆ allocate() [2/3]

Block * DynamicAllocator::allocate ( const Descriptor D,
unsigned  EvalID 
)

Allocate ONE element of the given descriptor.

Definition at line 63 of file DynamicAllocator.cpp.

References D, ID, and clang::interp::Block::invokeCtor().

Referenced by allocate().

◆ allocate() [3/3]

Block * DynamicAllocator::allocate ( const Expr Source,
PrimType  T,
size_t  NumElements,
unsigned  EvalID 
)

Allocate NumElements primitive elements of the given type.

Definition at line 42 of file DynamicAllocator.cpp.

References allocate(), D, clang::interp::Descriptor::InlineDescMD, and clang::T.

◆ allocation_sites()

llvm::iterator_range<const_virtual_iter> clang::interp::DynamicAllocator::allocation_sites ( ) const
inline

◆ cleanup()

void DynamicAllocator::cleanup ( )

◆ deallocate()

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 91 of file DynamicAllocator.cpp.

◆ getNumAllocations()

unsigned clang::interp::DynamicAllocator::getNumAllocations ( ) const
inline

◆ isArrayAllocation()

bool clang::interp::DynamicAllocator::isArrayAllocation ( const Expr Source) const
inline

Checks whether the allocation done at the given source is an array allocation.

Definition at line 75 of file DynamicAllocator.h.


The documentation for this class was generated from the following files: