Common: Add a memory pool implementation, remove use of boost::pool

This commit is contained in:
MerryMage 2016-08-06 20:41:00 +01:00
parent 411e804b0d
commit 4d127c19dd
6 changed files with 85 additions and 5 deletions

View file

@ -10,13 +10,13 @@
#include <memory>
#include <vector>
#include <boost/pool/pool.hpp>
#include <boost/intrusive/list.hpp>
#include <boost/optional.hpp>
#include <boost/variant.hpp>
#include "common/assert.h"
#include "common/common_types.h"
#include "common/memory_pool.h"
#include "frontend/arm_types.h"
#include "frontend/ir/opcodes.h"
@ -244,7 +244,7 @@ public:
/// List of instructions in this block.
boost::intrusive::list<Inst, InstListLinkMode> instructions;
/// Memory pool for instruction list
std::unique_ptr<boost::pool<>> instruction_alloc_pool = std::make_unique<boost::pool<>>(sizeof(Inst));
std::unique_ptr<Common::Pool> instruction_alloc_pool = std::make_unique<Common::Pool>(sizeof(Inst), 4096);
/// Terminal instruction of this block.
Terminal terminal = Term::Invalid{};

View file

@ -352,7 +352,7 @@ void IREmitter::SetTerm(const IR::Terminal& terminal) {
}
IR::Value IREmitter::Inst(IR::Opcode op, std::initializer_list<IR::Value> args) {
IR::Inst* inst = new(block.instruction_alloc_pool->malloc()) IR::Inst(op);
IR::Inst* inst = new(block.instruction_alloc_pool->Alloc()) IR::Inst(op);
DEBUG_ASSERT(args.size() == inst->NumArgs());
std::for_each(args.begin(), args.end(), [&inst, op, index = size_t(0)](const auto& v) mutable {