Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java @ 14951:6decd59291a8
remove leftover forceDump call
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 02 Apr 2014 11:54:49 -0700 |
parents | 159b21f41915 |
children | 769fc3629f59 |
rev | line source |
---|---|
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.compiler.test; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
12573
6332050441eb
fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
25 import static com.oracle.graal.nodes.ConstantNode.*; |
10788
ac3cb56f47a0
made use of symbolic constants for branch probabilities
Doug Simon <doug.simon@oracle.com>
parents:
10786
diff
changeset
|
26 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*; |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
27 import static org.junit.Assert.*; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
28 |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import org.junit.*; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
31 import com.oracle.graal.nodes.*; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
32 import com.oracle.graal.nodes.calc.*; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
33 import com.oracle.graal.nodes.java.*; |
10788
ac3cb56f47a0
made use of symbolic constants for branch probabilities
Doug Simon <doug.simon@oracle.com>
parents:
10786
diff
changeset
|
34 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12655
diff
changeset
|
35 import com.oracle.graal.nodes.spi.*; |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.phases.common.*; |
11568
ae27f6ac3374
Avoid direct usage of CanonicalizerPhase.Instance in tests.
Roland Schatz <roland.schatz@oracle.com>
parents:
11409
diff
changeset
|
37 import com.oracle.graal.phases.tiers.*; |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 /** |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 * Collection of tests for {@link ConditionalEliminationPhase} including those that triggered bugs |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 * in this phase. |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 */ |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 public class ConditionalEliminationTest extends GraalCompilerTest { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 |
10841
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
45 public static Object field; |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
46 |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 static class Entry { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 final String name; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 public Entry(String name) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 this.name = name; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 static class EntryWithNext extends Entry { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 public EntryWithNext(String name, Entry next) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 super(name); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 this.next = next; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 final Entry next; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 public static Entry search(Entry start, String name, Entry alternative) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 Entry current = start; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 do { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 while (current instanceof EntryWithNext) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 if (name != null && current.name == name) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 current = null; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 } else { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 Entry next = ((EntryWithNext) current).next; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 current = next; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 if (current != null) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 if (current.name.equals(name)) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 return current; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 if (current == alternative) { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 return null; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 current = alternative; |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 } while (true); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 } |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 /** |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 * This test presents a code pattern that triggered a bug where a (non-eliminated) checkcast |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 * caused an enclosing instanceof (for the same object and target type) to be incorrectly |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 * eliminated. |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 */ |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 @Test |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 public void testReanchoringIssue() { |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 Entry end = new Entry("end"); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 EntryWithNext e1 = new EntryWithNext("e1", end); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 EntryWithNext e2 = new EntryWithNext("e2", e1); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 test("search", e2, "e3", new Entry("e4")); |
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 } |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
104 |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
105 @SuppressWarnings("unused") |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
106 public static int testNullnessSnippet(Object a, Object b) { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
107 if (a == null) { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
108 if (a == b) { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
109 if (b == null) { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
110 return 1; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
111 } else { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
112 return -2; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
113 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
114 } else { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
115 if (b == null) { |
10840
e43eb9fe98e5
check for one more case in ConditionalEliminationTest
Lukas Stadler <lukas.stadler@jku.at>
parents:
10789
diff
changeset
|
116 return -3; |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
117 } else { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
118 return 4; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
119 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
120 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
121 } else { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
122 if (a == b) { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
123 if (b == null) { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
124 return -5; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
125 } else { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
126 return 6; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
127 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
128 } else { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
129 if (b == null) { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
130 return 7; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
131 } else { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
132 return 8; |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
133 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
134 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
135 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
136 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
137 |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
138 @Test |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
139 public void testNullness() { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
140 test("testNullnessSnippet", null, null); |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
141 test("testNullnessSnippet", null, new Object()); |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
142 test("testNullnessSnippet", new Object(), null); |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
143 test("testNullnessSnippet", new Object(), new Object()); |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
144 |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
145 StructuredGraph graph = parse("testNullnessSnippet"); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11688
diff
changeset
|
146 new ConditionalEliminationPhase(getMetaAccess()).apply(graph); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
147 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12573
diff
changeset
|
148 for (ConstantNode constant : getConstantNodes(graph)) { |
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12573
diff
changeset
|
149 if (ConstantNodeRecordsUsages || !constant.gatherUsages(graph).isEmpty()) { |
12573
6332050441eb
fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
150 assertTrue("unexpected constant: " + constant, constant.asConstant().isNull() || constant.asConstant().asInt() > 0); |
6332050441eb
fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
151 } |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
152 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
153 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
154 |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
155 @SuppressWarnings("unused") |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
156 public static int testDisjunctionSnippet(Object a) { |
13694
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
157 try { |
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
158 if (a instanceof Integer) { |
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
159 if (a == null) { |
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
160 return -1; |
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
161 } else { |
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
162 return 2; |
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
163 } |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
164 } else { |
13694
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
165 return 3; |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
166 } |
13694
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
167 } finally { |
0e8c22aa6ec3
adapt tests for new IfNode and MergeNode simplifications
Lukas Stadler <lukas.stadler@jku.at>
parents:
13614
diff
changeset
|
168 field = null; |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
169 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
170 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
171 |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
172 @Test |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
173 public void testDisjunction() { |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
174 StructuredGraph graph = parse("testDisjunctionSnippet"); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
175 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
176 IfNode ifNode = (IfNode) graph.start().next(); |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
177 InstanceOfNode instanceOf = (InstanceOfNode) ifNode.condition(); |
13614
0774f3303c2e
rename LocalNode to ParameterNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
13505
diff
changeset
|
178 IsNullNode x = graph.unique(new IsNullNode(graph.getParameter(0))); |
10786
745322b36359
added a field to LogicBinaryNode capturing the probability that the evaluation of the logic node is short-circuited (i.e. only the left input is evaluated)
Doug Simon <doug.simon@oracle.com>
parents:
10767
diff
changeset
|
179 InstanceOfNode y = instanceOf; |
10789
ec4c7c33e8e5
rename: LogicBinaryNode -> ShortCircuitBooleanNode, Logic[Conjunction|Disjunction]Node -> ShortCircuit[And|Or]Node
Doug Simon <doug.simon@oracle.com>
parents:
10788
diff
changeset
|
180 ShortCircuitOrNode disjunction = graph.unique(new ShortCircuitOrNode(x, false, y, false, NOT_FREQUENT_PROBABILITY)); |
11409
1f302b6e16b0
Introduce LogicNegationNode and remove Negatable interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
10841
diff
changeset
|
181 LogicNegationNode negation = graph.unique(new LogicNegationNode(disjunction)); |
1f302b6e16b0
Introduce LogicNegationNode and remove Negatable interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
10841
diff
changeset
|
182 ifNode.setCondition(negation); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
183 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11688
diff
changeset
|
184 new ConditionalEliminationPhase(getMetaAccess()).apply(graph); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
185 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12573
diff
changeset
|
186 for (ConstantNode constant : getConstantNodes(graph)) { |
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12573
diff
changeset
|
187 if (ConstantNodeRecordsUsages || !constant.gatherUsages(graph).isEmpty()) { |
12573
6332050441eb
fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
188 assertTrue("unexpected constant: " + constant, constant.asConstant().isNull() || constant.asConstant().asInt() > 0); |
6332050441eb
fixed tests that need to take into account ConstantNodes not recording their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12054
diff
changeset
|
189 } |
10750
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
190 } |
9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10532
diff
changeset
|
191 } |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
192 |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
193 public static int testInvokeSnippet(Number n) { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
194 if (n instanceof Integer) { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
195 return n.intValue(); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
196 } else { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
197 return 1; |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
198 } |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
199 } |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
200 |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
201 @Test |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
202 public void testInvoke() { |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
203 test("testInvokeSnippet", new Integer(16)); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
204 StructuredGraph graph = parse("testInvokeSnippet"); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
205 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11688
diff
changeset
|
206 new ConditionalEliminationPhase(getMetaAccess()).apply(graph); |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
207 |
11688
0d3b767e5356
removed the IterableNodeType marker interface from InvokeNode (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents:
11625
diff
changeset
|
208 InvokeNode invoke = graph.getNodes().filter(InvokeNode.class).first(); |
10767
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
209 assertEquals(InvokeKind.Special, ((MethodCallTargetNode) invoke.callTarget()).invokeKind()); |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
210 } |
88d0dc388450
let ConditionalEliminationPhase change invokes to InvokeKind.Special based on type information
Lukas Stadler <lukas.stadler@jku.at>
parents:
10750
diff
changeset
|
211 |
10841
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
212 public static void testTypeMergingSnippet(Object o, boolean b) { |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
213 if (b) { |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
214 if (!(o instanceof Double)) { |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
215 return; |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
216 } |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
217 } else { |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
218 if (!(o instanceof Integer)) { |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
219 return; |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
220 } |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
221 } |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
222 |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
223 /* |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
224 * For this test the conditional elimination has to correctly merge the type information it |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
225 * has about o, so that it can remove the check on Number. |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
226 */ |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
227 if (!(o instanceof Number)) { |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
228 field = o; |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
229 } |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
230 } |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
231 |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
232 @Test |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
233 public void testTypeMerging() { |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
234 StructuredGraph graph = parse("testTypeMergingSnippet"); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
235 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11688
diff
changeset
|
236 new ConditionalEliminationPhase(getMetaAccess()).apply(graph); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
237 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
10841
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
238 |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
239 assertEquals(0, graph.getNodes().filter(StoreFieldNode.class).count()); |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
240 } |
020f63bfd781
fix merging of types in ConditionalEliminationPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
10840
diff
changeset
|
241 |
11625
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
242 public static String testInstanceOfCheckCastSnippet(Object e) { |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
243 if (e instanceof Entry) { |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
244 return ((Entry) e).name; |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
245 } |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
246 return null; |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
247 } |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
248 |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
249 @Test |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
250 public void testInstanceOfCheckCast() { |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
251 StructuredGraph graph = parse("testInstanceOfCheckCastSnippet"); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
252 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11688
diff
changeset
|
253 new ConditionalEliminationPhase(getMetaAccess()).apply(graph); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
254 new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null)); |
11625
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
255 |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
256 assertEquals(0, graph.getNodes().filter(CheckCastNode.class).count()); |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
257 } |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
258 |
14936
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
259 public static int testRedundantComparesSnippet(int[] array) { |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
260 if (array == null) { |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
261 return 0; |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
262 } |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
263 return array[0] + array[1] + array[2] + array[3]; |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
264 } |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
265 |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
266 @Test |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
267 public void testRedundantCompares() { |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
268 StructuredGraph graph = parse("testRedundantComparesSnippet"); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
269 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
270 PhaseContext context = new PhaseContext(getProviders(), null); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
271 |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
272 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
273 canonicalizer.apply(graph, context); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
274 new FloatingReadPhase().apply(graph); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
275 new ConditionalEliminationPhase(getMetaAccess()).apply(graph); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
276 canonicalizer.apply(graph, context); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
277 |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
278 assertEquals(1, graph.getNodes().filter(GuardNode.class).count()); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
279 } |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
280 |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
281 public static int testDuplicateNullChecksSnippet(Object a) { |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
282 if (a == null) { |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
283 return 2; |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
284 } |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
285 try { |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
286 return ((Integer) a).intValue(); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
287 } catch (ClassCastException e) { |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
288 return 0; |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
289 } |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
290 } |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
291 |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
292 @Test |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
293 @Ignore |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
294 public void testDuplicateNullChecks() { |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
295 // This tests whether explicit null checks properly eliminate later null guards. Currently |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
296 // it's failing. |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
297 StructuredGraph graph = parse("testDuplicateNullChecksSnippet"); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
298 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
299 PhaseContext context = new PhaseContext(getProviders(), null); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
300 |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
301 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
302 canonicalizer.apply(graph, context); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
303 new FloatingReadPhase().apply(graph); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
304 new ConditionalEliminationPhase(getMetaAccess()).apply(graph); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
305 canonicalizer.apply(graph, context); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
306 |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
307 assertEquals(1, graph.getNodes().filter(GuardNode.class).count()); |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
308 } |
159b21f41915
add redundant compare test and fix breakage
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13694
diff
changeset
|
309 |
11625
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
310 @Test |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
311 @Ignore |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
312 public void testInstanceOfCheckCastLowered() { |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
313 StructuredGraph graph = parse("testInstanceOfCheckCastSnippet"); |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
314 |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
315 CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); |
12054
bba234a1670e
grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12052
diff
changeset
|
316 PhaseContext context = new PhaseContext(getProviders(), null); |
11625
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
317 |
13505
75a67ebd50e8
Introduce a LoweringStage so that lowerings can be conditional on one of the three times that lowering is performed by default
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12655
diff
changeset
|
318 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context); |
11625
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
319 canonicalizer.apply(graph, context); |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11688
diff
changeset
|
320 new ConditionalEliminationPhase(getMetaAccess()).apply(graph); |
11625
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
321 canonicalizer.apply(graph, context); |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
322 |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
323 assertEquals(0, graph.getNodes().filter(GuardNode.class).count()); |
94a28e1b2c86
Add a test to ConditionalEliminationTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11568
diff
changeset
|
324 } |
10532
1194e94f9c16
fixed bug in ConditionalEliminationPhase (GRAAL-346)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
325 } |