8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
authorrschatz
Thu, 21 Jan 2016 16:22:01 +0100
changeset 35591 35ab7c6816e9
parent 35590 39a11b5f4283
child 35592 5814f874d736
8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass Reviewed-by: twisti
hotspot/test/compiler/jvmci/code/TestAssembler.java
hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java
--- a/hotspot/test/compiler/jvmci/code/TestAssembler.java	Fri Jan 22 12:37:32 2016 +0100
+++ b/hotspot/test/compiler/jvmci/code/TestAssembler.java	Thu Jan 21 16:22:01 2016 +0100
@@ -295,6 +295,15 @@
             data.putFloat(f);
         }
 
+        public void align(int alignment) {
+            int pos = data.position();
+            int misaligned = pos % alignment;
+            if (misaligned != 0) {
+                pos += alignment - misaligned;
+                data.position(pos);
+            }
+        }
+
         private byte[] finish() {
             return Arrays.copyOf(data.array(), data.position());
         }
--- a/hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java	Fri Jan 22 12:37:32 2016 +0100
+++ b/hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java	Thu Jan 21 16:22:01 2016 +0100
@@ -109,10 +109,11 @@
 
     @Override
     public Register emitLoadLong(long c) {
-        if ((c & 0xFFFFFFFF) == c) {
+        if ((c & 0xFFFF_FFFFL) == c) {
             return emitLoadInt((int) c);
         } else {
             DataSectionReference ref = new DataSectionReference();
+            data.align(8);
             ref.setOffset(data.position());
             data.emitLong(c);
             return emitLoadPointer(ref);
@@ -133,6 +134,7 @@
     @Override
     public Register emitLoadFloat(float c) {
         DataSectionReference ref = new DataSectionReference();
+        data.align(4);
         ref.setOffset(data.position());
         data.emitFloat(c);
 
@@ -262,4 +264,14 @@
         recordImplicitException(info);
         emitOp3(0b11, SPARC.g0, 0b001011, SPARC.g0, 0); // LDX [g0+0], g0
     }
+
+    @Override
+    public DataSectionReference emitDataItem(HotSpotConstant c) {
+        if (c.isCompressed()) {
+            data.align(4);
+        } else {
+            data.align(8);
+        }
+        return super.emitDataItem(c);
+    }
 }