1 /*
2 * Copyright (c) 2001, 2016, 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 *
223 // Find a contiguous set of empty or unavailable regions of length num. Returns the
224 // start index of that set, or G1_NO_HRM_INDEX.
225 uint find_contiguous_empty_or_unavailable(size_t num) { return find_contiguous(num, false); }
226
227 HeapRegion* next_region_in_heap(const HeapRegion* r) const;
228
229 // Find the highest free or uncommitted region in the reserved heap,
230 // and if uncommitted, commit it. If none are available, return G1_NO_HRM_INDEX.
231 // Set the 'expanded' boolean true if a new region was committed.
232 uint find_highest_free(bool* expanded);
233
234 // Allocate the regions that contain the address range specified, committing the
235 // regions if necessary. Return false if any of the regions is already committed
236 // and not free, and return the number of regions newly committed in commit_count.
237 bool allocate_containing_regions(MemRegion range, size_t* commit_count, WorkGang* pretouch_workers);
238
239 // Apply blk->doHeapRegion() on all committed regions in address order,
240 // terminating the iteration early if doHeapRegion() returns true.
241 void iterate(HeapRegionClosure* blk) const;
242
243 void par_iterate(HeapRegionClosure* blk, uint worker_id, HeapRegionClaimer* hrclaimer, bool concurrent) const;
244
245 // Uncommit up to num_regions_to_remove regions that are completely free.
246 // Return the actual number of uncommitted regions.
247 uint shrink_by(uint num_regions_to_remove);
248
249 // Uncommit a number of regions starting at the specified index, which must be available,
250 // empty, and free.
251 void shrink_at(uint index, size_t num_regions);
252
253 void verify();
254
255 // Do some sanity checking.
256 void verify_optional() PRODUCT_RETURN;
257 };
258
259 // The HeapRegionClaimer is used during parallel iteration over heap regions,
260 // allowing workers to claim heap regions, gaining exclusive rights to these regions.
261 class HeapRegionClaimer : public StackObj {
262 uint _n_workers;
263 uint _n_regions;
|
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 *
223 // Find a contiguous set of empty or unavailable regions of length num. Returns the
224 // start index of that set, or G1_NO_HRM_INDEX.
225 uint find_contiguous_empty_or_unavailable(size_t num) { return find_contiguous(num, false); }
226
227 HeapRegion* next_region_in_heap(const HeapRegion* r) const;
228
229 // Find the highest free or uncommitted region in the reserved heap,
230 // and if uncommitted, commit it. If none are available, return G1_NO_HRM_INDEX.
231 // Set the 'expanded' boolean true if a new region was committed.
232 uint find_highest_free(bool* expanded);
233
234 // Allocate the regions that contain the address range specified, committing the
235 // regions if necessary. Return false if any of the regions is already committed
236 // and not free, and return the number of regions newly committed in commit_count.
237 bool allocate_containing_regions(MemRegion range, size_t* commit_count, WorkGang* pretouch_workers);
238
239 // Apply blk->doHeapRegion() on all committed regions in address order,
240 // terminating the iteration early if doHeapRegion() returns true.
241 void iterate(HeapRegionClosure* blk) const;
242
243 void par_iterate(HeapRegionClosure* blk, uint worker_id, HeapRegionClaimer* hrclaimer) const;
244
245 // Uncommit up to num_regions_to_remove regions that are completely free.
246 // Return the actual number of uncommitted regions.
247 uint shrink_by(uint num_regions_to_remove);
248
249 // Uncommit a number of regions starting at the specified index, which must be available,
250 // empty, and free.
251 void shrink_at(uint index, size_t num_regions);
252
253 void verify();
254
255 // Do some sanity checking.
256 void verify_optional() PRODUCT_RETURN;
257 };
258
259 // The HeapRegionClaimer is used during parallel iteration over heap regions,
260 // allowing workers to claim heap regions, gaining exclusive rights to these regions.
261 class HeapRegionClaimer : public StackObj {
262 uint _n_workers;
263 uint _n_regions;
|