1 /*
 2  * Copyright Amazon.com Inc. 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 #ifndef SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHYOUNGHEURISTICS_HPP
25 #define SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHYOUNGHEURISTICS_HPP
26 
27 #include "gc/shenandoah/heuristics/shenandoahGenerationalHeuristics.hpp"
28 
29 class ShenandoahYoungGeneration;
30 
31 /*
32  * This is a specialization of the generational heuristic which chooses
33  * young regions for evacuation. This heuristic also has additional triggers
34  * designed to expedite mixed collections and promotions.
35  */
36 class ShenandoahYoungHeuristics : public ShenandoahGenerationalHeuristics {
37 public:
38   explicit ShenandoahYoungHeuristics(ShenandoahYoungGeneration* generation);
39 
40 
41   void choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,
42                                              RegionData* data, size_t size,
43                                              size_t actual_free) override;
44 
45   bool should_start_gc() override;
46 
47   size_t bytes_of_allocation_runway_before_gc_trigger(size_t young_regions_to_be_reclaimed);
48 
49 private:
50   void choose_young_collection_set(ShenandoahCollectionSet* cset,
51                                    const RegionData* data,
52                                    size_t size, size_t actual_free,
53                                    size_t cur_young_garbage) const;
54 
55 };
56 
57 #endif // SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHYOUNGHEURISTICS_HPP