Fix SA heap iteration code epsilon-gc-branch
authorshade
Tue, 05 Jun 2018 17:17:19 +0200
branchepsilon-gc-branch
changeset 56667 d999bdb8173c
parent 56666 80185413d7fd
child 56668 5cd17d3d3f83
Fix SA heap iteration code
src/hotspot/share/gc/epsilon/vmStructs_epsilon.hpp
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/epsilon/EpsilonHeap.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java
--- a/src/hotspot/share/gc/epsilon/vmStructs_epsilon.hpp	Thu May 31 16:09:17 2018 +0200
+++ b/src/hotspot/share/gc/epsilon/vmStructs_epsilon.hpp	Tue Jun 05 17:17:19 2018 +0200
@@ -26,12 +26,14 @@
 #define SHARE_GC_EPSILON_VMSTRUCTS_HPP
 
 #include "gc/epsilon/epsilonHeap.hpp"
+#include "gc/shared/space.hpp"
 #include "memory/virtualspace.hpp"
 
 #define VM_STRUCTS_EPSILONGC(nonstatic_field,                       \
                             volatile_nonstatic_field,               \
                             static_field)                           \
-  nonstatic_field(EpsilonHeap, _virtual_space, VirtualSpace)
+  nonstatic_field(EpsilonHeap, _virtual_space, VirtualSpace)        \
+  nonstatic_field(EpsilonHeap, _space, ContiguousSpace*)
 
 #define VM_TYPES_EPSILONGC(declare_type,                            \
                           declare_toplevel_type,                    \
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/epsilon/EpsilonHeap.java	Thu May 31 16:09:17 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/epsilon/EpsilonHeap.java	Tue Jun 05 17:17:19 2018 +0200
@@ -27,8 +27,7 @@
 import java.io.*;
 import java.util.*;
 
-import sun.jvm.hotspot.gc.shared.CollectedHeap;
-import sun.jvm.hotspot.gc.shared.CollectedHeapName;
+import sun.jvm.hotspot.gc.shared.*;
 import sun.jvm.hotspot.code.*;
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.runtime.*;
@@ -37,8 +36,10 @@
 
 public class EpsilonHeap extends CollectedHeap {
 
-  private static Field spaceField;
-  private VirtualSpace space;
+  private static AddressField spaceField;
+  private static Field virtualSpaceField;
+  private ContiguousSpace space;
+  private VirtualSpace virtualSpace;
 
   static {
     VM.registerVMInitializedObserver(new Observer() {
@@ -50,12 +51,14 @@
 
   private static void initialize(TypeDataBase db) {
     Type type = db.lookupType("EpsilonHeap");
-    spaceField = type.getField("_virtual_space");
+    spaceField = type.getAddressField("_space");
+    virtualSpaceField = type.getField("_virtual_space");
   }
 
   public EpsilonHeap(Address addr) {
     super(addr);
-    space = new VirtualSpace(addr.addOffsetTo(spaceField.getOffset()));
+    space = new ContiguousSpace(spaceField.getValue(addr));
+    virtualSpace = new VirtualSpace(addr.addOffsetTo(virtualSpaceField.getOffset()));
   }
 
   @Override
@@ -63,7 +66,7 @@
     return CollectedHeapName.EPSILON;
   }
 
-  public VirtualSpace space() {
+  public ContiguousSpace space() {
     return space;
   }
 
@@ -71,8 +74,9 @@
   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() + "]");
+     tty.println(" reserved:  [" + mr.start() + ", " + mr.end() + "]");
+     tty.println(" committed: [" + virtualSpace.low() + ", " + virtualSpace.high() + "]");
+     tty.println(" used:      [" + space.bottom() + ", " + space.top() + "]");
   }
 
 }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Thu May 31 16:09:17 2018 +0200
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java	Tue Jun 05 17:17:19 2018 +0200
@@ -441,7 +441,8 @@
         g1h.heapRegionIterate(lrc);
     } else if (heap instanceof EpsilonHeap) {
        EpsilonHeap eh = (EpsilonHeap) heap;
-       liveRegions.add(eh.space());
+       liveRegions.add(eh.space().top());
+       liveRegions.add(eh.space().bottom());
     } else {
        if (Assert.ASSERTS_ENABLED) {
           Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +