Serviceability support for Epsilon epsilon-gc-branch
authorshade
Sat, 19 May 2018 23:51:09 +0200
branchepsilon-gc-branch
changeset 56576 92316ff16d5c
parent 56540 ada11a8e2ebc
child 56577 338a117fb65c
Serviceability support for Epsilon
src/hotspot/share/gc/epsilon/epsilonHeap.hpp
src/hotspot/share/gc/epsilon/vmStructs_epsilon.hpp
src/hotspot/share/gc/shared/vmStructs_gc.hpp
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/epsilon/EpsilonHeap.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeapName.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java
--- a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp	Fri May 11 18:33:36 2018 +0200
+++ b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp	Sat May 19 23:51:09 2018 +0200
@@ -34,6 +34,7 @@
 #include "gc/epsilon/epsilon_globals.hpp"
 
 class EpsilonHeap : public CollectedHeap {
+  friend class VMStructs;
 private:
   EpsilonCollectorPolicy* _policy;
   SoftRefPolicy _soft_ref_policy;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/epsilon/vmStructs_epsilon.hpp	Sat May 19 23:51:09 2018 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2018, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * 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.
+ *
+ */
+
+#ifndef SHARE_GC_EPSILON_VMSTRUCTS_HPP
+#define SHARE_GC_EPSILON_VMSTRUCTS_HPP
+
+#include "gc/epsilon/epsilonHeap.hpp"
+#include "memory/virtualspace.hpp"
+
+#define VM_STRUCTS_EPSILONGC(nonstatic_field,                       \
+                            volatile_nonstatic_field,               \
+                            static_field)                           \
+  nonstatic_field(EpsilonHeap, _virtual_space, VirtualSpace)
+
+#define VM_TYPES_EPSILONGC(declare_type,                            \
+                          declare_toplevel_type,                    \
+                          declare_integer_type)                     \
+  declare_type(EpsilonHeap, CollectedHeap)
+
+#define VM_INT_CONSTANTS_EPSILONGC(declare_constant,                \
+                                  declare_constant_with_value)
+
+#endif // SHARE_GC_EPSILON_VMSTRUCTS_HPP
--- a/src/hotspot/share/gc/shared/vmStructs_gc.hpp	Fri May 11 18:33:36 2018 +0200
+++ b/src/hotspot/share/gc/shared/vmStructs_gc.hpp	Sat May 19 23:51:09 2018 +0200
@@ -47,6 +47,9 @@
 #include "gc/serial/defNewGeneration.hpp"
 #include "gc/serial/vmStructs_serial.hpp"
 #endif
+#if INCLUDE_EPSILONGC
+#include "gc/epsilon/vmStructs_epsilon.hpp"
+#endif
 
 #define VM_STRUCTS_GC(nonstatic_field,                                                                                               \
                       volatile_nonstatic_field,                                                                                      \
@@ -64,6 +67,9 @@
   SERIALGC_ONLY(VM_STRUCTS_SERIALGC(nonstatic_field,                                                                                 \
                                     volatile_nonstatic_field,                                                                        \
                                     static_field))                                                                                   \
+  EPSILONGC_ONLY(VM_STRUCTS_EPSILONGC(nonstatic_field,                                                                               \
+                                    volatile_nonstatic_field,                                                                        \
+                                    static_field))                                                                                   \
   /**********************************************************************************/                                               \
   /* Generation and Space hierarchies                                               */                                               \
   /**********************************************************************************/                                               \
@@ -162,6 +168,9 @@
   SERIALGC_ONLY(VM_TYPES_SERIALGC(declare_type,                           \
                                   declare_toplevel_type,                  \
                                   declare_integer_type))                  \
+  EPSILONGC_ONLY(VM_TYPES_EPSILONGC(declare_type,                         \
+                                  declare_toplevel_type,                  \
+                                  declare_integer_type))                  \
   /******************************************/                            \
   /* Generation and space hierarchies       */                            \
   /* (needed for run-time type information) */                            \
@@ -231,6 +240,8 @@
                                               declare_constant_with_value)) \
   SERIALGC_ONLY(VM_INT_CONSTANTS_SERIALGC(declare_constant,                 \
                                           declare_constant_with_value))     \
