--- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java 2018-12-03 17:46:55.002638964 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java 2018-12-03 17:46:54.837640142 +0100 @@ -36,6 +36,7 @@ import sun.jvm.hotspot.gc.epsilon.*; import sun.jvm.hotspot.gc.parallel.*; import sun.jvm.hotspot.gc.shared.*; +import sun.jvm.hotspot.gc.shenandoah.*; import sun.jvm.hotspot.gc.g1.*; import sun.jvm.hotspot.gc.z.*; import sun.jvm.hotspot.interpreter.*; @@ -1113,6 +1114,10 @@ } else if (collHeap instanceof EpsilonHeap) { anno = "Epsilon "; bad = false; + } else if (collHeap instanceof ShenandoahHeap) { + ShenandoahHeap heap = (ShenandoahHeap) collHeap; + anno = "ShenandoahHeap "; + bad = false; } else if (collHeap instanceof ZCollectedHeap) { ZCollectedHeap heap = (ZCollectedHeap) collHeap; anno = "ZHeap "; --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeapName.java 2018-12-03 17:46:55.248637207 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeapName.java 2018-12-03 17:46:55.089638343 +0100 @@ -37,6 +37,7 @@ public static final CollectedHeapName G1 = new CollectedHeapName("G1"); public static final CollectedHeapName EPSILON = new CollectedHeapName("Epsilon"); public static final CollectedHeapName Z = new CollectedHeapName("Z"); + public static final CollectedHeapName SHENANDOAH = new CollectedHeapName("Shenandoah"); public String toString() { return name; --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/GCCause.java 2018-12-03 17:46:55.469635629 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/GCCause.java 2018-12-03 17:46:55.310636765 +0100 @@ -67,6 +67,12 @@ _z_allocation_stall ("Allocation Stall"), _z_proactive ("Proactive"), + _shenandoah_stop_vm ("Stop VM"), + _shenandoah_allocation_failure_evac ("Allocation Failure During Evacuation"), + _shenandoah_concurrent_gc ("Concurrent GC"), + _shenandoah_traversal_gc ("Traversal GC"), + _shenandoah_upgrade_to_full_gc ("Upgrade to Full GC"), + _last_gc_cause ("ILLEGAL VALUE - last gc cause - ILLEGAL VALUE"); private final String value; --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/GCName.java 2018-12-03 17:46:55.695634016 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/GCName.java 2018-12-03 17:46:55.534635165 +0100 @@ -38,6 +38,7 @@ G1Old ("G1Old"), G1Full ("G1Full"), Z ("Z"), + Shenandoah ("Shenandoah"), NA ("N/A"), GCNameEndSentinel ("GCNameEndSentinel"); --- /dev/null 2018-12-03 11:58:50.256341286 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeap.java 2018-12-03 17:46:55.759633559 +0100 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package sun.jvm.hotspot.gc.shenandoah; + +import sun.jvm.hotspot.gc.shared.CollectedHeap; +import sun.jvm.hotspot.gc.shared.CollectedHeapName; +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; +import sun.jvm.hotspot.memory.MemRegion; +import sun.jvm.hotspot.types.CIntegerField; +import java.io.PrintStream; +import java.util.Observable; +import java.util.Observer; + +public class ShenandoahHeap extends CollectedHeap { + static private CIntegerField numRegions; + static private CIntegerField used; + static private CIntegerField committed; + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + static private synchronized void initialize(TypeDataBase db) { + Type type = db.lookupType("ShenandoahHeap"); + numRegions = type.getCIntegerField("_num_regions"); + used = type.getCIntegerField("_used"); + committed = type.getCIntegerField("_committed"); + } + + @Override + public CollectedHeapName kind() { + return CollectedHeapName.SHENANDOAH; + } + + public long numOfRegions() { + return numRegions.getValue(addr); + } + + @Override + public long used() { + return used.getValue(addr); + } + + public long committed() { + return committed.getValue(addr); + } + + @Override + public void printOn(PrintStream tty) { + MemRegion mr = reservedRegion(); + tty.print("Shenandoah heap"); + tty.print(" [" + mr.start() + ", " + mr.end() + "]"); + tty.println(" region size " + ShenandoahHeapRegion.regionSizeBytes() / 1024 + " K"); + } + + public ShenandoahHeap(Address addr) { + super(addr); + } +} --- /dev/null 2018-12-03 11:58:50.256341286 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shenandoah/ShenandoahHeapRegion.java 2018-12-03 17:46:56.008631781 +0100 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package sun.jvm.hotspot.gc.shenandoah; + +import sun.jvm.hotspot.gc.shared.ContiguousSpace; +import sun.jvm.hotspot.types.CIntegerField; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; +import sun.jvm.hotspot.debugger.Address; + +import java.util.Observable; +import java.util.Observer; + + +public class ShenandoahHeapRegion extends ContiguousSpace { + private static CIntegerField RegionSizeBytes; + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + static private synchronized void initialize(TypeDataBase db) { + Type type = db.lookupType("ShenandoahHeapRegion"); + RegionSizeBytes = type.getCIntegerField("RegionSizeBytes"); + } + + public static long regionSizeBytes() { return RegionSizeBytes.getValue(); } + + public ShenandoahHeapRegion(Address addr) { + super(addr); + } +} --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java 2018-12-03 17:46:56.416628867 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java 2018-12-03 17:46:56.260629981 +0100 @@ -36,6 +36,7 @@ import sun.jvm.hotspot.gc.parallel.ParallelScavengeHeap; import sun.jvm.hotspot.gc.serial.SerialHeap; import sun.jvm.hotspot.gc.shared.CollectedHeap; +import sun.jvm.hotspot.gc.shenandoah.ShenandoahHeap; import sun.jvm.hotspot.gc.z.ZCollectedHeap; import sun.jvm.hotspot.oops.Oop; import sun.jvm.hotspot.runtime.BasicType; @@ -100,6 +101,7 @@ addHeapTypeIfInDB(db, G1CollectedHeap.class); addHeapTypeIfInDB(db, EpsilonHeap.class); addHeapTypeIfInDB(db, ZCollectedHeap.class); + addHeapTypeIfInDB(db, ShenandoahHeap.class); mainThreadGroupField = type.getOopField("_main_thread_group"); systemThreadGroupField = type.getOopField("_system_thread_group"); --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java 2018-12-03 17:46:56.643627247 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java 2018-12-03 17:46:56.484628382 +0100 @@ -36,6 +36,7 @@ import sun.jvm.hotspot.gc.shared.*; import sun.jvm.hotspot.gc.epsilon.*; import sun.jvm.hotspot.gc.g1.*; +import sun.jvm.hotspot.gc.shenandoah.*; import sun.jvm.hotspot.gc.parallel.*; import sun.jvm.hotspot.gc.z.*; import sun.jvm.hotspot.memory.*; @@ -367,6 +368,10 @@ } else if (heap instanceof G1CollectedHeap) { G1CollectedHeap g1h = (G1CollectedHeap) heap; g1h.heapRegionIterate(lrc); + } else if (heap instanceof ShenandoahHeap) { + // Operation (currently) not supported with Shenandoah GC. Print + // a warning and leave the list of live regions empty. + System.err.println("Warning: Operation not supported with Shenandoah GC"); } else if (heap instanceof ZCollectedHeap) { // Operation (currently) not supported with ZGC. Print // a warning and leave the list of live regions empty. --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VMOps.java 2018-12-03 17:46:56.868625640 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VMOps.java 2018-12-03 17:46:56.712626754 +0100 @@ -55,6 +55,7 @@ CMS_Final_Remark, G1CollectFull, ZOperation, + ShenandoahOperation, G1CollectForAllocation, G1IncCollectionPause, EnableBiasedLocking, --- old/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java 2018-12-03 17:46:57.087624076 +0100 +++ new/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java 2018-12-03 17:46:56.931625190 +0100 @@ -29,6 +29,7 @@ import sun.jvm.hotspot.gc.g1.*; import sun.jvm.hotspot.gc.parallel.*; import sun.jvm.hotspot.gc.serial.*; +import sun.jvm.hotspot.gc.shenandoah.*; import sun.jvm.hotspot.gc.shared.*; import sun.jvm.hotspot.gc.z.*; import sun.jvm.hotspot.debugger.JVMDebugger; @@ -83,7 +84,11 @@ printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap)); printValMB("CompressedClassSpaceSize = ", getFlagValue("CompressedClassSpaceSize", flagMap)); printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap)); - printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes()); + if (heap instanceof ShenandoahHeap) { + printValMB("ShenandoahRegionSize = ", ShenandoahHeapRegion.regionSizeBytes()); + } else { + printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes()); + } System.out.println(); System.out.println("Heap Usage:"); @@ -126,6 +131,14 @@ printValMB("used = ", oldGen.used()); printValMB("free = ", oldFree); System.out.println(alignment + (double)oldGen.used() * 100.0 / oldGen.capacity() + "% used"); + } else if (heap instanceof ShenandoahHeap) { + ShenandoahHeap sh = (ShenandoahHeap) heap; + long num_regions = sh.numOfRegions(); + System.out.println("Shenandoah Heap:"); + System.out.println(" regions = " + num_regions); + printValMB("capacity = ", num_regions * ShenandoahHeapRegion.regionSizeBytes()); + printValMB("used = ", sh.used()); + printValMB("committed = ", sh.committed()); } else if (heap instanceof EpsilonHeap) { EpsilonHeap eh = (EpsilonHeap) heap; printSpace(eh.space()); @@ -183,6 +196,12 @@ return; } + l = getFlagValue("UseShenandoahGC", flagMap); + if (l == 1L) { + System.out.print("Shenandoah GC"); + return; + } + System.out.println("Mark Sweep Compact GC"); }