Always add a sign when spewing jump distances.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
21 #include "PoolAllocator.h"
25 PoolAllocator::PoolAllocator()
31 PoolAllocator::~PoolAllocator()
39 PoolAllocator::enter()
47 PoolAllocator::leave(char *pos)
53 PoolAllocator::unwind(char *pos)
56 if (pos && pos >= last_->base && pos < last_->end)
58 Pool *prev = last_->prev;
60 if (last_->size() <= kMaxReserveSize &&
61 (!reserved_ || reserved_->size() < last_->size()))
82 PoolAllocator::slowAllocate(size_t actualBytes)
84 size_t bytesNeeded = actualBytes + sizeof(Pool);
85 if (bytesNeeded < kDefaultPoolSize)
86 bytesNeeded = kDefaultPoolSize;
89 if (reserved_ && reserved_->size() >= bytesNeeded) {
93 pool = (Pool *)malloc(bytesNeeded);
95 throw std::bad_alloc();
96 pool->base = (char *)(pool + 1);
97 pool->end = (char *)pool + bytesNeeded;
99 pool->ptr = pool->base + actualBytes;