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 *
23 */
24
25 #ifndef SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
26 #define SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
27
28 #include "gc/g1/g1BiasedArray.hpp"
29 #include "gc/g1/g1RegionToSpaceMapper.hpp"
30 #include "gc/g1/heapRegionSet.hpp"
31 #include "services/memoryUsage.hpp"
32
33 class HeapRegion;
34 class HeapRegionClosure;
35 class HeapRegionClaimer;
36 class FreeRegionList;
37 class WorkGang;
38
39 class G1HeapRegionTable : public G1BiasedMappedArray<HeapRegion*> {
40 protected:
41 virtual HeapRegion* default_value() const { return NULL; }
42 };
43
44 // This class keeps track of the actual heap memory, auxiliary data
45 // and its metadata (i.e., HeapRegion instances) and the list of free regions.
46 //
47 // This allows maximum flexibility for deciding what to commit or uncommit given
48 // a request from outside.
49 //
50 // HeapRegions are kept in the _regions array in address order. A region's
266 static const uint Unclaimed = 0;
267 static const uint Claimed = 1;
268
269 public:
270 HeapRegionClaimer(uint n_workers);
271 ~HeapRegionClaimer();
272
273 inline uint n_regions() const {
274 return _n_regions;
275 }
276
277 // Calculate the starting region for given worker so
278 // that they do not all start from the same region.
279 uint start_region_for_worker(uint worker_id) const;
280
281 // Check if region has been claimed with this HRClaimer.
282 bool is_region_claimed(uint region_index) const;
283
284 // Claim the given region, returns true if successfully claimed.
285 bool claim_region(uint region_index);
286 };
287 #endif // SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
|
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 *
23 */
24
25 #ifndef SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
26 #define SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
27
28 #include "gc/g1/g1BiasedArray.hpp"
29 #include "gc/g1/g1RegionToSpaceMapper.hpp"
30 #include "gc/g1/heapRegionSet.hpp"
31 #include "gc/shared/workgroup.hpp"
32 #include "services/memoryUsage.hpp"
33
34 class HeapRegion;
35 class HeapRegionClosure;
36 class HeapRegionClaimer;
37 class FreeRegionList;
38 class WorkGang;
39
40 class G1HeapRegionTable : public G1BiasedMappedArray<HeapRegion*> {
41 protected:
42 virtual HeapRegion* default_value() const { return NULL; }
43 };
44
45 // This class keeps track of the actual heap memory, auxiliary data
46 // and its metadata (i.e., HeapRegion instances) and the list of free regions.
47 //
48 // This allows maximum flexibility for deciding what to commit or uncommit given
49 // a request from outside.
50 //
51 // HeapRegions are kept in the _regions array in address order. A region's
267 static const uint Unclaimed = 0;
268 static const uint Claimed = 1;
269
270 public:
271 HeapRegionClaimer(uint n_workers);
272 ~HeapRegionClaimer();
273
274 inline uint n_regions() const {
275 return _n_regions;
276 }
277
278 // Calculate the starting region for given worker so
279 // that they do not all start from the same region.
280 uint start_region_for_worker(uint worker_id) const;
281
282 // Check if region has been claimed with this HRClaimer.
283 bool is_region_claimed(uint region_index) const;
284
285 // Claim the given region, returns true if successfully claimed.
286 bool claim_region(uint region_index);
287 };
288
289 // Subclass of AbstractGangTask that uses a HeapRegionClaimer to parallelize work on a region basis
290 class G1ParallelizeByRegionsTask: public AbstractGangTask {
291 HeapRegionClaimer _hrclaimer;
292
293 public:
294 G1ParallelizeByRegionsTask(const char* name, uint num_workers) :
295 AbstractGangTask(name),
296 _hrclaimer(num_workers) {}
297
298 protected:
299 void all_heap_regions_work(HeapRegionClosure* cl,
300 uint worker_id,
301 bool concurrent = false);
302 };
303 #endif // SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
|