ysr@777: /* ysr@777: * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. ysr@777: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ysr@777: * ysr@777: * This code is free software; you can redistribute it and/or modify it ysr@777: * under the terms of the GNU General Public License version 2 only, as ysr@777: * published by the Free Software Foundation. ysr@777: * ysr@777: * This code is distributed in the hope that it will be useful, but WITHOUT ysr@777: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ysr@777: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ysr@777: * version 2 for more details (a copy is included in the LICENSE file that ysr@777: * accompanied this code). ysr@777: * ysr@777: * You should have received a copy of the GNU General Public License version ysr@777: * 2 along with this work; if not, write to the Free Software Foundation, ysr@777: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ysr@777: * ysr@777: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, ysr@777: * CA 95054 USA or visit www.sun.com if you need additional information or ysr@777: * have any questions. ysr@777: * ysr@777: */ ysr@777: ysr@777: // Inline functions for G1CollectedHeap ysr@777: ysr@777: inline HeapRegion* ysr@777: G1CollectedHeap::heap_region_containing(const void* addr) const { ysr@777: HeapRegion* hr = _hrs->addr_to_region(addr); ysr@777: // hr can be null if addr in perm_gen ysr@777: if (hr != NULL && hr->continuesHumongous()) { ysr@777: hr = hr->humongous_start_region(); ysr@777: } ysr@777: return hr; ysr@777: } ysr@777: ysr@777: inline HeapRegion* ysr@777: G1CollectedHeap::heap_region_containing_raw(const void* addr) const { ysr@777: HeapRegion* res = _hrs->addr_to_region(addr); ysr@777: assert(res != NULL, "addr outside of heap?"); ysr@777: return res; ysr@777: } ysr@777: ysr@777: inline bool G1CollectedHeap::obj_in_cs(oop obj) { ysr@777: HeapRegion* r = _hrs->addr_to_region(obj); ysr@777: return r != NULL && r->in_collection_set(); ysr@777: } ysr@777: ysr@777: inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size, ysr@777: bool permit_collection_pause) { ysr@777: HeapWord* res = NULL; ysr@777: ysr@777: assert( SafepointSynchronize::is_at_safepoint() || ysr@777: Heap_lock->owned_by_self(), "pre-condition of the call" ); ysr@777: ysr@777: if (_cur_alloc_region != NULL) { ysr@777: ysr@777: // If this allocation causes a region to become non empty, ysr@777: // then we need to update our free_regions count. ysr@777: ysr@777: if (_cur_alloc_region->is_empty()) { ysr@777: res = _cur_alloc_region->allocate(word_size); ysr@777: if (res != NULL) ysr@777: _free_regions--; ysr@777: } else { ysr@777: res = _cur_alloc_region->allocate(word_size); ysr@777: } ysr@777: } ysr@777: if (res != NULL) { ysr@777: if (!SafepointSynchronize::is_at_safepoint()) { ysr@777: assert( Heap_lock->owned_by_self(), "invariant" ); ysr@777: Heap_lock->unlock(); ysr@777: } ysr@777: return res; ysr@777: } ysr@777: // attempt_allocation_slow will also unlock the heap lock when appropriate. ysr@777: return attempt_allocation_slow(word_size, permit_collection_pause); ysr@777: } ysr@777: ysr@777: inline RefToScanQueue* G1CollectedHeap::task_queue(int i) { ysr@777: return _task_queues->queue(i); ysr@777: } ysr@777: ysr@777: ysr@777: inline bool G1CollectedHeap::isMarkedPrev(oop obj) const { ysr@777: return _cm->prevMarkBitMap()->isMarked((HeapWord *)obj); ysr@777: } ysr@777: ysr@777: inline bool G1CollectedHeap::isMarkedNext(oop obj) const { ysr@777: return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj); ysr@777: }