Mercurial > hg > truffle
comparison test/compiler/EscapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java @ 17894:87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
Summary: use correct set_escape_state() method.
Reviewed-by: kvn, iignatyev
Contributed-by: Richard Reingruber <richard.reingruber@sap.com>
author | kvn |
---|---|
date | Wed, 16 Apr 2014 14:49:03 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17893:a163af774cb9 | 17894:87b5e00100fe |
---|---|
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 */ | |
23 | |
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 */ | |
31 | |
32 import java.lang.reflect.Field; | |
33 import sun.misc.Unsafe; | |
34 | |
35 public class TestUnsafePutAddressNullObjMustNotEscape { | |
36 | |
37 public static Unsafe usafe; | |
38 public static long mem; | |
39 public static long checksum; | |
40 | |
41 public static void main(String[] args) throws Exception { | |
42 System.out.println("EXECUTING test."); | |
43 | |
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 } | |
52 | |
53 System.out.println("SUCCESSFULLY passed test."); | |
54 } | |
55 | |
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 } | |
63 | |
64 public static class IDGen { | |
65 private static long id; | |
66 public long nextId() { | |
67 return id++; | |
68 } | |
69 } | |
70 | |
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 } | |
78 | |
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 } |