Path: blob/master/src/hotspot/share/gc/g1/g1CollectionSetChooser.hpp
40957 views
/*1* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP25#define SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP2627#include "gc/g1/heapRegion.hpp"28#include "memory/allocation.hpp"29#include "runtime/globals.hpp"3031class G1CollectionSetCandidates;32class WorkGang;3334// Helper class to calculate collection set candidates, and containing some related35// methods.36class G1CollectionSetChooser : public AllStatic {37static uint calculate_work_chunk_size(uint num_workers, uint num_regions);3839// Remove regions in the collection set candidates as long as the G1HeapWastePercent40// criteria is met. Keep at least the minimum amount of old regions to guarantee41// some progress.42static void prune(G1CollectionSetCandidates* candidates);43public:4445static size_t mixed_gc_live_threshold_bytes() {46return HeapRegion::GrainBytes * (size_t) G1MixedGCLiveThresholdPercent / 100;47}4849static bool region_occupancy_low_enough_for_evac(size_t live_bytes) {50return live_bytes < mixed_gc_live_threshold_bytes();51}5253// Determine whether to add the given region to the collection set candidates or54// not. Currently, we skip pinned regions and regions whose live55// bytes are over the threshold. Humongous regions may be reclaimed during cleanup.56// Regions also need a complete remembered set to be a candidate.57static bool should_add(HeapRegion* hr);5859// Build and return set of collection set candidates sorted by decreasing gc60// efficiency.61static G1CollectionSetCandidates* build(WorkGang* workers, uint max_num_regions);62};6364#endif // SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP656667