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     // Leaving this here for the day we re-enable class unloading
36     FLAG_SET_DEFAULT(ShenandoahSuspendibleWorkers, true);
37     FLAG_SET_DEFAULT(VerifyBeforeExit, false);
38   }
39 
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 
62 const char* affiliation_name(ShenandoahRegionAffiliation type) {
63   switch (type) {
64     case ShenandoahRegionAffiliation::FREE:
65       return "FREE";
66     case ShenandoahRegionAffiliation::YOUNG_GENERATION:
67       return "YOUNG";
68     case ShenandoahRegionAffiliation::OLD_GENERATION:
69       return "OLD";
70     default:
71       ShouldNotReachHere();
72       return nullptr;
73   }
74 }