342N/A/*
3681N/A * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
342N/A *
342N/A * This code is free software; you can redistribute it and/or modify it
342N/A * under the terms of the GNU General Public License version 2 only, as
342N/A * published by the Free Software Foundation.
342N/A *
342N/A * This code is distributed in the hope that it will be useful, but WITHOUT
342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
342N/A * version 2 for more details (a copy is included in the LICENSE file that
342N/A * accompanied this code).
342N/A *
342N/A * You should have received a copy of the GNU General Public License version
342N/A * 2 along with this work; if not, write to the Free Software Foundation,
342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
342N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
342N/A *
342N/A */
342N/A
1879N/A#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_INLINE_HPP
1879N/A#define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_INLINE_HPP
1879N/A
2591N/A#include "gc_implementation/g1/heapRegion.hpp"
1879N/A#include "gc_implementation/g1/heapRegionSeq.hpp"
1879N/A
3681N/Ainline uintx HeapRegionSeq::addr_to_index_biased(HeapWord* addr) const {
2591N/A assert(_heap_bottom <= addr && addr < _heap_end,
2591N/A err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT,
2591N/A addr, _heap_bottom, _heap_end));
3681N/A uintx index = (uintx) addr >> _region_shift;
2591N/A return index;
2591N/A}
2591N/A
2591N/Ainline HeapRegion* HeapRegionSeq::addr_to_region_unsafe(HeapWord* addr) const {
2591N/A assert(_heap_bottom <= addr && addr < _heap_end,
2591N/A err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT" end: "PTR_FORMAT,
2591N/A addr, _heap_bottom, _heap_end));
3681N/A uintx index_biased = addr_to_index_biased(addr);
2591N/A HeapRegion* hr = _regions_biased[index_biased];
2591N/A assert(hr != NULL, "invariant");
2591N/A return hr;
2591N/A}
2591N/A
2591N/Ainline HeapRegion* HeapRegionSeq::addr_to_region(HeapWord* addr) const {
2591N/A if (addr != NULL && addr < _heap_end) {
2591N/A assert(addr >= _heap_bottom,
2591N/A err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT, addr, _heap_bottom));
2591N/A return addr_to_region_unsafe(addr);
342N/A }
342N/A return NULL;
342N/A}
1879N/A
3681N/Ainline HeapRegion* HeapRegionSeq::at(uint index) const {
2591N/A assert(index < length(), "pre-condition");
2591N/A HeapRegion* hr = _regions[index];
2591N/A assert(hr != NULL, "sanity");
2591N/A assert(hr->hrs_index() == index, "sanity");
2591N/A return hr;
2591N/A}
2591N/A
1879N/A#endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGIONSEQ_INLINE_HPP