Split ArrayType from Type.
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"
23 #include "Spaces-inl.h"
28 PoolAllocator::PoolAllocator()
34 PoolAllocator::~PoolAllocator()
42 PoolAllocator::enter()
50 PoolAllocator::leave(char *pos)
56 PoolAllocator::unwind(char *pos)
59 if (pos && pos >= last_->base && pos < last_->end)
61 Pool *prev = last_->prev;
63 if (last_->size() <= kMaxReserveSize &&
64 (!reserved_ || reserved_->size() < last_->size()))
85 PoolAllocator::slowAllocate(size_t actualBytes)
87 size_t bytesNeeded = actualBytes + sizeof(Pool);
88 if (bytesNeeded < kDefaultPoolSize)
89 bytesNeeded = kDefaultPoolSize;
92 if (reserved_ && reserved_->size() >= bytesNeeded) {
96 pool = (Pool *)malloc(bytesNeeded);
98 ZONE()->reportOutOfMemory();
101 pool->base = (char *)(pool + 1);
102 pool->end = (char *)pool + bytesNeeded;
104 pool->ptr = pool->base + actualBytes;
111 PoolAllocationPolicy::reportOutOfMemory()
113 ZONE()->reportOutOfMemory();
117 PoolAllocationPolicy::reportAllocationOverflow()
119 ZONE()->reportError(Message_AllocationOverflow);
123 PoolAllocationPolicy::malloc(size_t bytes)
125 return ZONE()->pool().rawAllocate(bytes);
129 PoolAllocationPolicy::free(void *ptr)