Comments, adding Region to Heap
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, macos-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
#include "region.h"
|
||||
|
||||
namespace mimir {
|
||||
|
||||
// Arena memory allocator, baed by a mimir::Region
|
||||
class Arena
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -33,14 +33,18 @@
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "region.h"
|
||||
|
||||
namespace mimir {
|
||||
|
||||
// Heap implementation based on Two-Level Segregated Fit (TLSF) memory allocation
|
||||
class Heap
|
||||
{
|
||||
public:
|
||||
Heap();
|
||||
~Heap();
|
||||
|
||||
bool init(size_t minSize = 1ULL << 24, size_t maxSize = 1ULL << 32);
|
||||
bool init(size_t maxSize = 1ULL << 32);
|
||||
|
||||
// Allocate `size` bytes
|
||||
std::byte* alloc(size_t size);
|
||||
@@ -50,6 +54,9 @@ public:
|
||||
|
||||
// Allocate `size` bytes, aligned to 64 bytes and padded to next 64-byte offset.
|
||||
std::byte* allocA64(size_t size);
|
||||
|
||||
private:
|
||||
Region m_region;
|
||||
};
|
||||
|
||||
} // namespace mimir
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
#include <cstddef>
|
||||
|
||||
namespace mimir {
|
||||
|
||||
// Dynamically growable memory region with a contiguous address range.
|
||||
// Provides OS and hardware agnostic reservation and committing of memory pages.
|
||||
class Region
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
|
||||
namespace mimir {
|
||||
|
||||
// Two-Level Segregated Fit (TLSF): http://www.gii.upv.es/tlsf/files/papers/ecrts04_tlsf.pdf
|
||||
|
||||
Heap::Heap()
|
||||
{
|
||||
}
|
||||
@@ -46,9 +48,12 @@ Heap::~Heap()
|
||||
{
|
||||
}
|
||||
|
||||
bool Heap::init(size_t minSize, size_t maxSize)
|
||||
bool Heap::init(size_t maxSize)
|
||||
{
|
||||
return false; // not implemented
|
||||
if (!m_region.init(maxSize)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Allocate `size` bytes
|
||||
|
||||
Reference in New Issue
Block a user