1 /* 2 * Copyright (c) 2001, 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 * 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 public: 40 mixed_gc_live_threshold_bytes()41 static size_t mixed_gc_live_threshold_bytes() { 42 return HeapRegion::GrainBytes * (size_t) G1MixedGCLiveThresholdPercent / 100; 43 } 44 region_occupancy_low_enough_for_evac(size_t live_bytes)45 static bool region_occupancy_low_enough_for_evac(size_t live_bytes) { 46 return live_bytes < mixed_gc_live_threshold_bytes(); 47 } 48 49 // Determine whether to add the given region to the collection set candidates or 50 // not. Currently, we skip pinned regions and regions whose live 51 // bytes are over the threshold. Humongous regions may be reclaimed during cleanup. 52 // Regions also need a complete remembered set to be a candidate. 53 static bool should_add(HeapRegion* hr); 54 55 // Build and return set of collection set candidates sorted by decreasing gc 56 // efficiency. 57 static G1CollectionSetCandidates* build(WorkGang* workers, uint max_num_regions); 58 }; 59 60 #endif // SHARE_GC_G1_G1COLLECTIONSETCHOOSER_HPP 61