dvander@49: /* vim: set ts=4 sw=4 tw=99 et: dvander@49: * dvander@49: * Copyright (C) 2012 David Anderson dvander@49: * dvander@49: * This file is part of JITCraft. dvander@49: * dvander@49: * JITCraft is free software: you can redistribute it and/or modify it under dvander@49: * the terms of the GNU General Public License as published by the Free dvander@49: * Software Foundation, either version 3 of the License, or (at your option) dvander@49: * any later version. dvander@49: * dvander@49: * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY dvander@49: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS dvander@49: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. dvander@49: * dvander@49: * You should have received a copy of the GNU General Public License along with dvander@49: * JITCraft. If not, see http://www.gnu.org/licenses/. dvander@49: */ dvander@49: #ifndef _include_jitcraft_spaces_inl_h_ dvander@49: #define _include_jitcraft_spaces_inl_h_ dvander@49: danderson@91: #include "Objects.h" danderson@91: dvander@59: namespace ke { dvander@49: dvander@49: inline Address dvander@49: HeapStack::allocate(size_t nbytes) dvander@49: { dvander@49: nbytes = Align(nbytes, kObjectAlignment); dvander@49: dvander@51: if (cursor_ + nbytes > chunk_->end()) dvander@49: return NULL; dvander@49: dvander@51: Address ptr = cursor_; dvander@51: cursor_ += nbytes; dvander@49: return ptr; dvander@49: } dvander@49: dvander@49: inline void dvander@49: HeapStack::unwind(Address to) dvander@49: { dvander@51: assert(to <= cursor_ && to >= chunk_->first()); dvander@51: cursor_ = to; dvander@11: } dvander@11: dvander@12: inline Address dvander@11: OldSpace::allocate(size_t nbytes) dvander@11: { dvander@11: assert(IsAligned(nbytes, kObjectAlignment)); dvander@11: dvander@51: if (cursor_ + nbytes > last_->end()) dvander@51: return allocateSlow(nbytes); dvander@11: dvander@53: Address addr = cursor_; dvander@51: cursor_ += nbytes; dvander@51: return addr; dvander@49: } dvander@49: danderson@91: template inline Object * danderson@91: ChunkObjectIteratorBase::next() danderson@91: { danderson@91: while (current_ && current_ != top_) { danderson@91: Object *obj = reinterpret_cast(current_); danderson@91: size_t size = evaluator_(obj, obj->map()); danderson@91: current_ += size; danderson@91: if (current_ == chunk_->end()) { danderson@91: chunk_ = chunk_->next(); danderson@91: current_ = chunk_ ? chunk_->first() : NULL; danderson@91: } danderson@91: if (obj->is(MapKind_FreeRegion)) danderson@91: continue; danderson@91: } danderson@91: return NULL; danderson@91: } danderson@91: dvander@49: } dvander@49: dvander@49: #endif // _include_jitcraft_spaces_inl_h_