8189069: regression after push of 8187403: "AssertionFailure: addr should be OopHandle"
authorysuenaga
Wed, 11 Oct 2017 23:29:24 +0900
changeset 47619 74f5b6c267e3
parent 47617 44117bc2bedf
child 47620 39575526c6d9
child 47641 5fbb4e3b5c92
8189069: regression after push of 8187403: "AssertionFailure: addr should be OopHandle" Reviewed-by: sspitsyn, jgeorge
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/G1HeapRegionTable.java
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegion.java
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/G1HeapRegionTable.java	Wed Oct 11 10:03:22 2017 -0400
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/G1HeapRegionTable.java	Wed Oct 11 23:29:24 2017 +0900
@@ -37,7 +37,6 @@
 import sun.jvm.hotspot.types.CIntegerField;
 import sun.jvm.hotspot.types.Type;
 import sun.jvm.hotspot.types.TypeDataBase;
-import sun.jvm.hotspot.utilities.Assert;
 
 // Mirror class for G1HeapRegionTable. It's essentially an index -> HeapRegion map.
 
@@ -136,11 +135,10 @@
     }
 
     public HeapRegion getByAddress(Address addr) {
-        if (Assert.ASSERTS_ENABLED) {
-            Assert.that(addr instanceof OopHandle, "addr should be OopHandle");
-        }
-
         long biasedIndex = addr.asLongValue() >>> shiftBy();
-        return new HeapRegion(addr.addOffsetToAsOopHandle(biasedIndex * HeapRegion.getPointerSize()));
+        long offset = biasedIndex * HeapRegion.getPointerSize();
+        Address result = (addr instanceof OopHandle) ? addr.addOffsetToAsOopHandle(offset)
+                                                     : addr.addOffsetTo(offset);
+        return new HeapRegion(result);
     }
 }
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegion.java	Wed Oct 11 10:03:22 2017 -0400
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/g1/HeapRegion.java	Wed Oct 11 23:29:24 2017 +0900
@@ -38,7 +38,6 @@
 import sun.jvm.hotspot.types.CIntegerField;
 import sun.jvm.hotspot.types.Type;
 import sun.jvm.hotspot.types.TypeDataBase;
-import sun.jvm.hotspot.utilities.Assert;
 
 // Mirror class for HeapRegion. Currently we don't actually include
 // any of its fields but only iterate over it.
@@ -76,12 +75,8 @@
 
     public HeapRegion(Address addr) {
         super(addr);
-
-        if (Assert.ASSERTS_ENABLED) {
-            Assert.that(addr instanceof OopHandle, "addr should be OopHandle");
-        }
-
-        Address typeAddr = addr.addOffsetToAsOopHandle(typeFieldOffset);
+        Address typeAddr = (addr instanceof OopHandle) ? addr.addOffsetToAsOopHandle(typeFieldOffset)
+                                                       : addr.addOffsetTo(typeFieldOffset);
         type = (HeapRegionType)VMObjectFactory.newObject(HeapRegionType.class, typeAddr);
     }