test/compiler/EscapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.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 2014 SAP AG.  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  */
    24 /**
    25  * @test
    26  * @bug 8038048
    27  * @summary assert(null_obj->escape_state() == PointsToNode::NoEscape,etc)
    28  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+DoEscapeAnalysis -XX:-TieredCompilation -Xbatch TestUnsafePutAddressNullObjMustNotEscape
    29  * @author Richard Reingruber richard DOT reingruber AT sap DOT com
    30  */
    32 import java.lang.reflect.Field;
    33 import sun.misc.Unsafe;
    35 public class TestUnsafePutAddressNullObjMustNotEscape {
    37     public static Unsafe usafe;
    38     public static long mem;
    39     public static long checksum;
    41     public static void main(String[] args) throws Exception {
    42         System.out.println("EXECUTING test.");
    44         {
    45             System.out.println("Acquiring sun.misc.Unsafe.theUnsafe using reflection.");
    46             getUnsafe();
    47             System.out.println("Allocating raw memory.");
    48             mem = (usafe.allocateMemory(1024) + 8L) & ~7L;
    49             System.out.println("Triggering JIT compilation of the test method");
    50             triggerJitCompilationOfTestMethod();
    51         }
    53         System.out.println("SUCCESSFULLY passed test.");
    54     }
    56     public static void triggerJitCompilationOfTestMethod() {
    57         long sum = 0;
    58         for (int ii = 50000; ii >= 0; ii--) {
    59             sum = testMethod();
    60         }
    61         checksum = sum;
    62     }
    64     public static class IDGen {
    65         private static long id;
    66         public long nextId() {
    67             return id++;
    68         }
    69     }
    71     public static long testMethod() {
    72         // dummy alloc to trigger escape analysis
    73         IDGen gen = new IDGen();
    74         // StoreP of null_obj to raw mem triggers assertion in escape analysis
    75         usafe.putAddress(mem, 0L);
    76         return gen.nextId();
    77     }
    79     private static void getUnsafe() throws Exception {
    80         Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
    81         field.setAccessible(true);
    82         usafe = (sun.misc.Unsafe) field.get(null);
    83     }
    84 }

mercurial