author | jiangli |
Fri, 02 Nov 2018 19:30:31 -0400 | |
changeset 52397 | 1322829d1501 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
32579
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
1 |
/* |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
4 |
* |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
8 |
* |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
13 |
* accompanied this code). |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
14 |
* |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
18 |
* |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
21 |
* questions. |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
22 |
*/ |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
23 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
24 |
/* |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
25 |
* @test |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
26 |
* @bug 8134031 |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
27 |
* @summary Bad rewiring of memory edges when we split unique types during EA |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
28 |
* |
40059 | 29 |
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement |
30 |
* -XX:CompileCommand=dontinline,compiler.escapeAnalysis.TestEABadMergeMem::m_notinlined |
|
31 |
* compiler.escapeAnalysis.TestEABadMergeMem |
|
32579
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
32 |
*/ |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
33 |
|
40059 | 34 |
package compiler.escapeAnalysis; |
35 |
||
32579
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
36 |
public class TestEABadMergeMem { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
37 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
38 |
static class Box { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
39 |
int i; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
40 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
41 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
42 |
static void m_notinlined() { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
43 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
44 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
45 |
static float dummy1; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
46 |
static float dummy2; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
47 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
48 |
static int test(Box a, Box c, int i, int j, int k, boolean flag1, boolean flag2) { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
49 |
Box b = new Box(); // non escaping |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
50 |
a.i = i; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
51 |
b.i = j; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
52 |
c.i = k; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
53 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
54 |
m_notinlined(); |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
55 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
56 |
boolean flag3 = false; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
57 |
if (flag1) { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
58 |
for (int ii = 0; ii < 100; ii++) { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
59 |
if (flag2) { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
60 |
dummy1 = (float)ii; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
61 |
} else { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
62 |
dummy2 = (float)ii; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
63 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
64 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
65 |
flag3 = true; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
66 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
67 |
// Memory Phi here with projection of not inlined call as one edge, MergeMem as other |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
68 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
69 |
if (flag3) { // will split through Phi during loopopts |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
70 |
int res = c.i + b.i; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
71 |
m_notinlined(); // prevents split through phi during igvn |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
72 |
return res; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
73 |
} else { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
74 |
return 44 + 43; |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
75 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
76 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
77 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
78 |
static public void main(String[] args) { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
79 |
for (int i = 0; i < 20000; i++) { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
80 |
// m(2); |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
81 |
Box a = new Box(); |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
82 |
Box c = new Box(); |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
83 |
int res = test(a, c, 42, 43, 44, (i%2) == 0, (i%3) == 0); |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
84 |
if (res != 44 + 43) { |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
85 |
throw new RuntimeException("Bad result " + res); |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
86 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
87 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
88 |
} |
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
89 |
|
268acc7bc111
8134031: Incorrect JIT compilation of complex code with inlining and escape analysis
roland
parents:
diff
changeset
|
90 |
} |