author | roland |
Fri, 11 Dec 2015 16:57:08 +0100 | |
changeset 35545 | a8f29dfd62b2 |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
35545
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
1 |
/* |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
4 |
* |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
8 |
* |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
13 |
* accompanied this code). |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
14 |
* |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
18 |
* |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
21 |
* questions. |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
22 |
* |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
23 |
*/ |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
24 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
25 |
/** |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
26 |
* @test |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
27 |
* @bug 8139771 |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
28 |
* @summary Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
29 |
* @requires vm.gc=="Serial" | vm.gc=="Parallel" |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
30 |
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:+IgnoreUnrecognizedVMOptions -XX:+StressGCM TestEliminatedCastPPAtPhi |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
31 |
* |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
32 |
*/ |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
33 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
34 |
public class TestEliminatedCastPPAtPhi { |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
35 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
36 |
static TestEliminatedCastPPAtPhi saved; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
37 |
static TestEliminatedCastPPAtPhi saved_not_null; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
38 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
39 |
int f; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
40 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
41 |
static int test(TestEliminatedCastPPAtPhi obj, int[] array, boolean flag) { |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
42 |
int ret = array[0] + array[20]; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
43 |
saved = obj; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
44 |
if (obj == null) { |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
45 |
return ret; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
46 |
} |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
47 |
saved_not_null = obj; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
48 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
49 |
// empty loop to be optimized out. Delays range check smearing |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
50 |
// for the array access below until the if diamond is |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
51 |
// optimized out |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
52 |
int i = 0; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
53 |
for (; i < 10; i++); |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
54 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
55 |
ret += array[i]; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
56 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
57 |
TestEliminatedCastPPAtPhi res; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
58 |
if (flag) { |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
59 |
// load is optimized out and res is obj here |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
60 |
res = saved; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
61 |
} else { |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
62 |
// load is optimized out and res is non null CastPP of res here |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
63 |
res = saved_not_null; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
64 |
} |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
65 |
// null check + CastPP here for res field load below |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
66 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
67 |
// 1) null check is pushed in the branches of the if above by |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
68 |
// split through phi because res is non null in the second |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
69 |
// branch and the null check can be optimized out in that |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
70 |
// branch. The Castpp stays here. |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
71 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
72 |
// 2) null check in the first branch is also optimized out |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
73 |
// because a dominating null check is found (the explicit null |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
74 |
// check at the beggining of the test) |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
75 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
76 |
// 3) the Phi for the if above merges a CastPP'ed value and |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
77 |
// the same value so it's optimized out and replaced by the |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
78 |
// uncasted value: obj |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
79 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
80 |
// 4) the if above has 2 empty branches so it's optimized |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
81 |
// out. The control of the CastPP that is still here is now |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
82 |
// the success branch of the range check for the array access |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
83 |
// above |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
84 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
85 |
// 5) the loop above is optimized out, i = 10, the range check |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
86 |
// for the array access above is optimized out and all its |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
87 |
// uses are replaced by the range check for the array accesses |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
88 |
// at the beginning of the method. The castPP here is one of |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
89 |
// the uses and so its control is now the range check at the |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
90 |
// beginning of the method: the control of the CastPP bypasses |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
91 |
// the explicit null check |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
92 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
93 |
return ret + res.f; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
94 |
} |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
95 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
96 |
static public void main(String[] args) { |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
97 |
int[] array = new int[100]; |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
98 |
TestEliminatedCastPPAtPhi obj = new TestEliminatedCastPPAtPhi(); |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
99 |
for (int i = 0; i < 20000; i++) { |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
100 |
test(obj, array, (i%2) == 0); |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
101 |
} |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
102 |
test(null, array, true); |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
103 |
} |
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
104 |
|
a8f29dfd62b2
8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents:
diff
changeset
|
105 |
} |