1 /* 2 * Copyright (c) 2019, 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 25 #include "precompiled.hpp" 26 #include "gc/shenandoah/mode/shenandoahGenerationalMode.hpp" 27 #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" 28 #include "gc/shenandoah/shenandoahHeap.inline.hpp" 29 #include "logging/log.hpp" 30 #include "logging/logTag.hpp" 31 #include "runtime/globals_extension.hpp" 32 33 void ShenandoahGenerationalMode::initialize_flags() const { 34 if (ClassUnloading) { 35 FLAG_SET_DEFAULT(ShenandoahSuspendibleWorkers, true); 36 FLAG_SET_DEFAULT(VerifyBeforeExit, false); 37 } 38 39 SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUnloadClassesFrequency, 0); 40 SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent); 41 SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent); 42 43 // This helps most multi-core hardware hosts, enable by default 44 SHENANDOAH_ERGO_ENABLE_FLAG(UseCondCardMark); 45 46 // Final configuration checks 47 SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier); 48 SHENANDOAH_CHECK_FLAG_UNSET(ShenandoahIUBarrier); 49 SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier); 50 SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier); 51 SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier); 52 } 53 54 const char* affiliation_name(oop ptr) { 55 ShenandoahHeap* heap = ShenandoahHeap::heap(); 56 assert(heap->is_in(ptr), "Oop must be in the heap."); 57 ShenandoahHeapRegion* region = heap->heap_region_containing(ptr); 58 return affiliation_name(region->affiliation()); 59 } 60 61 const char affiliation_code(ShenandoahRegionAffiliation type) { 62 switch(type) { 63 case ShenandoahRegionAffiliation::FREE: 64 return 'F'; 65 case ShenandoahRegionAffiliation::YOUNG_GENERATION: 66 return 'Y'; 67 case ShenandoahRegionAffiliation::OLD_GENERATION: 68 return 'O'; 69 default: 70 ShouldNotReachHere(); 71 return 'X'; 72 } 73 } 74 75 const char* affiliation_name(ShenandoahRegionAffiliation type) { 76 switch (type) { 77 case ShenandoahRegionAffiliation::FREE: 78 return "FREE"; 79 case ShenandoahRegionAffiliation::YOUNG_GENERATION: 80 return "YOUNG"; 81 case ShenandoahRegionAffiliation::OLD_GENERATION: 82 return "OLD"; 83 default: 84 ShouldNotReachHere(); 85 return nullptr; 86 } 87 } 88 89 const char* generation_name(GenerationMode mode) { 90 switch (mode) { 91 case GenerationMode::GLOBAL: 92 return "Global"; 93 case GenerationMode::OLD: 94 return "Old"; 95 case GenerationMode::YOUNG: 96 return "Young"; 97 default: 98 ShouldNotReachHere(); 99 return nullptr; 100 } 101 }