author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58425 | f4a4804ab3e6 |
permissions | -rw-r--r-- |
57664
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
1 |
/* |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
4 |
* |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
8 |
* |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
13 |
* accompanied this code). |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
14 |
* |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
18 |
* |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
21 |
* questions. |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
22 |
*/ |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
23 |
|
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
24 |
/* |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
25 |
* @test |
58332
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
26 |
* @bug 8229016 8231055 |
57664
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
27 |
* @summary Test correct elimination of array allocation with arraycopy to itself. |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
28 |
* @library /test/lib |
58425
f4a4804ab3e6
8231665: 8231055 broke escapeAnalysis/TestSelfArrayCopy.java
roland
parents:
58332
diff
changeset
|
29 |
* @run main/othervm -Xbatch -XX:CompileCommand=compileonly,compiler.escapeAnalysis.TestSelfArrayCopy::test* |
57664
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
30 |
* compiler.escapeAnalysis.TestSelfArrayCopy |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
31 |
*/ |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
32 |
|
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
33 |
package compiler.escapeAnalysis; |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
34 |
|
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
35 |
import jdk.test.lib.Utils; |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
36 |
|
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
37 |
public class TestSelfArrayCopy { |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
38 |
private static boolean b = false; |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
39 |
private static final int rI1 = Utils.getRandomInstance().nextInt(); |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
40 |
private static final int rI2 = Utils.getRandomInstance().nextInt(); |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
41 |
|
58332
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
42 |
private static int test1() { |
57664
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
43 |
// Non-escaping allocation |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
44 |
Integer[] array = {rI1, rI2}; |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
45 |
// Arraycopy with src == dst |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
46 |
System.arraycopy(array, 0, array, 0, array.length - 1); |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
47 |
if (b) { |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
48 |
// Uncommon trap |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
49 |
System.out.println(array[0]); |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
50 |
} |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
51 |
return array[0] + array[1]; |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
52 |
} |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
53 |
|
58332
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
54 |
private static int test2() { |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
55 |
// Non-escaping allocation |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
56 |
Integer[] array = {rI1, rI2}; |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
57 |
// Arraycopy with src == dst |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
58 |
System.arraycopy(array, 0, array, 1, 1); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
59 |
if (b) { |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
60 |
// Uncommon trap |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
61 |
System.out.println(array[0]); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
62 |
} |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
63 |
return array[0] + array[1]; |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
64 |
} |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
65 |
|
57664
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
66 |
public static void main(String[] args) { |
58332
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
67 |
int expected1 = rI1 + rI2; |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
68 |
int expected2 = rI1 + rI1; |
57664
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
69 |
// Trigger compilation |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
70 |
for (int i = 0; i < 20_000; ++i) { |
58332
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
71 |
int result = test1(); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
72 |
if (result != expected1) { |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
73 |
throw new RuntimeException("Incorrect result: " + result + " != " + expected1); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
74 |
} |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
75 |
result = test2(); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
76 |
if (result != expected2) { |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
77 |
throw new RuntimeException("Incorrect result: " + result + " != " + expected2); |
57664
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
78 |
} |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
79 |
} |
58332
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
80 |
b = true; |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
81 |
int result = test1(); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
82 |
if (result != expected1) { |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
83 |
throw new RuntimeException("Incorrect result: " + result + " != " + expected1); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
84 |
} |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
85 |
result = test2(); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
86 |
if (result != expected2) { |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
87 |
throw new RuntimeException("Incorrect result: " + result + " != " + expected2); |
b311681bc3f9
8231055: C2: arraycopy with same non escaping src and dest but different positions causes wrong execution
roland
parents:
57664
diff
changeset
|
88 |
} |
57664
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
89 |
} |
1d2ea8db7083
8229016: C2 scalarization crashes with assert(node->Opcode() == Op_CastP2X) failed: ConvP2XNode required
thartmann
parents:
diff
changeset
|
90 |
} |