8202948: C2: assert(init_offset >= 0) failed: positive offset from object start

Fri, 15 Jun 2018 08:28:08 -0700

author
kvn
date
Fri, 15 Jun 2018 08:28:08 -0700
changeset 9740
b290489738b8
parent 9739
bf9503046dd4
child 9741
7e0a4478e80f

8202948: C2: assert(init_offset >= 0) failed: positive offset from object start
Summary: convert the assert into compilation check which will skip superword optimization
Reviewed-by: roland, thartmann

src/share/vm/opto/superword.cpp file | annotate | diff | comparison | revisions
test/compiler/loopopts/superword/TestNegBaseOffset.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/superword.cpp	Fri Dec 14 11:22:26 2018 +0100
     1.2 +++ b/src/share/vm/opto/superword.cpp	Fri Jun 15 08:28:08 2018 -0700
     1.3 @@ -482,7 +482,9 @@
     1.4    if (init_nd->is_Con() && p.invar() == NULL) {
     1.5      int init = init_nd->bottom_type()->is_int()->get_con();
     1.6      int init_offset = init * p.scale_in_bytes() + offset;
     1.7 -    assert(init_offset >= 0, "positive offset from object start");
     1.8 +    if (init_offset < 0) { // negative offset from object start?
     1.9 +      return false;        // may happen in dead loop
    1.10 +    }
    1.11      if (vw % span == 0) {
    1.12        // If vm is a multiple of span, we use formula (1).
    1.13        if (span > 0) {
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/compiler/loopopts/superword/TestNegBaseOffset.java	Fri Jun 15 08:28:08 2018 -0700
     2.3 @@ -0,0 +1,59 @@
     2.4 +/*
     2.5 + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    2.23 + * or visit www.oracle.com if you need additional information or have any
    2.24 + * questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @bug 8202948
    2.30 + * @summary Test skipping vector packs with negative base offset.
    2.31 + * @comment Test fails only with -Xcomp when profiling data is not present.
    2.32 + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
    2.33 + *                   -Xcomp -XX:-TieredCompilation -XX:CICompilerCount=1
    2.34 + *                   -XX:CompileOnly=compiler/loopopts/superword/TestNegBaseOffset
    2.35 + *                   compiler.loopopts.superword.TestNegBaseOffset
    2.36 + */
    2.37 +
    2.38 +package compiler.loopopts.superword;
    2.39 +
    2.40 +public class TestNegBaseOffset {
    2.41 +    public static final int N = 400;
    2.42 +    public static int iFld=10;
    2.43 +    public static int iArr[]=new int[N];
    2.44 +
    2.45 +    public static void mainTest() {
    2.46 +        int i0=1, i2;
    2.47 +        while (++i0 < 339) {
    2.48 +            if ((i0 % 2) == 0) {
    2.49 +                for (i2 = 2; i2 > i0; i2 -= 3) {
    2.50 +                    iArr[i2 - 1] &= iFld;
    2.51 +                }
    2.52 +            }
    2.53 +        }
    2.54 +    }
    2.55 +
    2.56 +    public static void main(String[] strArr) {
    2.57 +        for (int i = 0; i < 10; i++) {
    2.58 +            mainTest();
    2.59 +        }
    2.60 +    }
    2.61 +}
    2.62 +

mercurial