changeset 21002:95931055060f

fix handling of uncompressed vector oopmaps
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 16 Apr 2015 22:41:22 -0700
parents acc86d08e1cc
children a7f216accfb5
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java
diffstat 1 files changed, 39 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java	Thu Apr 16 16:07:34 2015 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java	Thu Apr 16 22:41:22 2015 -0700
@@ -165,8 +165,8 @@
             return new HotSpotOopMap(this);
         }
 
-        private void setNarrowOop(int offset, int index) {
-            setNarrowEntry(offset + index, OOP32);
+        private void setNarrowOop(int offset) {
+            setNarrowEntry(offset, OOP32);
         }
 
         private void setEntry(int regIdx, int value) {
@@ -356,62 +356,44 @@
     }
 
     // setters
-
-    private static void setOop(HotSpotOopMap map, int startIdx, LIRKind kind) {
-        int length = kind.getPlatformKind().getVectorLength();
-        for (int i = 0, idx = startIdx; i < length; i++, idx += 1) {
-            if (kind.isReference(i)) {
-                map.setOop(idx);
-            }
-
-        }
-    }
-
-    private static void setNarrowOop(HotSpotOopMap map, int offset, LIRKind kind) {
-        int length = kind.getPlatformKind().getVectorLength();
-        for (int i = 0; i < length; i++) {
-            if (kind.isReference(i)) {
-                map.setNarrowOop(offset, i);
-            }
-        }
+    @Override
+    public void setRegister(int idx, LIRKind kind) {
+        set(registerRefMap, idx * 2, kind);
     }
 
     @Override
-    public void setRegister(int idx, LIRKind kind) {
+    public void setStackSlot(int offset, LIRKind kind) {
+        assert offset % bytesPerElement(kind) == 0 : "unaligned value in ReferenceMap";
+        set(frameRefMap, offset / 4, kind);
+    }
+
+    private void set(HotSpotOopMap refMap, int index, LIRKind kind) {
         if (kind.isDerivedReference()) {
             throw GraalInternalError.shouldNotReachHere("derived reference cannot be inserted in ReferenceMap");
         }
 
-        PlatformKind platformKind = kind.getPlatformKind();
-        int bytesPerElement = target.getSizeInBytes(platformKind) / platformKind.getVectorLength();
-
+        int bytesPerElement = bytesPerElement(kind);
+        int length = kind.getPlatformKind().getVectorLength();
         if (bytesPerElement == 8) {
-            setOop(registerRefMap, idx * 2, kind);
+            for (int i = 0; i < length; i++) {
+                if (kind.isReference(i)) {
+                    refMap.setOop(index + i * 2);
+                }
+            }
         } else if (bytesPerElement == 4) {
-            setNarrowOop(registerRefMap, idx * 2, kind);
+            for (int i = 0; i < length; i++) {
+                if (kind.isReference(i)) {
+                    refMap.setNarrowOop(index + i);
+                }
+            }
         } else {
-            assert kind.isValue() : "unsupported reference kind " + kind;
+            assert kind.isValue() : "unknown reference kind " + kind;
         }
     }
 
-    @Override
-    public void setStackSlot(int offset, LIRKind kind) {
-        if (kind.isDerivedReference()) {
-            throw GraalInternalError.shouldNotReachHere("derived reference cannot be inserted in ReferenceMap");
-        }
-
+    private int bytesPerElement(LIRKind kind) {
         PlatformKind platformKind = kind.getPlatformKind();
-        int bytesPerElement = target.getSizeInBytes(platformKind) / platformKind.getVectorLength();
-        assert offset % bytesPerElement == 0 : "unaligned value in ReferenceMap";
-
-        int index = offset / 4; // Addressing is done in increments of 4 bytes
-        if (bytesPerElement == 8) {
-            setOop(frameRefMap, index, kind);
-        } else if (bytesPerElement == 4) {
-            setNarrowOop(frameRefMap, index, kind);
-        } else {
-            assert kind.isValue() : "unknown reference kind " + kind;
-        }
+        return target.getSizeInBytes(platformKind) / platformKind.getVectorLength();
     }
 
     public HotSpotOopMap getFrameMap() {
@@ -423,47 +405,28 @@
     }
 
     // clear
-
-    private static void clearOop(HotSpotOopMap map, int offset, PlatformKind platformKind) {
-        int length = platformKind.getVectorLength();
-        for (int i = 0; i < length; i++) {
-            map.clearOop(offset + i * 2);
-        }
-    }
-
-    private static void clearNarrowOop(HotSpotOopMap map, int offset, PlatformKind platformKind) {
-        int length = platformKind.getVectorLength();
-        for (int i = 0; i < length; i++) {
-            map.clearNarrowOop(offset + i);
-        }
-    }
-
     @Override
     public void clearRegister(int idx, LIRKind kind) {
-        PlatformKind platformKind = kind.getPlatformKind();
-        int bytesPerElement = target.getSizeInBytes(platformKind) / platformKind.getVectorLength();
-
-        if (bytesPerElement == 8) {
-            clearOop(registerRefMap, idx * 2, platformKind);
-        } else if (bytesPerElement == 4) {
-            clearNarrowOop(registerRefMap, idx * 2, platformKind);
-        } else {
-            assert kind.isValue() : "unsupported reference kind " + kind;
-        }
+        clear(registerRefMap, idx * 2, kind);
     }
 
     @Override
     public void clearStackSlot(int offset, LIRKind kind) {
-
-        PlatformKind platformKind = kind.getPlatformKind();
-        int bytesPerElement = target.getSizeInBytes(platformKind) / platformKind.getVectorLength();
-        assert offset % bytesPerElement == 0 : "unaligned value in ReferenceMap";
+        assert offset % bytesPerElement(kind) == 0 : "unaligned value in ReferenceMap";
+        clear(frameRefMap, offset / 4, kind);
+    }
 
-        int index = offset / 4; // Addressing is done in increments of 4 bytes
+    private void clear(HotSpotOopMap refMap, int index, LIRKind kind) {
+        int bytesPerElement = bytesPerElement(kind);
+        int length = kind.getPlatformKind().getVectorLength();
         if (bytesPerElement == 8) {
-            clearOop(frameRefMap, index, platformKind);
+            for (int i = 0; i < length; i++) {
+                refMap.clearOop(index + i * 2);
+            }
         } else if (bytesPerElement == 4) {
-            clearNarrowOop(frameRefMap, index, platformKind);
+            for (int i = 0; i < length; i++) {
+                refMap.clearNarrowOop(index + i);
+            }
         } else {
             assert kind.isValue() : "unknown reference kind " + kind;
         }