+  EPSILONGC_ONLY(VM_INT_CONSTANTS_EPSILONGC(declare_constant,               \
+                                          declare_constant_with_value))     \
                                                                             \
   /********************************************/                            \
   /* Generation and Space Hierarchy Constants */                            \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/epsilon/EpsilonHeap.java	Sat May 19 23:51:09 2018 +0200
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * 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.epsilon;
+
+import java.io.*;
+import java.util.*;
+
+import sun.jvm.hotspot.gc.shared.CollectedHeap;
+import sun.jvm.hotspot.gc.shared.CollectedHeapName;
+import sun.jvm.hotspot.code.*;
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.memory.*;
+
+public class EpsilonHeap extends CollectedHeap {
+
+  private static Field spaceField;
+  private VirtualSpace space;
+
+  static {
+    VM.registerVMInitializedObserver(new Observer() {
+        public void update(Observable o, Object data) {
+          initialize(VM.getVM().getTypeDataBase());
+        }
+      });
+  }
+
+  private static void initialize(TypeDataBase db) {
+    Type type = db.lookupType("EpsilonHeap");
+    spaceField = type.getField("_virtual_space");
+  }
+
+  public EpsilonHeap(Address addr) {
+    super(addr);
+    space = new VirtualSpace(addr.addOffsetTo(spaceField.getOffset()));
+  }
+
+  @Override
+  public CollectedHeapName kind() {
+    return CollectedHeapName.EPSILON;
+  }
+
+  public VirtualSpace space() {
+    return space;
+  }
+
+  @Override
+  public void printOn(PrintStream tty) {
+     MemRegion mr = reservedRegion();
+     tty.println("Epsilon heap");
+     tty.println(" reserved: [" + mr.start() + ", " + mr.end() + "]");
+     tty.println(" committed: [" + space.low() + ", " + space.high() + "]");
+  }
+
+}
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeapName.java	Fri May 11 18:33:36 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/shared/CollectedHeapName.java	Sat May 19 23:51:09 2018 +0200
@@ -35,6 +35,7 @@
   public static final CollectedHeapName PARALLEL = new CollectedHeapName("Parallel");
   public static final CollectedHeapName CMS = new CollectedHeapName("CMS");
   public static final CollectedHeapName G1 = new CollectedHeapName("G1");
+  public static final CollectedHeapName EPSILON = new CollectedHeapName("Epsilon");
 
   public String toString() {
     return name;
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java	Fri May 11 18:33:36 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java	Sat May 19 23:51:09 2018 +0200
@@ -31,6 +31,7 @@
 import sun.jvm.hotspot.gc.serial.SerialHeap;
 import sun.jvm.hotspot.gc.shared.*;
 import sun.jvm.hotspot.gc.g1.G1CollectedHeap;
+import sun.jvm.hotspot.gc.epsilon.EpsilonHeap;
 import sun.jvm.hotspot.gc.parallel.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.types.*;
@@ -82,6 +83,7 @@
     heapConstructor.addMapping("SerialHeap", SerialHeap.class);
     heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
     heapConstructor.addMapping("G1CollectedHeap", G1CollectedHeap.class);
+    heapConstructor.addMapping("EpsilonHeap", EpsilonHeap.class);
 
     mainThreadGroupField   = type.getOopField("_main_thread_group");
     systemThreadGroupField = type.getOopField("_system_thread_group");
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Fri May 11 18:33:36 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Sat May 19 23:51:09 2018 +0200
@@ -34,6 +34,7 @@
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.gc.cms.*;
 import sun.jvm.hotspot.gc.shared.*;
+import sun.jvm.hotspot.gc.epsilon.*;
 import sun.jvm.hotspot.gc.g1.*;
 import sun.jvm.hotspot.gc.parallel.*;
 import sun.jvm.hotspot.memory.*;
@@ -438,6 +439,9 @@
     } else if (heap instanceof G1CollectedHeap) {
         G1CollectedHeap g1h = (G1CollectedHeap) heap;
         g1h.heapRegionIterate(lrc);
+    } else if (heap instanceof EpsilonHeap) {
+       EpsilonHeap eh = (EpsilonHeap) heap;
+       liveRegions.add(eh.space());
     } else {
        if (Assert.ASSERTS_ENABLED) {
           Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +