![]() |
mutable
A Database System for Research and Fast Prototyping
|
A simple linear allocator which keeps a global pointer to the next free memory address and advances it for allocation. More...
Public Member Functions | |
LinearAllocator (const memory::AddressSpace &memory, uint32_t start_addr) | |
~LinearAllocator () | |
void * | raw_allocate (uint32_t bytes, uint32_t alignment) override |
Pre-allocates memory for bytes consecutive bytes with alignment requirement align and returns a raw pointer to the beginning of this memory. | |
Ptr< void > | pre_allocate (uint32_t bytes, uint32_t alignment) override |
Pre-allocates memory for bytes consecutive bytes with alignment requirement align and returns a pointer to the beginning of this memory. | |
Var< Ptr< void > > | allocate (U32x1 bytes, uint32_t alignment) override |
Allocates memory for bytes consecutive bytes with alignment requirement align and returns a pointer to the beginning of this memory. | |
void | deallocate (Ptr< void > ptr, U32x1 bytes) override |
Deallocates the bytes consecutive bytes of allocated memory at address ptr . | |
uint32_t | perform_pre_allocations () override |
Performs the actual pre-allocations. | |
uint32_t | pre_allocated_memory_consumption () const override |
Returns the pre-allocated memory overall consumption. | |
U32x1 | allocated_memory_consumption () const override |
Returns the allocated memory overall consumption. | |
U32x1 | allocated_memory_peak () const override |
Returns the allocated memory peak consumption. | |
Var< Ptr< void > > | allocate (uint32_t bytes, uint32_t align=1) |
void | deallocate (Ptr< void > ptr, uint32_t bytes) |
template<dsl_primitive T> | |
T * | raw_malloc () |
Pre-allocates memory for exactly one value of type. | |
template<dsl_primitive T> | |
T * | raw_malloc (uint32_t count) |
Pre-allocates memory for an array of count consecutive values of type. | |
template<dsl_primitive T, std::size_t L = 1> | |
Ptr< PrimitiveExpr< T, L > > | pre_malloc () |
Pre-allocates memory for exactly one value of type. | |
template<dsl_primitive T, std::size_t L = 1> | |
Ptr< PrimitiveExpr< T, L > > | pre_malloc (uint32_t count) |
Pre-allocates memory for an array of count consecutive values of type. | |
template<dsl_primitive T, std::size_t L = 1> | |
Var< Ptr< PrimitiveExpr< T, L > > > | malloc () |
Allocates memory for exactly one value of type. | |
template<dsl_primitive T, std::size_t L = 1, typename U > requires requires (U &&u) { U32x1(std::forward<U>(u)); } | |
Var< Ptr< PrimitiveExpr< T, L > > > | malloc (U &&count) |
Allocates memory for an array of count consecutive values of type. | |
template<primitive_convertible T> requires requires (T &&t) { primitive_expr_t<T>(std::forward<T>(t)).template to<void*>(); } | |
void | free (T &&ptr) |
Frees exactly one value of type. | |
void | free (T &&ptr, U &&count) |
Data Fields | |
template<primitive_convertible T, typename U > | |
and { primitive_expr_t<T>(std::forward<T>(t)).template to<void*>() | |
Frees count consecutive values of type. | |
Private Member Functions | |
void | align_pre_memory (uint32_t alignment) |
Aligns the memory for pre-allocations with alignment requirement align . | |
void | align_memory (uint32_t alignment) |
Aligns the memory for allocations with alignment requirement align . | |
Private Attributes | |
const memory::AddressSpace & | memory_ |
| |
bool | pre_allocations_performed_ = false |
| |
uint32_t | pre_alloc_addr_ |
| |
Global< U32x1 > | alloc_addr_ |
| |
uint32_t | pre_alloc_total_mem_ = 0 |
| |
Global< U32x1 > | alloc_total_mem_ |
| |
Global< U32x1 > | alloc_peak_mem_ |
| |
A simple linear allocator which keeps a global pointer to the next free memory address and advances it for allocation.
Deallocation can only reclaim memory if all chronologically later allocations have been deallocated before. If possible, deallocate memory in the inverse order of allocation.
Definition at line 217 of file WasmDSL.cpp.
|
inline |
Definition at line 236 of file WasmDSL.cpp.
References M_insist.
|
inline |
Definition at line 248 of file WasmDSL.cpp.
References M_insist.
|
inlineprivate |
Aligns the memory for allocations with alignment requirement align
.
Definition at line 317 of file WasmDSL.cpp.
References m::is_pow_2(), and M_insist.
|
inlineprivate |
Aligns the memory for pre-allocations with alignment requirement align
.
Definition at line 312 of file WasmDSL.cpp.
References m::is_pow_2(), and M_insist.
Allocates memory for bytes
consecutive bytes with alignment requirement align
and returns a pointer to the beginning of this memory.
Implements m::wasm::Allocator.
Definition at line 278 of file WasmDSL.cpp.
References m::is_pow_2(), M_insist, m::wasm::Select(), m::memory::AddressSpace::size(), and Wasm_insist.
|
inlineinherited |
Definition at line 6518 of file WasmDSL.hpp.
References m::wasm::Allocator::allocate().
Referenced by m::wasm::Allocator::allocate().
|
inlineoverridevirtual |
Returns the allocated memory overall consumption.
Implements m::wasm::Allocator.
Definition at line 307 of file WasmDSL.cpp.
|
inlineoverridevirtual |
Returns the allocated memory peak consumption.
Implements m::wasm::Allocator.
Definition at line 308 of file WasmDSL.cpp.
|
inlineoverridevirtual |
Deallocates the bytes
consecutive bytes of allocated memory at address ptr
.
Implements m::wasm::Allocator.
Definition at line 291 of file WasmDSL.cpp.
References IF, and Wasm_insist.
|
inlineinherited |
Definition at line 6519 of file WasmDSL.hpp.
References m::wasm::Allocator::deallocate().
Referenced by m::wasm::Allocator::deallocate().
|
inlineinherited |
Frees exactly one value of type.
T | of allocated memory pointed by ptr . |
Definition at line 6577 of file WasmDSL.hpp.
References m::wasm::Allocator::free().
Referenced by m::wasm::Allocator::free().
Definition at line 6583 of file WasmDSL.hpp.
References m::wasm::L, and m::T().
|
inlineinherited |
Allocates memory for exactly one value of type.
T | and number of SIMD lanes |
L. | Returns a pointer to this memory. |
Definition at line 6532 of file WasmDSL.hpp.
|
inlineinherited |
Allocates memory for an array of count
consecutive values of type.
T | and number of SIMD lanes |
L. | Returns a pointer to this memory. |
Definition at line 6553 of file WasmDSL.hpp.
References m::wasm::L, and m::T().
|
inlineoverridevirtual |
Performs the actual pre-allocations.
Must be called exactly once after the last pre-allocation was requested. Returns the initial allocation address, i.e. an address after the last pre-allocated address.
Implements m::wasm::Allocator.
Definition at line 298 of file WasmDSL.cpp.
References m::wasm::Module::Get(), and M_insist.
|
inlineoverridevirtual |
Pre-allocates memory for bytes
consecutive bytes with alignment requirement align
and returns a pointer to the beginning of this memory.
Implements m::wasm::Allocator.
Definition at line 265 of file WasmDSL.cpp.
References m::is_pow_2(), M_insist, and m::memory::AddressSpace::size().
|
inlineoverridevirtual |
Returns the pre-allocated memory overall consumption.
Implements m::wasm::Allocator.
Definition at line 306 of file WasmDSL.cpp.
|
inlineinherited |
Pre-allocates memory for exactly one value of type.
T | and number of SIMD lanes |
L. | Returns a pointer to this memory. |
Definition at line 6528 of file WasmDSL.hpp.
|
inlineinherited |
Pre-allocates memory for an array of count
consecutive values of type.
T | and number of SIMD lanes |
L. | Returns a pointer to this memory. |
Definition at line 6541 of file WasmDSL.hpp.
References m::wasm::L, and m::T().
|
inlineoverridevirtual |
Pre-allocates memory for bytes
consecutive bytes with alignment requirement align
and returns a raw pointer to the beginning of this memory.
Implements m::wasm::Allocator.
Definition at line 252 of file WasmDSL.cpp.
References m::memory::AddressSpace::addr(), m::is_pow_2(), M_insist, and m::memory::AddressSpace::size().
|
inlineinherited |
Pre-allocates memory for exactly one value of type.
T. | Returns a raw pointer to this memory. |
Definition at line 6524 of file WasmDSL.hpp.
References m::T().
|
inlineinherited |
Pre-allocates memory for an array of count
consecutive values of type.
T. | Returns a raw pointer to this memory. |
Definition at line 6537 of file WasmDSL.hpp.
References m::T().
|
private |
runtime global size of the currently used memory, used as pointer to next free allocation
Definition at line 227 of file WasmDSL.cpp.
|
private |
runtime peak memory consumption
Definition at line 233 of file WasmDSL.cpp.
|
private |
runtime total memory consumption
Definition at line 231 of file WasmDSL.cpp.
|
inherited |
Frees count
consecutive values of type.
T | of allocated memory pointed by ptr . |
Definition at line 6581 of file WasmDSL.hpp.
|
private |
the underlying virtual address space used
Definition at line 221 of file WasmDSL.cpp.
|
private |
compile-time size of the currently used memory, used as pointer to next free pre-allocation
Definition at line 225 of file WasmDSL.cpp.
|
private |
compile-time total memory consumption
Definition at line 229 of file WasmDSL.cpp.
|
private |
flag whether pre-allocations were already performed, i.e.
perform_pre_allocations()
was already called
Definition at line 223 of file WasmDSL.cpp.