Mercurial > hg > truffle
annotate test/compiler/EscapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java @ 21621:993853d22c14
Fix in the bytecode parser: Do not overwrite the stateAfter of the start instruction.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 31 May 2015 23:20:24 +0200 |
parents | 87b5e00100fe |
children |
rev | line source |
---|---|
17894
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
1 /* |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
2 * Copyright 2014 SAP AG. All Rights Reserved. |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
4 * |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
8 * |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
13 * accompanied this code). |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
14 * |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
18 * |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
21 * questions. |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
22 */ |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
23 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
24 /** |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
25 * @test |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
26 * @bug 8038048 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
27 * @summary assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
28 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+DoEscapeAnalysis -XX:-TieredCompilation -Xbatch TestUnsafePutAddressNullObjMustNotEscape |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
29 * @author Richard Reingruber richard DOT reingruber AT sap DOT com |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
30 */ |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
31 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
32 import java.lang.reflect.Field; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
33 import sun.misc.Unsafe; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
34 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
35 public class TestUnsafePutAddressNullObjMustNotEscape { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
36 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
37 public static Unsafe usafe; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
38 public static long mem; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
39 public static long checksum; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
40 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
41 public static void main(String[] args) throws Exception { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
42 System.out.println("EXECUTING test."); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
43 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
44 { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
45 System.out.println("Acquiring sun.misc.Unsafe.theUnsafe using reflection."); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
46 getUnsafe(); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
47 System.out.println("Allocating raw memory."); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
48 mem = (usafe.allocateMemory(1024) + 8L) & ~7L; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
49 System.out.println("Triggering JIT compilation of the test method"); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
50 triggerJitCompilationOfTestMethod(); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
51 } |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
52 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
53 System.out.println("SUCCESSFULLY passed test."); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
54 } |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
55 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
56 public static void triggerJitCompilationOfTestMethod() { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
57 long sum = 0; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
58 for (int ii = 50000; ii >= 0; ii--) { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
59 sum = testMethod(); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
60 } |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
61 checksum = sum; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
62 } |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
63 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
64 public static class IDGen { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
65 private static long id; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
66 public long nextId() { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
67 return id++; |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
68 } |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
69 } |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
70 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
71 public static long testMethod() { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
72 // dummy alloc to trigger escape analysis |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
73 IDGen gen = new IDGen(); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
74 // StoreP of null_obj to raw mem triggers assertion in escape analysis |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
75 usafe.putAddress(mem, 0L); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
76 return gen.nextId(); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
77 } |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
78 |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
79 private static void getUnsafe() throws Exception { |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
80 Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe"); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
81 field.setAccessible(true); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
82 usafe = (sun.misc.Unsafe) field.get(null); |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
83 } |
87b5e00100fe
8038048: assert(null_obj->escape_state() == PointsToNode::NoEscape,etc) runThese -full
kvn
parents:
diff
changeset
|
84 } |