ysr@777: /* stefank@2314: * Copyright (c) 2001, 2010, Oracle and/or its affiliates. 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: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. ysr@777: * ysr@777: */ ysr@777: stefank@2314: #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP stefank@2314: #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP stefank@2314: stefank@2314: #include "gc_implementation/g1/concurrentMark.hpp" stefank@2314: #include "gc_implementation/g1/g1CollectedHeap.hpp" stefank@2314: #include "gc_implementation/g1/heapRegionSeq.hpp" stefank@2314: #include "utilities/taskqueue.hpp" stefank@2314: 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 { tonyp@961: assert(_g1_reserved.contains(addr), "invariant"); johnc@1187: size_t index = pointer_delta(addr, _g1_reserved.start(), 1) johnc@1187: >> HeapRegion::LogOfHRGrainBytes; johnc@1187: tonyp@961: HeapRegion* res = _hrs->at(index); tonyp@961: assert(res == _hrs->addr_to_region(addr), "sanity"); 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: tonyp@2073: // All humongous allocation requests should go through the slow path in tonyp@2073: // attempt_allocation_slow(). tonyp@2073: if (!isHumongous(word_size) && _cur_alloc_region != NULL) { 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: } tonyp@2073: tonyp@2073: if (res != NULL) { tonyp@2073: if (!SafepointSynchronize::is_at_safepoint()) { tonyp@2073: assert( Heap_lock->owned_by_self(), "invariant" ); tonyp@2073: Heap_lock->unlock(); tonyp@2073: } tonyp@2073: return res; ysr@777: } 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: jcoomes@2064: inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const { ysr@777: return _task_queues->queue(i); 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: } stefank@2314: stefank@2314: #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP