1 /* 2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_GC_G1_HEAPREGIONMANAGER_INLINE_HPP 26 #define SHARE_VM_GC_G1_HEAPREGIONMANAGER_INLINE_HPP 27 28 #include "gc/g1/heapRegion.hpp" 29 #include "gc/g1/heapRegionManager.hpp" 30 #include "gc/g1/heapRegionSet.inline.hpp" 31 32 inline HeapRegion* HeapRegionManager::addr_to_region(HeapWord* addr) const { 33 assert(addr < heap_end(), 34 err_msg("addr: "PTR_FORMAT" end: "PTR_FORMAT, p2i(addr), p2i(heap_end()))); 35 assert(addr >= heap_bottom(), 36 err_msg("addr: "PTR_FORMAT" bottom: "PTR_FORMAT, p2i(addr), p2i(heap_bottom()))); 37 38 HeapRegion* hr = _regions.get_by_address(addr); 39 return hr; 40 } 41 42 inline uint HeapRegionManager::addr_to_index(HeapWord* addr) const { 43 // Called routine will assert that index is in bounds (and thus address is within 44 // the maximum heap (which might be outside the current heap)). 45 return _regions.get_index_by_address(addr); 46 } 47 48 inline HeapRegion* HeapRegionManager::at(uint index) const { 49 assert(is_available(index), "pre-condition"); 50 HeapRegion* hr = _regions.get_by_index(index); 51 assert(hr != NULL, "sanity"); 52 assert(hr->hrm_index() == index, "sanity"); 53 return hr; 54 } 55 56 inline HeapRegion* HeapRegionManager::at_or_null(uint index) const { 57 assert(index <= max_length(), "index out of range"); 58 HeapRegion* hr = _regions.get_by_index(index); 59 return hr; 60 } 61 62 inline void HeapRegionManager::insert_into_free_list(HeapRegion* hr) { 63 _free_list.add_ordered(hr); 64 } 65 66 inline void HeapRegionManager::allocate_free_regions_starting_at(uint first, uint num_regions) { 67 _free_list.remove_starting_at(at(first), num_regions); 68 } 69 70 #endif // SHARE_VM_GC_G1_HEAPREGIONMANAGER_INLINE_HPP