Mercurial > hg > graal-compiler
annotate test/compiler/macronodes/TestEliminateAllocationPhi.java @ 20505:8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
Summary: Ergonomics updates flags for number of GC threads
Reviewed-by: tschatzl, jwilhelm
Contributed-by: sangheon.kim@oracle.com
author | jwilhelm |
---|---|
date | Sat, 27 Sep 2014 15:11:41 +0200 |
parents | f8afcfbdbf1c |
children |
rev | line source |
---|---|
20452
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
1 /* |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
4 * |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
8 * |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
13 * accompanied this code). |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
14 * |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
18 * |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
21 * questions. |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
22 */ |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
23 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
24 /* |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
25 * @test |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
26 * @bug 8046698 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
27 * @summary PhiNode inserted between AllocateNode and Initialization node confuses allocation elimination |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
28 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestEliminateAllocationPhi |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
29 * |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
30 */ |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
31 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
32 public class TestEliminateAllocationPhi { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
33 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
34 // This will return I when called from m(0 and once optimized will |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
35 // go away but this will confuse escape analysis in m(): it will |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
36 // find I as non escaping but non scalar replaceable. In its own |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
37 // method so that we can make the profile of the if() branch look |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
38 // like it's taken sometimes. |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
39 static Integer m2(Integer I, int i) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
40 for (; i < 10; i=(i+2)*(i+2)) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
41 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
42 if (i == 121) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
43 return II; |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
44 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
45 return I; |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
46 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
47 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
48 static Integer II = new Integer(42); |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
49 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
50 static int m(int[] integers, boolean flag) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
51 int j = 0; |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
52 while(true) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
53 try { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
54 int k = integers[j++]; |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
55 // A branch that will cause loop unswitching |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
56 if (flag) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
57 k += 42; |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
58 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
59 if (k < 1000) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
60 throw new Exception(); |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
61 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
62 // Because of the try/catch the Allocate node for this |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
63 // new will be in the loop while the Initialization |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
64 // node will be outside the loop. When loop |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
65 // unswitching happens, the Allocate node will be |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
66 // cloned and the results of both will be inputs to a |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
67 // Phi that will be between the Allocate nodes and the |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
68 // Initialization nodes. |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
69 Integer I = new Integer(k); |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
70 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
71 I = m2(I, 0); |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
72 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
73 int i = I.intValue(); |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
74 return i; |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
75 } catch(Exception e) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
76 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
77 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
78 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
79 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
80 static public void main(String[] args) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
81 for (int i = 0; i < 5000; i++) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
82 m2(null, 1); |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
83 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
84 |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
85 int[] integers = { 2000 }; |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
86 for (int i = 0; i < 6000; i++) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
87 m(integers, (i%2) == 0); |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
88 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
89 int[] integers2 = { 1, 2, 3, 4, 5, 2000 }; |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
90 for (int i = 0; i < 10000; i++) { |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
91 m(integers2, (i%2) == 0); |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
92 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
93 } |
f8afcfbdbf1c
8046698: assert(false) failed: only Initialize or AddP expected macro.cpp:943
roland
parents:
diff
changeset
|
94 } |