#include <allocator.hpp>
Definition at line 409 of file allocator.hpp.
◆ wasm_allocator() [1/2]
sysio::vm::wasm_allocator::wasm_allocator |
( |
| ) |
|
|
inline |
Definition at line 439 of file allocator.hpp.
439 {
440 std::size_t syspagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
441 raw = (
char*)mmap(NULL,
max_memory + 2*syspagesize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
442 SYS_VM_ASSERT( raw != MAP_FAILED, wasm_bad_alloc,
"mmap failed to alloca pages" );
443 int err = mprotect(raw, syspagesize, PROT_READ);
445 raw += syspagesize;
446 page = 0;
447 }
#define SYS_VM_ASSERT(expr, exc_type, msg)
◆ wasm_allocator() [2/2]
sysio::vm::wasm_allocator::wasm_allocator |
( |
| ) |
|
|
inline |
Definition at line 439 of file allocator.hpp.
439 {
440 std::size_t syspagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
441 raw = (
char*)mmap(NULL,
max_memory + 2*syspagesize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
442 SYS_VM_ASSERT( raw != MAP_FAILED, wasm_bad_alloc,
"mmap failed to alloca pages" );
443 int err = mprotect(raw, syspagesize, PROT_READ);
445 raw += syspagesize;
446 page = 0;
447 }
◆ alloc() [1/2]
void sysio::vm::wasm_allocator::alloc |
( |
size_t | size = 1 | ) |
|
|
inline |
Definition at line 416 of file allocator.hpp.
416 {
417 if (size == 0) return;
418 SYS_VM_ASSERT(page >= 0, wasm_bad_alloc,
"require memory to allocate");
420 int err = mprotect(raw + (
page_size * page), (
page_size * size), PROT_READ | PROT_WRITE);
424 page += size;
425 }
#define T(meth, val, expected)
memset(pInfo->slotDescription, ' ', 64)
◆ alloc() [2/2]
void sysio::vm::wasm_allocator::alloc |
( |
size_t | size = 1 | ) |
|
|
inline |
Definition at line 416 of file allocator.hpp.
416 {
417 if (size == 0) return;
418 SYS_VM_ASSERT(page >= 0, wasm_bad_alloc,
"require memory to allocate");
420 int err = mprotect(raw + (
page_size * page), (
page_size * size), PROT_READ | PROT_WRITE);
424 page += size;
425 }
◆ create_pointer() [1/2]
T * sysio::vm::wasm_allocator::create_pointer |
( |
uint32_t | offset | ) |
|
|
inline |
Definition at line 484 of file allocator.hpp.
484{
return reinterpret_cast<T*
>(raw + offset); }
◆ create_pointer() [2/2]
T * sysio::vm::wasm_allocator::create_pointer |
( |
uint32_t | offset | ) |
|
|
inline |
Definition at line 484 of file allocator.hpp.
484{
return reinterpret_cast<T*
>(raw + offset); }
◆ free() [1/4]
void sysio::vm::wasm_allocator::free |
( |
| ) |
|
|
inline |
Definition at line 435 of file allocator.hpp.
435 {
436 std::size_t syspagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
437 munmap(raw - syspagesize,
max_memory + 2*syspagesize);
438 }
◆ free() [2/4]
void sysio::vm::wasm_allocator::free |
( |
| ) |
|
|
inline |
Definition at line 435 of file allocator.hpp.
435 {
436 std::size_t syspagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
437 munmap(raw - syspagesize,
max_memory + 2*syspagesize);
438 }
◆ free() [3/4]
void sysio::vm::wasm_allocator::free |
( |
std::size_t | size | ) |
|
|
inline |
Definition at line 427 of file allocator.hpp.
427 {
428 if (size == 0) return;
429 SYS_VM_ASSERT(page >= 0, wasm_bad_alloc,
"require memory to deallocate");
431 page -= size;
434 }
◆ free() [4/4]
void sysio::vm::wasm_allocator::free |
( |
std::size_t | size | ) |
|
|
inline |
Definition at line 427 of file allocator.hpp.
427 {
428 if (size == 0) return;
429 SYS_VM_ASSERT(page >= 0, wasm_bad_alloc,
"require memory to deallocate");
431 page -= size;
434 }
◆ get_base_ptr() [1/2]
T * sysio::vm::wasm_allocator::get_base_ptr |
( |
| ) |
const |
|
inline |
Definition at line 480 of file allocator.hpp.
480 {
481 return reinterpret_cast<T*
>(raw);
482 }
◆ get_base_ptr() [2/2]
T * sysio::vm::wasm_allocator::get_base_ptr |
( |
| ) |
const |
|
inline |
Definition at line 480 of file allocator.hpp.
480 {
481 return reinterpret_cast<T*
>(raw);
482 }
◆ get_current_page() [1/2]
int32_t sysio::vm::wasm_allocator::get_current_page |
( |
| ) |
const |
|
inline |
◆ get_current_page() [2/2]
int32_t sysio::vm::wasm_allocator::get_current_page |
( |
| ) |
const |
|
inline |
◆ is_in_region() [1/2]
bool sysio::vm::wasm_allocator::is_in_region |
( |
char * | p | ) |
|
|
inline |
◆ is_in_region() [2/2]
bool sysio::vm::wasm_allocator::is_in_region |
( |
char * | p | ) |
|
|
inline |
◆ reset() [1/4]
void sysio::vm::wasm_allocator::reset |
( |
| ) |
|
|
inline |
Definition at line 469 of file allocator.hpp.
469 {
470 if (page >= 0) {
471 std::size_t syspagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
473 int err = mprotect(raw - syspagesize,
page_size * page + syspagesize, PROT_NONE);
475 }
476 page = -1;
477 }
◆ reset() [2/4]
void sysio::vm::wasm_allocator::reset |
( |
| ) |
|
|
inline |
Definition at line 469 of file allocator.hpp.
469 {
470 if (page >= 0) {
471 std::size_t syspagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
473 int err = mprotect(raw - syspagesize,
page_size * page + syspagesize, PROT_NONE);
475 }
476 page = -1;
477 }
◆ reset() [3/4]
void sysio::vm::wasm_allocator::reset |
( |
uint32_t | new_pages | ) |
|
|
inline |
Definition at line 452 of file allocator.hpp.
452 {
453 if (page >= 0) {
455 } else {
456 std::size_t syspagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
457 int err = mprotect(raw - syspagesize, syspagesize, PROT_READ);
459 page = 0;
460 }
461 if(new_pages >
static_cast<uint32_t>(page)) {
463 }
else if(new_pages <
static_cast<uint32_t>(page)) {
465 }
466 }
void alloc(size_t size=1)
◆ reset() [4/4]
void sysio::vm::wasm_allocator::reset |
( |
uint32_t | new_pages | ) |
|
|
inline |
Definition at line 452 of file allocator.hpp.
452 {
453 if (page >= 0) {
455 } else {
456 std::size_t syspagesize = static_cast<std::size_t>(::sysconf(_SC_PAGESIZE));
457 int err = mprotect(raw - syspagesize, syspagesize, PROT_READ);
459 page = 0;
460 }
461 if(new_pages >
static_cast<uint32_t>(page)) {
463 }
else if(new_pages <
static_cast<uint32_t>(page)) {
465 }
466 }
The documentation for this class was generated from the following files: