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 
25 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHYOUNGGENERATION_HPP
26 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHYOUNGGENERATION_HPP
27 
28 #include "gc/shenandoah/shenandoahGeneration.hpp"
29 #include "gc/shenandoah/heuristics/shenandoahYoungHeuristics.hpp"
30 
31 class ShenandoahYoungGeneration : public ShenandoahGeneration {
32 private:
33   ShenandoahObjToScanQueueSet* _old_gen_task_queues;
34   ShenandoahYoungHeuristics* _young_heuristics;
35 
36 public:
37   ShenandoahYoungGeneration(uint max_queues, size_t max_capacity, size_t max_soft_capacity);
38 
39   virtual ShenandoahHeuristics* initialize_heuristics(ShenandoahMode* gc_mode) override;
40 
41   const char* name() const override {
42     return "YOUNG";
43   }
44 
45   ShenandoahYoungHeuristics* heuristics() const override {
46     return _young_heuristics;
47   }
48 
49   void set_concurrent_mark_in_progress(bool in_progress) override;
50   bool is_concurrent_mark_in_progress() override;
51 
52   void parallel_heap_region_iterate(ShenandoahHeapRegionClosure* cl) override;
53 
54   void parallel_region_iterate_free(ShenandoahHeapRegionClosure* cl) override;
55 
56   void heap_region_iterate(ShenandoahHeapRegionClosure* cl) override;
57 
58   bool contains(ShenandoahHeapRegion* region) const override;
59   bool contains(oop obj) const override;
60 
61   void reserve_task_queues(uint workers) override;
62   void set_old_gen_task_queues(ShenandoahObjToScanQueueSet* old_gen_queues) {
63     _old_gen_task_queues = old_gen_queues;
64   }
65   ShenandoahObjToScanQueueSet* old_gen_task_queues() const override {
66     return _old_gen_task_queues;
67   }
68 
69   // Returns true if the young generation is configured to enqueue old
70   // oops for the old generation mark queues.
71   bool is_bootstrap_cycle() {
72     return _old_gen_task_queues != nullptr;
73   }
74 
75   size_t available() const override;
76 
77   // Do not override available_with_reserve() because that needs to see memory reserved for Collector
78 
79   size_t soft_available() const override;
80 
81   virtual void prepare_gc() override;
82 };
83 
84 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHYOUNGGENERATION_HPP