[aarch64-port-dev ] Patch for assertion failure with Unsafes

ed at camswl.com ed at camswl.com
Mon Jul 22 03:23:13 PDT 2013


Hi,

The patch below fixes a problem where if you run 'Galaxians' with -Xcomp you
get an assertion failure.

~/work/aarch64/jdk8/build/linux-aarch64-normal-client-slowdebug/images/j2sdk-image/bin/appletviewer -J-Xcomp -J-XX:+PrintUnsafeOptimization -J-XX:+PrintCompilation Galaxians.html

...
  26235 1479     n       sun.awt.X11.XlibWrapper::XGetGeometry (native)   (static)
  26236 1480   !b        sun.awt.X11.XToolkit::getWorkArea (111 bytes)
Canonicalizer: UnsafeRawOp id 129: base = id 63, index = id 113, log2_scale = 0
Canonicalizer: UnsafeRawOp id 135: base = id 63, index = id 113, log2_scale = 0
Canonicalizer: UnsafeRawOp id 162: base = id 63, index = id 146, log2_scale = 1
Canonicalizer: UnsafeRawOp id 168: base = id 63, index = id 146, log2_scale = 1
Canonicalizer: UnsafeRawOp id 195: base = id 63, index = id 181, log2_scale = 0
Canonicalizer: UnsafeRawOp id 201: base = id 63, index = id 181, log2_scale = 0
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/assembler_aarch64.hpp:467
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/ed/work/aarch64/jdk8/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp:467), pid=3788, tid=139671006906112
#  assert(_ext.shift() == (int)size) failed: bad shift
#


In sun.awt.X11.XToolkit::getWorkArea it does

..
                int rootX = (int)Native.getLong(native_ptr, 0);
                int rootY = (int)Native.getLong(native_ptr, 1);
                int rootWidth = (int)Native.getLong(native_ptr, 2);
                int rootHeight = (int)Native.getLong(native_ptr, 3);
..

And from Native.getLong

    static long getLong(long ptr, int index) {
        return getLong(ptr + index*getLongSize());
    }

getLongSize() is simply an accessor returning a variable.

All of this gets inlined to form an address of the form [ptr + index << 1]
which causes the assertion failure above.

This fix I have applied is to turn off the optimisation in c1_Canonicalizer.cpp
when the shift is not either 0, or log2 of the type size.

Following this patch I can now run Galaxians completely with -Xcomp!

Please review,

Thanks,
Ed.

--- CUT HERE ---
exporting patch:
# HG changeset patch
# User Edward Nevill ed at camswl.com
# Date 1374486885 -3600
# Node ID dcb2fb66cdae2cc028ba57f646ced7fddedd63ea
# Parent  88c01e23c81857f61ce87daad4864dd12c0474db
Fix assert failure with Unsafes

diff -r 88c01e23c818 -r dcb2fb66cdae src/share/vm/c1/c1_Canonicalizer.cpp
--- a/src/share/vm/c1/c1_Canonicalizer.cpp	Fri Jul 19 12:41:02 2013 +0100
+++ b/src/share/vm/c1/c1_Canonicalizer.cpp	Mon Jul 22 10:54:45 2013 +0100
@@ -904,6 +904,13 @@
     return false;
   }
 
+// AARCH64 cannot handle shifts which are not either 0, or log2 of the type size
+#ifdef AARCH64
+  if (*log2_scale != 0 &&
+	(1 << *log2_scale) != type2aelembytes(x->basic_type(), true))
+    return false;
+#endif
+
   // If the value is pinned then it will be always be computed so
   // there's no profit to reshaping the expression.
   return !root->is_pinned();
--- CUT HERE ---



More information about the aarch64-port-dev mailing list