Compare commits

..

No commits in common. "58681803e9fe6b1f4711f609e441f3e3168775fd" and "76de033fe82221ca11b0c559b953a859fed512e1" have entirely different histories.

4 changed files with 5 additions and 33 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(blt-gp VERSION 0.1.12)
project(blt-gp VERSION 0.1.9)
include(CTest)

View File

@ -20,7 +20,6 @@
#define BLT_GP_STACK_H
#include <blt/std/types.h>
#include <blt/std/atomic_allocator.h>
#include <blt/std/assert.h>
#include <blt/std/logging.h>
#include <blt/std/allocator.h>
@ -43,29 +42,13 @@ namespace blt::gp
BLT_META_MAKE_FUNCTION_CHECK(drop);
}
class aligned_allocator
{
public:
void* allocate(blt::size_t bytes) // NOLINT
{
return std::aligned_alloc(8, bytes);
}
void deallocate(void* ptr, blt::size_t) // NOLINT
{
std::free(ptr);
}
};
class stack_allocator
{
constexpr static blt::size_t PAGE_SIZE = 0x1000;
constexpr static blt::size_t MAX_ALIGNMENT = 8;
template<typename T>
using NO_REF_T = std::remove_cv_t<std::remove_reference_t<T>>;
using Allocator = aligned_allocator;
public:
static Allocator& get_allocator();
struct size_data_t
{
blt::size_t total_size_bytes = 0;
@ -121,8 +104,7 @@ namespace blt::gp
~stack_allocator()
{
//std::free(data_);
get_allocator().deallocate(data_, size_);
std::free(data_);
}
void insert(const stack_allocator& stack)
@ -270,12 +252,10 @@ namespace blt::gp
void expand(blt::size_t bytes)
{
bytes = to_nearest_page_size(bytes);
// auto new_data = static_cast<blt::u8*>(std::malloc(bytes));
auto new_data = static_cast<blt::u8*>(get_allocator().allocate(bytes));
auto new_data = static_cast<blt::u8*>(std::malloc(bytes));
if (bytes_stored > 0)
std::memcpy(new_data, data_, bytes_stored);
// std::free(data_);
get_allocator().deallocate(data_, size_);
std::free(data_);
data_ = new_data;
size_ = bytes;
}
@ -330,8 +310,6 @@ namespace blt::gp
blt::size_t bytes_stored = 0;
blt::size_t size_ = 0;
};
}
#endif //BLT_GP_STACK_H

@ -1 +1 @@
Subproject commit 72211e3d7b29cec887257d59578669f198c2d3da
Subproject commit 97990401e2332276b5397060a3ccaf19f07fb999

View File

@ -50,12 +50,6 @@ namespace blt::gp
return random_engine;
}
stack_allocator::Allocator& stack_allocator::get_allocator()
{
thread_local static Allocator allocator;
return allocator;
}
void gp_program::create_threads()
{
if (config.threads == 0)