Mercurial > hg > truffle
annotate graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java @ 6583:adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 26 Oct 2012 17:32:57 +0200 |
parents | 77fb2026fcbe |
children | 0b8410de1365 |
rev | line source |
---|---|
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
5779
1458f656b060
moved snippet related tests to com.oracle.graal.snippets.test project
Doug Simon <doug.simon@oracle.com>
parents:
5541
diff
changeset
|
23 package com.oracle.graal.snippets; |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import org.junit.*; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5439
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.*; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.java.*; |
6526
ee651c726397
split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
32 import com.oracle.graal.phases.*; |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
33 import com.oracle.graal.snippets.CheckCastTest.Depth12; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
34 import com.oracle.graal.snippets.CheckCastTest.Depth13; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
35 import com.oracle.graal.snippets.CheckCastTest.Depth14; |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 /** |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 * Tests the implementation of instanceof, allowing profiling information to |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 * be manually specified. |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 */ |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 public class InstanceOfTest extends TypeCheckTest { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 @Override |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
44 protected void editPhasePlan(ResolvedJavaMethod method, StructuredGraph graph, PhasePlan phasePlan) { |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
45 // phasePlan.disablePhase(InliningPhase.class); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
46 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
47 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
48 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
49 protected void replaceProfile(StructuredGraph graph, JavaTypeProfile profile) { |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 InstanceOfNode ion = graph.getNodes().filter(InstanceOfNode.class).first(); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 if (ion != null) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 InstanceOfNode ionNew = graph.add(new InstanceOfNode(ion.targetClassInstruction(), ion.targetClass(), ion.object(), profile)); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 graph.replaceFloating(ion, ionNew); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 @Test |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 public void test1() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 test("isString", profile(), "object"); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 test("isString", profile(String.class), "object"); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 test("isString", profile(), Object.class); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 test("isString", profile(String.class), Object.class); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 @Test |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 public void test2() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 test("isStringInt", profile(), "object"); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 test("isStringInt", profile(String.class), "object"); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 test("isStringInt", profile(), Object.class); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 test("isStringInt", profile(String.class), Object.class); |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 @Test |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
76 public void test2_1() { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
77 test("isStringIntComplex", profile(), "object"); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
78 test("isStringIntComplex", profile(String.class), "object"); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
79 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
80 test("isStringIntComplex", profile(), Object.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
81 test("isStringIntComplex", profile(String.class), Object.class); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
82 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
83 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
84 @Test |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 public void test3() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 Throwable throwable = new Exception(); |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
87 test("isThrowable", profile(), throwable); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
88 test("isThrowable", profile(Throwable.class), throwable); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
89 test("isThrowable", profile(Exception.class, Error.class), throwable); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
91 test("isThrowable", profile(), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
92 test("isThrowable", profile(Throwable.class), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
93 test("isThrowable", profile(Exception.class, Error.class), Object.class); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 @Test |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
97 public void test3_1() { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
98 onlyFirstIsException(new Exception(), new Error()); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
99 test("onlyFirstIsException", profile(), new Exception(), new Error()); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
100 test("onlyFirstIsException", profile(), new Error(), new Exception()); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
101 test("onlyFirstIsException", profile(), new Exception(), new Exception()); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
102 test("onlyFirstIsException", profile(), new Error(), new Error()); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
103 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
104 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
105 @Test |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 public void test4() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 Throwable throwable = new Exception(); |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
108 test("isThrowableInt", profile(), throwable); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
109 test("isThrowableInt", profile(Throwable.class), throwable); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
110 test("isThrowableInt", profile(Exception.class, Error.class), throwable); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
112 test("isThrowableInt", profile(), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
113 test("isThrowableInt", profile(Throwable.class), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
114 test("isThrowableInt", profile(Exception.class, Error.class), Object.class); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 @Test |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 public void test5() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 Map map = new HashMap<>(); |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
120 test("isMap", profile(), map); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
121 test("isMap", profile(HashMap.class), map); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
122 test("isMap", profile(TreeMap.class, HashMap.class), map); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
124 test("isMap", profile(), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
125 test("isMap", profile(HashMap.class), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
126 test("isMap", profile(TreeMap.class, HashMap.class), Object.class); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 @Test |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 public void test6() { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 Map map = new HashMap<>(); |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
132 test("isMapInt", profile(), map); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
133 test("isMapInt", profile(HashMap.class), map); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
134 test("isMapInt", profile(TreeMap.class, HashMap.class), map); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 |
5439
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
136 test("isMapInt", profile(), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
137 test("isMapInt", profile(HashMap.class), Object.class); |
4fc3a8040430
improved InstanceOfTest
Doug Simon <doug.simon@oracle.com>
parents:
5433
diff
changeset
|
138 test("isMapInt", profile(TreeMap.class, HashMap.class), Object.class); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 |
6305
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
141 @Test |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
142 public void test7() { |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
143 Object o = new Depth13(); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
144 test("isDepth12", profile(), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
145 test("isDepth12", profile(Depth13.class), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
146 test("isDepth12", profile(Depth13.class, Depth14.class), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
147 |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
148 o = "not a depth"; |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
149 test("isDepth12", profile(), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
150 test("isDepth12", profile(Depth13.class), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
151 test("isDepth12", profile(Depth13.class, Depth14.class), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
152 } |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
153 |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
154 @Test |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
155 public void test8() { |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
156 Object o = new Depth13(); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
157 test("isDepth12Int", profile(), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
158 test("isDepth12Int", profile(Depth13.class), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
159 test("isDepth12Int", profile(Depth13.class, Depth14.class), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
160 |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
161 o = "not a depth"; |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
162 test("isDepth12Int", profile(), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
163 test("isDepth12Int", profile(Depth13.class), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
164 test("isDepth12Int", profile(Depth13.class, Depth14.class), o); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
165 } |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
166 |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 public static boolean isString(Object o) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 return o instanceof String; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 public static int isStringInt(Object o) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 if (o instanceof String) { |
6567
3bc7183309e0
improved InstanceOfTest.isStringInt()
Doug Simon <doug.simon@oracle.com>
parents:
6526
diff
changeset
|
173 return id(1); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 } |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
175 return id(0); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
176 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
177 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
178 public static int isStringIntComplex(Object o) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
179 if (o instanceof String || o instanceof Integer) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
180 return id(o instanceof String ? 1 : 0); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
181 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
182 return id(0); |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
183 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
184 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
185 public static int id(int value) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
186 return value; |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
189 public static boolean isThrowable(Object o) { |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
190 return ((Throwable) o) instanceof Exception; |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
192 |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
193 public static int onlyFirstIsException(Throwable t1, Throwable t2) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
194 if (t1 instanceof Exception ^ t2 instanceof Exception) { |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
195 return t1 instanceof Exception ? 1 : -1; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
196 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
197 return -1; |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
198 } |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
199 |
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
200 |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 public static int isThrowableInt(Object o) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 if (o instanceof Throwable) { |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
203 return id(1); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 } |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
205 if (o instanceof Throwable) { |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
206 return id(2); |
6302
5d7d9a6953bd
added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents:
5779
diff
changeset
|
207 } |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 return 0; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 public static boolean isMap(Object o) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
212 return o instanceof Map; |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 } |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
214 |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
215 public static int isMapInt(Object o) { |
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
216 if (o instanceof Map) { |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
217 return id(1); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
218 } |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
219 return id(0); |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
220 } |
6305
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
221 |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
222 public static boolean isDepth12(Object o) { |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
223 return o instanceof Depth12; |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
224 } |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
225 |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
226 public static int isDepth12Int(Object o) { |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
227 if (o instanceof Depth12) { |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
228 return id(0); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
229 } |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
230 return id(0); |
94ed0ba0a1f2
added more tests to InstanceOfTest for testing against types with a deep hierarchy
Doug Simon <doug.simon@oracle.com>
parents:
6302
diff
changeset
|
231 } |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
232 |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
233 /** |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6579
diff
changeset
|
234 * This test exists to show the kind of pattern that is be optimizable by |
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6579
diff
changeset
|
235 * {@code removeIntermediateMaterialization()} in {@link IfNode}. |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
236 * <p> |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
237 * The test exists in this source file as the transformation was originally motivated by the need to |
6583
adb3879ffbe2
improved IfNode simplification of removing intermediate materializations to handle (some) MergeNodes with a non-null frame state
Doug Simon <doug.simon@oracle.com>
parents:
6579
diff
changeset
|
238 * remove use of special JumpNodes in the {@code InstanceOfSnippets}. |
6579
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
239 */ |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
240 @Test |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
241 public void test_removeIntermediateMaterialization() { |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
242 List<String> list = Arrays.asList("1", "2", "3", "4"); |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
243 test("removeIntermediateMaterialization", profile(), list, "2", "yes", "no"); |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
244 test("removeIntermediateMaterialization", profile(), list, null, "yes", "no"); |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
245 test("removeIntermediateMaterialization", profile(), null, "2", "yes", "no"); |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
246 } |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
247 |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
248 public static String removeIntermediateMaterialization(List<Object> list, Object e, String a, String b) { |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
249 boolean test; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
250 if (list == null || e == null) { |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
251 test = false; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
252 } else { |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
253 test = false; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
254 for (Object i : list) { |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
255 if (i.equals(e)) { |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
256 test = true; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
257 break; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
258 } |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
259 } |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
260 } |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
261 if (test) { |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
262 return a; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
263 } |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
264 return b; |
77fb2026fcbe
added test case to demonstrate current limitation in the IfNode simplification of removing intermediate materializations
Doug Simon <doug.simon@oracle.com>
parents:
6567
diff
changeset
|
265 } |
5433
d7b5cc23945e
refactored tests to share support for dump-aware compilation
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
266 } |