1 /*
2 * Copyright (c) 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 *
246 }
247 if (cur == start_idx - 1) {
248 return num_regions_found;
249 }
250 jlong old_cur = cur;
251 // cur indexes the first empty region
252 while (cur >= start_idx && is_available(cur) && at(cur)->is_empty()) {
253 cur--;
254 }
255 *res_idx = cur + 1;
256 num_regions_found = old_cur - cur;
257
258 #ifdef ASSERT
259 for (uint i = *res_idx; i < (*res_idx + num_regions_found); i++) {
260 assert(at(i)->is_empty(), "just checking");
261 }
262 #endif
263 return num_regions_found;
264 }
265
266 HeapRegion* HeterogeneousHeapRegionManager::allocate_free_region(HeapRegionType type) {
267
268 // We want to prevent mutators from proceeding when we have borrowed regions from the last collection. This
269 // will force a full collection to remedy the situation.
270 // Free region requests from GC threads can proceed.
271 if(type.is_eden() || type.is_humongous()) {
272 if(has_borrowed_regions()) {
273 return NULL;
274 }
275 }
276
277 // old and humongous regions are allocated from nv-dimm; eden and survivor regions are allocated from dram
278 // assumption: dram regions take higher indexes
279 bool from_nvdimm = (type.is_old() || type.is_humongous()) ? true : false;
280 bool from_head = from_nvdimm;
281 HeapRegion* hr = _free_list.remove_region(from_head);
282
283 if (hr != NULL && ( (from_nvdimm && !is_in_nvdimm(hr->hrm_index())) || (!from_nvdimm && !is_in_dram(hr->hrm_index())) ) ) {
284 _free_list.add_ordered(hr);
285 hr = NULL;
286 }
|
1 /*
2 * Copyright (c) 2018, 2019, 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 *
246 }
247 if (cur == start_idx - 1) {
248 return num_regions_found;
249 }
250 jlong old_cur = cur;
251 // cur indexes the first empty region
252 while (cur >= start_idx && is_available(cur) && at(cur)->is_empty()) {
253 cur--;
254 }
255 *res_idx = cur + 1;
256 num_regions_found = old_cur - cur;
257
258 #ifdef ASSERT
259 for (uint i = *res_idx; i < (*res_idx + num_regions_found); i++) {
260 assert(at(i)->is_empty(), "just checking");
261 }
262 #endif
263 return num_regions_found;
264 }
265
266 HeapRegion* HeterogeneousHeapRegionManager::allocate_free_region(HeapRegionType type, uint node_index) {
267
268 // We want to prevent mutators from proceeding when we have borrowed regions from the last collection. This
269 // will force a full collection to remedy the situation.
270 // Free region requests from GC threads can proceed.
271 if(type.is_eden() || type.is_humongous()) {
272 if(has_borrowed_regions()) {
273 return NULL;
274 }
275 }
276
277 // old and humongous regions are allocated from nv-dimm; eden and survivor regions are allocated from dram
278 // assumption: dram regions take higher indexes
279 bool from_nvdimm = (type.is_old() || type.is_humongous()) ? true : false;
280 bool from_head = from_nvdimm;
281 HeapRegion* hr = _free_list.remove_region(from_head);
282
283 if (hr != NULL && ( (from_nvdimm && !is_in_nvdimm(hr->hrm_index())) || (!from_nvdimm && !is_in_dram(hr->hrm_index())) ) ) {
284 _free_list.add_ordered(hr);
285 hr = NULL;
286 }
|