Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp
40957 views
1
/*
2
* Copyright (c) 2001, 2021, 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_GC_G1_G1COLLECTIONSETCHOOSER_HPP
26
#define SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP
27
28
#include "gc/g1/heapRegion.hpp"
29
#include "memory/allocation.hpp"
30
#include "runtime/globals.hpp"
31
32
class G1CollectionSetCandidates;
33
class WorkGang;
34
35
// Helper class to calculate collection set candidates, and containing some related
36
// methods.
37
class G1CollectionSetChooser : public AllStatic {
38
static uint calculate_work_chunk_size(uint num_workers, uint num_regions);
39
40
// Remove regions in the collection set candidates as long as the G1HeapWastePercent
41
// criteria is met. Keep at least the minimum amount of old regions to guarantee
42
// some progress.
43
static void prune(G1CollectionSetCandidates* candidates);
44
public:
45
46
static size_t mixed_gc_live_threshold_bytes() {
47
return HeapRegion::GrainBytes * (size_t) G1MixedGCLiveThresholdPercent / 100;
48
}
49
50
static bool region_occupancy_low_enough_for_evac(size_t live_bytes) {
51
return live_bytes < mixed_gc_live_threshold_bytes();
52
}
53
54
// Determine whether to add the given region to the collection set candidates or
55
// not. Currently, we skip pinned regions and regions whose live
56
// bytes are over the threshold. Humongous regions may be reclaimed during cleanup.
57
// Regions also need a complete remembered set to be a candidate.
58
static bool should_add(HeapRegion* hr);
59
60
// Build and return set of collection set candidates sorted by decreasing gc
61
// efficiency.
62
static G1CollectionSetCandidates* build(WorkGang* workers, uint max_num_regions);
63
};
64
65
#endif // SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP
66
67