1 /*
2 * Copyright (c) 2001, 2017, 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 *
151 // is valid.
152 inline HeapRegion* at(uint index) const;
153
154 // Return the next region (by index) that is part of the same
155 // humongous object that hr is part of.
156 inline HeapRegion* next_region_in_humongous(HeapRegion* hr) const;
157
158 // If addr is within the committed space return its corresponding
159 // HeapRegion, otherwise return NULL.
160 inline HeapRegion* addr_to_region(HeapWord* addr) const;
161
162 // Insert the given region into the free region list.
163 inline void insert_into_free_list(HeapRegion* hr);
164
165 // Insert the given region list into the global free region list.
166 void insert_list_into_free_list(FreeRegionList* list) {
167 _free_list.add_ordered(list);
168 }
169
170 HeapRegion* allocate_free_region(bool is_old) {
171 HeapRegion* hr = _free_list.remove_region(is_old);
172
173 if (hr != NULL) {
174 assert(hr->next() == NULL, "Single region should not have next");
175 assert(is_available(hr->hrm_index()), "Must be committed");
176 }
177 return hr;
178 }
179
180 inline void allocate_free_regions_starting_at(uint first, uint num_regions);
181
182 // Remove all regions from the free list.
183 void remove_all_free_regions() {
184 _free_list.remove_all();
185 }
186
187 // Return the number of committed free regions in the heap.
188 uint num_free_regions() const {
189 return _free_list.length();
190 }
191
192 size_t total_free_bytes() const {
|
1 /*
2 * Copyright (c) 2001, 2018, 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 *
151 // is valid.
152 inline HeapRegion* at(uint index) const;
153
154 // Return the next region (by index) that is part of the same
155 // humongous object that hr is part of.
156 inline HeapRegion* next_region_in_humongous(HeapRegion* hr) const;
157
158 // If addr is within the committed space return its corresponding
159 // HeapRegion, otherwise return NULL.
160 inline HeapRegion* addr_to_region(HeapWord* addr) const;
161
162 // Insert the given region into the free region list.
163 inline void insert_into_free_list(HeapRegion* hr);
164
165 // Insert the given region list into the global free region list.
166 void insert_list_into_free_list(FreeRegionList* list) {
167 _free_list.add_ordered(list);
168 }
169
170 HeapRegion* allocate_free_region(bool is_old) {
171 HeapRegion* hr = NULL;
172 if (os::has_nvdimm() && !is_old) {
173 hr = _free_list.show_tail();
174 if ((address)(hr->top()) < os::dram_heapbase()) {
175 return NULL;
176 }
177 }
178 hr = _free_list.remove_region(is_old);
179 if (hr != NULL) {
180 assert(hr->next() == NULL, "Single region should not have next");
181 assert(is_available(hr->hrm_index()), "Must be committed");
182 }
183 return hr;
184 }
185
186 inline void allocate_free_regions_starting_at(uint first, uint num_regions);
187
188 // Remove all regions from the free list.
189 void remove_all_free_regions() {
190 _free_list.remove_all();
191 }
192
193 // Return the number of committed free regions in the heap.
194 uint num_free_regions() const {
195 return _free_list.length();
196 }
197
198 size_t total_free_bytes() const {
|