[11] RFR(XS) 8202948: C2: assert(init_offset >= 0) failed: positive offset from object start

Vladimir Kozlov vladimir.kozlov at oracle.com
Wed Jun 13 17:14:52 UTC 2018


https://bugs.openjdk.java.net/browse/JDK-8202948

Predicates and Range checks before main loop will not help since they 
are runtime checks and limit is not constant. The problem happens during 
compilation because vectorization is attempted for over-unrolling loop 
which will not be executed in runtime (dead loop). Stride is negative 
(-3) value and initial is 2 - loop will be executed at least once (or 
never) because of other conditions in code. C2 did not recognize this 
because the test fails only with -Xcomp when profiling data is no 
available (it passed without -Xcomp).

Simplest fix is to convert the assert into compilation check which will 
skip superword optimization in such case.

diff -r 0d47e89382ed src/hotspot/share/opto/superword.cpp
--- a/src/hotspot/share/opto/superword.cpp
+++ b/src/hotspot/share/opto/superword.cpp
@@ -887,7 +887,9 @@
    if (init_nd->is_Con() && p.invar() == NULL) {
      int init = init_nd->bottom_type()->is_int()->get_con();
      int init_offset = init * p.scale_in_bytes() + offset;
-    assert(init_offset >= 0, "positive offset from object start");
+    if (init_offset < 0) { // negative offset from object start?
+      return false;        // may happen in dead loop
+    }
      if (vw % span == 0) {
        // If vm is a multiple of span, we use formula (1).
        if (span > 0) {

Test passed with and without Predicates with this fix.

Tested with tier1, tier2, precheckin-xcomp

-- 
Thanks,
Vladimir


More information about the hotspot-compiler-dev mailing list