test/compiler/7044738/Test7044738.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 0
f90c822e73f8
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

     1 /*
     2  * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 /**
    26  * @test
    27  * @bug 7044738
    28  * @summary Loop unroll optimization causes incorrect result
    29  *
    30  * @run main/othervm -Xbatch Test7044738
    31  */
    33 public class Test7044738 {
    35   private static final int INITSIZE = 10000;
    36   public int d[] = { 1, 2, 3, 4 };
    37   public int i, size;
    39   private static int iter = 5;
    41   boolean done() { return (--iter > 0); }
    43   public static void main(String args[]) {
    44     Test7044738 t = new Test7044738();
    45     t.test();
    46   }
    48   int test() {
    50     while (done()) {
    51       size = INITSIZE;
    53       for (i = 0; i < size; i++) {
    54         d[0] = d[1]; // 2
    55         d[1] = d[2]; // 3
    56         d[2] = d[3]; // 4
    57         d[3] = d[0]; // 2
    59         d[0] = d[1]; // 3
    60         d[1] = d[2]; // 4
    61         d[2] = d[3]; // 2
    62         d[3] = d[0]; // 3
    64         d[0] = d[1]; // 4
    65         d[1] = d[2]; // 2
    66         d[2] = d[3]; // 3
    67         d[3] = d[0]; // 4
    69         d[0] = d[1]; // 2
    70         d[1] = d[2]; // 3
    71         d[2] = d[3]; // 4
    72         d[3] = d[0]; // 2
    74         d[0] = d[1]; // 3
    75         d[1] = d[2]; // 4
    76         d[2] = d[3]; // 2
    77         d[3] = d[0]; // 3
    79         d[0] = d[1]; // 4
    80         d[1] = d[2]; // 2
    81         d[2] = d[3]; // 3
    82         d[3] = d[0]; // 4
    84         d[0] = d[1]; // 2
    85         d[1] = d[2]; // 3
    86         d[2] = d[3]; // 4
    87         d[3] = d[0]; // 2
    89         d[0] = d[1]; // 3
    90         d[1] = d[2]; // 4
    91         d[2] = d[3]; // 2
    92         d[3] = d[0]; // 3
    93       }
    95       // try to defeat dead code elimination
    96       if (d[0] == d[1]) {
    97         System.out.println("test failed: iter=" + iter + "  i=" + i + " d[] = { " + d[0] + ", " + d[1] + ", " + d[2] + ", " + d[3] + " } ");
    98         System.exit(97);
    99       }
   100     }
   101     return d[3];
   102   }
   104 }

mercurial