#include <allocator.hpp>
|
template<std::size_t align_amt> |
static constexpr size_t | align_offset (size_t offset) |
|
static std::size_t | align_to_page (std::size_t offset) |
|
template<std::size_t align_amt> |
static constexpr size_t | align_offset (size_t offset) |
|
static std::size_t | align_to_page (std::size_t offset) |
|
Definition at line 267 of file allocator.hpp.
◆ growable_allocator() [1/2]
sysio::vm::growable_allocator::growable_allocator |
( |
size_t | size | ) |
|
|
inline |
Definition at line 281 of file allocator.hpp.
281 {
285 if (size != 0) {
288 mprotect((
char*)
_base,
_size, PROT_READ | PROT_WRITE);
289 }
291 }
static constexpr size_t max_memory_size
static constexpr size_t align_offset(size_t offset)
static constexpr size_t chunk_size
#define SYS_VM_ASSERT(expr, exc_type, msg)
◆ ~growable_allocator() [1/2]
sysio::vm::growable_allocator::~growable_allocator |
( |
| ) |
|
|
inline |
Definition at line 293 of file allocator.hpp.
293 {
297 }
298 }
static jit_allocator & instance()
void free(void *ptr) noexcept
◆ growable_allocator() [2/2]
sysio::vm::growable_allocator::growable_allocator |
( |
size_t | size | ) |
|
|
inline |
Definition at line 281 of file allocator.hpp.
281 {
285 if (size != 0) {
288 mprotect((
char*)
_base,
_size, PROT_READ | PROT_WRITE);
289 }
291 }
◆ ~growable_allocator() [2/2]
sysio::vm::growable_allocator::~growable_allocator |
( |
| ) |
|
|
inline |
◆ align_offset() [1/2]
template<std::size_t align_amt>
static constexpr size_t sysio::vm::growable_allocator::align_offset |
( |
size_t | offset | ) |
|
|
inlinestaticconstexpr |
Definition at line 272 of file allocator.hpp.
272{ return (offset + align_amt - 1) & ~(align_amt - 1); }
◆ align_offset() [2/2]
template<std::size_t align_amt>
static constexpr size_t sysio::vm::growable_allocator::align_offset |
( |
size_t | offset | ) |
|
|
inlinestaticconstexpr |
Definition at line 272 of file allocator.hpp.
272{ return (offset + align_amt - 1) & ~(align_amt - 1); }
◆ align_to_page() [1/2]
static std::size_t sysio::vm::growable_allocator::align_to_page |
( |
std::size_t | offset | ) |
|
|
inlinestatic |
Definition at line 274 of file allocator.hpp.
274 {
275 std::size_t pagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
277 return (offset + pagesize - 1) & ~(pagesize - 1);
278 }
◆ align_to_page() [2/2]
static std::size_t sysio::vm::growable_allocator::align_to_page |
( |
std::size_t | offset | ) |
|
|
inlinestatic |
Definition at line 274 of file allocator.hpp.
274 {
275 std::size_t pagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
277 return (offset + pagesize - 1) & ~(pagesize - 1);
278 }
◆ alloc() [1/2]
T * sysio::vm::growable_allocator::alloc |
( |
size_t | size = 0 | ) |
|
|
inline |
Definition at line 302 of file allocator.hpp.
302 {
303 static_assert(
max_memory_size %
alignof(
T) == 0,
"alignment must divide max_memory_size.");
305
306
308 size_t aligned = (
sizeof(
T) * size) +
_offset;
309 if (aligned >
_size) {
313 }
314
317 return ptr;
318 }
#define T(meth, val, expected)
◆ alloc() [2/2]
T * sysio::vm::growable_allocator::alloc |
( |
size_t | size = 0 | ) |
|
|
inline |
Definition at line 302 of file allocator.hpp.
302 {
303 static_assert(
max_memory_size %
alignof(
T) == 0,
"alignment must divide max_memory_size.");
305
306
308 size_t aligned = (
sizeof(
T) * size) +
_offset;
309 if (aligned >
_size) {
313 }
314
317 return ptr;
318 }
◆ disable_code() [1/2]
void sysio::vm::growable_allocator::disable_code |
( |
| ) |
|
|
inline |
◆ disable_code() [2/2]
void sysio::vm::growable_allocator::disable_code |
( |
| ) |
|
|
inline |
◆ enable_code() [1/2]
void sysio::vm::growable_allocator::enable_code |
( |
bool | is_jit | ) |
|
|
inline |
◆ enable_code() [2/2]
void sysio::vm::growable_allocator::enable_code |
( |
bool | is_jit | ) |
|
|
inline |
◆ end_code() [1/2]
template<bool IsJit>
void sysio::vm::growable_allocator::end_code |
( |
void * | code_base | ) |
|
|
inline |
Definition at line 325 of file allocator.hpp.
325 {
326 assert((
char*)code_base >=
_base);
331 if constexpr (IsJit) {
333 void * executable_code = jit_alloc.alloc(
_code_size);
334 int err = mprotect(executable_code,
_code_size, PROT_READ | PROT_WRITE);
340 }
342 }
void enable_code(bool is_jit)
static std::size_t align_to_page(std::size_t offset)
◆ end_code() [2/2]
template<bool IsJit>
void sysio::vm::growable_allocator::end_code |
( |
void * | code_base | ) |
|
|
inline |
Definition at line 325 of file allocator.hpp.
325 {
326 assert((
char*)code_base >=
_base);
331 if constexpr (IsJit) {
333 void * executable_code = jit_alloc.alloc(
_code_size);
334 int err = mprotect(executable_code,
_code_size, PROT_READ | PROT_WRITE);
340 }
342 }
◆ finalize() [1/2]
void sysio::vm::growable_allocator::finalize |
( |
| ) |
|
|
inline |
◆ finalize() [2/2]
void sysio::vm::growable_allocator::finalize |
( |
| ) |
|
|
inline |
◆ free() [1/2]
void sysio::vm::growable_allocator::free |
( |
| ) |
|
|
inline |
◆ free() [2/2]
void sysio::vm::growable_allocator::free |
( |
| ) |
|
|
inline |
◆ get_code_start() [1/2]
const void * sysio::vm::growable_allocator::get_code_start |
( |
| ) |
const |
|
inline |
◆ get_code_start() [2/2]
const void * sysio::vm::growable_allocator::get_code_start |
( |
| ) |
const |
|
inline |
◆ reclaim() [1/2]
void sysio::vm::growable_allocator::reclaim |
( |
const T * | ptr, |
|
|
size_t | size = 0 ) |
|
inline |
Definition at line 359 of file allocator.hpp.
359 {
361 SYS_VM_ASSERT( size == 0 || (
char*)(ptr + size) == (
_base +
_offset), wasm_bad_alloc,
"reclaiming memory must be strictly LIFO");
362 if ( size != 0 )
364 }
◆ reclaim() [2/2]
void sysio::vm::growable_allocator::reclaim |
( |
const T * | ptr, |
|
|
size_t | size = 0 ) |
|
inline |
Definition at line 359 of file allocator.hpp.
359 {
361 SYS_VM_ASSERT( size == 0 || (
char*)(ptr + size) == (
_base +
_offset), wasm_bad_alloc,
"reclaiming memory must be strictly LIFO");
362 if ( size != 0 )
364 }
◆ reset() [1/2]
void sysio::vm::growable_allocator::reset |
( |
| ) |
|
|
inline |
◆ reset() [2/2]
void sysio::vm::growable_allocator::reset |
( |
| ) |
|
|
inline |
◆ start_code() [1/2]
void * sysio::vm::growable_allocator::start_code |
( |
| ) |
|
|
inline |
◆ start_code() [2/2]
void * sysio::vm::growable_allocator::start_code |
( |
| ) |
|
|
inline |
◆ _base
char * sysio::vm::growable_allocator::_base |
◆ _capacity
std::size_t sysio::vm::growable_allocator::_capacity = 0 |
◆ _code_base
char * sysio::vm::growable_allocator::_code_base = nullptr |
◆ _code_size
size_t sysio::vm::growable_allocator::_code_size = 0 |
◆ _offset
size_t sysio::vm::growable_allocator::_offset = 0 |
◆ _size
size_t sysio::vm::growable_allocator::_size = 0 |
◆ chunk_size
static constexpr size_t sysio::vm::growable_allocator::chunk_size = 128 * 1024 |
|
staticconstexpr |
◆ is_jit
bool sysio::vm::growable_allocator::is_jit = false |
◆ max_memory_size
static constexpr size_t sysio::vm::growable_allocator::max_memory_size = 1024 * 1024 * 1024 |
|
staticconstexpr |
The documentation for this class was generated from the following files: