1 /* 2 * Copyright (c) 2018, Red Hat, Inc. and/or its affiliates. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 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 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #include "precompiled.hpp" 25 #include "gc_implementation/shenandoah/heuristics/shenandoahPassiveHeuristics.hpp" 26 #include "gc_implementation/shenandoah/shenandoahCollectionSet.hpp" 27 #include "gc_implementation/shenandoah/shenandoahHeap.hpp" 28 #include "gc_implementation/shenandoah/shenandoahHeapRegion.hpp" 29 #include "gc_implementation/shenandoah/shenandoahLogging.hpp" 30 31 ShenandoahPassiveHeuristics::ShenandoahPassiveHeuristics() : ShenandoahHeuristics() { 32 // Do not allow concurrent cycles. 33 FLAG_SET_DEFAULT(ExplicitGCInvokesConcurrent, false); 34 35 // Passive runs with max speed, reacts on allocation failure. 36 FLAG_SET_DEFAULT(ShenandoahPacing, false); 37 38 // Disable known barriers by default. 39 SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahSATBBarrier); 40 SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahWriteBarrier); 41 SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahReadBarrier); 42 SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahCASBarrier); 43 SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahAcmpBarrier); 44 SHENANDOAH_ERGO_DISABLE_FLAG(ShenandoahCloneBarrier); 45 } 46 47 void ShenandoahPassiveHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset, 48 RegionData* data, size_t size, 49 size_t free) { 50 for (size_t idx = 0; idx < size; idx++) { 51 ShenandoahHeapRegion* r = data[idx]._region; 52 if (r->garbage() > 0) { 53 cset->add_region(r); 54 } 55 } 56 } 57 58 bool ShenandoahPassiveHeuristics::should_start_normal_gc() const { 59 // Never do concurrent GCs. 60 return false; 61 } 62 63 bool ShenandoahPassiveHeuristics::should_process_references() { 64 if (ShenandoahRefProcFrequency == 0) return false; 65 // Always process references. 66 return true; 67 } 68 69 bool ShenandoahPassiveHeuristics::should_unload_classes() { 70 if (ShenandoahUnloadClassesFrequency == 0) return false; 71 // Always unload classes. 72 return true; 73 } 74 75 bool ShenandoahPassiveHeuristics::should_degenerate_cycle() { 76 // Always fail to Full GC 77 return false; 78 } 79 80 const char* ShenandoahPassiveHeuristics::name() { 81 return "passive"; 82 } 83 84 bool ShenandoahPassiveHeuristics::is_diagnostic() { 85 return true; 86 } 87 88 bool ShenandoahPassiveHeuristics::is_experimental() { 89 return false; 90 }