Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::jit_allocator Class Reference

#include <allocator.hpp>

Public Member Functions

void * alloc (std::size_t size)
 
void free (void *ptr) noexcept
 
void * alloc (std::size_t size)
 
void free (void *ptr) noexcept
 

Static Public Member Functions

static jit_allocatorinstance ()
 
static jit_allocatorinstance ()
 

Detailed Description

Definition at line 126 of file allocator.hpp.

Member Function Documentation

◆ alloc() [1/2]

void * sysio::vm::jit_allocator::alloc ( std::size_t size)
inline

Definition at line 130 of file allocator.hpp.

130 {
131 std::lock_guard l{_mutex};
132 size = round_to_page(size);
133 auto best = free_blocks_by_size.lower_bound(size);
134 if(best == free_blocks_by_size.end()) {
135 best = allocate_segment(size);
136 }
137 if (best->first > size) {
138 best = split_block(best, size);
139 }
140 transfer_node(free_blocks, allocated_blocks, best->second);
141 best = transfer_node(free_blocks_by_size, allocated_blocks_by_size, *best);
142 return best->second;
143 }
int l

◆ alloc() [2/2]

void * sysio::vm::jit_allocator::alloc ( std::size_t size)
inline

Definition at line 130 of file allocator.hpp.

130 {
131 std::lock_guard l{_mutex};
132 size = round_to_page(size);
133 auto best = free_blocks_by_size.lower_bound(size);
134 if(best == free_blocks_by_size.end()) {
135 best = allocate_segment(size);
136 }
137 if (best->first > size) {
138 best = split_block(best, size);
139 }
140 transfer_node(free_blocks, allocated_blocks, best->second);
141 best = transfer_node(free_blocks_by_size, allocated_blocks_by_size, *best);
142 return best->second;
143 }

◆ free() [1/2]

void sysio::vm::jit_allocator::free ( void * ptr)
inlinenoexcept

Definition at line 145 of file allocator.hpp.

145 {
146 std::lock_guard l{_mutex};
147 auto pos = transfer_node(allocated_blocks, free_blocks, ptr);
148 transfer_node(allocated_blocks_by_size, free_blocks_by_size, {pos->second, pos->first});
149
150 // merge the freed block with adjacent free blocks
151 if(pos != free_blocks.begin()) {
152 auto prev = pos;
153 --prev;
154 pos = maybe_consolidate_blocks(prev, pos);
155 }
156 auto next = pos;
157 ++next;
158 if (next != free_blocks.end()) {
159 maybe_consolidate_blocks(pos, next);
160 }
161 }
uint32_t next(octet_iterator &it, octet_iterator end)
Definition checked.h:137
Here is the caller graph for this function:

◆ free() [2/2]

void sysio::vm::jit_allocator::free ( void * ptr)
inlinenoexcept

Definition at line 145 of file allocator.hpp.

145 {
146 std::lock_guard l{_mutex};
147 auto pos = transfer_node(allocated_blocks, free_blocks, ptr);
148 transfer_node(allocated_blocks_by_size, free_blocks_by_size, {pos->second, pos->first});
149
150 // merge the freed block with adjacent free blocks
151 if(pos != free_blocks.begin()) {
152 auto prev = pos;
153 --prev;
154 pos = maybe_consolidate_blocks(prev, pos);
155 }
156 auto next = pos;
157 ++next;
158 if (next != free_blocks.end()) {
159 maybe_consolidate_blocks(pos, next);
160 }
161 }

◆ instance() [1/2]

static jit_allocator & sysio::vm::jit_allocator::instance ( )
inlinestatic

Definition at line 162 of file allocator.hpp.

162 {
163 static jit_allocator the_jit_allocator;
164 return the_jit_allocator;
165 }
Here is the caller graph for this function:

◆ instance() [2/2]

static jit_allocator & sysio::vm::jit_allocator::instance ( )
inlinestatic

Definition at line 162 of file allocator.hpp.

162 {
163 static jit_allocator the_jit_allocator;
164 return the_jit_allocator;
165 }

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