1 /* 2 * Copyright (c) 2020, Red Hat, Inc. 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 #include "precompiled.hpp" 25 26 #include "gc/shenandoah/shenandoahFreeSet.hpp" 27 #include "gc/shenandoah/shenandoahHeap.hpp" 28 #include "gc/shenandoah/shenandoahHeap.inline.hpp" 29 #include "gc/shenandoah/shenandoahOldGeneration.hpp" 30 #include "gc/shenandoah/shenandoahUtils.hpp" 31 #include "gc/shenandoah/shenandoahVerifier.hpp" 32 #include "gc/shenandoah/shenandoahYoungGeneration.hpp" 33 #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" 34 35 ShenandoahYoungGeneration::ShenandoahYoungGeneration(uint max_queues, size_t max_capacity, size_t soft_max_capacity) : 36 ShenandoahGeneration(YOUNG, max_queues, max_capacity, soft_max_capacity), 37 _old_gen_task_queues(nullptr) { 38 } 39 40 const char* ShenandoahYoungGeneration::name() const { 41 return "YOUNG"; 42 } 43 44 void ShenandoahYoungGeneration::set_concurrent_mark_in_progress(bool in_progress) { 45 ShenandoahHeap* heap = ShenandoahHeap::heap(); 46 heap->set_concurrent_young_mark_in_progress(in_progress); 47 if (is_bootstrap_cycle() && in_progress && !heap->is_prepare_for_old_mark_in_progress()) { 48 // This is not a bug. When the bootstrapping marking phase is complete, 49 // the old generation marking is still in progress, unless it's not. 50 // In the case that old-gen preparation for mixed evacuation has been 51 // preempted, we do not want to set concurrent old mark to be in progress. 52 heap->set_concurrent_old_mark_in_progress(in_progress); 53 } 54 } 55 56 bool ShenandoahYoungGeneration::contains(ShenandoahHeapRegion* region) const { 57 // TODO: why not test for equals YOUNG_GENERATION? As written, returns true for regions that are FREE 58 return region->affiliation() != OLD_GENERATION; 59 } 60 61 void ShenandoahYoungGeneration::parallel_heap_region_iterate(ShenandoahHeapRegionClosure* cl) { 62 // Just iterate over the young generation here. 63 ShenandoahGenerationRegionClosure<YOUNG> young_regions(cl); 64 ShenandoahHeap::heap()->parallel_heap_region_iterate(&young_regions); 65 } 66 67 void ShenandoahYoungGeneration::heap_region_iterate(ShenandoahHeapRegionClosure* cl) { 68 ShenandoahGenerationRegionClosure<YOUNG> young_regions(cl); 69 ShenandoahHeap::heap()->heap_region_iterate(&young_regions); 70 } 71 72 bool ShenandoahYoungGeneration::is_concurrent_mark_in_progress() { 73 return ShenandoahHeap::heap()->is_concurrent_young_mark_in_progress(); 74 } 75 76 void ShenandoahYoungGeneration::reserve_task_queues(uint workers) { 77 ShenandoahGeneration::reserve_task_queues(workers); 78 if (is_bootstrap_cycle()) { 79 _old_gen_task_queues->reserve(workers); 80 } 81 } 82 83 bool ShenandoahYoungGeneration::contains(oop obj) const { 84 return ShenandoahHeap::heap()->is_in_young(obj); 85 } 86 87 ShenandoahHeuristics* ShenandoahYoungGeneration::initialize_heuristics(ShenandoahMode* gc_mode) { 88 _heuristics = gc_mode->initialize_heuristics(this); 89 _heuristics->set_guaranteed_gc_interval(ShenandoahGuaranteedYoungGCInterval); 90 confirm_heuristics_mode(); 91 return _heuristics; 92 } 93 94 void ShenandoahYoungGeneration::add_collection_time(double time_seconds) { 95 if (is_bootstrap_cycle()) { 96 // This is a bootstrap cycle, so attribute time to old gc 97 ShenandoahHeap::heap()->old_generation()->add_collection_time(time_seconds); 98 } else { 99 ShenandoahGeneration::add_collection_time(time_seconds); 100 } 101 }