#include <allocator.hpp>
|
void * | alloc (std::size_t size) |
|
void | free (void *ptr) noexcept |
|
void * | alloc (std::size_t size) |
|
void | free (void *ptr) noexcept |
|
Definition at line 126 of file allocator.hpp.
◆ 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 }
◆ 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
151 if(pos != free_blocks.begin()) {
152 auto prev = pos;
153 --prev;
154 pos = maybe_consolidate_blocks(prev, pos);
155 }
158 if (next != free_blocks.end()) {
159 maybe_consolidate_blocks(pos, next);
160 }
161 }
uint32_t next(octet_iterator &it, octet_iterator end)
◆ 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
151 if(pos != free_blocks.begin()) {
152 auto prev = pos;
153 --prev;
154 pos = maybe_consolidate_blocks(prev, pos);
155 }
158 if (next != free_blocks.end()) {
159 maybe_consolidate_blocks(pos, next);
160 }
161 }
◆ instance() [1/2]
Definition at line 162 of file allocator.hpp.
162 {
163 static jit_allocator the_jit_allocator;
164 return the_jit_allocator;
165 }
◆ instance() [2/2]
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: